-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettingsView.swift
98 lines (88 loc) · 3.59 KB
/
SettingsView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//
// AccountView.swift
// GVCourses
//
// Created by Minh Tran on 24/10/2023.
//
import Foundation
import SwiftUI
import FirebaseAuth
struct SettingsView: View {
@EnvironmentObject var errorHandling: ErrorHandling
@EnvironmentObject var store: UserStore
var body: some View {
NavigationView {
VStack {
HStack {
Text("**Email:** \((store.user?.email)!)")
.multilineTextAlignment(.leading)
.font(.body)
.foregroundColor(Color.primary.opacity(0.9))
.padding(.bottom, 10)
Spacer()
}.padding(.horizontal, 20)
.frame(maxWidth: .infinity)
HStack {
Text("**App Version:** 1.0.0")
.multilineTextAlignment(.leading)
.font(.body)
.foregroundColor(Color.primary.opacity(0.9))
.padding(.bottom, 10)
Spacer()
}.padding(.horizontal, 20)
.frame(maxWidth: .infinity)
HStack {
Text("**Main provider:** \((store.user?.providerID)!)")
.multilineTextAlignment(.leading)
.font(.body)
.foregroundColor(Color.primary.opacity(0.9))
.padding(.bottom, 10)
Spacer()
}.padding(.horizontal, 20)
.frame(maxWidth: .infinity)
HStack {
Text("**Authentication provider:** \((store.user?.providerDataID)!)")
.multilineTextAlignment(.leading)
.font(.body)
.foregroundColor(Color.primary.opacity(0.9))
.padding(.bottom, 10)
Spacer()
}.padding(.horizontal, 20)
.frame(maxWidth: .infinity)
CustomButton(text: "Logout") {
// Perform logout action here
AuthManager.shared.signOut() { error in
errorHandling.handle(error: error)
}
}.padding(.bottom, 10)
HStack {
Button("Delete My Account", action: {
// Perform account deletion action here
self.store.deleteAndLogoutCurrentUser { error in
if let error = error {
// Handle the error, e.g., display an error message
print("Error deleting and logging out user: \(error.localizedDescription)")
errorHandling.handle(error: error)
} else {
// The user has been successfully deleted and logged out
print("User deleted and logged out.")
}
}
})
.foregroundColor(.red)
Spacer()
}.padding(.horizontal, 20)
.frame(maxWidth: .infinity)
Spacer()
}
.toolbar(.hidden, for: .tabBar)
.gvcoursesNavigationBar(
title: "Settings"
)
.frame(maxWidth: .infinity)
.padding(.top, 15)
}.refreshable {
store.refreshView()
}
}
}