style: linting

This commit is contained in:
Cilly Leang 2025-11-22 16:40:02 +11:00
parent 74e3278012
commit 42f06ebefa
Signed by: cilly
GPG key ID: 6500251E087653C9
11 changed files with 61 additions and 59 deletions

View file

@ -106,7 +106,7 @@ actual fun Maps(
} }
GoogleMap( GoogleMap(
modifier = Modifier.Companion.fillMaxSize(), modifier = Modifier.fillMaxSize(),
cameraPositionState = camPos, cameraPositionState = camPos,
mapColorScheme = if (isSystemInDarkTheme()) { mapColorScheme = if (isSystemInDarkTheme()) {
ComposeMapColorScheme.DARK ComposeMapColorScheme.DARK
@ -125,7 +125,7 @@ actual fun Maps(
myLocationButtonEnabled = false, myLocationButtonEnabled = false,
mapToolbarEnabled = 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 // [TODO]: Slight lag when routes with many stops such as the 901 bus is set
for (marker in state.stops) { for (marker in state.stops) {
@ -140,7 +140,7 @@ actual fun Maps(
} }
) { ) {
Box( Box(
modifier = Modifier.Companion modifier = Modifier
.size(12.dp) .size(12.dp)
.clip(CircleShape) .clip(CircleShape)
.background(BanksiaTheme.colors.surface) .background(BanksiaTheme.colors.surface)

View file

@ -25,7 +25,7 @@ val ClientModule = module {
// HTTP Clients // HTTP Clients
singleOf(::PtvService) singleOf(::PtvService)
single { single {
HttpClient() { HttpClient {
install(ContentNegotiation) { install(ContentNegotiation) {
json(Json { json(Json {
ignoreUnknownKeys = true ignoreUnknownKeys = true

View file

@ -128,9 +128,9 @@ const val ICON_PADDING = 0.25f
@Composable @Composable
private fun RouteIconPreview() { private fun RouteIconPreview() {
Row { Row {
RouteIcon(routeType = RouteType.MetroTrain) RouteIcon(routeType = MetroTrain)
RouteIcon(routeType = RouteType.MetroTram) RouteIcon(routeType = MetroTram)
RouteIcon(routeType = RouteType.MetroBus) RouteIcon(routeType = MetroBus)
} }
} }

View file

@ -45,7 +45,7 @@ fun InfoPanel(
val localDensity = LocalDensity.current val localDensity = LocalDensity.current
Column( Column(
Modifier.Companion Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(horizontal = 24.dp) .padding(horizontal = 24.dp)
.heightIn(max = 250.dp) .heightIn(max = 250.dp)
@ -64,10 +64,10 @@ fun InfoPanel(
if (state.loading) if (state.loading)
CircularProgressIndicator( 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, state: InfoPanelState.Route,
onEvent: (MapScreenEvent) -> Unit, onEvent: (MapScreenEvent) -> Unit,
) { ) {
Column(Modifier.Companion.fillMaxWidth()) { Column(Modifier.fillMaxWidth()) {
Row { Row {
RouteIcon(routeType = state.type) RouteIcon(routeType = state.type)
Text( Text(
state.name, state.name,
style = MaterialTheme.typography.titleLarge, style = MaterialTheme.typography.titleLarge,
fontWeight = FontWeight.Companion.SemiBold, fontWeight = FontWeight.SemiBold,
textAlign = TextAlign.Companion.Start textAlign = TextAlign.Start
) )
} }
} }
@ -94,14 +94,14 @@ private inline fun RunInfoPanel(
state: InfoPanelState.Run, state: InfoPanelState.Run,
onEvent: (MapScreenEvent) -> Unit, onEvent: (MapScreenEvent) -> Unit,
) { ) {
Column(Modifier.Companion.fillMaxWidth()) { Column(Modifier.fillMaxWidth()) {
Row { Row {
RouteIcon(routeType = state.type) RouteIcon(routeType = state.type)
Text( Text(
"${state.direction} via ${state.routeName ?: "..."}", "${state.direction} via ${state.routeName ?: "..."}",
style = MaterialTheme.typography.titleLarge, style = MaterialTheme.typography.titleLarge,
fontWeight = FontWeight.Companion.SemiBold, fontWeight = FontWeight.SemiBold,
textAlign = TextAlign.Companion.Start textAlign = TextAlign.Start
) )
} }
} }
@ -112,37 +112,37 @@ private inline fun StopInfoPanel(
state: InfoPanelState.Stop, state: InfoPanelState.Stop,
onEvent: (MapScreenEvent) -> Unit, onEvent: (MapScreenEvent) -> Unit,
) { ) {
Column(Modifier.Companion.fillMaxWidth()) { Column(Modifier.fillMaxWidth()) {
Text( Text(
state.name, state.name,
style = MaterialTheme.typography.titleLarge, style = MaterialTheme.typography.titleLarge,
fontWeight = FontWeight.Companion.SemiBold, fontWeight = FontWeight.SemiBold,
textAlign = TextAlign.Companion.Start textAlign = TextAlign.Start
) )
state.subname?.let { state.subname?.let {
Text( Text(
"/ $it", "/ $it",
modifier = Modifier.Companion.padding(start = 5.dp), modifier = Modifier.padding(start = 5.dp),
style = MaterialTheme.typography.titleSmall, style = MaterialTheme.typography.titleSmall,
color = Color.Companion.Gray, color = Color.Gray,
fontWeight = FontWeight.Companion.SemiBold, fontWeight = FontWeight.SemiBold,
textAlign = TextAlign.Companion.Start textAlign = TextAlign.Start
) )
} }
state.departures?.let { state.departures?.let {
Spacer(Modifier.Companion.height(5.dp)) Spacer(Modifier.height(5.dp))
it.forEach { (name, formatted) -> it.forEach { (name, formatted) ->
Row(verticalAlignment = Alignment.Companion.CenterVertically) { Row(verticalAlignment = Alignment.CenterVertically) {
Text( Text(
name, name,
style = MaterialTheme.typography.titleMedium, style = MaterialTheme.typography.titleMedium,
fontWeight = FontWeight.Companion.SemiBold fontWeight = FontWeight.SemiBold
) )
Text( Text(
formatted, formatted,
maxLines = 1, maxLines = 1,
overflow = TextOverflow.Companion.Ellipsis, overflow = TextOverflow.Ellipsis,
modifier = Modifier.Companion.padding(horizontal = 5.dp) modifier = Modifier.padding(horizontal = 5.dp)
) )
} }
} }

View file

@ -44,16 +44,16 @@ fun Searcher(
label = "padding" label = "padding"
) )
Box(modifier = Modifier.Companion.fillMaxSize()) { Box(modifier = Modifier.fillMaxSize()) {
SearchBar( SearchBar(
modifier = Modifier.Companion modifier = Modifier
.align(Alignment.Companion.TopCenter) .align(Alignment.TopCenter)
.fillMaxWidth() .fillMaxWidth()
.padding(horizontal = animatedPadding), .padding(horizontal = animatedPadding),
shadowElevation = 6.dp, // Elevation level 3 shadowElevation = 6.dp, // Elevation level 3
inputField = { inputField = {
SearchBarDefaults.InputField( SearchBarDefaults.InputField(
modifier = Modifier.Companion.padding(horizontal = 20.dp - animatedPadding), modifier = Modifier.padding(horizontal = 20.dp - animatedPadding),
query = state.text, query = state.text,
onQueryChange = { onEvent(MapScreenEvent.SearchUpdate(it)) }, onQueryChange = { onEvent(MapScreenEvent.SearchUpdate(it)) },
onSearch = {}, onSearch = {},
@ -65,7 +65,7 @@ fun Searcher(
Icon( Icon(
imageVector = Icons.Default.Clear, imageVector = Icons.Default.Clear,
contentDescription = null, contentDescription = null,
modifier = Modifier.Companion.clickable { modifier = Modifier.clickable {
onEvent( onEvent(
MapScreenEvent.SearchUpdate( MapScreenEvent.SearchUpdate(
"" ""
@ -79,15 +79,15 @@ fun Searcher(
expanded = expanded, expanded = expanded,
onExpandedChange = onExpandedChange, onExpandedChange = onExpandedChange,
) { ) {
LazyColumn(modifier = Modifier.Companion.fillMaxWidth()) { LazyColumn(modifier = Modifier.fillMaxWidth()) {
for (entry in state.entries) { for (entry in state.entries) {
item { item {
ListItem( ListItem(
headlineContent = { Text(entry.mainText) }, headlineContent = { Text(entry.mainText) },
supportingContent = { entry.subText?.let { Text(it) } }, supportingContent = { entry.subText?.let { Text(it) } },
leadingContent = { RouteIcon(routeType = entry.routeType) }, leadingContent = { RouteIcon(routeType = entry.routeType) },
colors = ListItemDefaults.colors(containerColor = Color.Companion.Transparent), colors = ListItemDefaults.colors(containerColor = Color.Transparent),
modifier = Modifier.Companion modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(horizontal = 16.dp, vertical = 4.dp) .padding(horizontal = 16.dp, vertical = 4.dp)
.clickable { .clickable {

View file

@ -87,7 +87,7 @@ fun MapScreen(
) { ) {
val offset = runCatching { sheetState.requireOffset() } val offset = runCatching { sheetState.requireOffset() }
val scaffoldOffset = offset.getOrDefault(0.0f).roundToInt() val scaffoldOffset = offset.getOrDefault(0.0f).roundToInt()
(getScreenHeight() - scaffoldOffset - WindowInsets.Companion.safeDrawing.getBottom( (getScreenHeight() - scaffoldOffset - WindowInsets.safeDrawing.getBottom(
LocalDensity.current)).coerceAtLeast(0) LocalDensity.current)).coerceAtLeast(0)
} else 0 } else 0
@ -108,7 +108,7 @@ fun MapScreen(
BottomSheetScaffold( BottomSheetScaffold(
scaffoldState = scaffoldState, scaffoldState = scaffoldState,
sheetPeekHeight = (handleHeight + peekHeight) * peekHeightMultiplier, sheetPeekHeight = (handleHeight + peekHeight) * peekHeightMultiplier,
modifier = Modifier.Companion.fillMaxSize(), modifier = Modifier.fillMaxSize(),
sheetContent = { sheetContent = {
InfoPanel( InfoPanel(
state = infoState, state = infoState,
@ -119,20 +119,20 @@ fun MapScreen(
sheetDragHandle = { sheetDragHandle = {
val density = LocalDensity.current val density = LocalDensity.current
Box( Box(
Modifier.Companion Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(horizontal = 10.dp) .padding(horizontal = 10.dp)
.onSizeChanged { .onSizeChanged {
handleHeight = with(density) { it.height.toDp() } handleHeight = with(density) { it.height.toDp() }
} }
) { ) {
BottomSheetDefaults.DragHandle(modifier = Modifier.Companion.align(Alignment.Companion.Center)) BottomSheetDefaults.DragHandle(modifier = Modifier.align(Alignment.Center))
} }
}, },
sheetSwipeEnabled = sheetSwipeEnabled, sheetSwipeEnabled = sheetSwipeEnabled,
) { ) {
Maps( Maps(
modifier = Modifier.Companion.fillMaxSize(), modifier = Modifier.fillMaxSize(),
state = mapState, state = mapState,
onEvent = viewModel::handleEvent, onEvent = viewModel::handleEvent,
cameraPositionFlow = viewModel.cameraChangeEmitter, cameraPositionFlow = viewModel.cameraChangeEmitter,
@ -175,12 +175,14 @@ fun MapScreen(
} }
Box( Box(
Modifier.Companion.windowInsetsPadding( modifier = Modifier
WindowInsets.Companion.safeContent.add( .fillMaxSize()
WindowInsets(bottom = extInsets) .windowInsetsPadding(
) WindowInsets.safeContent.add(
), WindowInsets(bottom = extInsets)
contentAlignment = Alignment.Companion.BottomEnd )
),
contentAlignment = Alignment.BottomEnd
) { ) {
FloatingActionButton( FloatingActionButton(
containerColor = MaterialTheme.colorScheme.surfaceContainer, containerColor = MaterialTheme.colorScheme.surfaceContainer,

View file

@ -241,7 +241,7 @@ class MapScreenViewModel(
if (element.size >= 5) if (element.size >= 5)
return@forEach 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 val min = (date - Clock.System.now()).inWholeMinutes
if (min <= -5) if (min <= -5)
return@forEach return@forEach
@ -344,13 +344,13 @@ class MapScreenViewModel(
var west = Double.MAX_VALUE var west = Double.MAX_VALUE
points.forEach { points.forEach {
if (it.lat > north) if (it.lat > north)
north = it.lat; north = it.lat
if (it.lat < south) if (it.lat < south)
south = it.lat; south = it.lat
if (it.lng > east) if (it.lng > east)
east = it.lng; east = it.lng
if (it.lng < west) if (it.lng < west)
west = it.lng; west = it.lng
} }
return CameraPositionBounds(Point(north, east), Point(south, west)) return CameraPositionBounds(Point(north, east), Point(south, west))
} }

View file

@ -69,7 +69,7 @@ class PtvService() {
val cache = PtvCache() val cache = PtvCache()
private val client = HttpClient() { private val client = HttpClient {
install(ContentNegotiation) { install(ContentNegotiation) {
json(Json { json(Json {
ignoreUnknownKeys = true ignoreUnknownKeys = true
@ -232,7 +232,7 @@ class PtvService() {
url { url {
appendPathSegments( appendPathSegments(
"route_type", routeType.asPtvType().ordinal.toString(), "route_type", routeType.asPtvType().ordinal.toString(),
"stop", stopId.toString(), "stop", stopId,
) )
parameter("expand", "Route") parameter("expand", "Route")
parameter("expand", "Direction") parameter("expand", "Direction")

View file

@ -28,7 +28,7 @@ data class FutureTime(
fun FutureTime.asInt() = fun FutureTime.asInt() =
trueHour * 3600 + minute * 60 + second trueHour * 3600 + minute * 60 + second
fun fromInt(int: Int) = FutureTime.from( fun fromInt(int: Int) = from(
int / 3600, int / 3600,
(int / 60) % 60, (int / 60) % 60,
int % 60, int % 60,

View file

@ -29,7 +29,7 @@ class CacheMap<K, V>(
} }
override fun put(key: K, value: V): 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) return innerMap.put(key, value)
} }

View file

@ -28,7 +28,7 @@ class LoopFlow<T>(private val block: suspend FlowCollector<T>.() -> Unit) : Abst
fun <T> Flow<T>.delayFor(delay: Long) = apply { fun <T> Flow<T>.delayFor(delay: Long) = apply {
@Suppress("UnusedFlow") @Suppress("UnusedFlow")
if (this is LoopFlow) if (this is LoopFlow)
this.delayMs = delay; this.delayMs = delay
else else
throw IllegalStateException() 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 { fun <T> Flow<T>.initWith(block: suspend FlowCollector<T>.() -> Unit) = apply {
@Suppress("UnusedFlow") @Suppress("UnusedFlow")
if (this is LoopFlow) if (this is LoopFlow)
this.init = block; this.init = block
else else
throw IllegalStateException() 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 { fun <T> Flow<T>.waitFor(waiter: suspend () -> Unit) = apply {
@Suppress("UnusedFlow") @Suppress("UnusedFlow")
if (this is LoopFlow) if (this is LoopFlow)
this.waiter = waiter; this.waiter = waiter
else else
throw IllegalStateException() throw IllegalStateException()
} }