Graphley / app · graphley.ai / Apps / iPhone / SyncSettings.swift
| 1 | import SwiftUI |
| 2 | import AnalyticsKit |
| 3 | import AnalyticsUI |
| 4 | |
| 5 | /// Settings on the iPhone (a tab) and the iPad (a sidebar row): the house iCloud Sync and Diagnostics |
| 6 | /// sections, copied from Inkspring's iPhone settings, in Tide cards. |
| 7 | struct PhoneSettingsView: View { |
| 8 | @Environment(PhoneModel.self) private var model |
| 9 | var body: some View { |
| 10 | NavigationStack { |
| 11 | ScrollView { SyncSettingsContent(showsHeading: false).padding(16) } |
| 12 | .refreshable { await model.load() } |
| 13 | .background(Tide.ground) |
| 14 | .navigationTitle("Settings") |
| 15 | } |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | struct SyncSettingsContent: View { |
| 20 | @Environment(PhoneModel.self) private var model |
| 21 | var showsHeading = true |
| 22 | |
| 23 | var body: some View { |
| 24 | VStack(alignment: .leading, spacing: 16) { |
| 25 | if showsHeading { ScreenHeading("Settings", subtitle: "How this device gets your numbers from your Mac.") } |
| 26 | TideCard("iCloud Sync", subtitle: "Your Mac puts a copy of the numbers in your private iCloud. This device reads it.", icon: "icloud") { |
| 27 | CloudSyncSection(status: model.cloud, busy: model.loading, |
| 28 | missingMessage: "iCloud has no numbers from your Mac yet. Open Graphley on your Mac and check Settings → iPhone and iPad.") { |
| 29 | Task { await model.load() } |
| 30 | } |
| 31 | } |
| 32 | TideCard("Diagnostics", icon: "stethoscope") { |
| 33 | CloudDiagnosticsSection(status: model.cloud) |
| 34 | } |
| 35 | TideCard("About", icon: "info.circle") { |
| 36 | Text("Graphley \(Self.version)").font(Tide.rowTitle).foregroundStyle(Tide.ink) |
| 37 | .accessibilityIdentifier("settingsAppVersion") |
| 38 | Text("Free and open source, public domain (Unlicense). Graphley has no server: your numbers stay in your private iCloud.") |
| 39 | .font(Tide.secondary).foregroundStyle(Tide.ink2).fixedSize(horizontal: false, vertical: true) |
| 40 | HStack(spacing: 16) { |
| 41 | Link("graphley.ai", destination: URL(string: "https://graphley.ai")!) |
| 42 | } |
| 43 | .font(Tide.secondary).tint(Tide.accent) |
| 44 | } |
| 45 | } |
| 46 | .task { if model.cloud.lastCheck == nil { await model.load() } } |
| 47 | } |
| 48 | |
| 49 | static var version: String { |
| 50 | let info = Bundle.main.infoDictionary ?? [:] |
| 51 | return "\(info["CFBundleShortVersionString"] as? String ?? "?") (\(info["CFBundleVersion"] as? String ?? "?"))" |
| 52 | } |
| 53 | } |