From b634c0686d77d94b84224edeb31034e5db035dbb Mon Sep 17 00:00:00 2001 From: FuelBoard Contributor Date: Sat, 15 Aug 2026 14:34:24 +0100 Subject: [PATCH] Onboarding: permission prompts fire on page arrival, not just Continue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Swiping past the Location/Notifications pages never triggered the system prompts — only tapping Continue did. The prompt now fires the moment its page comes into view (onChange(of: page)): swipe, auto-advance after a grant, or Continue all land on the page and request the permission. Both request methods are idempotent (already-determined → status refresh, no duplicate alert), so replay and the auto-advance path stay clean. --- FuelBoard/OnboardingView.swift | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) 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