Mercurial > public > geoquiz
comparison GeoQuiz/ProfileModalView.swift @ 14:136928bae534
add user profile
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Wed, 19 Oct 2022 07:56:33 +0200 |
parents | e09959b4e4a8 |
children | f1967f8cc67b |
comparison
equal
deleted
inserted
replaced
13:bdfff35dd43c | 14:136928bae534 |
---|---|
4 // | 4 // |
5 // Created by Dennis Concepción Martín on 25/9/22. | 5 // Created by Dennis Concepción Martín on 25/9/22. |
6 // | 6 // |
7 | 7 |
8 import SwiftUI | 8 import SwiftUI |
9 import PhotosUI | |
9 | 10 |
10 struct ProfileModalView: View { | 11 struct ProfileModalView: View { |
12 @ObservedObject var user: User | |
13 @ObservedObject var storeKitRC: StoreKitRC | |
14 | |
15 @Environment(\.dismiss) var dismiss | |
16 | |
17 @State private var showingEditModalView = false | |
18 | |
11 var body: some View { | 19 var body: some View { |
12 Text("Hello, World!") | 20 NavigationView { |
21 Form { | |
22 Section { | |
23 HStack(spacing: 20) { | |
24 UserImage(uiImage: user.data.uiImage) | |
25 | |
26 VStack(alignment: .leading, spacing: 8) { | |
27 Text(user.data.username) | |
28 .font(.title) | |
29 .fontWeight(.semibold) | |
30 | |
31 if storeKitRC.isActive { | |
32 Text("Premium user ⭐️") | |
33 .foregroundColor(.secondary) | |
34 } | |
35 } | |
36 } | |
37 } | |
38 | |
39 Section { | |
40 VStack(alignment: .leading) { | |
41 Text("Game 1") | |
42 Capsule() | |
43 .frame(height: 6) | |
44 } | |
45 | |
46 VStack(alignment: .leading) { | |
47 Text("Game 1") | |
48 Capsule() | |
49 .frame(height: 6) | |
50 } | |
51 VStack(alignment: .leading) { | |
52 Text("Game 1") | |
53 Capsule() | |
54 .frame(height: 6) | |
55 } | |
56 VStack(alignment: .leading) { | |
57 Text("Game 1") | |
58 Capsule() | |
59 .frame(height: 6) | |
60 } | |
61 } header: { | |
62 Text("Progress") | |
63 } | |
64 | |
65 Section { | |
66 ForEach(1..<10) { _ in | |
67 Text("Hello") | |
68 } | |
69 } header: { | |
70 Text("Recent games") | |
71 } | |
72 } | |
73 .navigationTitle("Profile") | |
74 .navigationBarTitleDisplayMode(.inline) | |
75 .toolbar { | |
76 ToolbarItem(placement: .cancellationAction) { | |
77 Button { | |
78 dismiss() | |
79 } label: { | |
80 Label("Exit", systemImage: "multiply") | |
81 } | |
82 } | |
83 | |
84 ToolbarItem(placement: .navigationBarTrailing) { | |
85 Button("Edit") { | |
86 showingEditModalView = true | |
87 } | |
88 } | |
89 } | |
90 | |
91 .sheet(isPresented: $showingEditModalView) { | |
92 ProfileEditModalView(user: user) | |
93 } | |
94 } | |
13 } | 95 } |
14 } | 96 } |
15 | 97 |
16 struct ProfileView_Previews: PreviewProvider { | 98 struct ProfileView_Previews: PreviewProvider { |
17 static var previews: some View { | 99 static var previews: some View { |
18 ProfileModalView() | 100 ProfileModalView(user: User(), storeKitRC: StoreKitRC()) |
19 } | 101 } |
20 } | 102 } |