Saved games view

main
Mathieu GROUSSEAU 1 month ago
parent 510cbd9d7c
commit 0317276ccb

@ -21,6 +21,8 @@
F0F59E4F2DD4996F00BE32D6 /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = F0F59E4E2DD4996F00BE32D6 /* Localizable.xcstrings */; };
F0F59E512DD49C2800BE32D6 /* Colors.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F0F59E502DD49C2800BE32D6 /* Colors.xcassets */; };
F0F59E532DDDC35100BE32D6 /* NewGameView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0F59E522DDDC35100BE32D6 /* NewGameView.swift */; };
F0F59E552DDDED1D00BE32D6 /* IngameView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0F59E542DDDED1D00BE32D6 /* IngameView.swift */; };
F0F59E572DE6D6E600BE32D6 /* SavedGamesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0F59E562DE6D6E600BE32D6 /* SavedGamesView.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -59,6 +61,8 @@
F0F59E4E2DD4996F00BE32D6 /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; name = Localizable.xcstrings; path = App/Localizable.xcstrings; sourceTree = "<group>"; };
F0F59E502DD49C2800BE32D6 /* Colors.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Colors.xcassets; sourceTree = "<group>"; };
F0F59E522DDDC35100BE32D6 /* NewGameView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewGameView.swift; sourceTree = "<group>"; };
F0F59E542DDDED1D00BE32D6 /* IngameView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IngameView.swift; sourceTree = "<group>"; };
F0F59E562DE6D6E600BE32D6 /* SavedGamesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SavedGamesView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -166,6 +170,8 @@
children = (
F001A04D2DD48FAB00809561 /* MainMenuView.swift */,
F0F59E522DDDC35100BE32D6 /* NewGameView.swift */,
F0F59E542DDDED1D00BE32D6 /* IngameView.swift */,
F0F59E562DE6D6E600BE32D6 /* SavedGamesView.swift */,
);
path = View;
sourceTree = "<group>";
@ -306,6 +312,8 @@
F001A04E2DD48FAB00809561 /* MainMenuView.swift in Sources */,
F001A04C2DD48FAB00809561 /* AppApp.swift in Sources */,
F0F59E532DDDC35100BE32D6 /* NewGameView.swift in Sources */,
F0F59E572DE6D6E600BE32D6 /* SavedGamesView.swift in Sources */,
F0F59E552DDDED1D00BE32D6 /* IngameView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

@ -14,9 +14,7 @@ struct MainMenuView: View {
NavigationLink("mainMenu.button.newGame", destination: NewGameView().navigationTitle("newGame.title"))
Button("mainMenu.button.scoreboard") {
// TODO
}
NavigationLink("mainMenu.button.scoreboard", destination: SavedGamesView().navigationTitle("savedGames.title"))
}
}
}

@ -0,0 +1,52 @@
//
// SavedGamesView.swift
// App
//
// Created by etudiant2 on 28/05/2025.
//
import SwiftUI
struct SavedGamesView: View {
var body: some View {
ScoreTable(key: "savedGames.section.unfinished")
ScoreTable(key: "savedGames.section.finished")
}
}
struct ScoreTable: View {
let key: LocalizedStringKey
@State private var unsinished = [
Result(date: "D1", player1: "P1", player2: "P2", rules: "Rule1"),
Result(date: "D2", player1: "P2", player2: "P3", rules: "Rule2"),
Result(date: "D3", player1: "P3", player2: "P4", rules: "Rule3"),
Result(date: "D4", player1: "P4", player2: "P5", rules: "Rule4"),
Result(date: "D5", player1: "P5", player2: "P1", rules: "Rule5")
];
var body: some View {
Section(self.key) {
Table(self.unsinished) {
TableColumn("savedGames.table.column.date", value: \.date)
TableColumn("savedGames.table.column.players") { result in
Text("\(result.player1) savedGames.table.column.players.entry \(result.player2)")
}
TableColumn("savedGames.table.column.rules", value: \.rules)
}
}
}
}
struct Result: Identifiable {
let id = UUID()
let date: String
let player1: String
let player2: String
let rules: String
}
#Preview {
SavedGamesView()
}
Loading…
Cancel
Save