INTEGRATION.md

6.7 KB · raw

rendered · source

1# D1 — OnboardingScreen integration23Drop-in screen drafted at `app/drafts/D1/OnboardingScreen.kt`.45## 1. Destination path67Move the file to:89```10app/src/main/java/com/peachpasswords/ui/onboarding/OnboardingScreen.kt11```1213Package is already `com.peachpasswords.ui.onboarding` (new package — create the folder).1415The screen exposes:1617```kotlin18@Composable19fun OnboardingScreen(onFinished: () -> Unit)20```2122It also exports two top-level constants the launch guard reuses (so the23SharedPreferences key/name live in exactly one place):2425```kotlin26const val ONBOARD_PREFS = "peach_prefs"27const val ONBOARD_KEY = "peach_onboarded"28```2930`OnboardingScreen` writes `peach_onboarded = true` to `SharedPreferences("peach_prefs")`31itself on "Get started" (in its internal `finish` lambda) before invoking32`onFinished`. The host does **not** need to write the flag — only read it for the guard.3334## 2. New nav route — `PeachNav.kt`3536This file is read-only for the drafter. Add this `data object` to the sealed37class. Insertion anchor — add it directly after the `Lock` entry:3839```kotlin40sealed class PeachNav(val route: String) {41    data object Lock : PeachNav("lock")42    data object VaultList : PeachNav("vault")43```4445becomes:4647```kotlin48sealed class PeachNav(val route: String) {49    data object Onboarding : PeachNav("onboarding")50    data object Lock : PeachNav("lock")51    data object VaultList : PeachNav("vault")52```5354## 3. Register the composable — `PeachAppNavHost.kt`5556Add the import (alongside the other screen imports near the top):5758```kotlin59import com.peachpasswords.ui.onboarding.OnboardingScreen60```6162Add this `composable(...)` block inside the `NavHost { ... }` lambda. Anchor —63place it immediately before the existing `Lock` block:6465```kotlin66        composable(PeachNav.Lock.route) {67            LockScreen(68```6970Insert above it:7172```kotlin73        composable(PeachNav.Onboarding.route) {74            OnboardingScreen(75                onFinished = {76                    // Onboarding flows straight into the create-vault flow.77                    // LockScreen shows the "NEW VAULT" / create state automatically78                    // when no vault exists (state.hasVault == false), so no extra79                    // argument is needed.80                    navController.navigate(PeachNav.Lock.route) {81                        popUpTo(PeachNav.Onboarding.route) { inclusive = true }82                    }83                },84            )85        }86```8788## 4. Launch guard — pick the start destination8990The app currently hard-starts at `PeachNav.Lock` (see `PeachAppNavHost`'s91default param `startDestination: PeachNav = PeachNav.Lock`, and `MainActivity`92calling `PeachAppNavHost()` with no argument).9394The guard logic from the brief:9596> On app launch, if no vault exists AND `peach_onboarded == false`,97> navigate to OnboardingScreen before LockScreen.9899`VaultRepository.hasVault(): Boolean` already exists and is synchronous100(`store.hasVault()`), and `LockViewModel` already reads it the same way. There101are two clean ways to wire the guard — pick one:102103### Option A (recommended) — compute in MainActivity, pass as startDestination104105`MainActivity` is a `@AndroidEntryPoint FragmentActivity`, so it can read both106SharedPreferences and an injected `VaultRepository`. Change the `PeachAppNavHost()`107call site:108109```kotlin110// MainActivity.kt — add field injection111@Inject lateinit var vault: com.peachpasswords.vault.VaultRepository112```113114(requires `import javax.inject.Inject`; field injection works on a Hilt115`@AndroidEntryPoint` activity.)116117Then in `onCreate`, before `setContent { ... }`:118119```kotlin120val prefs = getSharedPreferences("peach_prefs", MODE_PRIVATE)121val onboarded = prefs.getBoolean("peach_onboarded", false)122val start =123    if (!vault.hasVault() && !onboarded) com.peachpasswords.ui.PeachNav.Onboarding124    else com.peachpasswords.ui.PeachNav.Lock125```126127and pass it down:128129```kotlin130setContent {131    PeachTheme {132        PeachAppNavHost(startDestination = start)133    }134}135```136137`PeachAppNavHost` already accepts `startDestination` — no signature change needed.138139### Option B — compute inside PeachAppNavHost140141If you prefer to keep `MainActivity` untouched, compute the start destination142inside `PeachAppNavHost` using `LocalContext` + `hiltViewModel<LockViewModel>()`143(its `state.hasVault` already reflects `vault.hasVault()`), then choose the144`startDestination` before building the `NavHost`. Option A is cleaner because145the start destination must be known at first composition; reading it from a VM146inside the host risks a one-frame flash of Lock before redirect.147148Use the exported constants instead of raw strings to avoid drift:149150```kotlin151import com.peachpasswords.ui.onboarding.ONBOARD_PREFS152import com.peachpasswords.ui.onboarding.ONBOARD_KEY153...154val onboarded = prefs.getBoolean(ONBOARD_KEY, false)155```156157## 5. Visual notes / assumptions158159- **ShellBackground bloom**: used as the root wrapper, matching LockScreen /160  ImportScreen. ✓161- **Glass card panels**: `PeachColors.SurfaceElevated` (= `Color(0xE0131109)`),162  1dp `PeachColors.T3` border, 18.dp corner radius — per spec and matching163  LockScreen's private `GlassPanel`. ✓164- **Transitions**: card exit `translateX 0 → -12.dp` + `alpha 1 → 0` over 120ms;165  card enter `translateX 12.dp → 0` + `alpha 0 → 1` over 200ms using166  `PeachMotion.Spring`. Implemented in the private `CardSwitcher`. ✓167- **Nav row**: back hidden on card 1 (space reserved to keep dots centered),168  3 dot indicators (inactive 6dp `T2`, active 8dp accent), "next" → "Get started"169  on card 3. ✓170- **All type via PeachType, all colors via PeachColors / LocalPeachAccent** — no171  `MaterialTheme.typography`, no hardcoded hex. ✓172- **`RuneBackground` is OMITTED — it does not exist in the codebase.** The brief173  asks for "RuneBackground at alpha 0.05 behind cards"; a project-wide grep174  (`grep -rn RuneBackground app/src/main`) returns nothing — there is no such175  composable. Per `_CONVENTIONS.md`, it is left out rather than invented.176  **TODO (orchestrator):** if a rune layer is wanted, add a `RuneBackground`177  composable first, then place it inside `ShellBackground` behind the178  `CardSwitcher` `Box` at `Modifier.alpha(0.05f)`.179180## 6. No new ViewModel / Repository / model APIs required181182- No `OnboardingViewModel` — the screen is pure UI with local `remember` state.183- No new `VaultRepository` methods — the guard reuses the existing synchronous184  `VaultRepository.hasVault()`.185- The onboarded flag is plain `SharedPreferences("peach_prefs")` per the brief186  (not encrypted prefs), read in the guard and written by the screen.187188## 7. Suggested koh saves (orchestrator runs these)189190```191checkpoint "before OnboardingScreen"192save "feat: D1 OnboardingScreen — 3-card swipe flow, onboarded guard, nav (v2.1.31)"193```