Bucksley / app · bucksley.ai / Apps / iPhone / PhoneSettings.swift
| 1 | import SwiftUI |
| 2 | import BucksleyKit |
| 3 | import BucksleyUI |
| 4 | |
| 5 | struct PhoneSettingsScreen: View { |
| 6 | @Environment(PhoneModel.self) private var model |
| 7 | @Environment(\.palette) private var palette |
| 8 | @Environment(\.colorScheme) private var colorScheme |
| 9 | @Environment(\.openURL) private var openURL |
| 10 | @AppStorage(BucksleyTheme.preferenceKey) private var themeRaw = BucksleyTheme.defaultPreference.rawValue |
| 11 | @AppStorage(BucksleyAppearance.preferenceKey) private var appearanceRaw = BucksleyAppearance.system.rawValue |
| 12 | @State private var showShare = false |
| 13 | |
| 14 | var body: some View { |
| 15 | let theme = BucksleyTheme(preference: themeRaw) |
| 16 | Form { |
| 17 | Section { |
| 18 | Text("Settings").font(palette.title(32)).tracking(palette.titleTracking) |
| 19 | .listRowBackground(Color.clear).listRowInsets(EdgeInsets(top: 4, leading: 0, bottom: 4, trailing: 0)) |
| 20 | } |
| 21 | Section("Theme") { |
| 22 | ForEach(BucksleyTheme.allCases) { option in |
| 23 | Button { themeRaw = option.rawValue } label: { |
| 24 | HStack(spacing: 12) { |
| 25 | ThemeSwatch(theme: option, dark: colorScheme == .dark).frame(width: 64, height: 40) |
| 26 | VStack(alignment: .leading, spacing: 2) { |
| 27 | Text(option.title).font(.system(size: 16, weight: .semibold)).foregroundStyle(palette.text) |
| 28 | Text(option.summary).font(.system(size: 12)).foregroundStyle(palette.muted) |
| 29 | } |
| 30 | Spacer() |
| 31 | if option == theme { Image(systemName: "checkmark").font(.system(size: 14, weight: .bold)).foregroundStyle(palette.accent) } |
| 32 | } |
| 33 | } |
| 34 | .accessibilityIdentifier("settings.theme.\(option.rawValue)") |
| 35 | } |
| 36 | Picker("Appearance", selection: $appearanceRaw) { |
| 37 | ForEach(BucksleyAppearance.allCases) { Text($0.title).tag($0.rawValue) } |
| 38 | } |
| 39 | Text("The home screen icon changes with the theme.").font(.system(size: 12)).foregroundStyle(palette.muted) |
| 40 | } |
| 41 | .listRowBackground(palette.card) |
| 42 | |
| 43 | Section("Your Mac") { |
| 44 | LabeledContent("iCloud", value: model.status).font(.system(size: 14)) |
| 45 | Button("Sync now") { Task { await model.refresh() } }.disabled(model.refreshing) |
| 46 | Text("Bank connections live on your Mac. This \(UIDevice.current.userInterfaceIdiom == .pad ? "iPad" : "iPhone") reads what the Mac shares through your private iCloud and sends your reviews, categories and notes back.") |
| 47 | .font(.system(size: 12)).foregroundStyle(palette.muted) |
| 48 | } |
| 49 | .listRowBackground(palette.card) |
| 50 | |
| 51 | Section("Apple Wallet") { |
| 52 | Button { Task { await model.importWallet() } } label: { Label("Add Apple Card, Cash and Savings", systemImage: "wallet.pass") } |
| 53 | Text("Reads your Apple Wallet accounts with your permission and shares them with Bucksley on your Mac.") |
| 54 | .font(.system(size: 12)).foregroundStyle(palette.muted) |
| 55 | } |
| 56 | .listRowBackground(palette.card) |
| 57 | |
| 58 | Section("Support") { |
| 59 | Button { SupportPrompt.record(.support); openURL(SupportPrompt.Links.support) } label: { |
| 60 | row("Technical Support", "Free help from a real person", "person.crop.circle.badge.questionmark") |
| 61 | } |
| 62 | .accessibilityIdentifier("settings.technicalSupport") |
| 63 | } |
| 64 | .listRowBackground(palette.card) |
| 65 | |
| 66 | Section { |
| 67 | Button { SupportPrompt.record(.feedback); openURL(SupportPrompt.Links.feedback) } label: { row("Share Your Experience", "Rate Bucksley or send feedback", "star.fill") } |
| 68 | .accessibilityIdentifier("settings.review") |
| 69 | Button { SupportPrompt.record(.share); showShare = true } label: { row("Share Bucksley", "Tell a friend about it", "square.and.arrow.up") } |
| 70 | .accessibilityIdentifier("settings.share") |
| 71 | Button { SupportPrompt.record(.apps); openURL(SupportPrompt.Links.protomotaApps) } label: { row("More Free Apps from Project ATOM", "projectatom.ai/apps", "square.grid.2x2.fill") } |
| 72 | .accessibilityIdentifier("settings.apps") |
| 73 | } header: { Text("Support Bucksley") } footer: { |
| 74 | Text("Bucksley is free. Every feature, including support, stays free.") |
| 75 | } |
| 76 | .listRowBackground(palette.card) |
| 77 | |
| 78 | Section("About") { |
| 79 | Text("Bucksley").font(.system(size: 14, weight: .semibold)) |
| 80 | Text("Free and open source, public domain (Unlicense). Read-only: Bucksley never moves money.").font(.system(size: 12)).foregroundStyle(palette.muted) |
| 81 | Text("Version \(Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "0") (\(Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String ?? "0"))") |
| 82 | .font(.system(size: 12)).foregroundStyle(palette.muted) |
| 83 | } |
| 84 | .listRowBackground(palette.card) |
| 85 | |
| 86 | Section { |
| 87 | VStack(spacing: 10) { |
| 88 | ProtomotaProductPill() |
| 89 | Text("A Project ATOM project").font(.system(size: 12)).foregroundStyle(palette.muted) |
| 90 | } |
| 91 | .frame(maxWidth: .infinity) |
| 92 | .listRowBackground(Color.clear) |
| 93 | } |
| 94 | } |
| 95 | .scrollContentBackground(.hidden) |
| 96 | .background(palette.canvas.ignoresSafeArea()) |
| 97 | .tint(palette.accent) |
| 98 | .toolbar(.hidden, for: .navigationBar) |
| 99 | .sheet(isPresented: $showShare) { ShareSheet(items: [SupportPrompt.Links.website]) } |
| 100 | } |
| 101 | |
| 102 | func row(_ title: String, _ detail: String, _ symbol: String) -> some View { |
| 103 | HStack(spacing: 12) { |
| 104 | Image(systemName: symbol).font(.system(size: 15, weight: .semibold)).foregroundStyle(palette.accent).frame(width: 26) |
| 105 | VStack(alignment: .leading, spacing: 1) { |
| 106 | Text(title).font(.system(size: 15, weight: .medium)).foregroundStyle(palette.text) |
| 107 | Text(detail).font(.system(size: 12)).foregroundStyle(palette.muted) |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | struct ShareSheet: UIViewControllerRepresentable { |
| 114 | let items: [Any] |
| 115 | func makeUIViewController(context: Context) -> UIActivityViewController { UIActivityViewController(activityItems: items, applicationActivities: nil) } |
| 116 | func updateUIViewController(_ controller: UIActivityViewController, context: Context) {} |
| 117 | } |