style: linting
This commit is contained in:
parent
74e3278012
commit
42f06ebefa
11 changed files with 61 additions and 59 deletions
|
|
@ -106,7 +106,7 @@ actual fun Maps(
|
|||
}
|
||||
|
||||
GoogleMap(
|
||||
modifier = Modifier.Companion.fillMaxSize(),
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
cameraPositionState = camPos,
|
||||
mapColorScheme = if (isSystemInDarkTheme()) {
|
||||
ComposeMapColorScheme.DARK
|
||||
|
|
@ -125,7 +125,7 @@ actual fun Maps(
|
|||
myLocationButtonEnabled = false,
|
||||
mapToolbarEnabled = false,
|
||||
),
|
||||
contentPadding = WindowInsets.Companion.safeDrawing.add(extInsets).asPaddingValues()
|
||||
contentPadding = WindowInsets.safeDrawing.add(extInsets).asPaddingValues()
|
||||
) {
|
||||
// [TODO]: Slight lag when routes with many stops such as the 901 bus is set
|
||||
for (marker in state.stops) {
|
||||
|
|
@ -140,7 +140,7 @@ actual fun Maps(
|
|||
}
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier.Companion
|
||||
modifier = Modifier
|
||||
.size(12.dp)
|
||||
.clip(CircleShape)
|
||||
.background(BanksiaTheme.colors.surface)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ val ClientModule = module {
|
|||
// HTTP Clients
|
||||
singleOf(::PtvService)
|
||||
single {
|
||||
HttpClient() {
|
||||
HttpClient {
|
||||
install(ContentNegotiation) {
|
||||
json(Json {
|
||||
ignoreUnknownKeys = true
|
||||
|
|
|
|||
|
|
@ -128,9 +128,9 @@ const val ICON_PADDING = 0.25f
|
|||
@Composable
|
||||
private fun RouteIconPreview() {
|
||||
Row {
|
||||
RouteIcon(routeType = RouteType.MetroTrain)
|
||||
RouteIcon(routeType = RouteType.MetroTram)
|
||||
RouteIcon(routeType = RouteType.MetroBus)
|
||||
RouteIcon(routeType = MetroTrain)
|
||||
RouteIcon(routeType = MetroTram)
|
||||
RouteIcon(routeType = MetroBus)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ fun InfoPanel(
|
|||
val localDensity = LocalDensity.current
|
||||
|
||||
Column(
|
||||
Modifier.Companion
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 24.dp)
|
||||
.heightIn(max = 250.dp)
|
||||
|
|
@ -64,10 +64,10 @@ fun InfoPanel(
|
|||
|
||||
if (state.loading)
|
||||
CircularProgressIndicator(
|
||||
modifier = Modifier.Companion.width(32.dp).align(Alignment.Companion.CenterEnd)
|
||||
modifier = Modifier.width(32.dp).align(Alignment.CenterEnd)
|
||||
)
|
||||
}
|
||||
Spacer(Modifier.Companion.windowInsetsBottomHeight(WindowInsets.Companion.safeContent))
|
||||
Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.safeContent))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -76,14 +76,14 @@ private inline fun RouteInfoPanel(
|
|||
state: InfoPanelState.Route,
|
||||
onEvent: (MapScreenEvent) -> Unit,
|
||||
) {
|
||||
Column(Modifier.Companion.fillMaxWidth()) {
|
||||
Column(Modifier.fillMaxWidth()) {
|
||||
Row {
|
||||
RouteIcon(routeType = state.type)
|
||||
Text(
|
||||
state.name,
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
fontWeight = FontWeight.Companion.SemiBold,
|
||||
textAlign = TextAlign.Companion.Start
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
textAlign = TextAlign.Start
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -94,14 +94,14 @@ private inline fun RunInfoPanel(
|
|||
state: InfoPanelState.Run,
|
||||
onEvent: (MapScreenEvent) -> Unit,
|
||||
) {
|
||||
Column(Modifier.Companion.fillMaxWidth()) {
|
||||
Column(Modifier.fillMaxWidth()) {
|
||||
Row {
|
||||
RouteIcon(routeType = state.type)
|
||||
Text(
|
||||
"${state.direction} via ${state.routeName ?: "..."}",
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
fontWeight = FontWeight.Companion.SemiBold,
|
||||
textAlign = TextAlign.Companion.Start
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
textAlign = TextAlign.Start
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -112,37 +112,37 @@ private inline fun StopInfoPanel(
|
|||
state: InfoPanelState.Stop,
|
||||
onEvent: (MapScreenEvent) -> Unit,
|
||||
) {
|
||||
Column(Modifier.Companion.fillMaxWidth()) {
|
||||
Column(Modifier.fillMaxWidth()) {
|
||||
Text(
|
||||
state.name,
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
fontWeight = FontWeight.Companion.SemiBold,
|
||||
textAlign = TextAlign.Companion.Start
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
textAlign = TextAlign.Start
|
||||
)
|
||||
state.subname?.let {
|
||||
Text(
|
||||
"/ $it",
|
||||
modifier = Modifier.Companion.padding(start = 5.dp),
|
||||
modifier = Modifier.padding(start = 5.dp),
|
||||
style = MaterialTheme.typography.titleSmall,
|
||||
color = Color.Companion.Gray,
|
||||
fontWeight = FontWeight.Companion.SemiBold,
|
||||
textAlign = TextAlign.Companion.Start
|
||||
color = Color.Gray,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
textAlign = TextAlign.Start
|
||||
)
|
||||
}
|
||||
state.departures?.let {
|
||||
Spacer(Modifier.Companion.height(5.dp))
|
||||
Spacer(Modifier.height(5.dp))
|
||||
it.forEach { (name, formatted) ->
|
||||
Row(verticalAlignment = Alignment.Companion.CenterVertically) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Text(
|
||||
name,
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Companion.SemiBold
|
||||
fontWeight = FontWeight.SemiBold
|
||||
)
|
||||
Text(
|
||||
formatted,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Companion.Ellipsis,
|
||||
modifier = Modifier.Companion.padding(horizontal = 5.dp)
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
modifier = Modifier.padding(horizontal = 5.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,16 +44,16 @@ fun Searcher(
|
|||
label = "padding"
|
||||
)
|
||||
|
||||
Box(modifier = Modifier.Companion.fillMaxSize()) {
|
||||
Box(modifier = Modifier.fillMaxSize()) {
|
||||
SearchBar(
|
||||
modifier = Modifier.Companion
|
||||
.align(Alignment.Companion.TopCenter)
|
||||
modifier = Modifier
|
||||
.align(Alignment.TopCenter)
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = animatedPadding),
|
||||
shadowElevation = 6.dp, // Elevation level 3
|
||||
inputField = {
|
||||
SearchBarDefaults.InputField(
|
||||
modifier = Modifier.Companion.padding(horizontal = 20.dp - animatedPadding),
|
||||
modifier = Modifier.padding(horizontal = 20.dp - animatedPadding),
|
||||
query = state.text,
|
||||
onQueryChange = { onEvent(MapScreenEvent.SearchUpdate(it)) },
|
||||
onSearch = {},
|
||||
|
|
@ -65,7 +65,7 @@ fun Searcher(
|
|||
Icon(
|
||||
imageVector = Icons.Default.Clear,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.Companion.clickable {
|
||||
modifier = Modifier.clickable {
|
||||
onEvent(
|
||||
MapScreenEvent.SearchUpdate(
|
||||
""
|
||||
|
|
@ -79,15 +79,15 @@ fun Searcher(
|
|||
expanded = expanded,
|
||||
onExpandedChange = onExpandedChange,
|
||||
) {
|
||||
LazyColumn(modifier = Modifier.Companion.fillMaxWidth()) {
|
||||
LazyColumn(modifier = Modifier.fillMaxWidth()) {
|
||||
for (entry in state.entries) {
|
||||
item {
|
||||
ListItem(
|
||||
headlineContent = { Text(entry.mainText) },
|
||||
supportingContent = { entry.subText?.let { Text(it) } },
|
||||
leadingContent = { RouteIcon(routeType = entry.routeType) },
|
||||
colors = ListItemDefaults.colors(containerColor = Color.Companion.Transparent),
|
||||
modifier = Modifier.Companion
|
||||
colors = ListItemDefaults.colors(containerColor = Color.Transparent),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp, vertical = 4.dp)
|
||||
.clickable {
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ fun MapScreen(
|
|||
) {
|
||||
val offset = runCatching { sheetState.requireOffset() }
|
||||
val scaffoldOffset = offset.getOrDefault(0.0f).roundToInt()
|
||||
(getScreenHeight() - scaffoldOffset - WindowInsets.Companion.safeDrawing.getBottom(
|
||||
(getScreenHeight() - scaffoldOffset - WindowInsets.safeDrawing.getBottom(
|
||||
LocalDensity.current)).coerceAtLeast(0)
|
||||
} else 0
|
||||
|
||||
|
|
@ -108,7 +108,7 @@ fun MapScreen(
|
|||
BottomSheetScaffold(
|
||||
scaffoldState = scaffoldState,
|
||||
sheetPeekHeight = (handleHeight + peekHeight) * peekHeightMultiplier,
|
||||
modifier = Modifier.Companion.fillMaxSize(),
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
sheetContent = {
|
||||
InfoPanel(
|
||||
state = infoState,
|
||||
|
|
@ -119,20 +119,20 @@ fun MapScreen(
|
|||
sheetDragHandle = {
|
||||
val density = LocalDensity.current
|
||||
Box(
|
||||
Modifier.Companion
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 10.dp)
|
||||
.onSizeChanged {
|
||||
handleHeight = with(density) { it.height.toDp() }
|
||||
}
|
||||
) {
|
||||
BottomSheetDefaults.DragHandle(modifier = Modifier.Companion.align(Alignment.Companion.Center))
|
||||
BottomSheetDefaults.DragHandle(modifier = Modifier.align(Alignment.Center))
|
||||
}
|
||||
},
|
||||
sheetSwipeEnabled = sheetSwipeEnabled,
|
||||
) {
|
||||
Maps(
|
||||
modifier = Modifier.Companion.fillMaxSize(),
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
state = mapState,
|
||||
onEvent = viewModel::handleEvent,
|
||||
cameraPositionFlow = viewModel.cameraChangeEmitter,
|
||||
|
|
@ -175,12 +175,14 @@ fun MapScreen(
|
|||
}
|
||||
|
||||
Box(
|
||||
Modifier.Companion.windowInsetsPadding(
|
||||
WindowInsets.Companion.safeContent.add(
|
||||
WindowInsets(bottom = extInsets)
|
||||
)
|
||||
),
|
||||
contentAlignment = Alignment.Companion.BottomEnd
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.windowInsetsPadding(
|
||||
WindowInsets.safeContent.add(
|
||||
WindowInsets(bottom = extInsets)
|
||||
)
|
||||
),
|
||||
contentAlignment = Alignment.BottomEnd
|
||||
) {
|
||||
FloatingActionButton(
|
||||
containerColor = MaterialTheme.colorScheme.surfaceContainer,
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ class MapScreenViewModel(
|
|||
if (element.size >= 5)
|
||||
return@forEach
|
||||
|
||||
val date = Instant.Companion.parse(dep.estimatedDepartureUtc ?: dep.scheduledDepartureUtc)
|
||||
val date = Instant.parse(dep.estimatedDepartureUtc ?: dep.scheduledDepartureUtc)
|
||||
val min = (date - Clock.System.now()).inWholeMinutes
|
||||
if (min <= -5)
|
||||
return@forEach
|
||||
|
|
@ -344,13 +344,13 @@ class MapScreenViewModel(
|
|||
var west = Double.MAX_VALUE
|
||||
points.forEach {
|
||||
if (it.lat > north)
|
||||
north = it.lat;
|
||||
north = it.lat
|
||||
if (it.lat < south)
|
||||
south = it.lat;
|
||||
south = it.lat
|
||||
if (it.lng > east)
|
||||
east = it.lng;
|
||||
east = it.lng
|
||||
if (it.lng < west)
|
||||
west = it.lng;
|
||||
west = it.lng
|
||||
}
|
||||
return CameraPositionBounds(Point(north, east), Point(south, west))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ class PtvService() {
|
|||
|
||||
val cache = PtvCache()
|
||||
|
||||
private val client = HttpClient() {
|
||||
private val client = HttpClient {
|
||||
install(ContentNegotiation) {
|
||||
json(Json {
|
||||
ignoreUnknownKeys = true
|
||||
|
|
@ -232,7 +232,7 @@ class PtvService() {
|
|||
url {
|
||||
appendPathSegments(
|
||||
"route_type", routeType.asPtvType().ordinal.toString(),
|
||||
"stop", stopId.toString(),
|
||||
"stop", stopId,
|
||||
)
|
||||
parameter("expand", "Route")
|
||||
parameter("expand", "Direction")
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ data class FutureTime(
|
|||
fun FutureTime.asInt() =
|
||||
trueHour * 3600 + minute * 60 + second
|
||||
|
||||
fun fromInt(int: Int) = FutureTime.from(
|
||||
fun fromInt(int: Int) = from(
|
||||
int / 3600,
|
||||
(int / 60) % 60,
|
||||
int % 60,
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class CacheMap<K, V>(
|
|||
}
|
||||
|
||||
override fun put(key: K, value: V): V? {
|
||||
keyExpiries.put(key, counter + expiryMinutes + 1)
|
||||
keyExpiries[key] = counter + expiryMinutes + 1
|
||||
return innerMap.put(key, value)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class LoopFlow<T>(private val block: suspend FlowCollector<T>.() -> Unit) : Abst
|
|||
fun <T> Flow<T>.delayFor(delay: Long) = apply {
|
||||
@Suppress("UnusedFlow")
|
||||
if (this is LoopFlow)
|
||||
this.delayMs = delay;
|
||||
this.delayMs = delay
|
||||
else
|
||||
throw IllegalStateException()
|
||||
}
|
||||
|
|
@ -36,7 +36,7 @@ class LoopFlow<T>(private val block: suspend FlowCollector<T>.() -> Unit) : Abst
|
|||
fun <T> Flow<T>.initWith(block: suspend FlowCollector<T>.() -> Unit) = apply {
|
||||
@Suppress("UnusedFlow")
|
||||
if (this is LoopFlow)
|
||||
this.init = block;
|
||||
this.init = block
|
||||
else
|
||||
throw IllegalStateException()
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@ class LoopFlow<T>(private val block: suspend FlowCollector<T>.() -> Unit) : Abst
|
|||
fun <T> Flow<T>.waitFor(waiter: suspend () -> Unit) = apply {
|
||||
@Suppress("UnusedFlow")
|
||||
if (this is LoopFlow)
|
||||
this.waiter = waiter;
|
||||
this.waiter = waiter
|
||||
else
|
||||
throw IllegalStateException()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue