Mercurial > public > geoquiz
comparison GeoQuiz/GameStatsModalView.swift @ 4:de54f05adb78
add prototype game stats
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Thu, 22 Sep 2022 11:38:42 +0200 |
parents | |
children | 1946bbfde4af |
comparison
equal
deleted
inserted
replaced
3:4dbe0cd9dadc | 4:de54f05adb78 |
---|---|
1 // | |
2 // GameStatsModalView.swift | |
3 // GeoQuiz | |
4 // | |
5 // Created by Dennis Concepción Martín on 22/9/22. | |
6 // | |
7 | |
8 import SwiftUI | |
9 | |
10 struct GameStatsModalView<T: Game>: View { | |
11 @ObservedObject var game: T | |
12 @Environment(\.dismiss) var dismiss | |
13 | |
14 var body: some View { | |
15 NavigationView { | |
16 List { | |
17 Section { | |
18 ForEach(Array(game.correctAnswers.keys), id: \.self) { key in | |
19 Text(key) | |
20 } | |
21 } header: { | |
22 Text("Correct answers") | |
23 } | |
24 | |
25 Section { | |
26 ForEach(Array(game.wrongAnswers.keys), id: \.self) { key in | |
27 Text(key) | |
28 } | |
29 } header: { | |
30 Text("Wrong answers") | |
31 } | |
32 } | |
33 .navigationTitle("Game stats") | |
34 .toolbar { | |
35 ToolbarItem(placement: .cancellationAction) { | |
36 Button { | |
37 dismiss() | |
38 } label: { | |
39 Label("Exit", systemImage: "multiply") | |
40 } | |
41 } | |
42 } | |
43 } | |
44 } | |
45 } | |
46 | |
47 struct GameStatsModalView_Previews: PreviewProvider { | |
48 static var previews: some View { | |
49 GameStatsModalView(game: GuessTheFlag()) | |
50 } | |
51 } |