Mercurial > public > geoquiz
view GeoQuiz/Helpers/GameAlertsModifier.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 | d945e52b0704 |
line wrap: on
line source
// // GameAlertsModifier.swift // GeoQuiz // // Created by Dennis Concepción Martín on 22/9/22. // import SwiftUI struct GameAlertsModifier<T: Game>: ViewModifier { @ObservedObject var game: T @Binding var gameName: GameName? func body(content: Content) -> some View { content .alert(game.alertTitle, isPresented: $game.showingWrongAnswerAlert) { Button("Continue", role: .cancel) { game.askQuestion() } } message: { Text(game.alertMessage) } .alert(game.alertTitle, isPresented: $game.showingNoLivesAlert) { Button("Buy lives") { game.showingBuyLivesView = true } Button("Exit", role: .destructive) { gameName = nil } Button("Cancel", role: .cancel) { } } message: { Text(game.alertMessage) } .alert(game.alertTitle, isPresented: $game.showingEndGameAlert) { Button("Exit", role: .cancel) { gameName = nil } } message: { Text(game.alertMessage) } .alert("Are you sure?", isPresented: $game.showingExitGameAlert) { Button("Exit", role: .destructive) { gameName = nil } Button("Cancel", role: .cancel) { } } message: { Text("You'll loose the progress so far.") } } }