| @@ -16,6 +16,7 @@ struct OnboardingScreen: View { |
| 16 | 16 | @State private var step = Step.welcome |
| 17 | 17 | @State private var importing = false |
| 18 | 18 | @State private var problem: String? |
| 19 | @Environment(\.accessibilityReduceMotion) private var reduceMotion |
| 19 | 20 | |
| 20 | 21 | private enum Step: Int, CaseIterable { |
| 21 | 22 | case welcome, folder, notifications, calendar, reminders |
| @@ -34,7 +35,7 @@ struct OnboardingScreen: View { |
| 34 | 35 | } |
| 35 | 36 | .frame(maxWidth: 500, maxHeight: .infinity) |
| 36 | 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 | 39 | .id(step) |
| 39 | 40 | HStack(spacing: 8) { |
| 40 | 41 | ForEach(Step.allCases, id: \.self) { s in |
| @@ -43,6 +44,7 @@ struct OnboardingScreen: View { |
| 43 | 44 | } |
| 44 | 45 | .accessibilityElement(children: .ignore) |
| 45 | 46 | .accessibilityLabel("Step \(step.rawValue + 1) of \(Step.allCases.count)") |
| 47 | .padding(.top, 12) |
| 46 | 48 | .padding(.bottom, 12) |
| 47 | 49 | } |
| 48 | 50 | .tint(model.theme.accentColor) |
| @@ -63,7 +65,9 @@ struct OnboardingScreen: View { |
| 63 | 65 | } |
| 64 | 66 | |
| 65 | 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 | 71 | VStack(alignment: .leading, spacing: 18) { |
| 68 | 72 | feature("calendar", "The agenda", "Scheduled entries, deadlines and TODOs from all your files.") |
| 69 | 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 | 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 | 112 | private var calendar: some View { |
| 105 | 113 | page(symbol: "calendar.badge.clock", title: "Calendar events", |
| 106 | 114 | text: "Show events from Calendar among your agenda's entries. You can choose which calendars in Settings.") { |
| 107 | | EmptyView() |
| 115 | needsPro |
| 108 | 116 | } actions: { |
| 109 | 117 | primary("Continue") { |
| 110 | 118 | Task { |
| @@ -112,13 +120,14 @@ struct OnboardingScreen: View { |
| 112 | 120 | next() |
| 113 | 121 | } |
| 114 | 122 | } |
| 123 | secondary("Not Now") { next() } |
| 115 | 124 | } |
| 116 | 125 | } |
| 117 | 126 | |
| 118 | 127 | private var reminders: some View { |
| 119 | 128 | page(symbol: "checklist", title: "Reminders app", |
| 120 | 129 | text: "Show incomplete reminders with a due date from the Reminders app in your agenda, read-only.") { |
| 121 | | EmptyView() |
| 130 | needsPro |
| 122 | 131 | } actions: { |
| 123 | 132 | primary("Continue") { |
| 124 | 133 | Task { |
| @@ -126,6 +135,16 @@ struct OnboardingScreen: View { |
| 126 | 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 | 154 | finish() |
| 136 | 155 | return |
| 137 | 156 | } |
| 138 | | withAnimation(.snappy) { step = following } |
| 157 | withAnimation(reduceMotion ? .easeInOut(duration: 0.2) : .snappy) { step = following } |
| 139 | 158 | } |
| 140 | 159 | |
| 141 | 160 | // MARK: - Layout |
| @@ -144,18 +163,27 @@ struct OnboardingScreen: View { |
| 144 | 163 | symbol: String, title: LocalizedStringKey, text: LocalizedStringKey, |
| 145 | 164 | @ViewBuilder content: () -> Content, @ViewBuilder actions: () -> Actions |
| 146 | 165 | ) -> some View { |
| 147 | | VStack(spacing: 20) { |
| 148 | | Spacer(minLength: 24) |
| 149 | | Image(systemName: symbol) |
| 150 | | .font(.system(size: 44, weight: .semibold)) |
| 151 | | .foregroundStyle(Color.accentColor) |
| 152 | | .frame(width: 96, height: 96) |
| 153 | | .background(Color.accentColor.opacity(0.12), in: Circle()) |
| 154 | | .accessibilityHidden(true) |
| 155 | | Text(title).font(.title.bold()).multilineTextAlignment(.center) |
| 156 | | Text(text).font(.body).foregroundStyle(.secondary).multilineTextAlignment(.center) |
| 157 | | content() |
| 158 | | Spacer(minLength: 24) |
| 166 | // The text scrolls at large text sizes; the actions stay below it. |
| 167 | let content = content() |
| 168 | return VStack(spacing: 20) { |
| 169 | GeometryReader { geometry in |
| 170 | ScrollView { |
| 171 | VStack(spacing: 20) { |
| 172 | Image(systemName: symbol) |
| 173 | .font(.system(size: 44, weight: .semibold)) |
| 174 | .foregroundStyle(Color.accentColor) |
| 175 | .frame(width: 96, height: 96) |
| 176 | .background(Color.accentColor.opacity(0.12), in: Circle()) |
| 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 | 187 | VStack(spacing: 12) { actions() } |
| 160 | 188 | } |
| 161 | 189 | } |