Mercurial > public > geoquiz
annotate GeoQuiz/SettingsModalView.swift @ 30:eb23effeede7
add DatasetView
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Thu, 10 Nov 2022 11:51:52 +0100 |
parents | 3f4b366d476d |
children | 9d6dd0e59c22 |
rev | line source |
---|---|
5 | 1 // |
2 // SettingsModalView.swift | |
3 // GeoQuiz | |
4 // | |
5 // Created by Dennis Concepción Martín on 22/9/22. | |
6 // | |
7 | |
8 import SwiftUI | |
9 | |
10 struct SettingsModalView: View { | |
26 | 11 @ObservedObject var userController: UserController |
19 | 12 |
5 | 13 @Environment(\.dismiss) var dismiss |
10
a793f33f05fb
refactor code and fix layout
Dennis C. M. <dennis@denniscm.com>
parents:
9
diff
changeset
|
14 |
a793f33f05fb
refactor code and fix layout
Dennis C. M. <dennis@denniscm.com>
parents:
9
diff
changeset
|
15 var lives: [Int] { |
a793f33f05fb
refactor code and fix layout
Dennis C. M. <dennis@denniscm.com>
parents:
9
diff
changeset
|
16 var lives = [Int]() |
a793f33f05fb
refactor code and fix layout
Dennis C. M. <dennis@denniscm.com>
parents:
9
diff
changeset
|
17 for i in stride(from: 5, to: 55, by: 5) { |
a793f33f05fb
refactor code and fix layout
Dennis C. M. <dennis@denniscm.com>
parents:
9
diff
changeset
|
18 lives.append(i) |
a793f33f05fb
refactor code and fix layout
Dennis C. M. <dennis@denniscm.com>
parents:
9
diff
changeset
|
19 } |
a793f33f05fb
refactor code and fix layout
Dennis C. M. <dennis@denniscm.com>
parents:
9
diff
changeset
|
20 |
a793f33f05fb
refactor code and fix layout
Dennis C. M. <dennis@denniscm.com>
parents:
9
diff
changeset
|
21 return lives |
a793f33f05fb
refactor code and fix layout
Dennis C. M. <dennis@denniscm.com>
parents:
9
diff
changeset
|
22 } |
5 | 23 |
24 var body: some View { | |
19 | 25 NavigationStack { |
5 | 26 Form { |
7 | 27 Section { |
26 | 28 Picker("❤️ Lives", selection: $userController.data.numberOfLives) { |
10
a793f33f05fb
refactor code and fix layout
Dennis C. M. <dennis@denniscm.com>
parents:
9
diff
changeset
|
29 ForEach(lives, id: \.self) { numberOfLives in |
9 | 30 Text("\(numberOfLives)") |
31 .tag(numberOfLives) | |
32 } | |
33 } | |
7 | 34 } header: { |
27 | 35 Text("General") |
10
a793f33f05fb
refactor code and fix layout
Dennis C. M. <dennis@denniscm.com>
parents:
9
diff
changeset
|
36 } footer: { |
a793f33f05fb
refactor code and fix layout
Dennis C. M. <dennis@denniscm.com>
parents:
9
diff
changeset
|
37 Text("Number of lives at the beginning of each game.") |
7 | 38 } |
39 | |
40 Section { | |
30 | 41 Toggle("Haptics", isOn: $userController.data.haptics) |
42 Toggle("Sound effects", isOn: $userController.data.sound) | |
43 } | |
44 | |
45 Section { | |
27 | 46 Picker("Flag shape", selection: $userController.data.guessTheFlagShape) { |
47 ForEach(GuessTheFlagShape.allCases, id: \.self) { shape in | |
48 Text(shape.localizedName) | |
49 .tag(shape) | |
50 } | |
51 } | |
52 } header: { | |
53 Text("Guess the flag game") | |
54 } | |
55 | |
56 Section { | |
30 | 57 Link(destination: URL(string: "https://dennistech.io")!) { |
58 SettingsRow( | |
59 color: .mayaBlue, | |
60 symbol: "person.fill", | |
61 text: "About" | |
62 ) | |
63 } | |
64 | |
65 NavigationLink(destination: DatasetView()) { | |
66 SettingsRow( | |
67 color: .atomicTangerine, | |
68 symbol: "square.stack.3d.up.fill", | |
69 text: "Dataset" | |
70 ) | |
71 } | |
9 | 72 |
30 | 73 Link(destination: URL(string: "mailto:dmartin@dennistech.io")!) { |
74 SettingsRow( | |
75 color: .chinaPink, | |
76 symbol: "ant.fill", | |
77 text: "Report bugs" | |
78 ) | |
79 } | |
9 | 80 |
30 | 81 Link(destination: URL(string: "https://twitter.com/dennistech_")!) { |
82 SettingsRow( | |
83 color: .blueBell, | |
84 symbol: "message.fill", | |
85 text: "Twitter" | |
86 ) | |
87 } | |
27 | 88 } footer: { |
89 HStack { | |
90 Spacer() | |
91 VStack { | |
92 Text("© 2022 Dennis Technologies Ltd.") | |
93 Text("Proud to be indie.") | |
94 | |
95 if let versionNumber = getVersion() { | |
96 Text("Version \(versionNumber)") | |
97 } | |
98 } | |
99 Spacer() | |
100 } | |
101 .padding(.top) | |
7 | 102 } |
5 | 103 } |
104 .navigationTitle("Settings") | |
19 | 105 .navigationBarTitleDisplayMode(.inline) |
5 | 106 .toolbar { |
107 ToolbarItem(placement: .cancellationAction) { | |
108 Button { | |
109 dismiss() | |
110 } label: { | |
111 Label("Exit", systemImage: "multiply") | |
112 } | |
113 } | |
114 } | |
115 } | |
116 } | |
117 } | |
118 | |
119 struct SettingsModalView_Previews: PreviewProvider { | |
120 static var previews: some View { | |
26 | 121 SettingsModalView(userController: UserController()) |
5 | 122 } |
123 } |