Mercurial > public > geoquiz
comparison GeoQuiz/Helpers/GameToolbar.swift @ 4:de54f05adb78
add prototype game stats
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Thu, 22 Sep 2022 11:38:42 +0200 |
parents | 4dbe0cd9dadc |
children | 1946bbfde4af |
comparison
equal
deleted
inserted
replaced
3:4dbe0cd9dadc | 4:de54f05adb78 |
---|---|
6 // | 6 // |
7 | 7 |
8 import SwiftUI | 8 import SwiftUI |
9 | 9 |
10 struct GameToolbar<T: Game>: View { | 10 struct GameToolbar<T: Game>: View { |
11 @Binding var gameName: GameName? | |
12 @ObservedObject var game: T | 11 @ObservedObject var game: T |
13 | 12 |
14 | 13 |
15 var body: some View { | 14 var body: some View { |
16 HStack(spacing: 0) { | 15 HStack(spacing: 0) { |
17 Group { | 16 Group { |
18 Button { | 17 Button { |
19 gameName = nil | 18 game.showingExitGameAlert = true |
20 } label: { | 19 } label: { |
21 Image(systemName: "multiply") | 20 Image(systemName: "multiply") |
22 .padding(10) | 21 .padding(10) |
23 .background( | 22 .background( |
24 Circle() | 23 Circle() |
29 .foregroundColor(.white) | 28 .foregroundColor(.white) |
30 .font(.headline) | 29 .font(.headline) |
31 .frame(maxWidth: .infinity, alignment: .leading) | 30 .frame(maxWidth: .infinity, alignment: .leading) |
32 | 31 |
33 Group { | 32 Group { |
34 Text("\(game.userScore)") | 33 Button { |
35 .padding() | 34 game.showingGameStatsView = true |
36 .background( | 35 } label: { |
37 Circle() | 36 Text("\(game.userScore)") |
38 .strokeBorder(lineWidth: 3) | 37 .padding() |
39 ) | 38 .background( |
39 Circle() | |
40 .strokeBorder(lineWidth: 3) | |
41 ) | |
42 } | |
40 } | 43 } |
41 .foregroundColor(.white) | 44 .foregroundColor(.white) |
42 .font(.title2) | 45 .font(.title2) |
43 .scaleEffect(game.scoreScaleAmount) | 46 .scaleEffect(game.scoreScaleAmount) |
44 .frame(maxWidth: .infinity, alignment: .center) | 47 .frame(maxWidth: .infinity, alignment: .center) |
72 LinearGradient(gradient: .main, startPoint: .top, endPoint: .bottom) | 75 LinearGradient(gradient: .main, startPoint: .top, endPoint: .bottom) |
73 .ignoresSafeArea() | 76 .ignoresSafeArea() |
74 | 77 |
75 GeometryReader { geo in | 78 GeometryReader { geo in |
76 VStack { | 79 VStack { |
77 GameToolbar( | 80 GameToolbar(game: GuessTheFlag()) |
78 gameName: .constant(GameName.guessTheFlag), | |
79 game: GuessTheFlag() | |
80 ) | |
81 | 81 |
82 Spacer() | 82 Spacer() |
83 } | 83 } |
84 .padding() | 84 .padding() |
85 } | 85 } |