Mercurial > public > geoquiz
diff GeoQuiz/SettingsModalView.swift @ 10:a793f33f05fb
refactor code and fix layout
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Sat, 08 Oct 2022 21:36:40 +0200 |
parents | 3540c7efc216 |
children | 136928bae534 |
line wrap: on
line diff
--- a/GeoQuiz/SettingsModalView.swift Fri Oct 07 18:50:38 2022 +0200 +++ b/GeoQuiz/SettingsModalView.swift Sat Oct 08 21:36:40 2022 +0200 @@ -10,19 +10,30 @@ struct SettingsModalView: View { @Environment(\.dismiss) var dismiss @StateObject var user = User() + + var lives: [Int] { + var lives = [Int]() + for i in stride(from: 5, to: 55, by: 5) { + lives.append(i) + } + + return lives + } var body: some View { NavigationView { Form { Section { - Picker("Number of lives", selection: $user.settings.numberOfLives) { - ForEach(1..<11) { numberOfLives in + Picker("❤️ Lives", selection: $user.settings.numberOfLives) { + ForEach(lives, id: \.self) { numberOfLives in Text("\(numberOfLives)") .tag(numberOfLives) } } } header: { Text("Game") + } footer: { + Text("Number of lives at the beginning of each game.") } Section {