Browse Source

Update light (snow/drizzle) night assets

Carles Sentis 1 year ago
parent
commit
85aba8450c

+ 10 - 5
app/src/main/java/com/example/weather/app/ui/MainActivity.kt

@@ -43,22 +43,27 @@ class MainActivity : ComponentActivity() {
                         val state by viewModel.state.collectAsStateWithLifecycle()
 
                         WeatherScreen(
-                            navController = navController,
                             state = state,
                             handleEvent = viewModel.state::handleEvent,
                             action = viewModel.action
-                        )
+                        ) { route ->
+                            navController.navigate(route)
+                        }
                     }
                     composable(Screen.Geocoding.route) {
                         val viewModel = hiltViewModel<GeocodingViewModel>()
                         val state by viewModel.state.collectAsStateWithLifecycle()
 
                         GeocodingScreen(
-                            navController = navController,
                             state = state,
                             handleEvent = viewModel.state::handleEvent,
-                            action = viewModel.action
-                        )
+                            action = viewModel.action,
+                            navUp = { navController.navigateUp() }
+                        ) { route ->
+                            navController.navigate(route) {
+                                popUpTo(navController.graph.id) { inclusive = true }
+                            }
+                        }
                     }
                 }
             }

+ 8 - 20
feature/geocoding/src/main/java/com/trifork/feature/geocoding/presentation/components/GeocodingScreen.kt

@@ -30,10 +30,6 @@ import androidx.compose.material3.Text
 import androidx.compose.material3.TopAppBar
 import androidx.compose.material3.TopAppBarDefaults
 import androidx.compose.runtime.Composable
-import androidx.compose.runtime.getValue
-import androidx.compose.runtime.mutableStateOf
-import androidx.compose.runtime.remember
-import androidx.compose.runtime.setValue
 import androidx.compose.ui.Alignment
 import androidx.compose.ui.Alignment.Companion.CenterVertically
 import androidx.compose.ui.ExperimentalComposeUiApi
@@ -47,10 +43,9 @@ import androidx.compose.ui.text.style.TextAlign
 import androidx.compose.ui.text.style.TextOverflow
 import androidx.compose.ui.unit.dp
 import androidx.lifecycle.compose.LifecycleResumeEffect
-import androidx.navigation.NavController
+import com.trifork.feature.common.R
 import com.trifork.feature.common.components.ObserveAsEvents
 import com.trifork.feature.common.navigation.Screen
-import com.trifork.feature.common.R
 import com.trifork.feature.geocoding.presentation.mvi.GeoAction
 import com.trifork.feature.geocoding.presentation.mvi.GeoEvent
 import com.trifork.feature.geocoding.presentation.mvi.GeoState
@@ -59,10 +54,11 @@ import kotlinx.coroutines.flow.Flow
 @OptIn(ExperimentalMaterial3Api::class, ExperimentalComposeUiApi::class)
 @Composable
 fun GeocodingScreen(
-    navController: NavController,
     state: GeoState,
     handleEvent: (GeoEvent) -> Unit,
-    action: Flow<GeoAction>
+    action: Flow<GeoAction>,
+    navUp: () -> Unit,
+    navRoute: (String) -> Unit
 ) {
     val context = LocalContext.current
     val resources = context.resources
@@ -75,11 +71,7 @@ fun GeocodingScreen(
     ObserveAsEvents(flow = action) { onAction ->
         when (onAction) {
             is GeoAction.ShowToast -> {
-                Toast.makeText(
-                    context,
-                    onAction.message,
-                    Toast.LENGTH_SHORT,
-                ).show()
+                Toast.makeText(context, onAction.message, Toast.LENGTH_SHORT).show()
             }
         }
     }
@@ -99,7 +91,7 @@ fun GeocodingScreen(
                         Icons.Default.ArrowBack,
                         tint = MaterialTheme.colorScheme.primary,
                         contentDescription = resources.getString(R.string.back),
-                        modifier = Modifier.clickable { navController.navigateUp() },
+                        modifier = Modifier.clickable { navUp() },
                     )
                 }
             )
