Mercurial > public > geoquiz
view 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 |
line wrap: on
line source
// // GameToolbar.swift // GeoQuiz // // Created by Dennis Concepción Martín on 18/9/22. // import SwiftUI struct GameToolbar<T: Game>: View { @ObservedObject var game: T var body: some View { HStack(spacing: 0) { Group { Button { game.showingExitGameAlert = true } label: { Image(systemName: "multiply") .padding(10) .background( Circle() .strokeBorder(lineWidth: 2) ) } } .foregroundColor(.white) .font(.headline) .frame(maxWidth: .infinity, alignment: .leading) Group { Button { game.showingGameStatsView = true } label: { Text("\(game.userScore)") .padding() .background( Circle() .strokeBorder(lineWidth: 3) ) } } .foregroundColor(.white) .font(.title2) .scaleEffect(game.scoreScaleAmount) .frame(maxWidth: .infinity, alignment: .center) Group { Button { game.showingBuyLivesView = true } label: { HStack { Image(systemName: "heart.fill") Text("\(game.userLives)") } .padding(10) .background( Capsule() .strokeBorder(lineWidth: 2) ) .scaleEffect(game.livesScaleAmount) } } .foregroundColor(.white) .font(.headline) .frame(maxWidth: .infinity, alignment: .trailing) } } } struct GameToolbar_Previews: PreviewProvider { static var previews: some View { ZStack { LinearGradient(gradient: .main, startPoint: .top, endPoint: .bottom) .ignoresSafeArea() GeometryReader { geo in VStack { GameToolbar(game: GuessTheFlag()) Spacer() } .padding() } } } }