Modern Apps git

← Modern-Apps.git

euicc: dialogs are routes and every route has a capture

Commit
0e7b58da318aa3fc277030e2442c0166128e2898
Author
Vayun Mathur <[email protected]>
When
2026-12-02 10:23 UTC (4 days ago)
Parents
1ee294a
lintVitalRelease failed with 12 errors: 5 DialogAsRoute and 7
RouteScreenshotCoverage. The EID dialog and the enable, disable,
erase and rename confirmations on the profile detail screen are
now dialog destinations: Route.EidDialog, EnableProfileDialog,
DisableProfileDialog, EraseProfileDialog and
RenameProfileDialog are DialogPage() entries in Navigation.kt
with the EID or ICCID in the route, stateless content under
ui/dialogs/ (new Enable/Disable/EraseProfileDialogContent), and
the ViewModel actions performed by the destination host.
ProfileDetailScreen and DeviceInfoScreen push the routes from
their rows and hold no show-dialog state. No DIALOG LOCAL
EXCEPTION was needed: every identity is a String argument.

Screenshot coverage: the existing previews are renamed to the
routes they render (1-home, 2-home-empty, 3-profile-detail) and
new deterministic captures cover DeviceInfo, AddSim, ScanQr
(permission wall), ActivationCode, Download (carrier-confirm
phase), and all five dialog routes (4-13, group phone).

Tests now assert the pushed dialog routes from the screens and
render the dialog contents directly for confirm/dismiss/save.
Verified: :euicc:lint, :euicc:lintVitalRelease,
:euicc:testDevUnitTest and :euicc:compileReleaseKotlin pass,
and :euicc:compileDevScreenshotTestKotlin compiles.

Diff

