From a48051a3328e7b4da148da9aae4eb5c905cfaa71 Mon Sep 17 00:00:00 2001 From: Mathieu GROUSSEAU Date: Wed, 25 Jun 2025 08:45:34 +0200 Subject: [PATCH] Pretty tabs --- App/App.xcodeproj/project.pbxproj | 4 ++ App/App/Localizable.xcstrings | 16 +++++++ App/App/View/SavedGamesView.swift | 80 +++++++++++++------------------ 3 files changed, 52 insertions(+), 48 deletions(-) diff --git a/App/App.xcodeproj/project.pbxproj b/App/App.xcodeproj/project.pbxproj index 574a70b..028c32d 100644 --- a/App/App.xcodeproj/project.pbxproj +++ b/App/App.xcodeproj/project.pbxproj @@ -37,6 +37,7 @@ F08534D32E0951BD0002A3A0 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F08534D22E0951BD0002A3A0 /* Images.xcassets */; }; F08534D52E0A857D0002A3A0 /* Persistance.swift in Sources */ = {isa = PBXBuildFile; fileRef = F08534D42E0A857D0002A3A0 /* Persistance.swift */; }; F08534D72E0A88240002A3A0 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = F08534D62E0A88240002A3A0 /* String.swift */; }; + F08534D92E0BBF740002A3A0 /* NavigationLazyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F08534D82E0BBF740002A3A0 /* NavigationLazyView.swift */; }; 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 */; }; @@ -108,6 +109,7 @@ F08534D22E0951BD0002A3A0 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; F08534D42E0A857D0002A3A0 /* Persistance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Persistance.swift; sourceTree = ""; }; F08534D62E0A88240002A3A0 /* String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = String.swift; sourceTree = ""; }; + F08534D82E0BBF740002A3A0 /* NavigationLazyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationLazyView.swift; sourceTree = ""; }; F0F59E412DD492B400BE32D6 /* C4Persistance.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = C4Persistance.xcframework; path = ../precompiled/xcframeworks/C4Persistance.xcframework; sourceTree = ""; }; F0F59E422DD492B400BE32D6 /* C4Players.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = C4Players.xcframework; path = ../precompiled/xcframeworks/C4Players.xcframework; sourceTree = ""; }; F0F59E432DD492B400BE32D6 /* C4.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = C4.xcframework; path = ../precompiled/xcframeworks/C4.xcframework; sourceTree = ""; }; @@ -270,6 +272,7 @@ F0F59E582DE6EB2A00BE32D6 /* PlayerVSPage.swift */, F0F59E5A2DE6F68800BE32D6 /* ScoreboardView.swift */, F05DA2142E02D1850094A4A8 /* UIUtilities.swift */, + F08534D82E0BBF740002A3A0 /* NavigationLazyView.swift */, ); path = View; sourceTree = ""; @@ -427,6 +430,7 @@ F0143C2B2DF018F20086CAAA /* GameScene.swift in Sources */, F0F59E572DE6D6E600BE32D6 /* SavedGamesView.swift in Sources */, F05DA2172E082F5B0094A4A8 /* Owner.swift in Sources */, + F08534D92E0BBF740002A3A0 /* NavigationLazyView.swift in Sources */, F08534D52E0A857D0002A3A0 /* Persistance.swift in Sources */, F0143C342DF987490086CAAA /* PlayerType.swift in Sources */, F0F59E552DDDED1D00BE32D6 /* IngameView.swift in Sources */, diff --git a/App/App/Localizable.xcstrings b/App/App/Localizable.xcstrings index 5b3ff57..92ea3b5 100644 --- a/App/App/Localizable.xcstrings +++ b/App/App/Localizable.xcstrings @@ -680,6 +680,22 @@ } } }, + "savedGames.section.unfinished.badge %lld" : { + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "%lld" + } + }, + "fr" : { + "stringUnit" : { + "state" : "translated", + "value" : "%lld" + } + } + } + }, "savedGames.title" : { "localizations" : { "en" : { diff --git a/App/App/View/SavedGamesView.swift b/App/App/View/SavedGamesView.swift index 2cea61e..9fd9bfc 100644 --- a/App/App/View/SavedGamesView.swift +++ b/App/App/View/SavedGamesView.swift @@ -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)" - // // } - // //} - // } } }