Quellcode durchsuchen

Change Refresh Icon with Current Location Refresh

codeskraps vor 1 Jahr
Ursprung
Commit
4a740b702d

+ 3 - 1
app/src/main/java/com/example/weather/feature/geocoding/presentation/GeocodingViewModel.kt

@@ -48,7 +48,9 @@ class GeocodingViewModel @Inject constructor(
             when (val result = geocodingRepository.getCachedGeoLocation()) {
                 is Resource.Success -> {
                     if ((result.data?.size ?: 0) > 0) {
-                        state.handleEvent(GeoEvent.Loaded(result.data!!.sortedBy { it.name }))
+                        val cachedGeoLocations = result.data!!.sortedBy { it.name }
+                        state.handleEvent(GeoEvent.Loaded(cachedGeoLocations))
+
                     } else {
                         state.handleEvent(GeoEvent.Error("No results"))
                     }

+ 3 - 5
app/src/main/java/com/example/weather/feature/weather/presentation/components/WeatherScreen.kt

@@ -14,7 +14,7 @@ import androidx.compose.foundation.lazy.LazyColumn
 import androidx.compose.foundation.shape.CircleShape
 import androidx.compose.material.ExperimentalMaterialApi
 import androidx.compose.material.icons.Icons
-import androidx.compose.material.icons.filled.Refresh
+import androidx.compose.material.icons.filled.LocationOn
 import androidx.compose.material.icons.filled.Search
 import androidx.compose.material.pullrefresh.PullRefreshIndicator
 import androidx.compose.material.pullrefresh.pullRefresh
@@ -100,13 +100,11 @@ fun WeatherScreen(
                 actions = {
                     IconButton(onClick = {
                         viewModel.state.handleEvent(
-                            WeatherEvent.LoadWeatherInfo(
-                                geoLocation
-                            )
+                            WeatherEvent.LoadWeatherInfo(WeatherLocation())
                         )
                     }) {
                         Icon(
-                            imageVector = Icons.Filled.Refresh,
+                            imageVector = Icons.Filled.LocationOn,
                             tint = MaterialTheme.colorScheme.primary,
                             contentDescription = "Refresh"
                         )