euicc/AGENTS.md
diff --git a/euicc/AGENTS.md b/euicc/AGENTS.mdindex cb01411cb7..003c542092 100644--- a/euicc/AGENTS.md+++ b/euicc/AGENTS.md@@ -41,6 +41,9 @@ _Install: ./install euicc (dev by default)._ - com/vayunmathur/euicc/ui/QrScanner.kt - com/vayunmathur/euicc/ui/dialogs/EidDialog.kt - com/vayunmathur/euicc/ui/dialogs/RenameDialog.kt+- com/vayunmathur/euicc/ui/dialogs/EnableProfileDialog.kt โ€” stateless enable confirmation (`Route.EnableProfileDialog`)+- com/vayunmathur/euicc/ui/dialogs/DisableProfileDialog.kt โ€” stateless disable confirmation (`Route.DisableProfileDialog`)+- com/vayunmathur/euicc/ui/dialogs/EraseProfileDialog.kt โ€” stateless erase confirmation (`Route.EraseProfileDialog`) - com/vayunmathur/euicc/ui/download/ConfirmCarrierContent.kt - com/vayunmathur/euicc/ui/download/ConfirmationCodeContent.kt - com/vayunmathur/euicc/ui/download/InstallingContent.kt
euicc/src/main/java/com/vayunmathur/euicc/Navigation.kt
diff --git a/euicc/src/main/java/com/vayunmathur/euicc/Navigation.kt b/euicc/src/main/java/com/vayunmathur/euicc/Navigation.ktindex a38ce07d7a..3a8ef2b100 100644--- a/euicc/src/main/java/com/vayunmathur/euicc/Navigation.kt+++ b/euicc/src/main/java/com/vayunmathur/euicc/Navigation.kt@@ -10,6 +10,12 @@ import com.vayunmathur.euicc.ui.DownloadScreen import com.vayunmathur.euicc.ui.EuiccHomeScreen import com.vayunmathur.euicc.ui.ProfileDetailScreen import com.vayunmathur.euicc.ui.QrScannerScreen+import com.vayunmathur.euicc.ui.dialogs.DisableProfileDialogContent+import com.vayunmathur.euicc.ui.dialogs.EidDialog+import com.vayunmathur.euicc.ui.dialogs.EnableProfileDialogContent+import com.vayunmathur.euicc.ui.dialogs.EraseProfileDialogContent+import com.vayunmathur.euicc.ui.dialogs.RenameDialog+import com.vayunmathur.library.util.DialogPage import com.vayunmathur.library.util.ListDetailPage import com.vayunmathur.library.util.ListPage import com.vayunmathur.library.util.MainNavigation@@ -52,10 +58,6 @@ fun Navigation(viewModel: EuiccViewModel, start: Route? = null) {                 iccid = route.iccid,                 state = viewModel.state,                 backStack = backStack,-                onEnable = { viewModel.enable(it.iccid) },-                onDisable = { viewModel.disable(it.iccid) },-                onErase = { viewModel.delete(it.iccid) },-                onRename = { profile, name -> viewModel.rename(profile.iccid, name) },             )         }         entry<Route.DeviceInfo>(metadata = ListDetailPage()) {@@ -66,6 +68,64 @@ fun Navigation(viewModel: EuiccViewModel, start: Route? = null) {             )         }         entry<Route.AddSim> { AddSimScreen(backStack = backStack) }+        // Dialog destinations: every dialog is a route with DialogPage()+        // metadata, its arguments in the route, and stateless content+        // under ui/dialogs/ that the entry renders unconditionally.+        entry<Route.EidDialog>(metadata = DialogPage()) { route ->+            EidDialog(eid = route.eid, onDismiss = { backStack.pop() })+        }+        entry<Route.EnableProfileDialog>(metadata = DialogPage()) { route ->+            val profile = viewModel.state.profiles.firstOrNull { it.iccid == route.iccid }+            if (profile == null) {+                backStack.pop()+            } else {+                EnableProfileDialogContent(+                    profileLabel = profile.displayName,+                    currentLabel = viewModel.state.profiles.firstOrNull { it.isEnabled }?.displayName,+                    onConfirm = { viewModel.enable(profile.iccid) },+                    onDismiss = { backStack.pop() },+                )+            }+        }+        entry<Route.DisableProfileDialog>(metadata = DialogPage()) { route ->+            val profile = viewModel.state.profiles.firstOrNull { it.iccid == route.iccid }+            if (profile == null) {+                backStack.pop()+            } else {+                DisableProfileDialogContent(+                    profileLabel = profile.displayName,+                    onConfirm = { viewModel.disable(profile.iccid) },+                    onDismiss = { backStack.pop() },+                )+            }+        }+        entry<Route.EraseProfileDialog>(metadata = DialogPage()) { route ->+            val profile = viewModel.state.profiles.firstOrNull { it.iccid == route.iccid }+            if (profile == null) {+                backStack.pop()+            } else {+                EraseProfileDialogContent(+                    profileLabel = profile.displayName,+                    onConfirm = { viewModel.delete(profile.iccid) },+                    onDismiss = { backStack.pop() },+                )+            }+        }+        entry<Route.RenameProfileDialog>(metadata = DialogPage()) { route ->+            val profile = viewModel.state.profiles.firstOrNull { it.iccid == route.iccid }+            if (profile == null) {+                backStack.pop()+            } else {+                RenameDialog(+                    profile = profile,+                    onConfirm = { name ->+                        viewModel.rename(profile.iccid, name)+                        backStack.pop()+                    },+                    onDismiss = { backStack.pop() },+                )+            }+        }         entry<Route.ScanQr> {             QrScannerScreen(                 backStack = backStack,
euicc/src/main/java/com/vayunmathur/euicc/Route.kt
diff --git a/euicc/src/main/java/com/vayunmathur/euicc/Route.kt b/euicc/src/main/java/com/vayunmathur/euicc/Route.ktindex 30f5a0309c..f6a29062a6 100644--- a/euicc/src/main/java/com/vayunmathur/euicc/Route.kt+++ b/euicc/src/main/java/com/vayunmathur/euicc/Route.kt@@ -45,6 +45,26 @@ sealed interface Route : NavKey {      * up front); QR/universal-link entries leave them null and the flow collects the      * confirmation code mid-download when the SM-DP+ demands one.      */+    /** EID QR dialog (`DialogPage()`), pushed from the device-info EID row. */+    @Serializable+    data class EidDialog(val eid: String) : Route++    /** Enable-profile confirmation dialog (`DialogPage()`), keyed by ICCID. */+    @Serializable+    data class EnableProfileDialog(val iccid: String) : Route++    /** Disable-profile confirmation dialog (`DialogPage()`), keyed by ICCID. */+    @Serializable+    data class DisableProfileDialog(val iccid: String) : Route++    /** Erase-profile confirmation dialog (`DialogPage()`), keyed by ICCID. */+    @Serializable+    data class EraseProfileDialog(val iccid: String) : Route++    /** Rename-profile dialog (`DialogPage()`), keyed by ICCID. */+    @Serializable+    data class RenameProfileDialog(val iccid: String) : Route+     @Serializable     data class Download(         val activationCode: String,
euicc/src/main/java/com/vayunmathur/euicc/ui/DeviceInfoScreen.kt
diff --git a/euicc/src/main/java/com/vayunmathur/euicc/ui/DeviceInfoScreen.kt b/euicc/src/main/java/com/vayunmathur/euicc/ui/DeviceInfoScreen.ktindex 4122e55836..fd41e433d6 100644--- a/euicc/src/main/java/com/vayunmathur/euicc/ui/DeviceInfoScreen.kt+++ b/euicc/src/main/java/com/vayunmathur/euicc/ui/DeviceInfoScreen.kt@@ -1,16 +1,11 @@ package com.vayunmathur.euicc.ui  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.res.stringResource import com.vayunmathur.euicc.R import com.vayunmathur.library.ui.R as UiR import com.vayunmathur.euicc.Route import com.vayunmathur.euicc.platform.EuiccScreenState-import com.vayunmathur.euicc.ui.dialogs.EidDialog import androidx.compose.ui.Modifier import com.vayunmathur.library.ui.DetailScaffold import com.vayunmathur.library.ui.SettingsRow@@ -31,7 +26,6 @@ import com.vayunmathur.library.util.NavBackStack  */ @Composable fun DeviceInfoScreen(state: EuiccScreenState, backStack: NavBackStack<Route>, onRemoveNotification: (Int) -> Unit) {-    var showEidQr by remember { mutableStateOf(false) }     val eid = state.eid     val messenger = rememberMessenger()     val removedMessage = stringResource(R.string.notification_removed)@@ -46,7 +40,7 @@ fun DeviceInfoScreen(state: EuiccScreenState, backStack: NavBackStack<Route>, on                 title = stringResource(R.string.eid_number),                 supportingText = eid ?: stringResource(R.string.eid_not_found),                 enabled = eid != null,-                onClick = if (eid != null) ({ showEidQr = true }) else null,+                onClick = if (eid != null) ({ backStack.add(Route.EidDialog(eid)) }) else null,             )             SettingsRow(                 title = stringResource(R.string.sgp22_version),@@ -76,8 +70,4 @@ fun DeviceInfoScreen(state: EuiccScreenState, backStack: NavBackStack<Route>, on             }         }     }--    if (showEidQr && eid != null) {-        EidDialog(eid = eid, onDismiss = { showEidQr = false })-    } }
euicc/src/main/java/com/vayunmathur/euicc/ui/ProfileDetailScreen.kt
diff --git a/euicc/src/main/java/com/vayunmathur/euicc/ui/ProfileDetailScreen.kt b/euicc/src/main/java/com/vayunmathur/euicc/ui/ProfileDetailScreen.ktindex a817700d68..15f894d02c 100644--- a/euicc/src/main/java/com/vayunmathur/euicc/ui/ProfileDetailScreen.kt+++ b/euicc/src/main/java/com/vayunmathur/euicc/ui/ProfileDetailScreen.kt@@ -1,19 +1,11 @@ package com.vayunmathur.euicc.ui  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.Modifier import androidx.compose.ui.res.stringResource import com.vayunmathur.euicc.R-import com.vayunmathur.library.ui.R as UiR import com.vayunmathur.euicc.Route-import com.vayunmathur.euicc.data.Profile import com.vayunmathur.euicc.platform.EuiccScreenState-import com.vayunmathur.euicc.ui.dialogs.RenameDialog-import com.vayunmathur.library.ui.ConfirmDialog import com.vayunmathur.library.ui.DetailScaffold import com.vayunmathur.library.ui.SettingsRow import com.vayunmathur.library.ui.SettingsSection@@ -25,9 +17,9 @@ import com.vayunmathur.library.util.sharedText /**  * One profile: what it is, and the three things that can be done to it.  *- * Enable, disable and erase all go through a [ConfirmDialog] because each one drops the- * device's connection - switching carriers is not undoable from a spinner. The wording is- * the platform LPA's, so the consequence reads the same as it would on stock.+ * Enable, disable and erase all go through confirmation dialog routes because each one+ * drops the device's connection - switching carriers is not undoable from a spinner. The+ * wording is the platform LPA's, so the consequence reads the same as it would on stock.  *  * The profile is looked up from [state] by ICCID on every recomposition rather than passed  * in, so it stays current across the reload that follows each mutation. If the lookup@@ -38,10 +30,6 @@ fun ProfileDetailScreen(     iccid: String,     state: EuiccScreenState,     backStack: NavBackStack<Route>,-    onEnable: (Profile) -> Unit,-    onDisable: (Profile) -> Unit,-    onErase: (Profile) -> Unit,-    onRename: (Profile, String) -> Unit, ) {     val profile = state.profiles.firstOrNull { it.iccid == iccid }     if (profile == null) {@@ -55,13 +43,7 @@ fun ProfileDetailScreen(         return     } -    var confirmEnable by remember { mutableStateOf(false) }-    var confirmDisable by remember { mutableStateOf(false) }-    var confirmErase by remember { mutableStateOf(false) }-    var renaming by remember { mutableStateOf(false) }-     val label = profile.displayName-    val currentlyEnabled = state.profiles.firstOrNull { it.isEnabled }      DetailScaffold(         // The row the user tapped on the home list carries this name up into the bar. The slot@@ -72,7 +54,7 @@ fun ProfileDetailScreen(         onNavigateBack = { backStack.pop() },         isRefreshing = state.loading,         actions = {-            TextButton(onClick = { renaming = true }, enabled = !state.loading) {+            TextButton(onClick = { backStack.add(Route.RenameProfileDialog(profile.iccid)) }, enabled = !state.loading) {                 Text(stringResource(R.string.rename_profile_title))             }         },@@ -101,62 +83,20 @@ fun ProfileDetailScreen(                 SettingsRow(                     title = stringResource(R.string.disable_profile_title),                     enabled = !state.loading,-                    onClick = { confirmDisable = true },+                    onClick = { backStack.add(Route.DisableProfileDialog(profile.iccid)) },                 )             } else {                 SettingsRow(                     title = stringResource(R.string.enable_profile_title),                     enabled = !state.loading,-                    onClick = { confirmEnable = true },+                    onClick = { backStack.add(Route.EnableProfileDialog(profile.iccid)) },                 )             }             SettingsRow(                 title = stringResource(R.string.erase_sim_confirm_button),                 enabled = !state.loading,-                onClick = { confirmErase = true },+                onClick = { backStack.add(Route.EraseProfileDialog(profile.iccid)) },             )         }     }--    if (confirmEnable) {-        ConfirmDialog(-            title = stringResource(R.string.enable_carrier_dialog_title),-            message = currentlyEnabled?.let {-                stringResource(R.string.enable_carrier_dialog_text, label, it.displayName)-            } ?: stringResource(R.string.enable_carrier_dialog_text_no_current, label),-            confirmLabel = stringResource(R.string.enable_profile_title),-            dismissLabel = stringResource(UiR.string.cancel),-            onConfirm = { onEnable(profile) },-            onDismiss = { confirmEnable = false },-        )-    }-    if (confirmDisable) {-        ConfirmDialog(-            title = stringResource(R.string.disable_carrier_dialog_title),-            message = stringResource(R.string.disable_carrier_dialog_text, label),-            confirmLabel = stringResource(R.string.disable_profile_title),-            dismissLabel = stringResource(UiR.string.cancel),-            destructive = true,-            onConfirm = { onDisable(profile) },-            onDismiss = { confirmDisable = false },-        )-    }-    if (confirmErase) {-        ConfirmDialog(-            title = stringResource(R.string.erase_sim_dialog_title, label),-            message = stringResource(R.string.erase_sim_dialog_text, label),-            confirmLabel = stringResource(R.string.erase_sim_confirm_button),-            dismissLabel = stringResource(UiR.string.cancel),-            destructive = true,-            onConfirm = { onErase(profile) },-            onDismiss = { confirmErase = false },-        )-    }-    if (renaming) {-        RenameDialog(-            profile = profile,-            onConfirm = { onRename(profile, it); renaming = false },-            onDismiss = { renaming = false },-        )-    } }
euicc/src/main/java/com/vayunmathur/euicc/ui/dialogs/DisableProfileDialog.kt
diff --git a/euicc/src/main/java/com/vayunmathur/euicc/ui/dialogs/DisableProfileDialog.kt b/euicc/src/main/java/com/vayunmathur/euicc/ui/dialogs/DisableProfileDialog.ktnew file mode 100644index 0000000000..4f75a4f730--- /dev/null+++ b/euicc/src/main/java/com/vayunmathur/euicc/ui/dialogs/DisableProfileDialog.kt@@ -0,0 +1,28 @@+package com.vayunmathur.euicc.ui.dialogs++import androidx.compose.runtime.Composable+import androidx.compose.ui.res.stringResource+import com.vayunmathur.euicc.R+import com.vayunmathur.library.ui.ConfirmDialog+import com.vayunmathur.library.ui.R as UiR++/**+ * Stateless disable-profile confirmation, hosted as the+ * `Route.DisableProfileDialog` destination (`DialogPage()`).+ */+@Composable+fun DisableProfileDialogContent(+    profileLabel: String,+    onConfirm: () -> Unit,+    onDismiss: () -> Unit,+) {+    ConfirmDialog(+        title = stringResource(R.string.disable_carrier_dialog_title),+        message = stringResource(R.string.disable_carrier_dialog_text, profileLabel),+        confirmLabel = stringResource(R.string.disable_profile_title),+        dismissLabel = stringResource(UiR.string.cancel),+        destructive = true,+        onConfirm = onConfirm,+        onDismiss = onDismiss,+    )+}
euicc/src/main/java/com/vayunmathur/euicc/ui/dialogs/EnableProfileDialog.kt
diff --git a/euicc/src/main/java/com/vayunmathur/euicc/ui/dialogs/EnableProfileDialog.kt b/euicc/src/main/java/com/vayunmathur/euicc/ui/dialogs/EnableProfileDialog.ktnew file mode 100644index 0000000000..a1f855a034--- /dev/null+++ b/euicc/src/main/java/com/vayunmathur/euicc/ui/dialogs/EnableProfileDialog.kt@@ -0,0 +1,32 @@+package com.vayunmathur.euicc.ui.dialogs++import androidx.compose.runtime.Composable+import androidx.compose.ui.res.stringResource+import com.vayunmathur.euicc.R+import com.vayunmathur.library.ui.ConfirmDialog+import com.vayunmathur.library.ui.R as UiR++/**+ * Stateless enable-profile confirmation, hosted as the+ * `Route.EnableProfileDialog` destination (`DialogPage()`). The profile+ * label and the currently-enabled profile's label travel in as plain+ * values so screenshot captures and tests render it directly.+ */+@Composable+fun EnableProfileDialogContent(+    profileLabel: String,+    currentLabel: String?,+    onConfirm: () -> Unit,+    onDismiss: () -> Unit,+) {+    ConfirmDialog(+        title = stringResource(R.string.enable_carrier_dialog_title),+        message = currentLabel?.let {+            stringResource(R.string.enable_carrier_dialog_text, profileLabel, it)+        } ?: stringResource(R.string.enable_carrier_dialog_text_no_current, profileLabel),+        confirmLabel = stringResource(R.string.enable_profile_title),+        dismissLabel = stringResource(UiR.string.cancel),+        onConfirm = onConfirm,+        onDismiss = onDismiss,+    )+}
euicc/src/main/java/com/vayunmathur/euicc/ui/dialogs/EraseProfileDialog.kt
diff --git a/euicc/src/main/java/com/vayunmathur/euicc/ui/dialogs/EraseProfileDialog.kt b/euicc/src/main/java/com/vayunmathur/euicc/ui/dialogs/EraseProfileDialog.ktnew file mode 100644index 0000000000..4cdb8ab53f--- /dev/null+++ b/euicc/src/main/java/com/vayunmathur/euicc/ui/dialogs/EraseProfileDialog.kt@@ -0,0 +1,28 @@+package com.vayunmathur.euicc.ui.dialogs++import androidx.compose.runtime.Composable+import androidx.compose.ui.res.stringResource+import com.vayunmathur.euicc.R+import com.vayunmathur.library.ui.ConfirmDialog+import com.vayunmathur.library.ui.R as UiR++/**+ * Stateless erase-profile confirmation, hosted as the+ * `Route.EraseProfileDialog` destination (`DialogPage()`).+ */+@Composable+fun EraseProfileDialogContent(+    profileLabel: String,+    onConfirm: () -> Unit,+    onDismiss: () -> Unit,+) {+    ConfirmDialog(+        title = stringResource(R.string.erase_sim_dialog_title, profileLabel),+        message = stringResource(R.string.erase_sim_dialog_text, profileLabel),+        confirmLabel = stringResource(R.string.erase_sim_confirm_button),+        dismissLabel = stringResource(UiR.string.cancel),+        destructive = true,+        onConfirm = onConfirm,+        onDismiss = onDismiss,+    )+}
euicc/src/screenshotTest/kotlin/com/vayunmathur/euicc/ui/MetadataPreviews.kt
diff --git a/euicc/src/screenshotTest/kotlin/com/vayunmathur/euicc/ui/MetadataPreviews.kt b/euicc/src/screenshotTest/kotlin/com/vayunmathur/euicc/ui/MetadataPreviews.ktindex 9d0c0d223e..d74d5dd309 100644--- a/euicc/src/screenshotTest/kotlin/com/vayunmathur/euicc/ui/MetadataPreviews.kt+++ b/euicc/src/screenshotTest/kotlin/com/vayunmathur/euicc/ui/MetadataPreviews.kt@@ -12,7 +12,13 @@ import com.vayunmathur.euicc.Route import com.vayunmathur.euicc.data.EuiccInfo import com.vayunmathur.euicc.data.Notification import com.vayunmathur.euicc.data.Profile+import com.vayunmathur.euicc.platform.DownloadState import com.vayunmathur.euicc.platform.EuiccScreenState+import com.vayunmathur.euicc.ui.dialogs.DisableProfileDialogContent+import com.vayunmathur.euicc.ui.dialogs.EidDialog+import com.vayunmathur.euicc.ui.dialogs.EnableProfileDialogContent+import com.vayunmathur.euicc.ui.dialogs.EraseProfileDialogContent+import com.vayunmathur.euicc.ui.dialogs.RenameDialog import com.vayunmathur.library.ui.DynamicTheme import com.vayunmathur.library.util.NavBackStack @@ -64,7 +70,7 @@ class MetadataPreviews {     private val sampleInfo = EuiccInfo(svn = "2.2.0")      @PreviewTest-    @Preview(name = "1-profiles", device = PHONE, group = "phone", showSystemUi = true)+    @Preview(name = "1-home", device = PHONE, group = "phone", showSystemUi = true)     @Composable     fun Preview1Profiles() {         DynamicTheme(darkTheme = true) {@@ -84,7 +90,7 @@ class MetadataPreviews {     }      @PreviewTest-    @Preview(name = "2-empty", device = PHONE, group = "phone", showSystemUi = true)+    @Preview(name = "2-home-empty", device = PHONE, group = "phone", showSystemUi = true)     @Composable     fun Preview2Empty() {         DynamicTheme(darkTheme = true) {@@ -104,7 +110,7 @@ class MetadataPreviews {     }      @PreviewTest-    @Preview(name = "3-expanded", device = EXPANDED, group = "large-tablet", showSystemUi = true)+    @Preview(name = "3-profile-detail", device = EXPANDED, group = "large-tablet", showSystemUi = true)     @Composable     fun Preview3Expanded() {         DynamicTheme(darkTheme = true) {@@ -131,13 +137,122 @@ class MetadataPreviews {                         iccid = sampleProfiles.first().iccid,                         state = state,                         backStack = NavBackStack(arrayOf(Route.Home)),-                        onEnable = {},-                        onDisable = {},-                        onErase = {},-                        onRename = { _, _ -> },                     )                 }             }         }     }++    @PreviewTest+    @Preview(name = "4-device-info", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview4DeviceInfo() {+        DynamicTheme(darkTheme = true) {+            DeviceInfoScreen(+                state = EuiccScreenState(+                    loading = false,+                    eid = "89044000001234567890123456789012",+                    info = sampleInfo,+                    profiles = sampleProfiles,+                    notifications = sampleNotifications,+                ),+                backStack = NavBackStack(arrayOf(Route.Home, Route.DeviceInfo)),+                onRemoveNotification = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "5-add-sim", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview5AddSim() {+        DynamicTheme(darkTheme = true) {+            AddSimScreen(backStack = NavBackStack(arrayOf(Route.Home, Route.AddSim)))+        }+    }++    @PreviewTest+    @Preview(name = "6-scan-qr", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview6ScanQr() {+        DynamicTheme(darkTheme = true) {+            QrScannerScreen(+                backStack = NavBackStack(arrayOf(Route.Home, Route.ScanQr)),+                onResult = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "7-activation-code", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview7ActivationCode() {+        DynamicTheme(darkTheme = true) {+            ActivationCodeScreen(backStack = NavBackStack(arrayOf(Route.Home, Route.ActivationCode)))+        }+    }++    @PreviewTest+    @Preview(name = "8-download", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview8Download() {+        DynamicTheme(darkTheme = true) {+            DownloadScreen(+                activationCode = "LPA:1\$smdp.example.com\$MATCH1",+                imei = null,+                confirmationCode = null,+                state = DownloadState.Confirm(carrier = "Example Mobile", profileName = "Example Prepaid"),+                onStart = { _, _, _ -> },+                onConfirm = {},+                onSubmitCode = {},+                onCancelSession = {},+                onDone = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "9-eid-dialog", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview9EidDialog() {+        DynamicTheme(darkTheme = true) {+            EidDialog(eid = "89044000001234567890123456789012", onDismiss = {})+        }+    }++    @PreviewTest+    @Preview(name = "10-enable-profile-dialog", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview10EnableProfileDialog() {+        DynamicTheme(darkTheme = true) {+            EnableProfileDialogContent(profileLabel = "Global Data 5GB", currentLabel = "Work", onConfirm = {}, onDismiss = {})+        }+    }++    @PreviewTest+    @Preview(name = "11-disable-profile-dialog", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview11DisableProfileDialog() {+        DynamicTheme(darkTheme = true) {+            DisableProfileDialogContent(profileLabel = "Work", onConfirm = {}, onDismiss = {})+        }+    }++    @PreviewTest+    @Preview(name = "12-erase-profile-dialog", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview12EraseProfileDialog() {+        DynamicTheme(darkTheme = true) {+            EraseProfileDialogContent(profileLabel = "Work", onConfirm = {}, onDismiss = {})+        }+    }++    @PreviewTest+    @Preview(name = "13-rename-profile-dialog", device = PHONE, group = "phone", showSystemUi = true)+    @Composable+    fun Preview13RenameProfileDialog() {+        DynamicTheme(darkTheme = true) {+            RenameDialog(profile = sampleProfiles.first(), onConfirm = {}, onDismiss = {})+        }+    } }
euicc/src/test/java/com/vayunmathur/euicc/ui/UiScreensTest.kt
diff --git a/euicc/src/test/java/com/vayunmathur/euicc/ui/UiScreensTest.kt b/euicc/src/test/java/com/vayunmathur/euicc/ui/UiScreensTest.ktindex 1aec5f5fea..24ad70762f 100644--- a/euicc/src/test/java/com/vayunmathur/euicc/ui/UiScreensTest.kt+++ b/euicc/src/test/java/com/vayunmathur/euicc/ui/UiScreensTest.kt@@ -17,6 +17,10 @@ import com.vayunmathur.euicc.data.EuiccInfo import com.vayunmathur.euicc.data.Notification import com.vayunmathur.euicc.data.Profile import com.vayunmathur.euicc.platform.EuiccScreenState+import com.vayunmathur.euicc.ui.dialogs.DisableProfileDialogContent+import com.vayunmathur.euicc.ui.dialogs.EnableProfileDialogContent+import com.vayunmathur.euicc.ui.dialogs.EraseProfileDialogContent+import com.vayunmathur.euicc.ui.dialogs.RenameDialog import com.vayunmathur.library.util.NavBackStack import org.junit.Rule import org.junit.runner.RunWith@@ -165,8 +169,9 @@ class UiScreensTest {         rule.onNodeWithText(str(R.string.no_notifications)).assertExists()     } -    @Test fun `device info shows version notifications remove and eid dialog`() {+    @Test fun `device info shows version notifications remove and pushes eid dialog`() {         var removed: Int? = null+        val backStack = stack(Route.Home, Route.DeviceInfo)         rule.setContent {             DeviceInfoScreen(                 state = EuiccScreenState(@@ -174,7 +179,7 @@ class UiScreensTest {                     info = EuiccInfo(svn = "2.2.0"),                     notifications = listOf(Notification(seqNumber = 3, operation = "install", address = "smdp.example.com")),                 ),-                backStack = stack(Route.Home), onRemoveNotification = { removed = it },+                backStack = backStack, onRemoveNotification = { removed = it },             )         }         rule.onNodeWithText("2.2.0").assertExists()@@ -182,72 +187,108 @@ class UiScreensTest {         rule.onNodeWithText(str(com.vayunmathur.library.ui.R.string.remove)).performClick()         assertEquals(3, removed)         rule.onNodeWithText("89044000001234567890123456789012").performClick()-        rule.onNodeWithText("8904 4000 0012 3456 7890 1234 5678 9012").assertIsDisplayed()-        rule.onNodeWithText(str(com.vayunmathur.library.ui.R.string.done)).performClick()-        rule.onNodeWithText(str(R.string.eid_qr_code_dialog_title)).assertDoesNotExist()+        assertEquals(Route.EidDialog("89044000001234567890123456789012"), backStack.last())     }      // ---- ProfileDetail ---- -    @Test fun `profile detail disabled profile enable dialog confirms`() {-        var enabled: Profile? = null+    @Test fun `profile detail disabled profile pushes enable dialog and content confirms`() {+        val backStack = stack(Route.Home, Route.ProfileDetail("iccid-2"))         rule.setContent {             ProfileDetailScreen(                 iccid = "iccid-2",                 state = EuiccScreenState(loading = false, profiles = listOf(enabledProfile, disabledProfile)),-                backStack = stack(Route.Home),-                onEnable = { enabled = it }, onDisable = {}, onErase = {}, onRename = { _, _ -> },+                backStack = backStack,             )         }         rule.onNodeWithText(str(R.string.profile_status_disabled)).assertExists()         rule.onNodeWithText("Travel eSIM").assertExists()         rule.onNodeWithText("8901000002").assertExists()         rule.onNodeWithText(str(R.string.enable_profile_title)).performClick()+        assertEquals(Route.EnableProfileDialog("iccid-2"), backStack.last())+    }++    @Test fun `enable profile dialog content confirms`() {+        var confirmed = 0+        rule.setContent {+            EnableProfileDialogContent(+                profileLabel = "Global Data", currentLabel = "Work",+                onConfirm = { confirmed++ }, onDismiss = {},+            )+        }         rule.onNodeWithText(str(R.string.enable_carrier_dialog_text, "Global Data", "Work")).assertIsDisplayed()-        // Confirm button carries the same Enable label; click the last match (dialog).-        rule.onAllNodesWithText(str(R.string.enable_profile_title))[1].performClick()-        assertEquals(disabledProfile, enabled)+        rule.onNodeWithText(str(R.string.enable_profile_title)).performClick()+        assertEquals(1, confirmed)     } -    @Test fun `profile detail enabled profile disable and erase dialogs dismiss and confirm`() {-        var disabled: Profile? = null; var erased: Profile? = null+    @Test fun `profile detail enabled profile pushes disable and erase dialogs`() {+        val backStack = stack(Route.Home, Route.ProfileDetail("iccid-1"))         rule.setContent {             ProfileDetailScreen(                 iccid = "iccid-1",                 state = EuiccScreenState(loading = false, profiles = listOf(enabledProfile)),-                backStack = stack(Route.Home),-                onEnable = {}, onDisable = { disabled = it }, onErase = { erased = it }, onRename = { _, _ -> },+                backStack = backStack,             )         }         rule.onNodeWithText(str(R.string.profile_status_enabled)).assertExists()         rule.onNodeWithText(str(R.string.disable_profile_title)).performClick()-        rule.onNodeWithText(str(R.string.disable_carrier_dialog_text, "Work")).assertIsDisplayed()-        rule.onAllNodesWithText(str(R.string.disable_profile_title))[1].performClick()-        assertEquals(enabledProfile, disabled)+        assertEquals(Route.DisableProfileDialog("iccid-1"), backStack.last())+        backStack.pop()         rule.onNodeWithText(str(R.string.erase_sim_confirm_button)).performClick()+        assertEquals(Route.EraseProfileDialog("iccid-1"), backStack.last())+    }++    @Test fun `disable dialog content confirms after dismiss`() {+        var confirmed = 0; var dismissed = 0+        rule.setContent {+            DisableProfileDialogContent(+                profileLabel = "Work",+                onConfirm = { confirmed++ }, onDismiss = { dismissed++ },+            )+        }+        rule.onNodeWithText(str(R.string.disable_carrier_dialog_text, "Work")).assertIsDisplayed()+        rule.onNodeWithText(str(R.string.disable_profile_title)).performClick()+        // ConfirmDialog dismisses first, then confirms.+        assertEquals(1, dismissed)+        assertEquals(1, confirmed)+    }++    @Test fun `erase dialog content dismisses on cancel`() {+        var confirmed = 0; var dismissed = 0+        rule.setContent {+            EraseProfileDialogContent(+                profileLabel = "Work",+                onConfirm = { confirmed++ }, onDismiss = { dismissed++ },+            )+        }         rule.onNodeWithText(str(R.string.erase_sim_dialog_title, "Work")).assertIsDisplayed()         rule.onNodeWithText(str(com.vayunmathur.library.ui.R.string.cancel)).performClick()-        assertTrue(erased == null)-        rule.onNodeWithText(str(R.string.erase_sim_confirm_button)).performClick()-        rule.onAllNodesWithText(str(R.string.erase_sim_confirm_button))[1].performClick()-        assertEquals(enabledProfile, erased)+        assertEquals(1, dismissed)+        assertEquals(0, confirmed)     } -    @Test fun `profile detail rename dialog saves new name`() {-        var renamed: Pair<Profile, String>? = null+    @Test fun `profile detail pushes rename dialog and rename content saves`() {+        val backStack = stack(Route.Home, Route.ProfileDetail("iccid-1"))         rule.setContent {             ProfileDetailScreen(                 iccid = "iccid-1",                 state = EuiccScreenState(loading = false, profiles = listOf(enabledProfile)),-                backStack = stack(Route.Home),-                onEnable = {}, onDisable = {}, onErase = {}, onRename = { p, n -> renamed = p to n },+                backStack = backStack,             )         }         rule.onNodeWithText(str(R.string.rename_profile_title)).performClick()+        assertEquals(Route.RenameProfileDialog("iccid-1"), backStack.last())+    }++    @Test fun `rename dialog content saves new name`() {+        var renamed: String? = null+        rule.setContent {+            RenameDialog(profile = enabledProfile, onConfirm = { renamed = it }, onDismiss = {})+        }         val field = rule.onAllNodes(hasSetTextAction())[0]         field.performTextReplacement("Personal")         rule.onNodeWithText(str(com.vayunmathur.library.ui.R.string.save)).performClick()-        assertEquals(enabledProfile to "Personal", renamed)+        assertEquals("Personal", renamed)     }      @Test fun `profile detail without provider hides provider row`() {@@ -259,7 +300,6 @@ class UiScreensTest {                     profiles = listOf(Profile(iccid = "iccid-9", iccidDisplay = "89019", state = "disabled")),                 ),                 backStack = stack(Route.Home),-                onEnable = {}, onDisable = {}, onErase = {}, onRename = { _, _ -> },             )         }         rule.onNodeWithText(str(R.string.profile_provider)).assertDoesNotExist()@@ -273,7 +313,6 @@ class UiScreensTest {                 iccid = "gone",                 state = EuiccScreenState(loading = false, profiles = emptyList()),                 backStack = backStack,-                onEnable = {}, onDisable = {}, onErase = {}, onRename = { _, _ -> },             )         }         rule.waitForIdle()