| @@ -16,6 +16,7 @@ struct OnboardingScreen: View { |
| 16 | @State private var step = Step.welcome |
16 | @State private var step = Step.welcome |
| 17 | @State private var importing = false |
17 | @State private var importing = false |
| 18 | @State private var problem: String? |
18 | @State private var problem: String? |
| |
19 | @Environment(\.accessibilityReduceMotion) private var reduceMotion |
| 19 | |
20 | |
| 20 | private enum Step: Int, CaseIterable { |
21 | private enum Step: Int, CaseIterable { |
| 21 | case welcome, folder, notifications, calendar, reminders |
22 | case welcome, folder, notifications, calendar, reminders |
| @@ -34,7 +35,7 @@ struct OnboardingScreen: View { |
| 34 | } |
35 | } |
| 35 | .frame(maxWidth: 500, maxHeight: .infinity) |
36 | .frame(maxWidth: 500, maxHeight: .infinity) |
| 36 | .padding(.horizontal, 28) |
37 | .padding(.horizontal, 28) |
| 37 | .transition(.asymmetric(insertion: .move(edge: .trailing), removal: .move(edge: .leading)).combined(with: .opacity)) |
38 | .transition(reduceMotion ? .opacity : .asymmetric(insertion: .move(edge: .trailing), removal: .move(edge: .leading)).combined(with: .opacity)) |
| 38 | .id(step) |
39 | .id(step) |
| 39 | HStack(spacing: 8) { |
40 | HStack(spacing: 8) { |
| 40 | ForEach(Step.allCases, id: \.self) { s in |
41 | ForEach(Step.allCases, id: \.self) { s in |
| @@ -43,6 +44,7 @@ struct OnboardingScreen: View { |
| 43 | } |
44 | } |
| 44 | .accessibilityElement(children: .ignore) |
45 | .accessibilityElement(children: .ignore) |
| 45 | .accessibilityLabel("Step \(step.rawValue + 1) of \(Step.allCases.count)") |
46 | .accessibilityLabel("Step \(step.rawValue + 1) of \(Step.allCases.count)") |
| |
47 | .padding(.top, 12) |
| 46 | .padding(.bottom, 12) |
48 | .padding(.bottom, 12) |
| 47 | } |
49 | } |
| 48 | .tint(model.theme.accentColor) |
50 | .tint(model.theme.accentColor) |
| @@ -63,7 +65,9 @@ struct OnboardingScreen: View { |
| 63 | } |
65 | } |
| 64 | |
66 | |
| 65 | private var welcome: some View { |
67 | private var welcome: some View { |
| 66 | page(symbol: "star.fill", title: "Welcome to orgstar", text: "Your org files on iPhone, in the folders where they already are.") { |
68 | page(symbol: "star.fill", title: "Welcome to orgstar", |
| |
69 | text: UIDevice.current.userInterfaceIdiom == .pad ? "Your org files on iPad, in the folders where they already are." |
| |
70 | : "Your org files on iPhone, in the folders where they already are.") { |
| 67 | VStack(alignment: .leading, spacing: 18) { |
71 | VStack(alignment: .leading, spacing: 18) { |
| 68 | feature("calendar", "The agenda", "Scheduled entries, deadlines and TODOs from all your files.") |
72 | feature("calendar", "The agenda", "Scheduled entries, deadlines and TODOs from all your files.") |
| 69 | feature("hand.tap", "Tap to edit", "Change an entry's state, dates, tags and notes in place. Swipe to finish or reschedule.") |
73 | feature("hand.tap", "Tap to edit", "Change an entry's state, dates, tags and notes in place. Swipe to finish or reschedule.") |
| @@ -98,13 +102,17 @@ struct OnboardingScreen: View { |
| 98 | next() |
102 | next() |
| 99 | } |
103 | } |
| 100 | } |
104 | } |
| |
105 | secondary("Not Now") { |
| |
106 | model.set("reminders", to: .bool(false)) |
| |
107 | next() |
| |
108 | } |
| 101 | } |
109 | } |
| 102 | } |
110 | } |
| 103 | |
111 | |
| 104 | private var calendar: some View { |
112 | private var calendar: some View { |
| 105 | page(symbol: "calendar.badge.clock", title: "Calendar events", |
113 | page(symbol: "calendar.badge.clock", title: "Calendar events", |
| 106 | text: "Show events from Calendar among your agenda's entries. You can choose which calendars in Settings.") { |
114 | text: "Show events from Calendar among your agenda's entries. You can choose which calendars in Settings.") { |
| 107 | EmptyView() |
115 | needsPro |
| 108 | } actions: { |
116 | } actions: { |
| 109 | primary("Continue") { |
117 | primary("Continue") { |
| 110 | Task { |
118 | Task { |
| @@ -112,13 +120,14 @@ struct OnboardingScreen: View { |
| 112 | next() |
120 | next() |
| 113 | } |
121 | } |
| 114 | } |
122 | } |
| |
123 | secondary("Not Now") { next() } |
| 115 | } |
124 | } |
| 116 | } |
125 | } |
| 117 | |
126 | |
| 118 | private var reminders: some View { |
127 | private var reminders: some View { |
| 119 | page(symbol: "checklist", title: "Reminders app", |
128 | page(symbol: "checklist", title: "Reminders app", |
| 120 | text: "Show incomplete reminders with a due date from the Reminders app in your agenda, read-only.") { |
129 | text: "Show incomplete reminders with a due date from the Reminders app in your agenda, read-only.") { |
| 121 | EmptyView() |
130 | needsPro |
| 122 | } actions: { |
131 | } actions: { |
| 123 | primary("Continue") { |
132 | primary("Continue") { |
| 124 | Task { |
133 | Task { |
| @@ -126,6 +135,16 @@ struct OnboardingScreen: View { |
| 126 | next() |
135 | next() |
| 127 | } |
136 | } |
| 128 | } |
137 | } |
| |
138 | secondary("Not Now") { next() } |
| |
139 | } |
| |
140 | } |
| |
141 | |
| |
142 | /// Calendar and Reminders in the agenda are orgstar+ features. |
| |
143 | @ViewBuilder |
| |
144 | private var needsPro: some View { |
| |
145 | if !ProAccess.shared.isUnlocked { |
| |
146 | Label { Text("Needs orgstar+") } icon: { PlusBadge(size: 22) } |
| |
147 | .font(.subheadline.weight(.medium)) |
| 129 | } |
148 | } |
| 130 | } |
149 | } |
| 131 | |
150 | |
| @@ -135,7 +154,7 @@ struct OnboardingScreen: View { |
| 135 | finish() |
154 | finish() |
| 136 | return |
155 | return |
| 137 | } |
156 | } |
| 138 | withAnimation(.snappy) { step = following } |
157 | withAnimation(reduceMotion ? .easeInOut(duration: 0.2) : .snappy) { step = following } |
| 139 | } |
158 | } |
| 140 | |
159 | |
| 141 | // MARK: - Layout |
160 | // MARK: - Layout |
| @@ -144,18 +163,27 @@ struct OnboardingScreen: View { |
| 144 | symbol: String, title: LocalizedStringKey, text: LocalizedStringKey, |
163 | symbol: String, title: LocalizedStringKey, text: LocalizedStringKey, |
| 145 | @ViewBuilder content: () -> Content, @ViewBuilder actions: () -> Actions |
164 | @ViewBuilder content: () -> Content, @ViewBuilder actions: () -> Actions |
| 146 | ) -> some View { |
165 | ) -> some View { |
| 147 | VStack(spacing: 20) { |
166 | // The text scrolls at large text sizes; the actions stay below it. |
| 148 | Spacer(minLength: 24) |
167 | let content = content() |
| 149 | Image(systemName: symbol) |
168 | return VStack(spacing: 20) { |
| 150 | .font(.system(size: 44, weight: .semibold)) |
169 | GeometryReader { geometry in |
| 151 | .foregroundStyle(Color.accentColor) |
170 | ScrollView { |
| 152 | .frame(width: 96, height: 96) |
171 | VStack(spacing: 20) { |
| 153 | .background(Color.accentColor.opacity(0.12), in: Circle()) |
172 | Image(systemName: symbol) |
| 154 | .accessibilityHidden(true) |
173 | .font(.system(size: 44, weight: .semibold)) |
| 155 | Text(title).font(.title.bold()).multilineTextAlignment(.center) |
174 | .foregroundStyle(Color.accentColor) |
| 156 | Text(text).font(.body).foregroundStyle(.secondary).multilineTextAlignment(.center) |
175 | .frame(width: 96, height: 96) |
| 157 | content() |
176 | .background(Color.accentColor.opacity(0.12), in: Circle()) |
| 158 | Spacer(minLength: 24) |
177 | .accessibilityHidden(true) |
| |
178 | Text(title).font(.title.bold()).multilineTextAlignment(.center) |
| |
179 | Text(text).font(.body).foregroundStyle(.secondary).multilineTextAlignment(.center) |
| |
180 | content |
| |
181 | } |
| |
182 | .padding(.vertical, 24) |
| |
183 | .frame(maxWidth: .infinity, minHeight: geometry.size.height) |
| |
184 | } |
| |
185 | .scrollBounceBehavior(.basedOnSize) |
| |
186 | } |
| 159 | VStack(spacing: 12) { actions() } |
187 | VStack(spacing: 12) { actions() } |
| 160 | } |
188 | } |
| 161 | } |
189 | } |