Mercurial > public > geoquiz
annotate GeoQuiz/ContentView.swift @ 5:f31a61462e7a
add sound effects
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Sat, 24 Sep 2022 12:02:09 +0100 |
parents | de54f05adb78 |
children | 1946bbfde4af |
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 } |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
41 |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
42 NavigationLink( |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
43 destination: Text("Guess the country"), |
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 } |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
52 |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
53 NavigationLink( |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
54 destination: Text("Guess the population"), |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
55 tag: GameName.guessThePopulation, |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
56 selection: $gameName |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
57 ) { |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
58 GameButton( |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
59 gradient: .quaternary, |
259a15f485c5
fix bug with NavigationLink
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
60 level: "Level 4", symbol: "person.3.fill", name: "Guess the population" |
0 | 61 ) |
62 } | |
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 } |
92 } | |
93 } | |
94 | |
95 struct ContentView_Previews: PreviewProvider { | |
96 static var previews: some View { | |
97 ContentView() | |
98 } | |
99 } |