import SwiftUI import AnalyticsKit import AnalyticsUI /// Settings on the iPhone (a tab) and the iPad (a sidebar row): the house iCloud Sync and Diagnostics /// sections, copied from Inkspring's iPhone settings, in Tide cards. struct PhoneSettingsView: View { @Environment(PhoneModel.self) private var model var body: some View { NavigationStack { ScrollView { SyncSettingsContent(showsHeading: false).padding(16) } .refreshable { await model.load() } .background(Tide.ground) .navigationTitle("Settings") } } } struct SyncSettingsContent: View { @Environment(PhoneModel.self) private var model var showsHeading = true var body: some View { VStack(alignment: .leading, spacing: 16) { if showsHeading { ScreenHeading("Settings", subtitle: "How this device gets your numbers from your Mac.") } TideCard("iCloud Sync", subtitle: "Your Mac puts a copy of the numbers in your private iCloud. This device reads it.", icon: "icloud") { CloudSyncSection(status: model.cloud, busy: model.loading, missingMessage: "iCloud has no numbers from your Mac yet. Open Graphley on your Mac and check Settings → iPhone and iPad.") { Task { await model.load() } } } TideCard("Diagnostics", icon: "stethoscope") { CloudDiagnosticsSection(status: model.cloud) } TideCard("About", icon: "info.circle") { Text("Graphley \(Self.version)").font(Tide.rowTitle).foregroundStyle(Tide.ink) .accessibilityIdentifier("settingsAppVersion") Text("Free and open source, public domain (Unlicense). Graphley has no server: your numbers stay in your private iCloud.") .font(Tide.secondary).foregroundStyle(Tide.ink2).fixedSize(horizontal: false, vertical: true) HStack(spacing: 16) { Link("graphley.ai", destination: URL(string: "https://graphley.ai")!) } .font(Tide.secondary).tint(Tide.accent) } } .task { if model.cloud.lastCheck == nil { await model.load() } } } static var version: String { let info = Bundle.main.infoDictionary ?? [:] return "\(info["CFBundleShortVersionString"] as? String ?? "?") (\(info["CFBundleVersion"] as? String ?? "?"))" } }