Mercurial > public > geoquiz
comparison GeoQuiz/Helpers/GameToolbar.swift @ 6:1946bbfde4af
reformat data structures
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Thu, 29 Sep 2022 12:00:17 +0200 |
parents | de54f05adb78 |
children | d945e52b0704 |
comparison
equal
deleted
inserted
replaced
5:f31a61462e7a | 6:1946bbfde4af |
---|---|
8 import SwiftUI | 8 import SwiftUI |
9 | 9 |
10 struct GameToolbar<T: Game>: View { | 10 struct GameToolbar<T: Game>: View { |
11 @ObservedObject var game: T | 11 @ObservedObject var game: T |
12 | 12 |
13 var color: Color | |
13 | 14 |
14 var body: some View { | 15 var body: some View { |
15 HStack(spacing: 0) { | 16 HStack(spacing: 0) { |
16 Group { | 17 Group { |
17 Button { | 18 Button { |
18 game.showingExitGameAlert = true | 19 game.showingExitGameAlert = true |
19 } label: { | 20 } label: { |
20 Image(systemName: "multiply") | 21 Image(systemName: "multiply") |
22 .font(.headline) | |
23 .foregroundColor(color) | |
21 .padding(10) | 24 .padding(10) |
22 .background( | 25 .background( |
23 Circle() | 26 Circle() |
24 .strokeBorder(lineWidth: 2) | 27 .foregroundColor(.white) |
25 ) | 28 ) |
26 } | 29 } |
27 } | 30 } |
28 .foregroundColor(.white) | |
29 .font(.headline) | 31 .font(.headline) |
30 .frame(maxWidth: .infinity, alignment: .leading) | 32 .frame(maxWidth: .infinity, alignment: .leading) |
31 | 33 |
32 Group { | 34 Group { |
33 Button { | 35 Button { |
34 game.showingGameStatsView = true | 36 game.showingGameStatsView = true |
35 } label: { | 37 } label: { |
36 Text("\(game.userScore)") | 38 Text("\(game.userScore)") |
39 .font(.title.bold()) | |
40 .foregroundColor(color) | |
37 .padding() | 41 .padding() |
38 .background( | 42 .background( |
39 Circle() | 43 Circle() |
40 .strokeBorder(lineWidth: 3) | 44 .foregroundColor(.white) |
41 ) | 45 ) |
42 } | 46 } |
43 } | 47 } |
44 .foregroundColor(.white) | |
45 .font(.title2) | 48 .font(.title2) |
46 .scaleEffect(game.scoreScaleAmount) | 49 .scaleEffect(game.scoreScaleAmount) |
47 .frame(maxWidth: .infinity, alignment: .center) | 50 .frame(maxWidth: .infinity, alignment: .center) |
48 | 51 |
49 Group { | 52 Group { |
52 } label: { | 55 } label: { |
53 HStack { | 56 HStack { |
54 Image(systemName: "heart.fill") | 57 Image(systemName: "heart.fill") |
55 Text("\(game.userLives)") | 58 Text("\(game.userLives)") |
56 } | 59 } |
60 .font(.headline) | |
61 .foregroundColor(color) | |
57 .padding(10) | 62 .padding(10) |
58 .background( | 63 .background( |
59 Capsule() | 64 Capsule() |
60 .strokeBorder(lineWidth: 2) | 65 .foregroundColor(.white) |
61 ) | 66 ) |
62 .scaleEffect(game.livesScaleAmount) | 67 .scaleEffect(game.livesScaleAmount) |
63 } | 68 } |
64 } | 69 } |
65 .foregroundColor(.white) | |
66 .font(.headline) | 70 .font(.headline) |
67 .frame(maxWidth: .infinity, alignment: .trailing) | 71 .frame(maxWidth: .infinity, alignment: .trailing) |
68 } | 72 } |
69 } | 73 } |
70 } | 74 } |
75 LinearGradient(gradient: .main, startPoint: .top, endPoint: .bottom) | 79 LinearGradient(gradient: .main, startPoint: .top, endPoint: .bottom) |
76 .ignoresSafeArea() | 80 .ignoresSafeArea() |
77 | 81 |
78 GeometryReader { geo in | 82 GeometryReader { geo in |
79 VStack { | 83 VStack { |
80 GameToolbar(game: GuessTheFlag()) | 84 GameToolbar(game: CountryGame(), color: .mayaBlue) |
81 | 85 |
82 Spacer() | 86 Spacer() |
83 } | 87 } |
84 .padding() | 88 .padding() |
85 } | 89 } |