import SwiftUI struct SettingsView: View { @Environment(SyncEngine.self) private var syncEngine @Environment(ContextService.self) private var contextService var body: some View { NavigationStack { Form { Section("iCloud") { HStack { Text("Status") Spacer() switch syncEngine.iCloudStatus { case .checking: Text("Checking…").foregroundStyle(.secondary) case .available: Label("Connected", systemImage: "checkmark.icloud") .foregroundStyle(.green) case .unavailable: Label("Unavailable", systemImage: "xmark.icloud") .foregroundStyle(.red) } } if let error = syncEngine.lastSyncError { Text(error) .font(.footnote) .foregroundStyle(.red) } Button("Rebuild Local Cache") { Task { await syncEngine.rebuildCache() } } .disabled(syncEngine.iCloudStatus != .available || syncEngine.isSyncing) } Section("Context") { ContextSummaryRow( context: contextService.current, isRefreshing: contextService.isRefreshing ) if contextService.authorizationDenied { Text("Location access is off. Notes can still be taken, but they won't resurface by place. Enable location for Notes in Settings.") .font(.footnote) .foregroundStyle(.secondary) } Button("Refresh Context") { Task { await contextService.refresh() } } .disabled(contextService.isRefreshing) } } .formStyle(.grouped) .navigationTitle("Settings") } } }