Commit 490309ed9c
Verified · cmc
Layout: unified · split
Sources/OrgstarMobile/OnboardingScreen.swift +7 −12
| @@ -5,7 +5,7 @@ import SwiftUI | ||
| 5 | 5 | import UserNotifications |
| 6 | 6 | |
| 7 | 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. | |
| 9 | 9 | struct OnboardingScreen: View { |
| 10 | 10 | /// Set once onboarding is done or skipped for a workspace that had folders already. |
| 11 | 11 | static let doneKey = "onboarded" |
| @@ -90,17 +90,14 @@ struct OnboardingScreen: View { | ||
| 90 | 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 | 91 | EmptyView() |
| 92 | 92 | } actions: { |
| 93 | primary("Allow Notifications") { | |
| 93 | primary("Continue") { | |
| 94 | 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 | 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 | 106 | text: "Show events from Calendar among your agenda's entries. You can choose which calendars in Settings.") { |
| 110 | 107 | EmptyView() |
| 111 | 108 | } actions: { |
| 112 | primary("Show Calendar Events") { | |
| 109 | primary("Continue") { | |
| 113 | 110 | Task { |
| 114 | 111 | if await model.calendarEvents.requestAccess() { model.set("calendarEvents", to: .bool(true)) } |
| 115 | 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 | 120 | text: "Show incomplete reminders with a due date from the Reminders app in your agenda, read-only.") { |
| 125 | 121 | EmptyView() |
| 126 | 122 | } actions: { |
| 127 | primary("Show Reminders") { | |
| 123 | primary("Continue") { | |
| 128 | 124 | Task { |
| 129 | 125 | if await model.reminderLists.requestAccess() { model.set("agendaReminders", to: .bool(true)) } |
| 130 | 126 | next() |
| 131 | 127 | } |
| 132 | 128 | } |
| 133 | secondary("Not Now") { next() } | |
| 134 | 129 | } |
| 135 | 130 | } |
| 136 | 131 | |