From cf587aa0573ac4f34e1effe70108a9eca82093ac Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Tue, 24 Mar 2026 21:48:23 -0500 Subject: v1.0 --- Rune/Views/Settings/SettingsView.swift | 73 ++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 Rune/Views/Settings/SettingsView.swift (limited to 'Rune/Views/Settings/SettingsView.swift') diff --git a/Rune/Views/Settings/SettingsView.swift b/Rune/Views/Settings/SettingsView.swift new file mode 100644 index 0000000..4d07887 --- /dev/null +++ b/Rune/Views/Settings/SettingsView.swift @@ -0,0 +1,73 @@ +import SwiftUI + +struct SettingsView: View { + @ObservedObject var viewModel: SettingsViewModel + let onLogout: () -> Void + @State private var showingLogoutConfirmation = false + + var body: some View { + NavigationStack { + List { + Section("Wallet") { + if let balance = viewModel.balance { + HStack { + Text("Balance") + Spacer() + Text("€\(balance.balance)") + .foregroundStyle(.secondary) + } + } else if viewModel.isLoadingBalance { + ProgressView() + } else { + Text("Wallet balance unavailable.") + .foregroundStyle(.secondary) + } + + Button("Refresh Balance") { + Task { + do { + try await viewModel.refreshBalance() + } catch { + viewModel.errorMessage = error.localizedDescription + } + } + } + .disabled(viewModel.client == nil || viewModel.isLoadingBalance) + } + + Section("Account") { + Button("Logout", role: .destructive) { + showingLogoutConfirmation = true + } + .foregroundStyle(.red) + } + + if let errorMessage = viewModel.errorMessage { + Section { + Text(errorMessage) + .foregroundStyle(.red) + } + } + } + .navigationTitle("Settings") + } + .confirmationDialog( + "Log out of Rune?", + isPresented: $showingLogoutConfirmation, + titleVisibility: .visible + ) { + Button("Log Out", role: .destructive) { + do { + try viewModel.logout() + onLogout() + } catch { + viewModel.errorMessage = error.localizedDescription + } + } + + Button("Cancel", role: .cancel) {} + } message: { + Text("Your API token will be removed from this device.") + } + } +} -- cgit v1.2.3