Onboarding permission pages go straight to the system request !384

merged merged by cmc on 2026-11-17 05:36 UTC · krz/orgstar:onboarding-permission-continue into main

1 file changed, +7 −12

Layout: unified · split

Sources/OrgstarMobile/OnboardingScreen.swift +7 −12
@@ -5,7 +5,7 @@ import SwiftUI
55import UserNotifications
66
77/// First launch: what the app does, the folder of org files, and the permissions each
8/// optional feature needs, asked for one at a time and only when the user chooses to.
8/// optional feature needs, each explained on its own page before the system request.
99struct OnboardingScreen: View {
1010 /// Set once onboarding is done or skipped for a workspace that had folders already.
1111 static let doneKey = "onboarded"
@@ -90,17 +90,14 @@ struct OnboardingScreen: View {
9090 text: "orgstar can notify you before timed entries, as Org's appointment reminders do, and show today's overdue count on its icon.") {
9191 EmptyView()
9292 } actions: {
93 primary("Allow Notifications") {
93 primary("Continue") {
9494 Task {
95 _ = try? await UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge])
95 let granted = (try? await UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge])) ?? false
96 // Off when declined, so the agenda doesn't ask later; Settings turns it back on.
97 if !granted { model.set("reminders", to: .bool(false)) }
9698 next()
9799 }
98100 }
99 secondary("Not Now") {
100 // Off, so the agenda doesn't ask later; Settings turns it back on.
101 model.set("reminders", to: .bool(false))
102 next()
103 }
104101 }
105102 }
106103
@@ -109,13 +106,12 @@ struct OnboardingScreen: View {
109106 text: "Show events from Calendar among your agenda's entries. You can choose which calendars in Settings.") {
110107 EmptyView()
111108 } actions: {
112 primary("Show Calendar Events") {
109 primary("Continue") {
113110 Task {
114111 if await model.calendarEvents.requestAccess() { model.set("calendarEvents", to: .bool(true)) }
115112 next()
116113 }
117114 }
118 secondary("Not Now") { next() }
119115 }
120116 }
121117
@@ -124,13 +120,12 @@ struct OnboardingScreen: View {
124120 text: "Show incomplete reminders with a due date from the Reminders app in your agenda, read-only.") {
125121 EmptyView()
126122 } actions: {
127 primary("Show Reminders") {
123 primary("Continue") {
128124 Task {
129125 if await model.reminderLists.requestAccess() { model.set("agendaReminders", to: .bool(true)) }
130126 next()
131127 }
132128 }
133 secondary("Not Now") { next() }
134129 }
135130 }
136131