@@ -3,16 +3,51 @@ import InlineKit
3
3
import SwiftUI
4
4
5
5
struct SettingsView : View {
6
- @Query ( CurrentUser ( ) ) var currentUser : User ?
6
+ @Query ( CurrentUser ( ) ) var currentUser : UserInfo ?
7
7
@Environment ( \. auth) var auth
8
8
@EnvironmentObject private var webSocket : WebSocketManager
9
9
@EnvironmentObject private var navigation : Navigation
10
10
@EnvironmentObject private var onboardingNavigation : OnboardingNavigation
11
11
@EnvironmentObject private var mainRouter : MainViewRouter
12
+ @EnvironmentObject private var fileUploadViewModel : FileUploadViewModel
12
13
13
14
var body : some View {
14
15
List {
15
16
UserProfileSection ( currentUser: currentUser)
17
+ Section {
18
+ Button {
19
+ fileUploadViewModel. showImagePicker = true
20
+ } label: {
21
+ HStack {
22
+ Image ( systemName: " camera.fill " )
23
+ . font ( . callout)
24
+ . foregroundColor ( . white)
25
+ . frame ( width: 25 , height: 25 )
26
+ . background ( Color . pink)
27
+ . clipShape ( RoundedRectangle ( cornerRadius: 6 ) )
28
+ Text ( " Change Profile Photo " )
29
+ . foregroundColor ( . primary)
30
+ . padding ( . leading, 4 )
31
+ Spacer ( )
32
+ }
33
+ . padding ( . vertical, 2 )
34
+ }
35
+ }
36
+
37
+ NavigationLink ( destination: IntegrationsView ( ) ) {
38
+ HStack {
39
+ Image ( systemName: " app.connected.to.app.below.fill " )
40
+ . foregroundColor ( . white)
41
+ . frame ( width: 25 , height: 25 )
42
+ . background ( Color . purple)
43
+ . clipShape ( RoundedRectangle ( cornerRadius: 6 ) )
44
+ Text ( " Integrations " )
45
+ . foregroundColor ( . primary)
46
+ . padding ( . leading, 4 )
47
+ Spacer ( )
48
+ }
49
+ . padding ( . vertical, 2 )
50
+ }
16
51
NavigationLink ( destination: ThemeSection ( ) ) {
17
52
HStack {
18
53
Image ( systemName: " paintbrush.fill " )
@@ -27,6 +62,7 @@ struct SettingsView: View {
27
62
}
28
63
. padding ( . vertical, 2 )
29
64
}
65
+
30
66
LogoutSection ( )
31
67
}
32
68
. navigationBarTitleDisplayMode ( . inline)
@@ -46,6 +82,17 @@ struct SettingsView: View {
46
82
}
47
83
}
48
84
}
85
+ . sheet ( isPresented: $fileUploadViewModel. showImagePicker) {
86
+ ImagePicker ( sourceType: . photoLibrary) { image in
87
+ Task {
88
+ if let pngData = image. pngData ( ) {
89
+ await fileUploadViewModel. uploadImage ( pngData, fileType: . png)
90
+ } else if let jpegData = image. jpegData ( compressionQuality: 0.8 ) {
91
+ await fileUploadViewModel. uploadImage ( jpegData, fileType: . jpeg)
92
+ }
93
+ }
94
+ }
95
+ }
49
96
}
50
97
}
51
98
0 commit comments