Onboarding: add a Best Value page before the final screen
New page 5 of 6, sitting between "Prices, ready when you are" and "You're all
set":
- Explains the feature: the cheapest pump isn't always the cheapest fill-up.
- Asks whether to switch it on, with a toggle.
- Switched ON, it asks for the two figures the ranking needs — average fuel
economy and typical fill-up — using exactly the Settings slider pattern
(read-out above a slider, £/Litres picker, no text entry anywhere).
- Switched OFF, it says where to switch Best Value on later ("Settings, under
Fuel Savings") instead of showing controls the user has just declined, and
the button reads "Not now" rather than "Continue" so declining reads as a
decision.
Chosen figures are written to the store as the controls move — the same
immediate-persist rule as Settings — so swiping past the page cannot lose a
choice. ContentView now reloads the stored savings settings when onboarding
dismisses: onboarding is a full-screen cover writing straight to the store
rather than through ContentView's binding, so without the reload the choice
would not take effect until the next launch.
QA hooks (DEBUG only, alongside -tab / -skipOnboarding): -showOnboarding forces
the cover up (the app-group onboarding flag survives an app delete, so a
reinstall alone won't bring it back), -onboardingPage N opens straight on a
page, -onboardingBestValue on|off forces the page's choice.
Verified on the simulator: with the toggle off the page shows the title,
explanation, toggle, the "set it up in Settings" note and a "Not now" button;
with it on it shows the MPG slider (45 MPG), the £/Litres picker, the fill-up
slider (£40), the "change these in Settings" note and "Continue". Page 5 is
still "You're all set". Checked on an iPhone 17 Pro and on an iPhone SE (3rd
gen) screen — nothing clips on the small one.
172 tests, 0 failures.
This commit is contained in:
@@ -567,10 +567,19 @@ struct ContentView: View {
|
||||
// touching the stored flag.
|
||||
#if DEBUG
|
||||
let shouldSkipOnboarding = args.contains("-skipOnboarding")
|
||||
// The onboarding flag lives in app-group defaults, which survive an
|
||||
// app delete — so a reinstall alone won't bring onboarding back.
|
||||
// `-showOnboarding` forces it up for the screenshot harness (and
|
||||
// pairs with OnboardingView's `-onboardingPage` /
|
||||
// `-onboardingBestValue`).
|
||||
let shouldForceOnboarding = args.contains("-showOnboarding")
|
||||
#else
|
||||
let shouldSkipOnboarding = false
|
||||
let shouldForceOnboarding = false
|
||||
#endif
|
||||
if !FuelStore.shouldShowOnboarding()
|
||||
if shouldForceOnboarding {
|
||||
showOnboarding = true
|
||||
} else if !FuelStore.shouldShowOnboarding()
|
||||
|| shouldSkipOnboarding {
|
||||
locationManager.startForegroundTracking()
|
||||
// Geofences and the Live Activity must follow the user even in
|
||||
@@ -612,6 +621,13 @@ struct ContentView: View {
|
||||
// cache-gated refresh skip the fetch and leave the station list
|
||||
// empty on a brand-new install.
|
||||
if !showing, FuelStore.loadHasCompletedOnboarding() {
|
||||
// Onboarding can switch Best Value on and set the MPG and
|
||||
// fill-up figures. It is a full-screen cover with its own copy
|
||||
// of the settings, so it writes straight to the store instead of
|
||||
// through this view's binding — pull the stored values back in
|
||||
// or the choice wouldn't take effect until the next launch.
|
||||
fuelSavingsSettings = FuelStore.loadFuelSavingsSettings()
|
||||
sessionFuelSavingsAmount = fuelSavingsSettings.preferredAmount
|
||||
locationManager.startForegroundTracking()
|
||||
installLocationUpdateHook()
|
||||
ensureBackgroundMotionTrackingIfNeeded()
|
||||
|
||||
Reference in New Issue
Block a user