Mercurial > public > geoquiz
annotate GeoQuiz/ContentView.swift @ 6:1946bbfde4af
reformat data structures
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Thu, 29 Sep 2022 12:00:17 +0200 |
parents | f31a61462e7a |
children | d945e52b0704 |
rev | line source |
---|---|
0 | 1 // |
2 // ContentView.swift | |
3 // GeoQuiz | |
4 // | |
5 // Created by Dennis Concepción Martín on 5/9/22. | |
6 // | |
7 | |
8 import SwiftUI | |
9 | |
10 struct ContentView: View { | |
11 @State private var gameName: GameName? = nil | |
5 | 12 @State private var showingBuyLivesModalView = false |
13 @State private var showingSettingsModalView = false | |
0 | 14 |
15 var body: some View { | |
16 NavigationView { | |
17 ScrollView(showsIndicators: false) { | |
18 VStack(spacing: 20) { | |
19 | |
1
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
20 NavigationLink( |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
21 destination: GuessTheFlagView(gameName: $gameName), |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
22 tag: GameName.guessTheFlag, |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
23 selection: $gameName |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
24 ) { |
0 | 25 GameButton( |
26 gradient: .main, | |
1
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
27 level: "Level 1", symbol: "flag.fill", name: "Guess the flag" |
0 | 28 ) |
29 } | |
30 | |
1
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
31 NavigationLink( |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
32 destination: GuessTheCapitalView(gameName: $gameName), |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
33 tag: GameName.guessTheCapital, |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
34 selection: $gameName |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
35 ) { |
0 | 36 GameButton( |
37 gradient: .secondary, | |
1
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
38 level: "Level 2", symbol: "building.2.fill", name: "Guess the capital" |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
39 ) |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
40 } |
6 | 41 |
1
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
42 NavigationLink( |
6 | 43 destination: GuessTheCountryView(gameName: $gameName), |
1
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
44 tag: GameName.guessTheCountry, |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
45 selection: $gameName |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
46 ) { |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
47 GameButton( |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
48 gradient: .tertiary, |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
49 level: "Level 3", symbol: "globe.americas.fill", name: "Guess the country" |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
50 ) |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
51 } |
6 | 52 // |
53 // NavigationLink( | |
54 // destination: Text("Guess the population"), | |
55 // tag: GameName.guessThePopulation, | |
56 // selection: $gameName | |
57 // ) { | |
58 // GameButton( | |
59 // gradient: .quaternary, | |
60 // level: "Level 4", symbol: "person.3.fill", name: "Guess the population" | |
61 // ) | |
62 // } | |
0 | 63 } |
64 .padding() | |
65 } | |
66 .navigationTitle("Select a game 🎮") | |
67 .toolbar { | |
5 | 68 ToolbarItem(placement: .navigationBarLeading) { |
69 Button { | |
70 showingSettingsModalView = true | |
71 } label: { | |
72 Label("Settings", systemImage: "gear") | |
73 } | |
74 } | |
75 | |
76 ToolbarItemGroup { | |
77 Button { | |
78 showingBuyLivesModalView = true | |
79 } label: { | |
80 Label("Buy lives", systemImage: "heart.fill") | |
81 } | |
0 | 82 } |
83 } | |
5 | 84 .sheet(isPresented: $showingBuyLivesModalView) { |
4 | 85 BuyLivesModalView() |
0 | 86 } |
5 | 87 |
88 .sheet(isPresented: $showingSettingsModalView) { | |
89 SettingsModalView() | |
90 } | |
0 | 91 } |
6 | 92 .navigationViewStyle(StackNavigationViewStyle()) |
0 | 93 } |
94 } | |
95 | |
96 struct ContentView_Previews: PreviewProvider { | |
97 static var previews: some View { | |
98 ContentView() | |
99 } | |
100 } |