Onboarding: permission prompts fire on page arrival, not just Continue
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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user