From ee9f2904aa319231b7047fca3cb069f0c07019cd Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Sun, 12 Apr 2026 23:19:20 -0500 Subject: feat: add multi-account support Implements: https://todo.sr.ht/~ccleberg/hutch/49 Implements: https://todo.sr.ht/~ccleberg/hutch/50 Implements: https://todo.sr.ht/~ccleberg/hutch/51 --- Hutch/Views/Settings/SettingsView.swift | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'Hutch/Views/Settings') diff --git a/Hutch/Views/Settings/SettingsView.swift b/Hutch/Views/Settings/SettingsView.swift index 5abac90..b6ff8dd 100644 --- a/Hutch/Views/Settings/SettingsView.swift +++ b/Hutch/Views/Settings/SettingsView.swift @@ -2,10 +2,10 @@ import SwiftUI struct SettingsView: View { @Environment(AppState.self) private var appState - @AppStorage(AppStorageKeys.appTheme) private var appTheme: AppTheme = .system - @AppStorage(AppStorageKeys.displayDensity) private var displayDensity: DisplayDensity = .standard - @AppStorage(AppStorageKeys.swipeActionsEnabled) private var swipeActionsEnabled = true - @AppStorage(AppStorageKeys.contributionGraphsEnabled) private var contributionGraphsEnabled = true + @AppStorage(AppStorageKeys.appTheme, store: .standard) private var appTheme: AppTheme = .system + @AppStorage(AppStorageKeys.displayDensity, store: .standard) private var displayDensity: DisplayDensity = .standard + @AppStorage(AppStorageKeys.swipeActionsEnabled, store: .standard) private var swipeActionsEnabled = true + @AppStorage(AppStorageKeys.contributionGraphsEnabled, store: .standard) private var contributionGraphsEnabled = true @State private var pendingDestructiveAction: SettingsDestructiveAction? var body: some View { @@ -89,7 +89,25 @@ struct SettingsView: View { HStack { Image(systemName: "key.fill") .foregroundStyle(.secondary) - Text("Personal access token in use") + VStack(alignment: .leading, spacing: 2) { + Text(appState.currentUser?.canonicalName ?? "No active account") + Text("\(appState.accounts.count) saved account\(appState.accounts.count == 1 ? "" : "s")") + .font(.caption) + .foregroundStyle(.secondary) + } + } + .alignmentGuide(.listRowSeparatorLeading) { _ in 0 } + + NavigationLink { + AccountSwitcherView() + } label: { + Label("Manage Accounts", systemImage: "person.2") + } + + HStack { + Image(systemName: "lock.shield") + .foregroundStyle(.secondary) + Text("Tokens are stored separately per account in the iOS keychain") .font(.subheadline) .foregroundStyle(.secondary) } @@ -105,7 +123,7 @@ struct SettingsView: View { } header: { Text("Authentication") } footer: { - Text("Hutch stores your SourceHut token in the iOS keychain. Reset App Data removes saved token data, local settings, cached responses, cookies, and embedded web data on this device.") + Text("Account switching keeps local caches and saved state isolated per account. Sign Out removes all saved accounts from this device. Reset App Data also clears local settings, cached responses, cookies, and embedded web data.") } } -- cgit v1.2.3