Modern Apps git

← Modern-Apps.git

health: preview tab chrome in screenshots

Commit
c1dad0f28d1b5962d6fb4e059978a5d8eea2c3e8
Author
vayun-mathur <[email protected]>
When
2026-10-25 21:25 UTC (1 month ago)
Parents
bd5e4e9

Diff

health/src/screenshotTest/kotlin/com/vayunmathur/health/ui/MetadataPreviews.kt
diff --git a/health/src/screenshotTest/kotlin/com/vayunmathur/health/ui/MetadataPreviews.kt b/health/src/screenshotTest/kotlin/com/vayunmathur/health/ui/MetadataPreviews.ktindex 4451c8e00e..1fbe186852 100644--- a/health/src/screenshotTest/kotlin/com/vayunmathur/health/ui/MetadataPreviews.kt+++ b/health/src/screenshotTest/kotlin/com/vayunmathur/health/ui/MetadataPreviews.kt@@ -1,8 +1,15 @@ package com.vayunmathur.health.ui +import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable+import androidx.compose.runtime.CompositionLocalProvider+import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview+import androidx.navigationevent.compose.LocalNavigationEventDispatcherOwner+import androidx.navigationevent.compose.rememberNavigationEventDispatcherOwner import com.android.tools.screenshot.PreviewTest+import com.vayunmathur.health.Route import com.vayunmathur.health.data.NutritionData import com.vayunmathur.health.util.MainPageMetrics import com.vayunmathur.health.util.MetricDetailsActions@@ -12,6 +19,15 @@ import com.vayunmathur.health.util.NutritionUiState import com.vayunmathur.health.util.TodayActions import com.vayunmathur.health.util.TodayUiState import com.vayunmathur.library.ui.DynamicTheme+import com.vayunmathur.library.ui.IconBodySystem+import com.vayunmathur.library.ui.IconFavorite+import com.vayunmathur.library.ui.IconFire+import com.vayunmathur.library.ui.IconMedicalServices+import com.vayunmathur.library.util.BottomBarItem+import com.vayunmathur.library.util.BottomNavBar+import com.vayunmathur.library.util.MainNavigation+import com.vayunmathur.library.util.SiblingPage+import com.vayunmathur.library.util.rememberNavBackStack import kotlinx.datetime.LocalDate  /** Phone-shaped, roughly 1080x2340 at xxhdpi — comfortably above the F-Droid minimum. */@@ -60,7 +76,7 @@ class MetadataPreviews {     @Preview(name = "1-today", device = PHONE, group = "phone", showSystemUi = true)     @Composable     fun Preview1Today() {-        DynamicTheme(darkTheme = true) {+        ChromePreview(Route.Today) {             TodayScreen(                 state = TodayUiState(                     steps = 8_432L,@@ -87,7 +103,7 @@ class MetadataPreviews {     @Preview(name = "2-nutrition", device = PHONE, group = "phone", showSystemUi = true)     @Composable     fun Preview2Nutrition() {-        DynamicTheme(darkTheme = true) {+        ChromePreview(Route.NutritionDetails) {             NutritionScreen(                 state = NutritionUiState(                     totals = NutritionData(@@ -122,7 +138,7 @@ class MetadataPreviews {         val fullNames = listOf(             "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday",         )-        DynamicTheme(darkTheme = true) {+        ChromePreview(Route.BarChartDetails(HealthMetricConfig.STEPS)) {             BarChartDetailsScreen(                 state = MetricDetailsUiState(                     config = HealthMetricConfig.STEPS,@@ -159,7 +175,7 @@ class MetadataPreviews {             78.0, 74.0, 76.0, 80.0, 84.0, 79.0, 77.0, 88.0,             112.0, 134.0, 141.0, 96.0, 82.0, 74.0, 66.0, 60.0,         )-        DynamicTheme(darkTheme = true) {+        ChromePreview(Route.BarChartDetails(HealthMetricConfig.HEART_RATE)) {             BarChartDetailsScreen(                 state = MetricDetailsUiState(                     config = HealthMetricConfig.HEART_RATE,@@ -198,7 +214,7 @@ class MetadataPreviews {         val fullNames = listOf(             "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday",         )-        DynamicTheme(darkTheme = true) {+        ChromePreview(Route.BarChartDetails(HealthMetricConfig.STEPS)) {             BarChartDetailsScreen(                 state = MetricDetailsUiState(                     config = HealthMetricConfig.STEPS,@@ -223,6 +239,47 @@ class MetadataPreviews {             )         }     }++    /**+     * The app's real tab chrome around preview screen content: the same four+     * [BottomBarItem]s and unconditional [MainNavigation] host the activity+     * declares, with a literal back stack for the shown route. Body and Medical+     * need their ViewModels, so their entries show an empty page (never visible —+     * the stack stays on the previewed route).+     */+    @Composable+    private fun ChromePreview(route: Route, content: @Composable () -> Unit) {+        DynamicTheme(darkTheme = true) {+            CompositionLocalProvider(+                LocalNavigationEventDispatcherOwner provides rememberNavigationEventDispatcherOwner(+                    parent = null,+                ),+            ) {+                val backStack = rememberNavBackStack(route)+                MainNavigation(+                    backStack = backStack,+                    bottomBar = {+                        BottomNavBar(+                            backStack = backStack,+                            pages = listOf(+                                BottomBarItem("Today", Route.Today) { IconFavorite() },+                                BottomBarItem("Nutrition", Route.NutritionDetails) { IconFire() },+                                BottomBarItem("Body", Route.Body) { IconBodySystem() },+                                BottomBarItem("Medical", Route.Medical) { IconMedicalServices() },+                            ),+                            currentPage = backStack.last(),+                        )+                    },+                ) {+                    entry<Route.Today>(metadata = SiblingPage()) { content() }+                    entry<Route.NutritionDetails>(metadata = SiblingPage()) { content() }+                    entry<Route.BarChartDetails>(metadata = SiblingPage()) { content() }+                    entry<Route.Body>(metadata = SiblingPage()) { Box(Modifier.fillMaxSize()) }+                    entry<Route.Medical>(metadata = SiblingPage()) { Box(Modifier.fillMaxSize()) }+                }+            }+        }+    } }  /**
metadata_data/photos/health/large-tablet/1.png
diff --git a/metadata_data/photos/health/large-tablet/1.png b/metadata_data/photos/health/large-tablet/1.pngindex 494a60311c..df33bc2424 100644Binary files a/metadata_data/photos/health/large-tablet/1.png and b/metadata_data/photos/health/large-tablet/1.png differ
metadata_data/photos/health/phone/1.png
diff --git a/metadata_data/photos/health/phone/1.png b/metadata_data/photos/health/phone/1.pngindex e9e2d2514b..6d1def4b91 100644Binary files a/metadata_data/photos/health/phone/1.png and b/metadata_data/photos/health/phone/1.png differ
metadata_data/photos/health/phone/2.png
diff --git a/metadata_data/photos/health/phone/2.png b/metadata_data/photos/health/phone/2.pngindex 57b67b1ee8..4a3e802af8 100644Binary files a/metadata_data/photos/health/phone/2.png and b/metadata_data/photos/health/phone/2.png differ
metadata_data/photos/health/phone/3.png
diff --git a/metadata_data/photos/health/phone/3.png b/metadata_data/photos/health/phone/3.pngindex 9e3cd6e81f..8d66c01f8e 100644Binary files a/metadata_data/photos/health/phone/3.png and b/metadata_data/photos/health/phone/3.png differ
metadata_data/photos/health/phone/4.png
diff --git a/metadata_data/photos/health/phone/4.png b/metadata_data/photos/health/phone/4.pngindex a22fa3aa2a..c2fd3e307a 100644Binary files a/metadata_data/photos/health/phone/4.png and b/metadata_data/photos/health/phone/4.png differ