Mercurial > public > geoquiz
annotate GeoQuiz/ContentView.swift @ 3:4dbe0cd9dadc
first game prototype
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Thu, 22 Sep 2022 10:42:39 +0200 |
parents | 259a15f485c5 |
children | de54f05adb78 |
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 | |
12 @State private var showingBuyLivesModal = false | |
13 | |
14 var body: some View { | |
15 NavigationView { | |
16 ScrollView(showsIndicators: false) { | |
17 VStack(spacing: 20) { | |
18 | |
1
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
19 NavigationLink( |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
20 destination: GuessTheFlagView(gameName: $gameName), |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
21 tag: GameName.guessTheFlag, |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
22 selection: $gameName |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
23 ) { |
0 | 24 GameButton( |
25 gradient: .main, | |
1
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
26 level: "Level 1", symbol: "flag.fill", name: "Guess the flag" |
0 | 27 ) |
28 } | |
29 | |
1
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
30 NavigationLink( |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
31 destination: GuessTheCapitalView(gameName: $gameName), |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
32 tag: GameName.guessTheCapital, |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
33 selection: $gameName |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
34 ) { |
0 | 35 GameButton( |
36 gradient: .secondary, | |
1
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
37 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
|
38 ) |
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 |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
41 NavigationLink( |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
42 destination: Text("Guess the country"), |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
43 tag: GameName.guessTheCountry, |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
44 selection: $gameName |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
45 ) { |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
46 GameButton( |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
47 gradient: .tertiary, |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
48 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
|
49 ) |
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 |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
52 NavigationLink( |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
53 destination: Text("Guess the population"), |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
54 tag: GameName.guessThePopulation, |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
55 selection: $gameName |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
56 ) { |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
57 GameButton( |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
58 gradient: .quaternary, |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
59 level: "Level 4", symbol: "person.3.fill", name: "Guess the population" |
0 | 60 ) |
61 } | |
62 } | |
63 .padding() | |
64 } | |
65 .navigationTitle("Select a game 🎮") | |
66 .toolbar { | |
67 Button { | |
68 showingBuyLivesModal = true | |
69 } label: { | |
70 Label("Buy lives", systemImage: "heart.fill") | |
71 } | |
72 } | |
73 .sheet(isPresented: $showingBuyLivesModal) { | |
74 BuyLivesModal() | |
75 } | |
76 } | |
77 } | |
78 } | |
79 | |
80 struct ContentView_Previews: PreviewProvider { | |
81 static var previews: some View { | |
82 ContentView() | |
83 } | |
84 } |