aboutsummaryrefslogtreecommitdiff
path: root/iosApp/iosApp/Session/AccountView.swift
diff options
context:
space:
mode:
Diffstat (limited to 'iosApp/iosApp/Session/AccountView.swift')
-rw-r--r--iosApp/iosApp/Session/AccountView.swift73
1 files changed, 73 insertions, 0 deletions
diff --git a/iosApp/iosApp/Session/AccountView.swift b/iosApp/iosApp/Session/AccountView.swift
new file mode 100644
index 0000000..4ca453a
--- /dev/null
+++ b/iosApp/iosApp/Session/AccountView.swift
@@ -0,0 +1,73 @@
+//
+// AccountView.swift
+// iosApp
+//
+// Created by Iván on 15/02/22.
+// Copyright © 2022 orgName. All rights reserved.
+//
+
+import SwiftUI
+
+struct AccountView: View {
+ @StateObject var accountViewModel = AccountViewModel()
+ @EnvironmentObject var rootViewModel: RootViewModel
+
+ var body: some View {
+ List {
+ Section {
+ // MARK: - Name
+ if let name = accountViewModel.user?.name {
+ HStack {
+ Text("username")
+ Spacer()
+ Text(name).foregroundColor(.secondaryLabel)
+ }
+ }
+ // MARK: - E-mail
+ if let email = accountViewModel.user?.email {
+ HStack {
+ Text("email")
+ Spacer()
+ Text(email).foregroundColor(.secondaryLabel)
+ }
+ }
+ // MARK: - Unique ID
+ if let uid = accountViewModel.user?.id {
+ HStack {
+ Text("unique-id")
+ Spacer()
+ Text("\(uid)").foregroundColor(.secondaryLabel)
+ }
+ }
+ // MARK: - Administrator
+ if let admin = accountViewModel.user?.administrator {
+ HStack {
+ Text("admin")
+ Spacer()
+ Text("\(admin)").foregroundColor(.secondaryLabel)
+ }
+ }
+ // MARK: - Server URL
+ if let server = UserDefaults.standard.string(forKey: "server-url") {
+ HStack {
+ Text("server-url")
+ Spacer()
+ Text(server).foregroundColor(.secondaryLabel)
+ }
+ }
+ }
+
+ Section {
+ // MARK: - Sign out
+ Button {
+ rootViewModel.signOut()
+ } label: {
+ Label("signout", systemImage: "rectangle.portrait.and.arrow.right")
+ .foregroundColor(.systemRed)
+ }
+ }
+ }.onAppear {
+ accountViewModel.fetchUserInfo()
+ }
+ }
+}