summaryrefslogtreecommitdiff
path: root/Hutch/Views/More
diff options
context:
space:
mode:
Diffstat (limited to 'Hutch/Views/More')
-rw-r--r--Hutch/Views/More/AccountSwitcherView.swift49
-rw-r--r--Hutch/Views/More/ProfileView.swift2
2 files changed, 43 insertions, 8 deletions
diff --git a/Hutch/Views/More/AccountSwitcherView.swift b/Hutch/Views/More/AccountSwitcherView.swift
index aefcc82..5fde9c5 100644
--- a/Hutch/Views/More/AccountSwitcherView.swift
+++ b/Hutch/Views/More/AccountSwitcherView.swift
@@ -7,21 +7,35 @@ struct AccountSwitcherView: View {
@State private var showAddAccount = false
@State private var isSwitching = false
@State private var switchError: String?
+ @State private var pendingRemoval: AccountEntry?
var body: some View {
NavigationStack {
List {
Section {
ForEach(appState.accounts) { account in
+ let isActive = account.id == appState.activeAccountID
Button {
- guard account.id != appState.activeAccountID else { return }
+ guard !isActive else { return }
switchTo(account)
} label: {
- HStack {
- Text("~\(account.username)")
- .foregroundStyle(.primary)
+ HStack(spacing: 12) {
+ if isActive {
+ Image(systemName: "person.crop.circle.fill")
+ .foregroundStyle(.tint)
+ } else {
+ Image(systemName: "person.crop.circle")
+ .foregroundStyle(.secondary)
+ }
+ VStack(alignment: .leading, spacing: 2) {
+ Text("~\(account.username)")
+ .foregroundStyle(.primary)
+ Text(isActive ? "Active Account" : "Tap to switch")
+ .font(.caption)
+ .foregroundStyle(.secondary)
+ }
Spacer()
- if account.id == appState.activeAccountID {
+ if isActive {
Image(systemName: "checkmark")
.foregroundStyle(.tint)
}
@@ -31,8 +45,7 @@ struct AccountSwitcherView: View {
}
.onDelete { indexSet in
for index in indexSet {
- let account = appState.accounts[index]
- Task { await appState.removeAccount(id: account.id) }
+ pendingRemoval = appState.accounts[index]
}
}
}
@@ -71,6 +84,28 @@ struct AccountSwitcherView: View {
} message: {
Text(switchError ?? "")
}
+ .alert(
+ "Remove Account?",
+ isPresented: Binding(
+ get: { pendingRemoval != nil },
+ set: { isPresented in
+ if !isPresented {
+ pendingRemoval = nil
+ }
+ }
+ )
+ ) {
+ Button("Cancel", role: .cancel) {}
+ Button("Remove", role: .destructive) {
+ guard let pendingRemoval else { return }
+ Task { await appState.removeAccount(id: pendingRemoval.id) }
+ self.pendingRemoval = nil
+ }
+ } message: {
+ if let pendingRemoval {
+ Text("~\(pendingRemoval.username) and its isolated local cache will be removed from this device.")
+ }
+ }
.sheet(isPresented: $showAddAccount) {
AddAccountView()
}
diff --git a/Hutch/Views/More/ProfileView.swift b/Hutch/Views/More/ProfileView.swift
index 673b298..db3cb53 100644
--- a/Hutch/Views/More/ProfileView.swift
+++ b/Hutch/Views/More/ProfileView.swift
@@ -7,7 +7,7 @@ private let profileBioMarkdownOptions = AttributedString.MarkdownParsingOptions(
struct ProfileView: View {
@Environment(AppState.self) private var appState
- @AppStorage(AppStorageKeys.contributionGraphsEnabled) private var contributionGraphsEnabled = true
+ @AppStorage(AppStorageKeys.contributionGraphsEnabled, store: .standard) private var contributionGraphsEnabled = true
@State private var viewModel: SettingsViewModel?
@State private var contributionViewModel: UserProfileViewModel?
@State private var pendingDestructiveAction: ProfileDestructiveAction?