|
|
|
@ -6,62 +6,46 @@ struct SavedGamesView: View {
|
|
|
|
|
|
|
|
|
|
@Binding
|
|
|
|
|
var currentGame: IngameVM?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
|
TabView {
|
|
|
|
|
VStack {
|
|
|
|
|
Section("savedGames.section.unfinished") {
|
|
|
|
|
ScoreboardView(results: self.$vm.unfinished, currentGame: $currentGame, "scoreboard.table.column.players") {
|
|
|
|
|
result in
|
|
|
|
|
let n1 = if result.player1Name != nil {
|
|
|
|
|
Text(result.player1Name!)
|
|
|
|
|
} else {
|
|
|
|
|
Text(LocalizedStringKey(result.player1Type.baseTranslationKey))
|
|
|
|
|
}
|
|
|
|
|
let n2 = if result.player2Name != nil {
|
|
|
|
|
Text(result.player2Name!)
|
|
|
|
|
} else {
|
|
|
|
|
Text(LocalizedStringKey(result.player2Type.baseTranslationKey))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return LocalizedStringKey("\(n1) savedGames.section.unfinished.entry \(n2)")
|
|
|
|
|
}
|
|
|
|
|
ScoreboardView(results: self.$vm.unfinished, currentGame: $currentGame, "scoreboard.table.column.players") {
|
|
|
|
|
result in
|
|
|
|
|
let n1 = if result.player1Name != nil {
|
|
|
|
|
Text(result.player1Name!)
|
|
|
|
|
} else {
|
|
|
|
|
Text(LocalizedStringKey(result.player1Type.baseTranslationKey))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let n2 = if result.player2Name != nil {
|
|
|
|
|
Text(result.player2Name!)
|
|
|
|
|
} else {
|
|
|
|
|
Text(LocalizedStringKey(result.player2Type.baseTranslationKey))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return LocalizedStringKey("\(n1) savedGames.section.unfinished.entry \(n2)")
|
|
|
|
|
}.tabItem {
|
|
|
|
|
Label("savedGames.section.unfinished", systemImage: "play.rectangle")
|
|
|
|
|
}.badge("savedGames.section.unfinished.badge \(self.vm.unfinished.count)")
|
|
|
|
|
|
|
|
|
|
VStack {
|
|
|
|
|
Section("savedGames.section.finished") {
|
|
|
|
|
ScoreboardView(results: self.$vm.finished, currentGame: $currentGame, "scoreboard.table.column.players") {
|
|
|
|
|
result in
|
|
|
|
|
let n1 = if result.player1Name != nil {
|
|
|
|
|
Text(result.player1Name!)
|
|
|
|
|
} else {
|
|
|
|
|
Text(LocalizedStringKey(result.player1Type.baseTranslationKey))
|
|
|
|
|
}
|
|
|
|
|
let n2 = if result.player2Name != nil {
|
|
|
|
|
Text(result.player2Name!)
|
|
|
|
|
} else {
|
|
|
|
|
Text(LocalizedStringKey(result.player2Type.baseTranslationKey))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return LocalizedStringKey("\(n1) savedGames.section.finished.entry \(n2)")
|
|
|
|
|
}
|
|
|
|
|
ScoreboardView(results: self.$vm.finished, currentGame: $currentGame, "scoreboard.table.column.players") {
|
|
|
|
|
result in
|
|
|
|
|
let n1 = if result.player1Name != nil {
|
|
|
|
|
Text(result.player1Name!)
|
|
|
|
|
} else {
|
|
|
|
|
Text(LocalizedStringKey(result.player1Type.baseTranslationKey))
|
|
|
|
|
}
|
|
|
|
|
let n2 = if result.player2Name != nil {
|
|
|
|
|
Text(result.player2Name!)
|
|
|
|
|
} else {
|
|
|
|
|
Text(LocalizedStringKey(result.player2Type.baseTranslationKey))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return LocalizedStringKey("\(n1) savedGames.section.finished.entry \(n2)")
|
|
|
|
|
}.tabItem {
|
|
|
|
|
Label("savedGames.section.finished", systemImage: "rosette")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#if os(macOS)
|
|
|
|
|
.tabViewStyle(.automatic)
|
|
|
|
|
#else
|
|
|
|
|
.tabViewStyle(.page)
|
|
|
|
|
#endif
|
|
|
|
|
// VStack {
|
|
|
|
|
// // TODO: use the same collection view with headers instead? Or use collapsible sections?
|
|
|
|
|
// //Section("savedGames.section.") {
|
|
|
|
|
// // ScoreboardView("scoreboard.table.column.players") { result in
|
|
|
|
|
// // "\(result.player1) savedGames.section.unfinished.entry \(result.player2)"
|
|
|
|
|
// // }
|
|
|
|
|
// //}
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|