summaryrefslogtreecommitdiff
path: root/Rune/Views/Settings
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-03-24 21:48:23 -0500
committerChristian Cleberg <[email protected]>2026-03-24 21:48:23 -0500
commitcf587aa0573ac4f34e1effe70108a9eca82093ac (patch)
tree833e6f4961522e35b08af01b5f012983f8e34678 /Rune/Views/Settings
downloadrune-cf587aa0573ac4f34e1effe70108a9eca82093ac.tar.gz
rune-cf587aa0573ac4f34e1effe70108a9eca82093ac.tar.bz2
rune-cf587aa0573ac4f34e1effe70108a9eca82093ac.zip
v1.0v1.0.0
Diffstat (limited to 'Rune/Views/Settings')
-rw-r--r--Rune/Views/Settings/SettingsView.swift73
1 files changed, 73 insertions, 0 deletions
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.")
+ }
+ }
+}