From 83e595b51ebd5b70acfaf9b25cf81464545f3cee Mon Sep 17 00:00:00 2001 From: Cristan Meijer Date: Sun, 3 Nov 2024 11:32:39 +0100 Subject: [PATCH] Clean up the no GPS location found code --- .../nl/ovfietsbeschikbaarheid/ui/screen/HomeScreen.kt | 8 ++++---- .../nl/ovfietsbeschikbaarheid/viewmodel/HomeViewModel.kt | 6 +++--- app/src/main/res/values/strings.xml | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/nl/ovfietsbeschikbaarheid/ui/screen/HomeScreen.kt b/app/src/main/java/nl/ovfietsbeschikbaarheid/ui/screen/HomeScreen.kt index 4657f90..cc0dc26 100644 --- a/app/src/main/java/nl/ovfietsbeschikbaarheid/ui/screen/HomeScreen.kt +++ b/app/src/main/java/nl/ovfietsbeschikbaarheid/ui/screen/HomeScreen.kt @@ -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) ) } @@ -463,8 +463,8 @@ fun LoadingGpsPreview() { @Preview @Composable -fun GpsErrorPreview() { - TestHomeView("", HomeContent.GpsError("Geen locatie gevonden")) +fun NoGpsLocationPreview() { + TestHomeView("", HomeContent.NoGpsLocation) } @Preview diff --git a/app/src/main/java/nl/ovfietsbeschikbaarheid/viewmodel/HomeViewModel.kt b/app/src/main/java/nl/ovfietsbeschikbaarheid/viewmodel/HomeViewModel.kt index a05875d..e0a9d6a 100644 --- a/app/src/main/java/nl/ovfietsbeschikbaarheid/viewmodel/HomeViewModel.kt +++ b/app/src/main/java/nl/ovfietsbeschikbaarheid/viewmodel/HomeViewModel.kt @@ -50,7 +50,7 @@ class HomeViewModel( loadLocation() } - currentlyShown is HomeContent.GpsError -> { + currentlyShown is HomeContent.NoGpsLocation -> { // Let's try again loadLocation() } @@ -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) @@ -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, diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9e17a8d..68d1f7e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -39,6 +39,7 @@ Geen zoekresultaten voor \"%1$s\" In de buurt van \"%1$s\" + Geen locatie gevonden OV-fietsen beschikbaar Max aantal: %1$d