@@ -160,17 +152,13 @@ fun GeocodingScreen(
                                     modifier = Modifier
                                         .fillMaxSize()
                                         .clickable {
-                                            navController.navigate(
+                                            navRoute(
                                                 Screen.Weather.createRoute(
                                                     geoLocation.displayName(),
                                                     geoLocation.latitude,
                                                     geoLocation.longitude
                                                 )
-                                            ) {
-                                                popUpTo(navController.graph.id) {
-                                                    inclusive = true
-                                                }
-                                            }
+                                            )
                                         },
                                     horizontalArrangement = Arrangement.SpaceBetween
                                 ) {

+ 1 - 1
feature/weather/src/main/java/com/trifork/feature/weather/domain/model/WeatherType.kt

@@ -135,7 +135,7 @@ sealed class WeatherType(
 
     data object SlightSnowFallNight : WeatherType(
         weatherDescRes = com.trifork.feature.common.R.string.slight_snow_fall,
-        iconRes = R.drawable.ic_light_drizzel_night
+        iconRes = R.drawable.ic_light_snow_night
     )
 
     data object ModerateSnowFallDay : WeatherType(

+ 6 - 5
feature/weather/src/main/java/com/trifork/feature/weather/presentation/components/WeatherScreen.kt

@@ -58,10 +58,10 @@ import kotlinx.coroutines.flow.Flow
 @OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterialApi::class)
 @Composable
 fun WeatherScreen(
-    navController: NavController,
     state: WeatherState,
     handleEvent: (WeatherEvent) -> Unit,
-    action: Flow<WeatherAction>
+    action: Flow<WeatherAction>,
+    navRoute: (String) -> Unit
 ) {
 
     var menuExpanded by remember {
@@ -87,8 +87,9 @@ fun WeatherScreen(
     val context = LocalContext.current
     ObserveAsEvents(flow = action) { onAction ->
         when (onAction) {
-            is WeatherAction.Toast -> Toast.makeText(context, onAction.message, Toast.LENGTH_LONG)
-                .show()
+            is WeatherAction.Toast -> {
+                Toast.makeText(context, onAction.message, Toast.LENGTH_LONG).show()
+            }
         }
     }
 
@@ -182,7 +183,7 @@ fun WeatherScreen(
                 FloatingActionButton(
                     shape = CircleShape,
                     containerColor = MaterialTheme.colorScheme.primaryContainer,
-                    onClick = { navController.navigate(Screen.Geocoding.route) }) {
+                    onClick = { navRoute(Screen.Geocoding.route) }) {
                     Icon(
                         Icons.Default.Search,
                         tint = MaterialTheme.colorScheme.primary,

+ 3 - 21
feature/weather/src/main/res/drawable/ic_light_drizzel_night.xml

@@ -28,27 +28,9 @@
       android:strokeColor="#fff"/>
     <path
         android:fillColor="#00000000"
-        android:pathData="M28,32.5L28,37.5"
-        android:strokeWidth="1.2"
-        android:strokeColor="#57a0ee"
-        android:strokeLineCap="round" />
-    <path
-        android:fillColor="#00000000"
-        android:pathData="M29.768,33.232L26.232,36.768"
-        android:strokeWidth="1"
-        android:strokeColor="#57a0ee"
-        android:strokeLineCap="round" />
-    <path
-        android:fillColor="#00000000"
-        android:pathData="M30.5,35L25.5,35"
-        android:strokeWidth="1"
-        android:strokeColor="#57a0ee"
-        android:strokeLineCap="round" />
-    <path
-        android:fillColor="#00000000"
-        android:pathData="M29.768,36.768L26.232,33.232"
-        android:strokeWidth="1"
-        android:strokeColor="#57a0ee"
+        android:pathData="M26.918,32.944L25.529,40.822"
+        android:strokeWidth="2"
+        android:strokeColor="#91c0f8"
         android:strokeLineCap="round" />
   </group>
 </vector>

+ 54 - 0
feature/weather/src/main/res/drawable/ic_light_snow_night.xml

@@ -0,0 +1,54 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="56dp"
+    android:height="48dp"
+    android:viewportWidth="56"
+    android:viewportHeight="48">
+    <group
+        android:scaleX="1.1"
+        android:scaleY="1.1"
+        android:translateX="-7"
+        android:translateY="0">
+        <path
+            android:pathData="M33.2,4.64l0.96,-0.48l0.48,-0.96l0.56,0.96l0.96,0.48l-0.96,0.56l-0.56,0.96l-0.48,-0.96z"
+            android:fillColor="#ffa500"/>
+        <path
+            android:pathData="M49.2,12.64l0.96,-0.48l0.48,-0.96l0.56,0.96l0.96,0.48l-0.96,0.56l-0.56,0.96l-0.48,-0.96z"
+            android:fillColor="#ffa500"/>
+        <path
+            android:pathData="m43.6,12.56c0,-2.96 1.6,-5.52 4,-6.96 -1.2,-0.72 -2.56,-1.04 -4,-1.04 -4.4,0 -8,3.6 -8,8s3.6,8 8,8c1.44,0 2.8,-0.4 4,-1.04 -2.4,-1.36 -4,-4 -4,-6.96z"
+            android:strokeLineJoin="round"
+            android:strokeWidth="1.6"
+            android:fillColor="#ffa500"
+            android:strokeColor="#ffa500"/>
+        <path
+            android:pathData="m43.7,22.4c0,-4.6 -3.7,-8.2 -8.2,-8.2 -1,0 -1.9,0.2 -2.8,0.5 -0.3,-3.4 -3.1,-6.2 -6.6,-6.2 -3.7,0 -6.7,3 -6.7,6.7 0,0.8 0.2,1.6 0.4,2.3 -0.3,-0.1 -0.7,-0.1 -1,-0.1 -3.7,0 -6.7,3 -6.7,6.7 0,3.6 2.9,6.6 6.5,6.7h17.2c4.4,-0.5 7.9,-4 7.9,-8.4z"
+            android:strokeLineJoin="round"
+            android:strokeWidth="1.2"
+            android:fillColor="#57a0ee"
+            android:strokeColor="#fff"/>
+        <path
+            android:fillColor="#00000000"
+            android:pathData="M28,32.5L28,37.5"
+            android:strokeWidth="1.2"
+            android:strokeColor="#57a0ee"
+            android:strokeLineCap="round" />
+        <path
+            android:fillColor="#00000000"
+            android:pathData="M29.768,33.232L26.232,36.768"
+            android:strokeWidth="1"
+            android:strokeColor="#57a0ee"
+            android:strokeLineCap="round" />
+        <path
+            android:fillColor="#00000000"
+            android:pathData="M30.5,35L25.5,35"
+            android:strokeWidth="1"
+            android:strokeColor="#57a0ee"
+            android:strokeLineCap="round" />
+        <path
+            android:fillColor="#00000000"
+            android:pathData="M29.768,36.768L26.232,33.232"
+            android:strokeWidth="1"
+            android:strokeColor="#57a0ee"
+            android:strokeLineCap="round" />
+    </group>
+</vector>