Skip to content

Commit

Permalink
Clean up the no GPS location found code
Browse files Browse the repository at this point in the history
  • Loading branch information
cristan committed Nov 3, 2024
1 parent 24dc4d8 commit 83e595b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ private fun HomeView(
)
}

is HomeContent.GpsError -> {
is HomeContent.NoGpsLocation -> {
Text(
text = screen.message,
text = stringResource(R.string.home_no_gps_location),
modifier = Modifier.padding(horizontal = 16.dp)
)
}
Expand Down Expand Up @@ -463,8 +463,8 @@ fun LoadingGpsPreview() {

@Preview
@Composable
fun GpsErrorPreview() {
TestHomeView("", HomeContent.GpsError("Geen locatie gevonden"))
fun NoGpsLocationPreview() {
TestHomeView("", HomeContent.NoGpsLocation)
}

@Preview
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class HomeViewModel(
loadLocation()
}

currentlyShown is HomeContent.GpsError -> {
currentlyShown is HomeContent.NoGpsLocation -> {
// Let's try again
loadLocation()
}
Expand Down Expand Up @@ -184,7 +184,7 @@ class HomeViewModel(

val coordinates = locationLoader.loadCurrentCoordinates()
if (coordinates == null) {
_content.value = HomeContent.GpsError("Geen locatie gevonden")
_content.value = HomeContent.NoGpsLocation
} else {
val locationsWithDistance =
LocationsMapper.withDistance(overviewRepository.getAllLocations(), coordinates)
Expand All @@ -210,7 +210,7 @@ sealed class HomeContent {

data object GpsTurnedOff : HomeContent()

data class GpsError(val message: String) : HomeContent()
data object NoGpsLocation: HomeContent()

data class GpsContent(
val locations: List<LocationOverviewWithDistanceModel>,
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

<string name="home_no_search_results_for">Geen zoekresultaten voor \"%1$s\"</string>
<string name="home_search_results_for">In de buurt van \"%1$s\"</string>
<string name="home_no_gps_location">Geen locatie gevonden</string>

<string name="details_amount_available">OV-fietsen beschikbaar</string>
<string name="details_capacity">Max aantal: %1$d</string>
Expand Down

0 comments on commit 83e595b

Please sign in to comment.