From 0317276ccb4870870c6a2751815abb848163ed18 Mon Sep 17 00:00:00 2001 From: Mathieu GROUSSEAU Date: Wed, 28 May 2025 08:33:46 +0200 Subject: [PATCH] Saved games view --- App/App.xcodeproj/project.pbxproj | 8 +++++ App/App/View/MainMenuView.swift | 4 +-- App/App/View/SavedGamesView.swift | 52 +++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 App/App/View/SavedGamesView.swift diff --git a/App/App.xcodeproj/project.pbxproj b/App/App.xcodeproj/project.pbxproj index 9875b09..cee8262 100644 --- a/App/App.xcodeproj/project.pbxproj +++ b/App/App.xcodeproj/project.pbxproj @@ -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 = ""; }; F0F59E502DD49C2800BE32D6 /* Colors.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Colors.xcassets; sourceTree = ""; }; F0F59E522DDDC35100BE32D6 /* NewGameView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewGameView.swift; sourceTree = ""; }; + F0F59E542DDDED1D00BE32D6 /* IngameView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IngameView.swift; sourceTree = ""; }; + F0F59E562DE6D6E600BE32D6 /* SavedGamesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SavedGamesView.swift; sourceTree = ""; }; /* 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 = ""; @@ -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; }; diff --git a/App/App/View/MainMenuView.swift b/App/App/View/MainMenuView.swift index b4bee23..f0dfc55 100644 --- a/App/App/View/MainMenuView.swift +++ b/App/App/View/MainMenuView.swift @@ -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")) } } } diff --git a/App/App/View/SavedGamesView.swift b/App/App/View/SavedGamesView.swift new file mode 100644 index 0000000..22b8cd4 --- /dev/null +++ b/App/App/View/SavedGamesView.swift @@ -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() +}