# D1 — OnboardingScreen integration Drop-in screen drafted at `app/drafts/D1/OnboardingScreen.kt`. ## 1. Destination path Move the file to: ``` app/src/main/java/com/peachpasswords/ui/onboarding/OnboardingScreen.kt ``` Package is already `com.peachpasswords.ui.onboarding` (new package — create the folder). The screen exposes: ```kotlin @Composable fun OnboardingScreen(onFinished: () -> Unit) ``` It also exports two top-level constants the launch guard reuses (so the SharedPreferences key/name live in exactly one place): ```kotlin const val ONBOARD_PREFS = "peach_prefs" const val ONBOARD_KEY = "peach_onboarded" ``` `OnboardingScreen` writes `peach_onboarded = true` to `SharedPreferences("peach_prefs")` itself on "Get started" (in its internal `finish` lambda) before invoking `onFinished`. The host does **not** need to write the flag — only read it for the guard. ## 2. New nav route — `PeachNav.kt` This file is read-only for the drafter. Add this `data object` to the sealed class. Insertion anchor — add it directly after the `Lock` entry: ```kotlin sealed class PeachNav(val route: String) { data object Lock : PeachNav("lock") data object VaultList : PeachNav("vault") ``` becomes: ```kotlin sealed class PeachNav(val route: String) { data object Onboarding : PeachNav("onboarding") data object Lock : PeachNav("lock") data object VaultList : PeachNav("vault") ``` ## 3. Register the composable — `PeachAppNavHost.kt` Add the import (alongside the other screen imports near the top): ```kotlin import com.peachpasswords.ui.onboarding.OnboardingScreen ``` Add this `composable(...)` block inside the `NavHost { ... }` lambda. Anchor — place it immediately before the existing `Lock` block: ```kotlin composable(PeachNav.Lock.route) { LockScreen( ``` Insert above it: ```kotlin composable(PeachNav.Onboarding.route) { OnboardingScreen( onFinished = { // Onboarding flows straight into the create-vault flow. // LockScreen shows the "NEW VAULT" / create state automatically // when no vault exists (state.hasVault == false), so no extra // argument is needed. navController.navigate(PeachNav.Lock.route) { popUpTo(PeachNav.Onboarding.route) { inclusive = true } } }, ) } ``` ## 4. Launch guard — pick the start destination The app currently hard-starts at `PeachNav.Lock` (see `PeachAppNavHost`'s default param `startDestination: PeachNav = PeachNav.Lock`, and `MainActivity` calling `PeachAppNavHost()` with no argument). The guard logic from the brief: > On app launch, if no vault exists AND `peach_onboarded == false`, > navigate to OnboardingScreen before LockScreen. `VaultRepository.hasVault(): Boolean` already exists and is synchronous (`store.hasVault()`), and `LockViewModel` already reads it the same way. There are two clean ways to wire the guard — pick one: ### Option A (recommended) — compute in MainActivity, pass as startDestination `MainActivity` is a `@AndroidEntryPoint FragmentActivity`, so it can read both SharedPreferences and an injected `VaultRepository`. Change the `PeachAppNavHost()` call site: ```kotlin // MainActivity.kt — add field injection @Inject lateinit var vault: com.peachpasswords.vault.VaultRepository ``` (requires `import javax.inject.Inject`; field injection works on a Hilt `@AndroidEntryPoint` activity.) Then in `onCreate`, before `setContent { ... }`: ```kotlin val prefs = getSharedPreferences("peach_prefs", MODE_PRIVATE) val onboarded = prefs.getBoolean("peach_onboarded", false) val start = if (!vault.hasVault() && !onboarded) com.peachpasswords.ui.PeachNav.Onboarding else com.peachpasswords.ui.PeachNav.Lock ``` and pass it down: ```kotlin setContent { PeachTheme { PeachAppNavHost(startDestination = start) } } ``` `PeachAppNavHost` already accepts `startDestination` — no signature change needed. ### Option B — compute inside PeachAppNavHost If you prefer to keep `MainActivity` untouched, compute the start destination inside `PeachAppNavHost` using `LocalContext` + `hiltViewModel()` (its `state.hasVault` already reflects `vault.hasVault()`), then choose the `startDestination` before building the `NavHost`. Option A is cleaner because the start destination must be known at first composition; reading it from a VM inside the host risks a one-frame flash of Lock before redirect. Use the exported constants instead of raw strings to avoid drift: ```kotlin import com.peachpasswords.ui.onboarding.ONBOARD_PREFS import com.peachpasswords.ui.onboarding.ONBOARD_KEY ... val onboarded = prefs.getBoolean(ONBOARD_KEY, false) ``` ## 5. Visual notes / assumptions - **ShellBackground bloom**: used as the root wrapper, matching LockScreen / ImportScreen. ✓ - **Glass card panels**: `PeachColors.SurfaceElevated` (= `Color(0xE0131109)`), 1dp `PeachColors.T3` border, 18.dp corner radius — per spec and matching LockScreen's private `GlassPanel`. ✓ - **Transitions**: card exit `translateX 0 → -12.dp` + `alpha 1 → 0` over 120ms; card enter `translateX 12.dp → 0` + `alpha 0 → 1` over 200ms using `PeachMotion.Spring`. Implemented in the private `CardSwitcher`. ✓ - **Nav row**: back hidden on card 1 (space reserved to keep dots centered), 3 dot indicators (inactive 6dp `T2`, active 8dp accent), "next" → "Get started" on card 3. ✓ - **All type via PeachType, all colors via PeachColors / LocalPeachAccent** — no `MaterialTheme.typography`, no hardcoded hex. ✓ - **`RuneBackground` is OMITTED — it does not exist in the codebase.** The brief asks for "RuneBackground at alpha 0.05 behind cards"; a project-wide grep (`grep -rn RuneBackground app/src/main`) returns nothing — there is no such composable. Per `_CONVENTIONS.md`, it is left out rather than invented. **TODO (orchestrator):** if a rune layer is wanted, add a `RuneBackground` composable first, then place it inside `ShellBackground` behind the `CardSwitcher` `Box` at `Modifier.alpha(0.05f)`. ## 6. No new ViewModel / Repository / model APIs required - No `OnboardingViewModel` — the screen is pure UI with local `remember` state. - No new `VaultRepository` methods — the guard reuses the existing synchronous `VaultRepository.hasVault()`. - The onboarded flag is plain `SharedPreferences("peach_prefs")` per the brief (not encrypted prefs), read in the guard and written by the screen. ## 7. Suggested koh saves (orchestrator runs these) ``` checkpoint "before OnboardingScreen" save "feat: D1 OnboardingScreen — 3-card swipe flow, onboarded guard, nav (v2.1.31)" ```