comparison GeoQuiz/GameStatsModalView.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
comparison
equal deleted inserted replaced
5:f31a61462e7a 6:1946bbfde4af
1 ////
2 //// GameStatsModalView.swift
3 //// GeoQuiz
4 ////
5 //// Created by Dennis Concepción Martín on 22/9/22.
6 ////
1 // 7 //
2 // GameStatsModalView.swift 8 //import SwiftUI
3 // GeoQuiz
4 // 9 //
5 // Created by Dennis Concepción Martín on 22/9/22. 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 //}
6 // 46 //
7 47 //struct GameStatsModalView_Previews: PreviewProvider {
8 import SwiftUI 48 // static var previews: some View {
9 49 // GameStatsModalView(game: GuessTheFlag())
10 struct GameStatsModalView<T: Game>: View { 50 // }
11 @ObservedObject var game: T 51 //}
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 }