diff --git a/FuelBoard/OnboardingView.swift b/FuelBoard/OnboardingView.swift index afe5fae..93e3aaf 100644 --- a/FuelBoard/OnboardingView.swift +++ b/FuelBoard/OnboardingView.swift @@ -47,15 +47,25 @@ struct OnboardingView: View { .padding(.horizontal, 20) .padding(.bottom, 24) } - // Auto-advance once the user grants a permission — the prompt itself - // only fires when the Continue button is tapped (after reading the - // page's description), never when the page merely appears. + // Auto-advance once the user grants a permission. .onChange(of: prompter.locationGranted) { _, granted in if granted, page == 1 { page = 2 } } .onChange(of: prompter.notificationsGranted) { _, granted in if granted, page == 2 { page = 3 } } + // Fire the permission the moment its page comes into view — swiping + // must trigger the prompt exactly like tapping Continue does. Both + // request methods are idempotent: an already-determined permission + // just refreshes the status (no duplicate system alert), so this is + // safe for replay and for the auto-advance path. + .onChange(of: page) { _, newPage in + if newPage == 1 { + prompter.requestLocation() + } else if newPage == 2 { + prompter.requestNotifications() + } + } // No data-permission step: prices download from the internet (GitHub // mirror) with no permission at all — Local Network was removed from // the app when the relay left the consumer chain. @@ -237,8 +247,9 @@ struct OnboardingView: View { if prompter.locationDenied { openSettings() } else if !prompter.locationGranted { - // The system prompt fires HERE — after the user has read - // the description and tapped Continue — not on page appear. + // Safety net — the prompt already fired when this page + // came into view (see onChange(of: page)); re-requesting + // is a no-op unless the status is still undetermined. prompter.requestLocation() } else { page = 2