Skip to content

Commit

Permalink
Apply statusbarspadding
Browse files Browse the repository at this point in the history
  • Loading branch information
ksharma-xyz committed Oct 30, 2024
1 parent c860e7c commit 0f0f6da
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 51 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package xyz.ksharma.krail.trip.planner.ui.searchstop

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.lazy.LazyColumn
Expand Down Expand Up @@ -40,7 +41,6 @@ import xyz.ksharma.krail.trip.planner.ui.state.searchstop.model.StopItem
/**
* TODO - implement scroll to top, when too many search results are displayed.
*/
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun SearchStopScreen(
searchStopState: SearchStopState,
Expand Down Expand Up @@ -71,62 +71,63 @@ fun SearchStopScreen(
.collectLatest {}
}

LazyColumn(
Column(
modifier = modifier
.fillMaxSize()
.background(color = KrailTheme.colors.background),
contentPadding = PaddingValues(vertical = 16.dp),
.background(color = KrailTheme.colors.background)
.statusBarsPadding()
.imePadding(),
) {
stickyHeader {
TextField(
placeholder = "Search for stop",
modifier = Modifier
.focusRequester(focusRequester)
.padding(horizontal = 16.dp)
.padding(bottom = 12.dp)
.statusBarsPadding(),
) { value ->
Timber.d("value: $value")
textFieldText = value.toString()
}
TextField(
placeholder = "Search station / stop",
modifier = Modifier
.focusRequester(focusRequester)
.padding(horizontal = 16.dp),
) { value ->
Timber.d("value: $value")
textFieldText = value.toString()
}

if (searchStopState.isLoading) {
item {
Text(
text = "Loading...",
modifier = Modifier.padding(horizontal = 16.dp),
)
}
} else if (searchStopState.isError) {
item {
Text(
text = "Error",
modifier = Modifier.padding(horizontal = 16.dp),
)
}
} else if (searchStopState.stops.isNotEmpty() && textFieldText.isNotBlank()) {
searchStopState.stops.forEach { stop ->
LazyColumn(
contentPadding = PaddingValues(top = 16.dp, bottom = 48.dp),
) {
if (searchStopState.isLoading) {
item {
Text(
text = "Loading...",
modifier = Modifier.padding(horizontal = 16.dp),
)
}
} else if (searchStopState.isError) {
item {
StopSearchListItem(
stopId = stop.stopId,
stopName = stop.stopName,
transportModeSet = stop.transportModeType.toImmutableSet(),
onClick = { stopItem ->
keyboard?.hide()
onStopSelect(stopItem)
},
Text(
text = "Error",
modifier = Modifier.padding(horizontal = 16.dp),
)
}
} else if (searchStopState.stops.isNotEmpty() && textFieldText.isNotBlank()) {
searchStopState.stops.forEach { stop ->
item {
StopSearchListItem(
stopId = stop.stopId,
stopName = stop.stopName,
transportModeSet = stop.transportModeType.toImmutableSet(),
onClick = { stopItem ->
keyboard?.hide()
onStopSelect(stopItem)
},
)

Divider()
Divider()
}
}
} else {
item {
Text(
text = "Display Recent Search",
modifier = Modifier.padding(horizontal = 16.dp),
)
}
}
} else {
item {
Text(
text = "Display Recent Search",
modifier = Modifier.padding(horizontal = 16.dp),
)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions feature/trip-planner/ui/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="saved_trips_screen_title">Saved Trips</string>
<string name="from_text_field_placeholder">Starting from</string>
<string name="to_text_field_placeholder">To Destination</string>
<string name="from_text_field_placeholder">Starting from..</string>
<string name="to_text_field_placeholder">Going to..</string>
<string name="time_table_screen_title">Time Table</string>
<plurals name="stops">
<item quantity="one">%d stop</item>
Expand Down

0 comments on commit 0f0f6da

Please sign in to comment.