Modern Apps git

← Modern-Apps.git

all: chrome-wrapped screenshots for chess, youpipe, taxi; fix 5 broken preview modules

Commit
bb2349fc411279386605b8e5a779c7c641f0792e
Author
vayun-mathur <[email protected]>
When
2026-10-25 22:26 UTC (1 month ago)
Parents
ea0ec7a

Diff

backup/src/screenshotTest/kotlin/com/vayunmathur/backup/ui/MetadataPreviews.kt
diff --git a/backup/src/screenshotTest/kotlin/com/vayunmathur/backup/ui/MetadataPreviews.kt b/backup/src/screenshotTest/kotlin/com/vayunmathur/backup/ui/MetadataPreviews.ktindex a9a026f875..084c49c90d 100644--- a/backup/src/screenshotTest/kotlin/com/vayunmathur/backup/ui/MetadataPreviews.kt+++ b/backup/src/screenshotTest/kotlin/com/vayunmathur/backup/ui/MetadataPreviews.kt@@ -46,7 +46,6 @@ class MetadataPreviews {                 onFileBackupToggle = {},                 onBackupNow = {},                 onRestoreNow = {},-                onDismissMessages = {},             )         }     }
flashcards/src/screenshotTest/kotlin/com/vayunmathur/flashcards/ui/MetadataPreviews.kt
diff --git a/flashcards/src/screenshotTest/kotlin/com/vayunmathur/flashcards/ui/MetadataPreviews.kt b/flashcards/src/screenshotTest/kotlin/com/vayunmathur/flashcards/ui/MetadataPreviews.ktindex a7a917c826..dcadb7e096 100644--- a/flashcards/src/screenshotTest/kotlin/com/vayunmathur/flashcards/ui/MetadataPreviews.kt+++ b/flashcards/src/screenshotTest/kotlin/com/vayunmathur/flashcards/ui/MetadataPreviews.kt@@ -3,6 +3,7 @@ package com.vayunmathur.flashcards.ui import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable+import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview import com.android.tools.screenshot.PreviewTest import com.vayunmathur.flashcards.data.FIELD_SEPARATOR@@ -216,4 +217,3 @@ class MetadataPreviews {         }     } }-}
fooddelivery/src/screenshotTest/kotlin/com/vayunmathur/fooddelivery/ui/MetadataPreviews.kt
diff --git a/fooddelivery/src/screenshotTest/kotlin/com/vayunmathur/fooddelivery/ui/MetadataPreviews.kt b/fooddelivery/src/screenshotTest/kotlin/com/vayunmathur/fooddelivery/ui/MetadataPreviews.ktindex 8e29f7d45f..555add5341 100644--- a/fooddelivery/src/screenshotTest/kotlin/com/vayunmathur/fooddelivery/ui/MetadataPreviews.kt+++ b/fooddelivery/src/screenshotTest/kotlin/com/vayunmathur/fooddelivery/ui/MetadataPreviews.kt@@ -4,6 +4,7 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable+import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview import com.android.tools.screenshot.PreviewTest import com.vayunmathur.fooddelivery.data.CartItem@@ -13,6 +14,7 @@ import com.vayunmathur.fooddelivery.data.Merchant import com.vayunmathur.fooddelivery.data.MerchantDetail import com.vayunmathur.fooddelivery.data.Modifier as DataModifier import com.vayunmathur.fooddelivery.data.ModifierGroup+import com.vayunmathur.fooddelivery.data.SelectedModifier import com.vayunmathur.library.ui.DynamicTheme  /** Phone-shaped, roughly 1080x2340 at xxhdpi — comfortably above the F-Droid minimum. */@@ -204,7 +206,10 @@ class MetadataPreviews {         CartItem(             menuItem = carnitasTaco,             quantity = 2,-            selectedModifiers = listOf(DataModifier(id = 11, name = "Salsa verde"), DataModifier(id = 21, name = "Guacamole", price = 225)),+            selectedModifiers = listOf(+                SelectedModifier(modifierGroupId = 1, modifierId = 11, name = "Salsa verde"),+                SelectedModifier(modifierGroupId = 2, modifierId = 21, name = "Guacamole", price = 225),+            ),             merchantId = 101,             merchantName = "Taqueria del Sol",         ),
games/chess/src/screenshotTest/kotlin/com/vayunmathur/games/chess/MetadataPreviews.kt
diff --git a/games/chess/src/screenshotTest/kotlin/com/vayunmathur/games/chess/MetadataPreviews.kt b/games/chess/src/screenshotTest/kotlin/com/vayunmathur/games/chess/MetadataPreviews.ktindex 8429fb5ba5..b6233d89c9 100644--- a/games/chess/src/screenshotTest/kotlin/com/vayunmathur/games/chess/MetadataPreviews.kt+++ b/games/chess/src/screenshotTest/kotlin/com/vayunmathur/games/chess/MetadataPreviews.kt@@ -103,7 +103,7 @@ class MetadataPreviews {     @Preview(name = "4-game-expanded", device = EXPANDED, group = "large-tablet", showSystemUi = true)     @Composable     fun Preview4GameExpanded() {-        DynamicTheme(darkTheme = true) {+        ChromePreview(Route.Game) {             ChessGameScreen(                 state = ChessUiState(                     board = grecoAttack,
globalesim/src/main/java/com/vayunmathur/globalesim/ui/HomeScreen.kt
diff --git a/globalesim/src/main/java/com/vayunmathur/globalesim/ui/HomeScreen.kt b/globalesim/src/main/java/com/vayunmathur/globalesim/ui/HomeScreen.ktindex 35e23fb47d..1e037d4388 100644--- a/globalesim/src/main/java/com/vayunmathur/globalesim/ui/HomeScreen.kt+++ b/globalesim/src/main/java/com/vayunmathur/globalesim/ui/HomeScreen.kt@@ -60,6 +60,13 @@ fun HomeScreen(     onClearCryptoInvoice: () -> Unit,     onClaim: (simId: String) -> Unit,     onRefresh: () -> Unit,+    /**+     * Presents the Stripe payment sheet for a client secret. Hoisted so previews+     * can render without it: Stripe's launcher holds a ViewModel, which needs a+     * SavedStateRegistryOwner that Layoutlib does not provide. Production always+     * takes the default (null = real sheet).+     */+    onPresentPaymentSheet: ((secret: String) -> Unit)? = null, ) {     val messenger = rememberMessenger()     val context = LocalContext.current@@ -71,18 +78,26 @@ fun HomeScreen(             sheetError = null         }     }-    val paymentSheet = rememberPaymentSheet { result ->-        when (result) {-            is PaymentSheetResult.Completed -> {-                messenger.show("Payment complete — credit lands shortly.")-                onCardPurchaseDone(true)-            }-            is PaymentSheetResult.Canceled -> onCardPurchaseDone(false)-            is PaymentSheetResult.Failed -> {-                sheetError = result.error.localizedMessage ?: "Payment failed"-                onCardPurchaseDone(false)+    // The Stripe launcher holds a ViewModel, which Layoutlib cannot provide — so+    // previews pass onPresentPaymentSheet and skip creating the real sheet+    // entirely. rememberPaymentSheet itself would crash composition, not just+    // presentation, so the branch has to be around the remember, not the call.+    val paymentSheet = if (onPresentPaymentSheet == null) {+        rememberPaymentSheet { result ->+            when (result) {+                is PaymentSheetResult.Completed -> {+                    messenger.show("Payment complete — credit lands shortly.")+                    onCardPurchaseDone(true)+                }+                is PaymentSheetResult.Canceled -> onCardPurchaseDone(false)+                is PaymentSheetResult.Failed -> {+                    sheetError = result.error.localizedMessage ?: "Payment failed"+                    onCardPurchaseDone(false)+                }             }         }+    } else {+        null     }     // Present each client secret once. Saved across recreation so a rotation     // with the secret still pending doesn't present the sheet a second time.@@ -91,7 +106,8 @@ fun HomeScreen(     LaunchedEffect(pendingSecret) {         if (pendingSecret != null && pendingSecret != presentedSecret) {             presentedSecret = pendingSecret-            paymentSheet.presentWithPaymentIntent(pendingSecret, PaymentSheet.Configuration("Global eSIM"))+            onPresentPaymentSheet?.invoke(pendingSecret)+                ?: paymentSheet?.presentWithPaymentIntent(pendingSecret, PaymentSheet.Configuration("Global eSIM"))         }     }     AppScaffold(
globalesim/src/screenshotTest/kotlin/com/vayunmathur/globalesim/ui/MetadataPreviews.kt
diff --git a/globalesim/src/screenshotTest/kotlin/com/vayunmathur/globalesim/ui/MetadataPreviews.kt b/globalesim/src/screenshotTest/kotlin/com/vayunmathur/globalesim/ui/MetadataPreviews.ktindex ae0edfdb46..f9ef5361a6 100644--- a/globalesim/src/screenshotTest/kotlin/com/vayunmathur/globalesim/ui/MetadataPreviews.kt+++ b/globalesim/src/screenshotTest/kotlin/com/vayunmathur/globalesim/ui/MetadataPreviews.kt@@ -22,7 +22,7 @@ class MetadataPreviews {     private val demoProfile = ProfileDto(         iccid = "8999201200000000001",         status = "active",-        activationCode = "LPA:1$demo.example$CODE",+        activationCode = "LPA:1\$demo.example\$CODE",         smdpAddress = "demo.example",         walletUsdCents = 1250,     )@@ -59,6 +59,8 @@ class MetadataPreviews {                 onClearCryptoInvoice = {},                 onClaim = {},                 onRefresh = {},+                // No Stripe launcher in Layoutlib (it needs a SavedStateRegistryOwner).+                onPresentPaymentSheet = {},             )         }     }
logviewer/src/screenshotTest/kotlin/com/vayunmathur/logviewer/ui/MetadataPreviews.kt
diff --git a/logviewer/src/screenshotTest/kotlin/com/vayunmathur/logviewer/ui/MetadataPreviews.kt b/logviewer/src/screenshotTest/kotlin/com/vayunmathur/logviewer/ui/MetadataPreviews.ktindex 5e9c33a188..b7fd4f656b 100644--- a/logviewer/src/screenshotTest/kotlin/com/vayunmathur/logviewer/ui/MetadataPreviews.kt+++ b/logviewer/src/screenshotTest/kotlin/com/vayunmathur/logviewer/ui/MetadataPreviews.kt@@ -48,9 +48,9 @@ private val SAMPLE_LINES = listOf(     "    #01 pc 0000000000067890  /data/app/com.vayunmathur.weather/lib/arm64/libweather.so", ) -private const val SAMPLE_TRACE = """java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference+private val SAMPLE_TRACE = """java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference 	at com.vayunmathur.weather.platform.WeatherViewModel.refreshAll(WeatherViewModel.kt:42)-	at com.vayunmathur.weather.ui.HomePageKt$HomePage$3.invokeSuspend(HomePage.kt:118)+	at com.vayunmathur.weather.ui.HomePageKt${'$'}HomePage${'$'}3.invokeSuspend(HomePage.kt:118) 	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)"""  /**
metadata_data/photos/backup/phone/1.png
diff --git a/metadata_data/photos/backup/1.png b/metadata_data/photos/backup/phone/1.pngsimilarity index 100%rename from metadata_data/photos/backup/1.pngrename to metadata_data/photos/backup/phone/1.png
metadata_data/photos/backup/phone/2.png
diff --git a/metadata_data/photos/backup/2.png b/metadata_data/photos/backup/phone/2.pngsimilarity index 100%rename from metadata_data/photos/backup/2.pngrename to metadata_data/photos/backup/phone/2.png
metadata_data/photos/flashcards/large-tablet/1.png
diff --git a/metadata_data/photos/flashcards/large-tablet/1.png b/metadata_data/photos/flashcards/large-tablet/1.pngnew file mode 100644index 0000000000..370c259c12Binary files /dev/null and b/metadata_data/photos/flashcards/large-tablet/1.png differ
metadata_data/photos/flashcards/phone/1.png
diff --git a/metadata_data/photos/flashcards/phone/1.png b/metadata_data/photos/flashcards/phone/1.pngnew file mode 100644index 0000000000..bafe265a78Binary files /dev/null and b/metadata_data/photos/flashcards/phone/1.png differ
metadata_data/photos/flashcards/phone/2.png
diff --git a/metadata_data/photos/flashcards/phone/2.png b/metadata_data/photos/flashcards/phone/2.pngnew file mode 100644index 0000000000..ebb62a7de9Binary files /dev/null and b/metadata_data/photos/flashcards/phone/2.png differ
metadata_data/photos/flashcards/phone/3.png
diff --git a/metadata_data/photos/flashcards/phone/3.png b/metadata_data/photos/flashcards/phone/3.pngnew file mode 100644index 0000000000..cf1ada9db5Binary files /dev/null and b/metadata_data/photos/flashcards/phone/3.png differ
metadata_data/photos/flashcards/phone/4.png
diff --git a/metadata_data/photos/flashcards/phone/4.png b/metadata_data/photos/flashcards/phone/4.pngnew file mode 100644index 0000000000..546c2b7c92Binary files /dev/null and b/metadata_data/photos/flashcards/phone/4.png differ
metadata_data/photos/flashcards/phone/5.png
diff --git a/metadata_data/photos/flashcards/phone/5.png b/metadata_data/photos/flashcards/phone/5.pngnew file mode 100644index 0000000000..57fce3cde9Binary files /dev/null and b/metadata_data/photos/flashcards/phone/5.png differ
metadata_data/photos/fooddelivery/2.png
diff --git a/metadata_data/photos/fooddelivery/2.png b/metadata_data/photos/fooddelivery/2.pngdeleted file mode 100644index 27ef99eebd..0000000000Binary files a/metadata_data/photos/fooddelivery/2.png and /dev/null differ
metadata_data/photos/fooddelivery/3.png
diff --git a/metadata_data/photos/fooddelivery/3.png b/metadata_data/photos/fooddelivery/3.pngdeleted file mode 100644index 980fc4e4d5..0000000000Binary files a/metadata_data/photos/fooddelivery/3.png and /dev/null differ
metadata_data/photos/fooddelivery/large-tablet/1.png
diff --git a/metadata_data/photos/fooddelivery/large-tablet/1.png b/metadata_data/photos/fooddelivery/large-tablet/1.pngnew file mode 100644index 0000000000..24ac79d75cBinary files /dev/null and b/metadata_data/photos/fooddelivery/large-tablet/1.png differ
metadata_data/photos/fooddelivery/phone/1.png
diff --git a/metadata_data/photos/fooddelivery/1.png b/metadata_data/photos/fooddelivery/phone/1.pngsimilarity index 100%rename from metadata_data/photos/fooddelivery/1.pngrename to metadata_data/photos/fooddelivery/phone/1.png
metadata_data/photos/fooddelivery/phone/2.png
diff --git a/metadata_data/photos/fooddelivery/phone/2.png b/metadata_data/photos/fooddelivery/phone/2.pngnew file mode 100644index 0000000000..de4cc68617Binary files /dev/null and b/metadata_data/photos/fooddelivery/phone/2.png differ
metadata_data/photos/fooddelivery/phone/3.png
diff --git a/metadata_data/photos/fooddelivery/phone/3.png b/metadata_data/photos/fooddelivery/phone/3.pngnew file mode 100644index 0000000000..722a10c720Binary files /dev/null and b/metadata_data/photos/fooddelivery/phone/3.png differ
metadata_data/photos/games-chess/large-tablet/1.png
diff --git a/metadata_data/photos/games-chess/large-tablet/1.png b/metadata_data/photos/games-chess/large-tablet/1.pngindex 7b389df6f5..d254940c07 100644Binary files a/metadata_data/photos/games-chess/large-tablet/1.png and b/metadata_data/photos/games-chess/large-tablet/1.png differ
metadata_data/photos/globalesim/phone/1.png
diff --git a/metadata_data/photos/globalesim/phone/1.png b/metadata_data/photos/globalesim/phone/1.pngnew file mode 100644index 0000000000..53a0fc69e1Binary files /dev/null and b/metadata_data/photos/globalesim/phone/1.png differ
metadata_data/photos/globalesim/phone/2.png
diff --git a/metadata_data/photos/globalesim/phone/2.png b/metadata_data/photos/globalesim/phone/2.pngnew file mode 100644index 0000000000..5cc9fc519bBinary files /dev/null and b/metadata_data/photos/globalesim/phone/2.png differ
metadata_data/photos/logviewer/large-tablet/1.png
diff --git a/metadata_data/photos/logviewer/large-tablet/1.png b/metadata_data/photos/logviewer/large-tablet/1.pngnew file mode 100644index 0000000000..b09ac8e576Binary files /dev/null and b/metadata_data/photos/logviewer/large-tablet/1.png differ
metadata_data/photos/logviewer/phone/1.png
diff --git a/metadata_data/photos/logviewer/phone/1.png b/metadata_data/photos/logviewer/phone/1.pngnew file mode 100644index 0000000000..72543ac03aBinary files /dev/null and b/metadata_data/photos/logviewer/phone/1.png differ
metadata_data/photos/logviewer/phone/2.png
diff --git a/metadata_data/photos/logviewer/phone/2.png b/metadata_data/photos/logviewer/phone/2.pngnew file mode 100644index 0000000000..2741c7ec73Binary files /dev/null and b/metadata_data/photos/logviewer/phone/2.png differ
metadata_data/photos/taxi/large-tablet/1.png
diff --git a/metadata_data/photos/taxi/large-tablet/1.png b/metadata_data/photos/taxi/large-tablet/1.pngnew file mode 100644index 0000000000..b66e5c8422Binary files /dev/null and b/metadata_data/photos/taxi/large-tablet/1.png differ
metadata_data/photos/taxi/phone/1.png
diff --git a/metadata_data/photos/taxi/phone/1.png b/metadata_data/photos/taxi/phone/1.pngnew file mode 100644index 0000000000..5bc4887045Binary files /dev/null and b/metadata_data/photos/taxi/phone/1.png differ
scripts/check_preview_metadata.sh
diff --git a/scripts/check_preview_metadata.sh b/scripts/check_preview_metadata.shindex 9febd2479b..efeaf7bd71 100755--- a/scripts/check_preview_metadata.sh+++ b/scripts/check_preview_metadata.sh@@ -13,6 +13,9 @@ #     form-factor bucket the collector routes it to; Triple-T spellings verbatim) #   - duplicate Preview<N> numbers inside one bucket (per-bucket 1.png… order #     comes from the function-name sort, so a clash reshuffles that bucket)+#   - a chrome-owning screen rendered bare (a screen that ships under a tab bar,+#     rail or drawer on device, shown without it — the listing misses the chrome+#     users actually see; see CHROME_SCREENS below) #   - a leftover src/androidTest MetadataScreenshots.kt from the old on-device generator #   - a module that opted into previews but has no @Preview at all #@@ -32,6 +35,50 @@ problems=0 note() { printf '  %s\n' "$1"; } fail() { printf '  ✗ %s\n' "$1"; problems=$((problems + 1)); } +# Screens that ship under tab/rail/drawer chrome on device: a preview calling one+# outside chrome (a ChromePreview/Tabbed wrapper or drawer call in the same+# function) renders chrome-less. Format: "module:Screen,Screen module:Screen ...".+# Only screens with an existing chrome-wrapped precedent are listed — wrapping a+# new module means adding its screens here. Drawer-closed shells (files) need no+# entry: a closed drawer is invisible. Screens on pushed routes (no chrome on+# device) are deliberately absent: app detail/trust, contact details, office+# documents, hub Yuu, VPN now-playing/album/expanded, email conversation/compose.+CHROME_SCREENS="calculator:CalculatorScreen,GraphScreen,UnitConverterScreen clock:AlarmScreen,ClockScreen,TimerScreen,StopwatchScreen appstore:HomeScreen,SearchScreen,UpdatesScreen,LibraryScreen contacts:ContactListScreen,GroupsScreen office:HomeScreen vpn:ConfigListContent,LoggingContent games/chess:ChessGameScreen,PuzzleBoardScreen games/hub:DashboardScreen,GamesListScreen,ProfileScreen health:TodayScreen,NutritionScreen,BarChartDetailsScreen youpipe:SearchScreen,SubscriptionVideosScreen securemail:InboxScreen"++# True when every Preview in $1 that calls one of $2 (the module's chrome+# screens) also hosts chrome in the same function body — a ChromePreview/Tabbed+# wrapper or drawer call — i.e. the screen reaches the listing only through+# chrome. A preview proving a pushed route (no chrome on device) opts out with+# a `// CHROME EXEMPT: <reason>` comment above or inside its function. Prints+# the offending preview's line and returns non-zero otherwise. POSIX awk only+# (no gawk extensions — this also runs on macOS).+chrome_wrapped() {+    local file="$1" screens="$2"+    local screen_pat+    screen_pat=$(printf '%s' "$screens" | sed 's/,/|/g')+    awk -v pat="($screen_pat)\\(" '+        function flush() {+            if (in_preview && has_screen && !has_chrome && !exempt) {+                print FILENAME":"start": preview renders chrome screen without chrome"+                failed = 1+            }+        }+        /CHROME EXEMPT/ { exempt_next = 1; next }+        /^[[:space:]]*((private|internal)[[:space:]]+)?fun / {+            flush()+            in_preview = ($0 ~ /fun Preview[0-9]/)+            exempt = exempt_next; exempt_next = 0+            start = FNR+            has_screen = 0; has_chrome = 0+            next+        }+        /CHROME EXEMPT/ { exempt = 1 }+        /ChromePreview\(|TabbedPagerScaffold\(|ModalNavigationDrawer\(|MusicTabsBar\(/ { has_chrome = 1 }+        $0 ~ pat { has_screen = 1 }+        END { flush(); if (failed) exit 1 }+    ' "$file"+}+ echo "=== Compose preview metadata audit ===" echo @@ -154,6 +201,19 @@ ${pending}:${n}"         show; fail "duplicate screenshot number in bucket \"${d%%:*}\" (${d##*:} twice); per-bucket order will be wrong"     done +    # Chrome-owning screens must reach the listing through chrome, not bare.+    for entry in $CHROME_SCREENS; do+        entry_module="${entry%%:*}"+        if [[ "$module" == "$entry_module" ]]; then+            entry_screens="${entry#*:}"+            for f in $files; do+                if ! chrome_wrapped "$f" "$entry_screens"; then+                    show; fail "chrome-owning screen rendered bare in ${f#"$module"/} (see line above); wrap it in ChromePreview"+                fi+            done+        fi+    done+     if [[ "$n_preview" -eq 0 ]]; then         show; fail "no @Preview found under src/screenshotTest"     elif [[ "$n_previewtest" -ne "$n_preview" ]]; then
taxi/build.gradle.kts
diff --git a/taxi/build.gradle.kts b/taxi/build.gradle.ktsindex b506d45a5f..59702e45b6 100644--- a/taxi/build.gradle.kts+++ b/taxi/build.gradle.kts@@ -1,5 +1,6 @@ plugins {     id("common-conventions-app")+    id("common-conventions-preview-metadata") }  launcherIcon {
taxi/src/screenshotTest/kotlin/com/vayunmathur/taxi/ui/MetadataPreviews.kt
diff --git a/taxi/src/screenshotTest/kotlin/com/vayunmathur/taxi/ui/MetadataPreviews.kt b/taxi/src/screenshotTest/kotlin/com/vayunmathur/taxi/ui/MetadataPreviews.ktnew file mode 100644index 0000000000..0082f3fc20--- /dev/null+++ b/taxi/src/screenshotTest/kotlin/com/vayunmathur/taxi/ui/MetadataPreviews.kt@@ -0,0 +1,225 @@+package com.vayunmathur.taxi.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.library.map.CameraPosition+import com.vayunmathur.library.map.CameraState+import com.vayunmathur.library.map.GeoPoint+import com.vayunmathur.library.ui.DynamicTheme+import com.vayunmathur.library.ui.IconMap+import com.vayunmathur.library.ui.IconNavigationArrow+import com.vayunmathur.library.ui.IconSettings+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 com.vayunmathur.taxi.Route+import com.vayunmathur.taxi.data.LatLng+import com.vayunmathur.taxi.data.Place+import com.vayunmathur.taxi.data.Provider+import com.vayunmathur.taxi.data.QuoteResult+import com.vayunmathur.taxi.data.RideQuote++/** Phone-shaped, roughly 1080x2340 at xxhdpi — comfortably above the F-Droid minimum. */+private const val PHONE = "spec:width=411dp,height=891dp,dpi=420"++/** Desktop-wide (1280dp >= 840dp), so isExpandedWidth() side-by-side branches render. */+private const val EXPANDED = "spec:width=1280dp,height=800dp,dpi=240"++/**+ * Store listing images for `:taxi`, rendered from Compose previews instead of from+ * an instrumented test on a device.+ *+ * `./gradlew :taxi:metadata` renders these and copies the PNGs into+ * per-bucket `metadata_data/photos/taxi/<bucket>/` dirs (`phone/` for the+ * handset preview, `large-tablet/` for the expanded-layout preview — Play has no+ * desktop bucket and large-tablet is the closest Triple-T type), where the release+ * build picks them up.+ *+ * Ride tab only: the CurrentRide and Accounts tabs have no slices, so they render+ * as empty boxes here (never visible — the selected tab is always Ride).+ *+ * Two things to keep in mind when editing:+ *+ *  - Order matters, and it comes from the function names. The generated PNG filenames+ *    embed the function name, so `Preview1Ride`/`Preview2RideExpanded` sort into listing+ *    order no matter how the plugin formats the rest of the filename. Renumber the+ *    functions if you reorder the listing. Order is per bucket.+ *  - Each preview needs a `group` (the form-factor bucket: `phone`, `tablet`,+ *    `large-tablet`, `tv`, `wear`) as well as @PreviewTest.+ *  - Everything must be a literal. These render with no ViewModel, no database and no+ *    device, so the state below is the whole input — which is also what makes the output+ *    reproducible from a clean checkout.+ *  - Each preview needs @PreviewTest as well as @Preview. @Preview alone renders in+ *    Studio but is not collected as a screenshot test, and the build fails with the+ *    unhelpful "did not discover any tests".+ *  - The previews must be members of a class, not top-level functions. Android Studio+ *    renders top-level previews happily, but the screenshot engine discovers previews as+ *    JUnit tests and needs a real class to attach them to — top-level functions land in a+ *    synthetic `…Kt` facade and are silently skipped, which surfaces as "did not discover+ *    any tests".+ *  - The phone preview renders through [ChromePreview]: the bottom bar lives in the+ *    app's `Navigation`, above the pages, so a bare `RideNarrowContent` shot would miss+ *    the chrome users actually see. The expanded preview renders [RideWideContent]+ *    bare: production `Navigation` has no rail branch (it always uses `MainNavigation`+ *    + `BottomNavBar`), so there is no expanded chrome to reproduce.+ *  - The map renders without tiles here (Layoutlib has no native map renderer), so the+ *    `VectorMap` background, pins and results show against a plain backdrop. Acceptable+ *    per convention.+ *+ * Rendering goes through the app's real [DynamicTheme] with `darkTheme = true`, matching+ * the `cmd uimode night yes` the old on-device generator used. Note that Material You+ * sources its palette from the device wallpaper, which does not exist here, so these+ * render with the fallback scheme rather than a user's actual accent colour.+ */+class MetadataPreviews {++    @PreviewTest+    @Preview(name = "1-ride", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview1Ride() {+        ChromePreview(Route.Ride)+    }++    @PreviewTest+    @Preview(name = "2-ride-expanded", device = EXPANDED, group = "large-tablet", showSystemUi = true)+    @Composable+    fun Preview2RideExpanded() {+        DynamicTheme(darkTheme = true) {+            RideWideContent(+                data = ridePreviewData(),+                events = ridePreviewEvents(),+                modifier = Modifier.fillMaxSize(),+            )+        }+    }+}++/** Literals backing the Ride tab: a Ferry Building -> SFO trip with both fares compared. */+private fun ridePreviewData(): RideContentData {+    val pickup = Place(+        name = "Ferry Building",+        address = "1 Ferry Bldg, SF",+        location = LatLng(latitude = 37.7955, longitude = -122.3937),+    )+    val destination = Place(+        name = "SFO",+        address = "SFO, SF",+        location = LatLng(latitude = 37.6213, longitude = -122.3790),+    )+    val lyftQuote = RideQuote(+        provider = Provider.LYFT,+        productId = "lyft_std",+        displayName = "Lyft Standard",+        fareLowMinor = 1299,+        fareHighMinor = 1599,+        currency = "USD",+        pickupEtaMinutes = 4,+        tripDurationMinutes = 18,+        surgeMultiplier = null,+        capacity = 4,+    )+    val uberQuote = RideQuote(+        provider = Provider.UBER,+        productId = "uber_x",+        displayName = "UberX",+        fareLowMinor = 1499,+        fareHighMinor = 1499,+        currency = "USD",+        pickupEtaMinutes = 3,+        tripDurationMinutes = 18,+        surgeMultiplier = null,+        capacity = 4,+    )+    return RideContentData(+        camera = CameraState(CameraPosition(target = GeoPoint(-122.4194, 37.7749), zoom = 12.0)),+        routeOverlay = null,+        pickup = pickup,+        destination = destination,+        pickupQuery = pickup.name,+        destinationQuery = destination.name,+        suggestions = emptyList(),+        searching = false,+        active = null,+        results = mapOf(+            Provider.LYFT to QuoteResult.Success(quotes = listOf(lyftQuote)),+            Provider.UBER to QuoteResult.Success(quotes = listOf(uberQuote)),+        ),+        comparing = false,+    )+}++/** No-op callbacks: previews never drive state. */+private fun ridePreviewEvents() = RideContentEvents(+    onPickupChange = {},+    onPickupFocus = {},+    onResetPickup = {},+    onDestinationChange = {},+    onDestinationFocus = {},+    onClearDestination = {},+    onSearch = {},+    onSelect = {},+    onBook = { _, _ -> },+)++/**+ * The app's real navigation chrome around preview screen content: the same tab+ * list and the same [MainNavigation] host as `Navigation` — with a literal back+ * stack standing in for the selected tab, since previews have no ViewModel to+ * drive one.+ */+@Composable+private fun ChromePreview(route: Route) {+    DynamicTheme(darkTheme = true) {+        // NavDisplay requires a NavigationEventDispatcherOwner, which an Activity+        // normally provides — Layoutlib has no Activity, so previews supply a+        // root dispatcher explicitly (null parent).+        CompositionLocalProvider(+            LocalNavigationEventDispatcherOwner provides rememberNavigationEventDispatcherOwner(+                parent = null,+            ),+        ) {+            ChromePreviewContent(route)+        }+    }+}++@Composable+private fun ChromePreviewContent(route: Route) {+    val backStack = rememberNavBackStack(route)+    val current = backStack.last()+    val tabs = listOf(+        BottomBarItem("Ride", Route.Ride) { IconMap() },+        BottomBarItem("Current ride", Route.CurrentRide) { IconNavigationArrow() },+        BottomBarItem("Settings", Route.Accounts) { IconSettings() },+    )+    // Only the Ride tab has a slice. The other entries are empty boxes that are+    // never visible (the selected tab always matches the shown screen) — they+    // exist only so the entry set matches production's tab list.+    val entries: @Composable () -> Unit = {+        when (current) {+            Route.Ride -> RideNarrowContent(+                data = ridePreviewData(),+                events = ridePreviewEvents(),+                modifier = Modifier.fillMaxSize(),+            )+            else -> Box(Modifier.fillMaxSize()) { }+        }+    }+    MainNavigation(+        backStack,+        bottomBar = { BottomNavBar(backStack, tabs, current) },+    ) {+        entry<Route.Ride>(metadata = SiblingPage()) { entries() }+        entry<Route.CurrentRide>(metadata = SiblingPage()) { entries() }+        entry<Route.Accounts>(metadata = SiblingPage()) { entries() }+    }+}
youpipe/src/screenshotTest/kotlin/com/vayunmathur/youpipe/ui/MetadataPreviews.kt
diff --git a/youpipe/src/screenshotTest/kotlin/com/vayunmathur/youpipe/ui/MetadataPreviews.kt b/youpipe/src/screenshotTest/kotlin/com/vayunmathur/youpipe/ui/MetadataPreviews.ktindex 0819977953..b1077946ad 100644--- a/youpipe/src/screenshotTest/kotlin/com/vayunmathur/youpipe/ui/MetadataPreviews.kt+++ b/youpipe/src/screenshotTest/kotlin/com/vayunmathur/youpipe/ui/MetadataPreviews.kt@@ -147,45 +147,7 @@ class MetadataPreviews {     @Preview(name = "5-expanded-home", device = EXPANDED, group = "large-tablet", showSystemUi = true)     @Composable     fun Preview5ExpandedHome() {-        DynamicTheme(darkTheme = true) {-            SearchScreen(-                state = SearchUiState(-                    recommendations = listOf(-                        VideoRowState(-                            videoID = 1,-                            title = "The Absurd Engineering Inside a Modern Camera Sensor",-                            author = "Veritasium",-                            stats = "4.1M views | 2 weeks ago",-                            reason = "you watch a lot of optics",-                            percentWatched = 0.42f,-                        ),-                        VideoRowState(-                            videoID = 2,-                            title = "I Rebuilt My Home Server Rack (Again)",-                            author = "Linus Tech Tips",-                            stats = "1.2M views | 3 days ago",-                            reason = "from a channel you follow",-                        ),-                        VideoRowState(-                            videoID = 3,-                            title = "Why Bridges Don't Fall Down",-                            author = "Practical Engineering",-                            stats = "873K views | 1 month ago",-                            reason = "similar to Structural Failures Explained",-                            percentWatched = 1f,-                        ),-                        VideoRowState(-                            videoID = 4,-                            title = "Making Sourdough With No Starter",-                            author = "Adam Ragusea",-                            stats = "612K views | 5 days ago",-                            reason = "new upload",-                        ),-                    ),-                ),-                actions = SearchActions.Noop,-            )-        }+        ChromePreview(selectedTab = 0)     }      @PreviewTest@@ -204,6 +166,7 @@ class MetadataPreviews {     @PreviewTest     @Preview(name = "7-expanded-subscriptions", device = EXPANDED, group = "large-tablet", showSystemUi = true)     @Composable+    // CHROME EXEMPT: pushed subscription-videos route renders with no tab chrome on device.     fun Preview7ExpandedSubscriptions() {         DynamicTheme(darkTheme = true) {             SubscriptionVideosScreen(