diff --git a/ArkitDoushiQi/.DS_Store b/ArkitDoushiQi/.DS_Store deleted file mode 100644 index 5a1a5b9..0000000 Binary files a/ArkitDoushiQi/.DS_Store and /dev/null differ diff --git a/.gitignore b/ArkitDoushiQi/.gitignore similarity index 90% rename from .gitignore rename to ArkitDoushiQi/.gitignore index 1157326..671ce62 100644 --- a/.gitignore +++ b/ArkitDoushiQi/.gitignore @@ -116,4 +116,24 @@ fastlane/test_output # After new code Injection tools there's a generated folder /iOSInjectionProject # https://github.com/johnno1962/injectionforxcode -iOSInjectionProject/ \ No newline at end of file +iOSInjectionProject/ + +# Xcode +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +*.xccheckout +*.moved-aside +DerivedData +*.hmap +*.ipa +*.xcworkspace +!default.xcworkspace +*.swp +*.DS_Store diff --git a/ArkitDoushiQi/ArkitDoushiQi.xcodeproj/project.pbxproj b/ArkitDoushiQi/ArkitDoushiQi.xcodeproj/project.pbxproj index baed39e..e0dd8c0 100644 --- a/ArkitDoushiQi/ArkitDoushiQi.xcodeproj/project.pbxproj +++ b/ArkitDoushiQi/ArkitDoushiQi.xcodeproj/project.pbxproj @@ -7,12 +7,15 @@ objects = { /* Begin PBXBuildFile section */ + 1607D9CB2C09CF4C000AB3F2 /* Stub.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1607D9C92C09CF4C000AB3F2 /* Stub.swift */; }; + 1607D9CC2C09CF4C000AB3F2 /* PartyEnregistery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1607D9CA2C09CF4C000AB3F2 /* PartyEnregistery.swift */; }; + 1607D9CE2C09CFD3000AB3F2 /* ItemCollectionParty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1607D9CD2C09CFD3000AB3F2 /* ItemCollectionParty.swift */; }; + 168CD4FB2C0625A400419510 /* fr.lproj in Resources */ = {isa = PBXBuildFile; fileRef = 168CD4F92C0625A400419510 /* fr.lproj */; }; + 168CD4FC2C0625A400419510 /* en.lproj in Resources */ = {isa = PBXBuildFile; fileRef = 168CD4FA2C0625A400419510 /* en.lproj */; }; + 168CD4FF2C06265B00419510 /* LanguageSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 168CD4FE2C06265B00419510 /* LanguageSettings.swift */; }; 82CE59E92C045D1100ADEE24 /* GameScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82CE59E82C045D1100ADEE24 /* GameScene.swift */; }; 82CE59EB2C045E3800ADEE24 /* GameView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82CE59EA2C045E3800ADEE24 /* GameView.swift */; }; 82CE59EF2C0460E500ADEE24 /* SpriteMoople.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82CE59EE2C0460E500ADEE24 /* SpriteMoople.swift */; }; - 82F9D3312BFE3A9F009EDFAF /* HistoryGameDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82F9D3302BFE3A9F009EDFAF /* HistoryGameDetail.swift */; }; - 82F9D3332BFE3B12009EDFAF /* HistoryHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82F9D3322BFE3B12009EDFAF /* HistoryHeader.swift */; }; - 82F9D3362BFE3B3C009EDFAF /* HistoryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82F9D3352BFE3B3C009EDFAF /* HistoryView.swift */; }; C20310D62BFCB5FB0031657D /* PickerComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = C20310D52BFCB5FB0031657D /* PickerComponent.swift */; }; C20310D82BFCC2410031657D /* GeneralParametersMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C20310D72BFCC2410031657D /* GeneralParametersMenuView.swift */; }; C20310DA2BFCC8600031657D /* ToggleComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = C20310D92BFCC8600031657D /* ToggleComponent.swift */; }; @@ -54,12 +57,15 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 1607D9C92C09CF4C000AB3F2 /* Stub.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Stub.swift; sourceTree = ""; }; + 1607D9CA2C09CF4C000AB3F2 /* PartyEnregistery.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PartyEnregistery.swift; sourceTree = ""; }; + 1607D9CD2C09CFD3000AB3F2 /* ItemCollectionParty.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ItemCollectionParty.swift; sourceTree = ""; }; + 168CD4F92C0625A400419510 /* fr.lproj */ = {isa = PBXFileReference; lastKnownFileType = folder; path = fr.lproj; sourceTree = ""; }; + 168CD4FA2C0625A400419510 /* en.lproj */ = {isa = PBXFileReference; lastKnownFileType = folder; path = en.lproj; sourceTree = ""; }; + 168CD4FE2C06265B00419510 /* LanguageSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LanguageSettings.swift; sourceTree = ""; }; 82CE59E82C045D1100ADEE24 /* GameScene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameScene.swift; sourceTree = ""; }; 82CE59EA2C045E3800ADEE24 /* GameView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameView.swift; sourceTree = ""; }; 82CE59EE2C0460E500ADEE24 /* SpriteMoople.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpriteMoople.swift; sourceTree = ""; }; - 82F9D3302BFE3A9F009EDFAF /* HistoryGameDetail.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryGameDetail.swift; sourceTree = ""; }; - 82F9D3322BFE3B12009EDFAF /* HistoryHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryHeader.swift; sourceTree = ""; }; - 82F9D3352BFE3B3C009EDFAF /* HistoryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryView.swift; sourceTree = ""; }; C20310D52BFCB5FB0031657D /* PickerComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PickerComponent.swift; sourceTree = ""; }; C20310D72BFCC2410031657D /* GeneralParametersMenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeneralParametersMenuView.swift; sourceTree = ""; }; C20310D92BFCC8600031657D /* ToggleComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToggleComponent.swift; sourceTree = ""; }; @@ -111,6 +117,23 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 1607D9C82C09CF4C000AB3F2 /* PartyEnregistery */ = { + isa = PBXGroup; + children = ( + 1607D9C92C09CF4C000AB3F2 /* Stub.swift */, + 1607D9CA2C09CF4C000AB3F2 /* PartyEnregistery.swift */, + ); + path = PartyEnregistery; + sourceTree = ""; + }; + 168CD4FD2C06264300419510 /* Utils */ = { + isa = PBXGroup; + children = ( + 168CD4FE2C06265B00419510 /* LanguageSettings.swift */, + ); + path = Utils; + sourceTree = ""; + }; 8203E9052BF60117005F5C4A /* Frameworks */ = { isa = PBXGroup; children = ( @@ -136,19 +159,11 @@ path = SKNodes; sourceTree = ""; }; - 82F9D32F2BFE3A75009EDFAF /* History */ = { - isa = PBXGroup; - children = ( - 82F9D3302BFE3A9F009EDFAF /* HistoryGameDetail.swift */, - 82F9D3322BFE3B12009EDFAF /* HistoryHeader.swift */, - 82F9D3352BFE3B3C009EDFAF /* HistoryView.swift */, - ); - path = History; - sourceTree = ""; - }; C205A2AA2BF373360097BD93 = { isa = PBXGroup; children = ( + 168CD4FA2C0625A400419510 /* en.lproj */, + 168CD4F92C0625A400419510 /* fr.lproj */, C205A2B52BF373360097BD93 /* ArkitDoushiQi */, C205A2C62BF373380097BD93 /* ArkitDoushiQiTests */, C205A2D02BF373380097BD93 /* ArkitDoushiQiUITests */, @@ -170,6 +185,7 @@ C205A2B52BF373360097BD93 /* ArkitDoushiQi */ = { isa = PBXGroup; children = ( + 168CD4FD2C06264300419510 /* Utils */, 82CE59E52C045C7500ADEE24 /* Game */, C205A2B62BF373360097BD93 /* ArkitDoushiQiApp.swift */, C205A2B82BF373360097BD93 /* ContentView.swift */, @@ -182,13 +198,16 @@ C205A2BC2BF373380097BD93 /* Views */ = { isa = PBXGroup; children = ( +<<<<<<< HEAD C2F015022C09BC56000F7221 /* EventTriggers */, +======= + 1607D9C82C09CF4C000AB3F2 /* PartyEnregistery */, +>>>>>>> 40ae735863a246c32eefd036739aa3e93055aaf4 C24DAB5A2C061DAA00681CD0 /* Enum */, C25220F02C00AD7F0026B71F /* Components */, C25220EC2C00AC530026B71F /* GameParametersMenu */, C25220EB2C00A9230026B71F /* GeneralParametersMenu */, C25220EA2C00A9010026B71F /* MainMenu */, - 82F9D32F2BFE3A75009EDFAF /* History */, C205A2BD2BF373380097BD93 /* Preview Assets.xcassets */, ); path = Views; @@ -277,6 +296,7 @@ C2F394092C04636C0070B4F6 /* Visuals */ = { isa = PBXGroup; children = ( + 1607D9CD2C09CFD3000AB3F2 /* ItemCollectionParty.swift */, C2F3940A2C0463940070B4F6 /* ProfileComponent.swift */, C24DAB612C062DBC00681CD0 /* ProfileEdit.swift */, ); @@ -369,6 +389,7 @@ knownRegions = ( en, Base, + fr, ); mainGroup = C205A2AA2BF373360097BD93; productRefGroup = C205A2B42BF373360097BD93 /* Products */; @@ -387,7 +408,9 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 168CD4FC2C0625A400419510 /* en.lproj in Resources */, C205A2BE2BF373380097BD93 /* Preview Assets.xcassets in Resources */, + 168CD4FB2C0625A400419510 /* fr.lproj in Resources */, C205A2BB2BF373380097BD93 /* Assets.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -416,25 +439,37 @@ C205A2B92BF373360097BD93 /* ContentView.swift in Sources */, 82CE59EF2C0460E500ADEE24 /* SpriteMoople.swift in Sources */, 82CE59E92C045D1100ADEE24 /* GameScene.swift in Sources */, +<<<<<<< HEAD C2F015062C09C384000F7221 /* EditImageComponent.swift in Sources */, 82F9D3312BFE3A9F009EDFAF /* HistoryGameDetail.swift in Sources */, +======= +>>>>>>> 40ae735863a246c32eefd036739aa3e93055aaf4 C24659E92BF60FAA004E80D5 /* ButtonComponent.swift in Sources */, C24DAB5E2C061E3A00681CD0 /* Language.swift in Sources */, C2F394082C0462400070B4F6 /* PhotoButtonComponent.swift in Sources */, C24659E52BF5FE09004E80D5 /* MainMenu.swift in Sources */, - 82F9D3362BFE3B3C009EDFAF /* HistoryView.swift in Sources */, C20310D82BFCC2410031657D /* GeneralParametersMenuView.swift in Sources */, + 168CD4FF2C06265B00419510 /* LanguageSettings.swift in Sources */, C2F3940B2C0463940070B4F6 /* ProfileComponent.swift in Sources */, C2F015042C09BC6B000F7221 /* KeyboardReadable.swift in Sources */, C205A2B72BF373360097BD93 /* ArkitDoushiQiApp.swift in Sources */, + 1607D9CE2C09CFD3000AB3F2 /* ItemCollectionParty.swift in Sources */, C24DAB5C2C061DC700681CD0 /* AI.swift in Sources */, +<<<<<<< HEAD C25220F32C00AF490026B71F /* EditTextComponent.swift in Sources */, +======= + C25220F32C00AF490026B71F /* EditComponent.swift in Sources */, + 1607D9CB2C09CF4C000AB3F2 /* Stub.swift in Sources */, +>>>>>>> 40ae735863a246c32eefd036739aa3e93055aaf4 C20310D62BFCB5FB0031657D /* PickerComponent.swift in Sources */, - 82F9D3332BFE3B12009EDFAF /* HistoryHeader.swift in Sources */, 82CE59EB2C045E3800ADEE24 /* GameView.swift in Sources */, C20310DA2BFCC8600031657D /* ToggleComponent.swift in Sources */, C25220EE2C00AC7E0026B71F /* GameParametersMenuView.swift in Sources */, +<<<<<<< HEAD C24DAB622C062DBC00681CD0 /* ProfileEdit.swift in Sources */, +======= + 1607D9CC2C09CF4C000AB3F2 /* PartyEnregistery.swift in Sources */, +>>>>>>> 40ae735863a246c32eefd036739aa3e93055aaf4 ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/ArkitDoushiQi/ArkitDoushiQi.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ArkitDoushiQi/ArkitDoushiQi.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 2af9153..0000000 --- a/ArkitDoushiQi/ArkitDoushiQi.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/ArkitDoushiQi/ArkitDoushiQi.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ArkitDoushiQi/ArkitDoushiQi.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d9810..0000000 --- a/ArkitDoushiQi/ArkitDoushiQi.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/ArkitDoushiQi/ArkitDoushiQi.xcodeproj/project.xcworkspace/xcuserdata/lodufour1.xcuserdatad/UserInterfaceState.xcuserstate b/ArkitDoushiQi/ArkitDoushiQi.xcodeproj/project.xcworkspace/xcuserdata/lodufour1.xcuserdatad/UserInterfaceState.xcuserstate deleted file mode 100644 index 6f0d563..0000000 Binary files a/ArkitDoushiQi/ArkitDoushiQi.xcodeproj/project.xcworkspace/xcuserdata/lodufour1.xcuserdatad/UserInterfaceState.xcuserstate and /dev/null differ diff --git a/ArkitDoushiQi/ArkitDoushiQi.xcodeproj/xcuserdata/lodufour1.xcuserdatad/xcschemes/xcschememanagement.plist b/ArkitDoushiQi/ArkitDoushiQi.xcodeproj/xcuserdata/lodufour1.xcuserdatad/xcschemes/xcschememanagement.plist deleted file mode 100644 index 4577990..0000000 --- a/ArkitDoushiQi/ArkitDoushiQi.xcodeproj/xcuserdata/lodufour1.xcuserdatad/xcschemes/xcschememanagement.plist +++ /dev/null @@ -1,14 +0,0 @@ - - - - - SchemeUserState - - ArkitDoushiQi.xcscheme_^#shared#^_ - - orderHint - 0 - - - - diff --git a/ArkitDoushiQi/ArkitDoushiQi/.DS_Store b/ArkitDoushiQi/ArkitDoushiQi/.DS_Store deleted file mode 100644 index e4f19dd..0000000 Binary files a/ArkitDoushiQi/ArkitDoushiQi/.DS_Store and /dev/null differ diff --git a/ArkitDoushiQi/ArkitDoushiQi/ArkitDoushiQiApp.swift b/ArkitDoushiQi/ArkitDoushiQi/ArkitDoushiQiApp.swift index cfe6191..8790ce7 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/ArkitDoushiQiApp.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/ArkitDoushiQiApp.swift @@ -17,10 +17,16 @@ enum Theme { struct ArkitDoushiQiApp: App { @AppStorage("isDarkMode") private var isDarkMode = false - var body: some Scene { - WindowGroup { - MainMenu(playButtonText: "Jouer", registeredGamesButtonText: "Parties enregistrées",ParametersButtontText: "Paramètres") - .preferredColorScheme(isDarkMode ? .dark : .light) - } - } + + @StateObject private var languageSettings = LanguageSettings(selectedLanguage: .English) + var body: some Scene { + WindowGroup { + MainMenu( + playButtonText: "Play", + registeredGamesButtonText: "Registered Games", + parametersButtonText: "Parameters" + ) + .environmentObject(languageSettings) + } + } } diff --git a/ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/images/Perceval.imageset/Contents.json b/ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/images/Perceval.imageset/Contents.json new file mode 100644 index 0000000..ec55e48 --- /dev/null +++ b/ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/images/Perceval.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "Perceval.jpg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/images/Perceval.imageset/Perceval.jpg b/ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/images/Perceval.imageset/Perceval.jpg new file mode 100644 index 0000000..e36f1f9 Binary files /dev/null and b/ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/images/Perceval.imageset/Perceval.jpg differ diff --git a/ArkitDoushiQi/ArkitDoushiQi/Utils/LanguageSettings.swift b/ArkitDoushiQi/ArkitDoushiQi/Utils/LanguageSettings.swift new file mode 100644 index 0000000..ed07eaa --- /dev/null +++ b/ArkitDoushiQi/ArkitDoushiQi/Utils/LanguageSettings.swift @@ -0,0 +1,27 @@ +// +// LanguageSettings.swift +// ArkitDoushiQi +// +// Created by Louis DUFOUR on 28/05/2024. +// + +import Foundation + +class LanguageSettings: ObservableObject { + @Published var selectedLanguage: Language { + didSet { + UserDefaults.standard.set([selectedLanguage.localeIdentifier], forKey: "AppleLanguages") + UserDefaults.standard.synchronize() + NotificationCenter.default.post(name: NSNotification.Name("LanguageChanged"), object: nil) + } + } + + init(selectedLanguage: Language) { + self.selectedLanguage = selectedLanguage + UserDefaults.standard.set([selectedLanguage.localeIdentifier], forKey: "AppleLanguages") + } + + func changeLanguage(to newLanguage: Language) { + selectedLanguage = newLanguage + } +} diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/PickerComponent.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/PickerComponent.swift index bd252de..94d431f 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/PickerComponent.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/PickerComponent.swift @@ -8,11 +8,11 @@ import SwiftUI struct PickerComponent: View where EnumType.RawValue == String { - let title: String + let title: LocalizedStringKey @Binding var selectedOption: EnumType let options: [EnumType] - init(title: String, selectedOption: Binding, options: [EnumType]) { + init(title: LocalizedStringKey, selectedOption: Binding, options: [EnumType]) { self.title = title self._selectedOption = selectedOption self.options = options @@ -25,7 +25,8 @@ struct PickerComponent: Vi Picker(title, selection: $selectedOption) { ForEach(options) { option in Text(option.rawValue.description) - .padding() + .tag(option) + .padding() } } .labelsHidden() @@ -49,16 +50,12 @@ struct PickerComponent: Vi } struct PickerComponent_Previews: PreviewProvider { - @State static var selectedItem = AI.RandomAction + @State static var selectedItem = Language.English static var previews: some View { PickerComponent( - title: "Selectionne une IA :", + title: "Select Language:", selectedOption: $selectedItem, - options: AI.allCases - ) + options: Language.allCases + ) } } - - - - diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/ToggleComponent.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/ToggleComponent.swift index 0be4fe5..a77e99f 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/ToggleComponent.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/ToggleComponent.swift @@ -8,29 +8,29 @@ import SwiftUI struct ToggleComponent: View { - let description: String - let booleanName : String - @AppStorage private var boolean : Bool + let description: LocalizedStringKey + let booleanName: String + @AppStorage private var boolean: Bool - init(description: String, booleanName: String, booleanDefaultValue: Bool) { + init(description: LocalizedStringKey, booleanName: String, booleanDefaultValue: Bool) { self.description = description self.booleanName = booleanName _boolean = AppStorage(wrappedValue: booleanDefaultValue, booleanName) } var body: some View { - Divider().background(Color.gray).padding(.vertical, 1) - Toggle(description, isOn: $boolean) - .toggleStyle(SwitchToggleStyle(tint: .blue)) - .padding(EdgeInsets(top: 0, leading: 48, bottom: 0, trailing: 48)) + Divider().background(Color.gray).padding(.vertical, 1) + Toggle(description, isOn: $boolean) + .toggleStyle(SwitchToggleStyle(tint: .blue)) + .padding(EdgeInsets(top: 0, leading: 48, bottom: 0, trailing: 48)) Divider().background(Color.gray).padding(.vertical, 1) } } struct ToggleComponent_Previews: PreviewProvider { static var previews: some View { - VStack{ - ToggleComponent(description: "Dark mode", booleanName: "isDarkMode", booleanDefaultValue: false) + VStack { + ToggleComponent(description: LocalizedStringKey("Dark mode"), booleanName: "isDarkMode", booleanDefaultValue: false) } } } diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Visuals/ItemCollectionParty.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Visuals/ItemCollectionParty.swift new file mode 100644 index 0000000..997236b --- /dev/null +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Visuals/ItemCollectionParty.swift @@ -0,0 +1,92 @@ +// +// ItemCollectionParty.swift +// ArkitDoushiQi +// +// Created by Louis DUFOUR on 31/05/2024. +// + +import SwiftUI + +struct ItemCollectionParty: View { + var party: Party + + var body: some View { + VStack { + HStack { + Text(party.date) + .font(.headline) + .foregroundColor(.gray) + Spacer() + } + .padding(.bottom, 5) + + GeometryReader { geometry in + HStack(spacing: 10) { + HStack { + Image(party.player1Image) + .resizable() + .aspectRatio(contentMode: .fill) + .frame(width: geometry.size.width * 0.15, height: geometry.size.width * 0.15) + .clipShape(Circle()) + .overlay(Circle().stroke(Color.purple, lineWidth: 2)) + + VStack(alignment: .leading) { + Text(party.player1Name) + .fontWeight(.bold) + .foregroundColor(.purple) + .lineLimit(1) + .minimumScaleFactor(0.5) + .frame(maxWidth: geometry.size.width * 0.25, alignment: .leading) + + Text("\(party.player1Score)") + .font(.largeTitle) + .fontWeight(.bold) + .foregroundColor(.green) // Gagnant en vert + } + } + + Text("vs") + .font(.headline) + .foregroundColor(.gray) + + HStack { + VStack(alignment: .trailing) { + Text(party.player2Name) + .fontWeight(.bold) + .foregroundColor(.purple) + .lineLimit(1) + .minimumScaleFactor(0.5) + .frame(maxWidth: geometry.size.width * 0.25, alignment: .trailing) + + Text("\(party.player2Score)") + .font(.largeTitle) + .fontWeight(.bold) + .foregroundColor(.red) // Perdant en rouge + } + + Image(party.player2Image) + .resizable() + .aspectRatio(contentMode: .fill) + .frame(width: geometry.size.width * 0.15, height: geometry.size.width * 0.15) + .clipShape(Circle()) + .overlay(Circle().stroke(Color.purple, lineWidth: 2)) + } + } + .padding() + .background(Color.white) + .cornerRadius(15) + .shadow(radius: 3) // Réduction de l'ombre pour un effet plus léger + } + .frame(height: 120) // Ajustez la hauteur en fonction de votre contenu + } + .padding(.horizontal) + } +} + +struct ItemCollectionParty_Previews: PreviewProvider { + static var previews: some View { + ItemCollectionParty(party: Party(player1Name: "L'invaincu du samedi", player1Score: 2, player1Image: "Perceval", player2Name: "Le gars du dimanche", player2Score: 1, player2Image: "Perceval", date: "Samedi soir")) + .previewLayout(.sizeThatFits) + .padding() + } +} diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/Enum/Language.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/Enum/Language.swift index 91b1a95..104b667 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/Enum/Language.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/Enum/Language.swift @@ -7,8 +7,19 @@ import Foundation -enum Language: String, CaseIterable, Identifiable, Hashable { - case French = "Français" - case English = "English" +enum Language: String, CaseIterable, Identifiable { + case English = "en" + case French = "fr" + var id: String { self.rawValue } + var localeIdentifier: String { self.rawValue } + + var description: String { + switch self { + case .English: + return "English" + case .French: + return "Français" + } + } } diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/GeneralParametersMenu/GeneralParametersMenuView.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/GeneralParametersMenu/GeneralParametersMenuView.swift index c24760a..1a0862c 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/GeneralParametersMenu/GeneralParametersMenuView.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/GeneralParametersMenu/GeneralParametersMenuView.swift @@ -8,52 +8,46 @@ import SwiftUI struct GeneralParametersMenuView: View { + @EnvironmentObject var languageSettings: LanguageSettings @State private var selectedAIOption: AI - @State private var selectedLanguageOption: Language @State private var selectedRulesOption: Rules - let ParametersTitle : String - let DarkModeDescription : String - let DarModeBooleanName : String - let DarkModeDefaultValue : Bool - let LanguagePickerTitle : String - - init(parametersTitle: String,selectedAIOption: AI, selectedLanguageOption: Language, selectedRulesOption: Rules, DarkModeDescription: String, DarModeBooleanName: String, DarkModeDefaultValue: Bool, LanguagePickerTitle: String) { - self.ParametersTitle = parametersTitle - self.selectedAIOption = selectedAIOption - self.selectedLanguageOption = selectedLanguageOption - self.selectedRulesOption = selectedRulesOption - self.DarkModeDescription = DarkModeDescription - self.DarModeBooleanName = DarModeBooleanName - self.DarkModeDefaultValue = DarkModeDefaultValue - self.LanguagePickerTitle = LanguagePickerTitle + + let parametersTitle = LocalizedStringKey("ParametersTitle") + let darkModeDescription = LocalizedStringKey("DarkModeDescription") + let darkModeBooleanName: String = "isDarkMode" + let darkModeDefaultValue: Bool = false + let languagePickerTitle = LocalizedStringKey("LanguagePickerTitle") + + init(selectedAIOption: AI, selectedRulesOption: Rules) { + self._selectedAIOption = State(initialValue: selectedAIOption) + self._selectedRulesOption = State(initialValue: selectedRulesOption) } - + var body: some View { VStack(alignment: .leading) { HStack(alignment: .center) { - Text(ParametersTitle).bold().font(.title) + Text(parametersTitle).bold().font(.title) }.frame(maxWidth: .infinity) Spacer().frame(maxHeight: 30) - ToggleComponent(description: "Dark mode", booleanName: "isDarkMode", booleanDefaultValue: false) - PickerComponent(title: "Sélectionne un langage :", - selectedOption: $selectedLanguageOption, - options: Language.allCases) - - }.frame(maxHeight: .infinity, alignment: .top) + ToggleComponent(description: darkModeDescription, booleanName: darkModeBooleanName, booleanDefaultValue: darkModeDefaultValue) + PickerComponent(title: languagePickerTitle, + selectedOption: $languageSettings.selectedLanguage, + options: Language.allCases) + .onChange(of: languageSettings.selectedLanguage) { newLanguage in + languageSettings.changeLanguage(to: newLanguage) + } + } + .frame(maxHeight: .infinity, alignment: .top) } } struct GeneralParametersMenuView_Previews: PreviewProvider { static var previews: some View { + let languageSettings = LanguageSettings(selectedLanguage: .French) GeneralParametersMenuView( - parametersTitle: "Paramètres", selectedAIOption: .RandomAction, - selectedLanguageOption: .French, - selectedRulesOption: .Regular, - DarkModeDescription: "Dark Mode", - DarModeBooleanName: "isDarkMode", - DarkModeDefaultValue: false, - LanguagePickerTitle: "Séléctionne un langage" + selectedRulesOption: .Regular ) + .environmentObject(languageSettings) } } diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/History/HistoryGameDetail.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/History/HistoryGameDetail.swift deleted file mode 100644 index 164f0a0..0000000 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/History/HistoryGameDetail.swift +++ /dev/null @@ -1,33 +0,0 @@ -// -// DetailGameHistory.swift -// ArkitDoushiQi -// -// Created by Enzo JOLYS on 22/05/2024. -// - -import SwiftUI -import DouShouQiModel - -struct HistoryGameDetail: View { - - let game:Game - - var body: some View { - ZStack(){ - Color.red - Color.gray - HStack(){ - Text(game.players[.player1]?.name ?? "Inconnu") - Text(" VS ") - Text(game.players[.player2]?.name ?? "Inconnu") - Spacer() - } - } - } -} - -struct HistoryGameDetail_Previews: PreviewProvider { - static var previews: some View { - HistoryGameDetail(game: try! Game(withRules: VerySimpleRules(), andPlayer1: Player(withName: "Joueur 1 ", andId: .player1)!, andPlayer2: Player(withName: "Joueur 2 ", andId: .player2)!)) - } -} diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/History/HistoryHeader.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/History/HistoryHeader.swift deleted file mode 100644 index 14ca3f2..0000000 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/History/HistoryHeader.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// EnteteHistory.swift -// ArkitDoushiQi -// -// Created by Enzo JOLYS on 22/05/2024. -// - -import SwiftUI - -struct HistoryHeader: View { - var body: some View { - HStack(){ - Spacer() - Text("Historique !") - Spacer() - } - } -} - -struct HistoryHeader_Previews: PreviewProvider { - static var previews: some View { - HistoryHeader() - } -} diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/History/HistoryView.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/History/HistoryView.swift deleted file mode 100644 index 1b5363c..0000000 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/History/HistoryView.swift +++ /dev/null @@ -1,31 +0,0 @@ -// -// History.swift -// ArkitDoushiQi -// -// Created by Enzo JOLYS on 22/05/2024. -// - -import SwiftUI -import DouShouQiModel - -struct HistoryView: View { - - var listGame:[Game] = try! [Game(withRules: VerySimpleRules(), andPlayer1: Player(withName: "Player 1 ", andId: .player1)!, andPlayer2: Player(withName: "Player 2 ", andId: .player2)!)] - - var body: some View { - VStack(){ - HistoryHeader() - NavigationStack { - List(listGame, id: \.board){ game in - HistoryGameDetail(game: game) - } - } - } - } -} - -struct HistoryView_Previews: PreviewProvider { - static var previews: some View { - HistoryView() - } -} diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/MainMenu/MainMenu.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/MainMenu/MainMenu.swift index 2d6ff90..0f7ce70 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/MainMenu/MainMenu.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/MainMenu/MainMenu.swift @@ -8,11 +8,14 @@ import SwiftUI struct MainMenu: View { - let playButtonText : String - let registeredGamesButtonText : String - let ParametersButtontText : String + @EnvironmentObject var languageSettings: LanguageSettings + let playButtonText: String + let registeredGamesButtonText: String + let parametersButtonText: String @State private var action: Int? = 0 @AppStorage("isDarkMode") private var isDarkMode = false + @State private var reloadView = false // Déclarer reloadView ici + var body: some View { ZStack { NavigationView { @@ -29,30 +32,30 @@ struct MainMenu: View { { GameParametersMenuView() } Spacer().frame(height: 30) ButtonComponent(title: registeredGamesButtonText) - { Text("parties enregistrées page") } + { PartyListView() } Spacer().frame(height: 30) - ButtonComponent(title: ParametersButtontText) + ButtonComponent(title: parametersButtonText) { GeneralParametersMenuView( - parametersTitle: "Paramètres", selectedAIOption: .RandomAction, - selectedLanguageOption: .French, - selectedRulesOption: .Regular, - DarkModeDescription: "Dark Mode", - DarModeBooleanName: "isDarkMode", - DarkModeDefaultValue: false, - LanguagePickerTitle: "Séléctionne un langage" - ) } + selectedRulesOption: .Regular + ).id(reloadView) // Utilisez l'ID pour forcer le rechargement de la vue } - Spacer() } - .padding(EdgeInsets(top: 10, leading: 32, bottom: 10, trailing: 32)) + Spacer() } + .padding(EdgeInsets(top: 10, leading: 32, bottom: 10, trailing: 32)) + } + .environmentObject(languageSettings) + .onReceive(NotificationCenter.default.publisher(for: NSNotification.Name("LanguageChanged"))) { _ in + self.reloadView.toggle() // Changez la valeur pour forcer le rechargement } + } } } struct MainMenu_Previews: PreviewProvider { static var previews: some View { - MainMenu(playButtonText: "Jouer", registeredGamesButtonText: "Parties enregistrées",ParametersButtontText: "Paramètres") + MainMenu(playButtonText: "Jouer", registeredGamesButtonText: "Parties enregistrées", parametersButtonText: "Paramètres") + .environmentObject(LanguageSettings(selectedLanguage: .French)) } } diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/PartyEnregistery/PartyEnregistery.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/PartyEnregistery/PartyEnregistery.swift new file mode 100644 index 0000000..f459540 --- /dev/null +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/PartyEnregistery/PartyEnregistery.swift @@ -0,0 +1,34 @@ +// +// PartyEnregistery.swift +// ArkitDoushiQi +// +// Created by Louis DUFOUR on 31/05/2024. +// + +import SwiftUI + +import SwiftUI + +struct PartyListView: View { + let parties: [Party] = [ + Party(player1Name: "L'invaincu du samedi", player1Score: 2, player1Image: "Perceval", player2Name: "Le gars du dimanche", player2Score: 1, player2Image: "Perceval", date: "Samedi soir"), + Party(player1Name: "Le champion du vendredi", player1Score: 3, player1Image: "Perceval", player2Name: "Le perdant du lundi", player2Score: 0, player2Image: "Perceval", date: "Vendredi soir") + // Ajoutez plus de parties ici + ] + + var body: some View { + NavigationView { + List(parties) { party in + ItemCollectionParty(party: party) + .padding(.vertical, 5) + } + .navigationTitle("Liste des Parties") + } + } +} + +struct PartyListView_Previews: PreviewProvider { + static var previews: some View { + PartyListView() + } +} diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/PartyEnregistery/Stub.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/PartyEnregistery/Stub.swift new file mode 100644 index 0000000..08bac26 --- /dev/null +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/PartyEnregistery/Stub.swift @@ -0,0 +1,19 @@ +// +// Stub.swift +// ArkitDoushiQi +// +// Created by Louis DUFOUR on 31/05/2024. +// + +import SwiftUI + +struct Party: Identifiable { + let id = UUID() + let player1Name: String + let player1Score: Int + let player1Image: String + let player2Name: String + let player2Score: Int + let player2Image: String + let date: String +} diff --git a/ArkitDoushiQi/en.lproj/Localizable.strings b/ArkitDoushiQi/en.lproj/Localizable.strings new file mode 100644 index 0000000..86edfa0 --- /dev/null +++ b/ArkitDoushiQi/en.lproj/Localizable.strings @@ -0,0 +1,11 @@ +/* + Localizable.strings + ArkitDoushiQi + + Created by Louis DUFOUR on 28/05/2024. + +*/ + +"ParametersTitle" = "Parameters"; +"DarkModeDescription" = "Dark Mode"; +"LanguagePickerTitle" = "Language"; diff --git a/ArkitDoushiQi/fr.lproj/Localizable.strings b/ArkitDoushiQi/fr.lproj/Localizable.strings new file mode 100644 index 0000000..e309b3b --- /dev/null +++ b/ArkitDoushiQi/fr.lproj/Localizable.strings @@ -0,0 +1,11 @@ +/* + Localizable.strings + ArkitDoushiQi + + Created by Louis DUFOUR on 28/05/2024. + +*/ + +"ParametersTitle" = "Paramètres"; +"DarkModeDescription" = "Mode sombre"; +"LanguagePickerTitle" = "Langue";