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
5import UserNotifications 5import UserNotifications
6 6
7/// First launch: what the app does, the folder of org files, and the permissions each 7/// 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.
9struct OnboardingScreen: View { 9struct OnboardingScreen: View {
10 /// Set once onboarding is done or skipped for a workspace that had folders already. 10 /// Set once onboarding is done or skipped for a workspace that had folders already.
11 static let doneKey = "onboarded" 11 static let doneKey = "onboarded"
@@ -90,17 +90,14 @@ struct OnboardingScreen: View {
90 text: "orgstar can notify you before timed entries, as Org's appointment reminders do, and show today's overdue count on its icon.") { 90 text: "orgstar can notify you before timed entries, as Org's appointment reminders do, and show today's overdue count on its icon.") {
91 EmptyView() 91 EmptyView()
92 } actions: { 92 } actions: {
93 primary("Allow Notifications") { 93 primary("Continue") {
94 Task { 94 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)) }
96 next() 98 next()
97 } 99 }
98 } 100 }
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 }
104 } 101 }
105 } 102 }
106 103
@@ -109,13 +106,12 @@ struct OnboardingScreen: View {
109 text: "Show events from Calendar among your agenda's entries. You can choose which calendars in Settings.") { 106 text: "Show events from Calendar among your agenda's entries. You can choose which calendars in Settings.") {
110 EmptyView() 107 EmptyView()
111 } actions: { 108 } actions: {
112 primary("Show Calendar Events") { 109 primary("Continue") {
113 Task { 110 Task {
114 if await model.calendarEvents.requestAccess() { model.set("calendarEvents", to: .bool(true)) } 111 if await model.calendarEvents.requestAccess() { model.set("calendarEvents", to: .bool(true)) }
115 next() 112 next()
116 } 113 }
117 } 114 }
118 secondary("Not Now") { next() }
119 } 115 }
120 } 116 }
121 117
@@ -124,13 +120,12 @@ struct OnboardingScreen: View {
124 text: "Show incomplete reminders with a due date from the Reminders app in your agenda, read-only.") { 120 text: "Show incomplete reminders with a due date from the Reminders app in your agenda, read-only.") {
125 EmptyView() 121 EmptyView()
126 } actions: { 122 } actions: {
127 primary("Show Reminders") { 123 primary("Continue") {
128 Task { 124 Task {
129 if await model.reminderLists.requestAccess() { model.set("agendaReminders", to: .bool(true)) } 125 if await model.reminderLists.requestAccess() { model.set("agendaReminders", to: .bool(true)) }
130 next() 126 next()
131 } 127 }
132 } 128 }
133 secondary("Not Now") { next() }
134 } 129 }
135 } 130 }
136 131