Mercurial > public > geoquiz
comparison GeoQuiz/Helpers/GameAlertsModifier.swift @ 3:4dbe0cd9dadc
first game prototype
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Thu, 22 Sep 2022 10:42:39 +0200 |
parents | |
children | de54f05adb78 |
comparison
equal
deleted
inserted
replaced
2:5b7c89bd45c3 | 3:4dbe0cd9dadc |
---|---|
1 // | |
2 // GameAlertsModifier.swift | |
3 // GeoQuiz | |
4 // | |
5 // Created by Dennis Concepción Martín on 22/9/22. | |
6 // | |
7 | |
8 import SwiftUI | |
9 | |
10 struct GameAlertsModifier<T: Game>: ViewModifier { | |
11 @ObservedObject var game: T | |
12 @Binding var gameName: GameName? | |
13 | |
14 func body(content: Content) -> some View { | |
15 content | |
16 .alert(game.alertTitle, isPresented: $game.showingWrongAnswerAlert) { | |
17 Button("Continue", role: .cancel) { game.askQuestion() } | |
18 } message: { | |
19 Text(game.alertMessage) | |
20 } | |
21 | |
22 .alert(game.alertTitle, isPresented: $game.showingNoLivesAlert) { | |
23 Button("Buy lives") { game.showingBuyLivesView = true } | |
24 Button("Exit", role: .destructive) { gameName = nil } | |
25 Button("Cancel", role: .cancel) { } | |
26 } message: { | |
27 Text(game.alertMessage) | |
28 } | |
29 | |
30 .alert(game.alertTitle, isPresented: $game.showingEndGameAlert) { | |
31 Button("Exit", role: .cancel) { gameName = nil } | |
32 } message: { | |
33 Text(game.alertMessage) | |
34 } | |
35 } | |
36 } |