Mercurial > public > geoquiz
comparison GeoQuiz/SettingsModalView.swift @ 26:425078c01194
refactor code
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Wed, 09 Nov 2022 10:30:01 +0100 |
parents | e281791e0494 |
children | 3f4b366d476d |
comparison
equal
deleted
inserted
replaced
25:b3df0f5dc750 | 26:425078c01194 |
---|---|
6 // | 6 // |
7 | 7 |
8 import SwiftUI | 8 import SwiftUI |
9 | 9 |
10 struct SettingsModalView: View { | 10 struct SettingsModalView: View { |
11 @ObservedObject var user: UserController | 11 @ObservedObject var userController: UserController |
12 | 12 |
13 @Environment(\.dismiss) var dismiss | 13 @Environment(\.dismiss) var dismiss |
14 | 14 |
15 var lives: [Int] { | 15 var lives: [Int] { |
16 var lives = [Int]() | 16 var lives = [Int]() |
23 | 23 |
24 var body: some View { | 24 var body: some View { |
25 NavigationStack { | 25 NavigationStack { |
26 Form { | 26 Form { |
27 Section { | 27 Section { |
28 Picker("❤️ Lives", selection: $user.data.numberOfLives) { | 28 Picker("❤️ Lives", selection: $userController.data.numberOfLives) { |
29 ForEach(lives, id: \.self) { numberOfLives in | 29 ForEach(lives, id: \.self) { numberOfLives in |
30 Text("\(numberOfLives)") | 30 Text("\(numberOfLives)") |
31 .tag(numberOfLives) | 31 .tag(numberOfLives) |
32 } | 32 } |
33 } | 33 } |
36 } footer: { | 36 } footer: { |
37 Text("Number of lives at the beginning of each game.") | 37 Text("Number of lives at the beginning of each game.") |
38 } | 38 } |
39 | 39 |
40 Section { | 40 Section { |
41 Toggle("Haptics", isOn: $user.data.haptics) | 41 Toggle("Haptics", isOn: $userController.data.haptics) |
42 Toggle("Sound effects", isOn: $user.data.sound) | 42 Toggle("Sound effects", isOn: $userController.data.sound) |
43 } header: { | 43 } header: { |
44 Text("Effects") | 44 Text("Effects") |
45 } | 45 } |
46 | 46 |
47 Section { | 47 Section { |
84 } | 84 } |
85 } | 85 } |
86 | 86 |
87 struct SettingsModalView_Previews: PreviewProvider { | 87 struct SettingsModalView_Previews: PreviewProvider { |
88 static var previews: some View { | 88 static var previews: some View { |
89 SettingsModalView(user: UserController()) | 89 SettingsModalView(userController: UserController()) |
90 } | 90 } |
91 } | 91 } |