Mercurial > public > geoquiz
comparison GeoQuiz/SettingsModalView.swift @ 19:f140bb277c96
refactor code
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Sun, 23 Oct 2022 00:11:38 +0100 |
parents | 136928bae534 |
children | e281791e0494 |
comparison
equal
deleted
inserted
replaced
18:d20cf93c9812 | 19:f140bb277c96 |
---|---|
6 // | 6 // |
7 | 7 |
8 import SwiftUI | 8 import SwiftUI |
9 | 9 |
10 struct SettingsModalView: View { | 10 struct SettingsModalView: View { |
11 @ObservedObject var user: User | 11 @ObservedObject var user: UserController |
12 | |
12 @Environment(\.dismiss) var dismiss | 13 @Environment(\.dismiss) var dismiss |
13 | 14 |
14 var lives: [Int] { | 15 var lives: [Int] { |
15 var lives = [Int]() | 16 var lives = [Int]() |
16 for i in stride(from: 5, to: 55, by: 5) { | 17 for i in stride(from: 5, to: 55, by: 5) { |
19 | 20 |
20 return lives | 21 return lives |
21 } | 22 } |
22 | 23 |
23 var body: some View { | 24 var body: some View { |
24 NavigationView { | 25 NavigationStack { |
25 Form { | 26 Form { |
26 Section { | 27 Section { |
27 Picker("❤️ Lives", selection: $user.data.numberOfLives) { | 28 Picker("❤️ Lives", selection: $user.data.numberOfLives) { |
28 ForEach(lives, id: \.self) { numberOfLives in | 29 ForEach(lives, id: \.self) { numberOfLives in |
29 Text("\(numberOfLives)") | 30 Text("\(numberOfLives)") |
44 } | 45 } |
45 | 46 |
46 Section { | 47 Section { |
47 LinkComponent( | 48 LinkComponent( |
48 color: .mayaBlue, | 49 color: .mayaBlue, |
49 iconName: "info.circle.fill", | 50 symbol: "info.circle.fill", |
50 text: "About", | 51 text: "About", |
51 url: URL(string: "https://dennistech.io")! | 52 url: URL(string: "https://dennistech.io")! |
52 ) | 53 ) |
53 | 54 |
54 LinkComponent( | 55 LinkComponent( |
55 color: .atomicTangerine, | 56 color: .atomicTangerine, |
56 iconName: "ant.circle.fill", | 57 symbol: "ant.circle.fill", |
57 text: "Report bugs", | 58 text: "Report bugs", |
58 url: URL(string: "mailto:dmartin@dennistech.io")! | 59 url: URL(string: "mailto:dmartin@dennistech.io")! |
59 ) | 60 ) |
60 | 61 |
61 LinkComponent( | 62 LinkComponent( |
62 color: .blueBell, | 63 color: .blueBell, |
63 iconName: "message.circle.fill", | 64 symbol: "message.circle.fill", |
64 text: "Twitter", | 65 text: "Twitter", |
65 url: URL(string: "https://twitter.com/dennistech_")! | 66 url: URL(string: "https://twitter.com/dennistech_")! |
66 ) | 67 ) |
67 } header: { | 68 } header: { |
68 Text("Get in touch") | 69 Text("Get in touch") |
69 } | 70 } |
70 } | 71 } |
71 .navigationTitle("Settings") | 72 .navigationTitle("Settings") |
73 .navigationBarTitleDisplayMode(.inline) | |
72 .toolbar { | 74 .toolbar { |
73 ToolbarItem(placement: .cancellationAction) { | 75 ToolbarItem(placement: .cancellationAction) { |
74 Button { | 76 Button { |
75 dismiss() | 77 dismiss() |
76 } label: { | 78 } label: { |
82 } | 84 } |
83 } | 85 } |
84 | 86 |
85 struct SettingsModalView_Previews: PreviewProvider { | 87 struct SettingsModalView_Previews: PreviewProvider { |
86 static var previews: some View { | 88 static var previews: some View { |
87 SettingsModalView(user: User()) | 89 SettingsModalView(user: UserController()) |
88 } | 90 } |
89 } | 91 } |