Merge branch 'dev' of https://codefirst.iut.uca.fr/git/Binome/Swift_Ark into ComponentWithVariable

pull/22/head
Johan LACHENAL 11 months ago
commit 25c4b5abe3

Binary file not shown.

@ -117,3 +117,23 @@ fastlane/test_output
# https://github.com/johnno1962/injectionforxcode # https://github.com/johnno1962/injectionforxcode
iOSInjectionProject/ 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

@ -7,12 +7,15 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* 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 */; }; 82CE59E92C045D1100ADEE24 /* GameScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82CE59E82C045D1100ADEE24 /* GameScene.swift */; };
82CE59EB2C045E3800ADEE24 /* GameView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82CE59EA2C045E3800ADEE24 /* GameView.swift */; }; 82CE59EB2C045E3800ADEE24 /* GameView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82CE59EA2C045E3800ADEE24 /* GameView.swift */; };
82CE59EF2C0460E500ADEE24 /* SpriteMoople.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82CE59EE2C0460E500ADEE24 /* SpriteMoople.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 */; }; C20310D62BFCB5FB0031657D /* PickerComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = C20310D52BFCB5FB0031657D /* PickerComponent.swift */; };
C20310D82BFCC2410031657D /* GeneralParametersMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C20310D72BFCC2410031657D /* GeneralParametersMenuView.swift */; }; C20310D82BFCC2410031657D /* GeneralParametersMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C20310D72BFCC2410031657D /* GeneralParametersMenuView.swift */; };
C20310DA2BFCC8600031657D /* ToggleComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = C20310D92BFCC8600031657D /* ToggleComponent.swift */; }; C20310DA2BFCC8600031657D /* ToggleComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = C20310D92BFCC8600031657D /* ToggleComponent.swift */; };
@ -54,12 +57,15 @@
/* End PBXContainerItemProxy section */ /* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
1607D9C92C09CF4C000AB3F2 /* Stub.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Stub.swift; sourceTree = "<group>"; };
1607D9CA2C09CF4C000AB3F2 /* PartyEnregistery.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PartyEnregistery.swift; sourceTree = "<group>"; };
1607D9CD2C09CFD3000AB3F2 /* ItemCollectionParty.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ItemCollectionParty.swift; sourceTree = "<group>"; };
168CD4F92C0625A400419510 /* fr.lproj */ = {isa = PBXFileReference; lastKnownFileType = folder; path = fr.lproj; sourceTree = "<group>"; };
168CD4FA2C0625A400419510 /* en.lproj */ = {isa = PBXFileReference; lastKnownFileType = folder; path = en.lproj; sourceTree = "<group>"; };
168CD4FE2C06265B00419510 /* LanguageSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LanguageSettings.swift; sourceTree = "<group>"; };
82CE59E82C045D1100ADEE24 /* GameScene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameScene.swift; sourceTree = "<group>"; }; 82CE59E82C045D1100ADEE24 /* GameScene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameScene.swift; sourceTree = "<group>"; };
82CE59EA2C045E3800ADEE24 /* GameView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameView.swift; sourceTree = "<group>"; }; 82CE59EA2C045E3800ADEE24 /* GameView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameView.swift; sourceTree = "<group>"; };
82CE59EE2C0460E500ADEE24 /* SpriteMoople.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpriteMoople.swift; sourceTree = "<group>"; }; 82CE59EE2C0460E500ADEE24 /* SpriteMoople.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpriteMoople.swift; sourceTree = "<group>"; };
82F9D3302BFE3A9F009EDFAF /* HistoryGameDetail.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryGameDetail.swift; sourceTree = "<group>"; };
82F9D3322BFE3B12009EDFAF /* HistoryHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryHeader.swift; sourceTree = "<group>"; };
82F9D3352BFE3B3C009EDFAF /* HistoryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryView.swift; sourceTree = "<group>"; };
C20310D52BFCB5FB0031657D /* PickerComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PickerComponent.swift; sourceTree = "<group>"; }; C20310D52BFCB5FB0031657D /* PickerComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PickerComponent.swift; sourceTree = "<group>"; };
C20310D72BFCC2410031657D /* GeneralParametersMenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeneralParametersMenuView.swift; sourceTree = "<group>"; }; C20310D72BFCC2410031657D /* GeneralParametersMenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeneralParametersMenuView.swift; sourceTree = "<group>"; };
C20310D92BFCC8600031657D /* ToggleComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToggleComponent.swift; sourceTree = "<group>"; }; C20310D92BFCC8600031657D /* ToggleComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToggleComponent.swift; sourceTree = "<group>"; };
@ -111,6 +117,23 @@
/* End PBXFrameworksBuildPhase section */ /* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */ /* Begin PBXGroup section */
1607D9C82C09CF4C000AB3F2 /* PartyEnregistery */ = {
isa = PBXGroup;
children = (
1607D9C92C09CF4C000AB3F2 /* Stub.swift */,
1607D9CA2C09CF4C000AB3F2 /* PartyEnregistery.swift */,
);
path = PartyEnregistery;
sourceTree = "<group>";
};
168CD4FD2C06264300419510 /* Utils */ = {
isa = PBXGroup;
children = (
168CD4FE2C06265B00419510 /* LanguageSettings.swift */,
);
path = Utils;
sourceTree = "<group>";
};
8203E9052BF60117005F5C4A /* Frameworks */ = { 8203E9052BF60117005F5C4A /* Frameworks */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@ -136,19 +159,11 @@
path = SKNodes; path = SKNodes;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
82F9D32F2BFE3A75009EDFAF /* History */ = {
isa = PBXGroup;
children = (
82F9D3302BFE3A9F009EDFAF /* HistoryGameDetail.swift */,
82F9D3322BFE3B12009EDFAF /* HistoryHeader.swift */,
82F9D3352BFE3B3C009EDFAF /* HistoryView.swift */,
);
path = History;
sourceTree = "<group>";
};
C205A2AA2BF373360097BD93 = { C205A2AA2BF373360097BD93 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
168CD4FA2C0625A400419510 /* en.lproj */,
168CD4F92C0625A400419510 /* fr.lproj */,
C205A2B52BF373360097BD93 /* ArkitDoushiQi */, C205A2B52BF373360097BD93 /* ArkitDoushiQi */,
C205A2C62BF373380097BD93 /* ArkitDoushiQiTests */, C205A2C62BF373380097BD93 /* ArkitDoushiQiTests */,
C205A2D02BF373380097BD93 /* ArkitDoushiQiUITests */, C205A2D02BF373380097BD93 /* ArkitDoushiQiUITests */,
@ -170,6 +185,7 @@
C205A2B52BF373360097BD93 /* ArkitDoushiQi */ = { C205A2B52BF373360097BD93 /* ArkitDoushiQi */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
168CD4FD2C06264300419510 /* Utils */,
82CE59E52C045C7500ADEE24 /* Game */, 82CE59E52C045C7500ADEE24 /* Game */,
C205A2B62BF373360097BD93 /* ArkitDoushiQiApp.swift */, C205A2B62BF373360097BD93 /* ArkitDoushiQiApp.swift */,
C205A2B82BF373360097BD93 /* ContentView.swift */, C205A2B82BF373360097BD93 /* ContentView.swift */,
@ -182,13 +198,16 @@
C205A2BC2BF373380097BD93 /* Views */ = { C205A2BC2BF373380097BD93 /* Views */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
<<<<<<< HEAD
C2F015022C09BC56000F7221 /* EventTriggers */, C2F015022C09BC56000F7221 /* EventTriggers */,
=======
1607D9C82C09CF4C000AB3F2 /* PartyEnregistery */,
>>>>>>> 40ae735863a246c32eefd036739aa3e93055aaf4
C24DAB5A2C061DAA00681CD0 /* Enum */, C24DAB5A2C061DAA00681CD0 /* Enum */,
C25220F02C00AD7F0026B71F /* Components */, C25220F02C00AD7F0026B71F /* Components */,
C25220EC2C00AC530026B71F /* GameParametersMenu */, C25220EC2C00AC530026B71F /* GameParametersMenu */,
C25220EB2C00A9230026B71F /* GeneralParametersMenu */, C25220EB2C00A9230026B71F /* GeneralParametersMenu */,
C25220EA2C00A9010026B71F /* MainMenu */, C25220EA2C00A9010026B71F /* MainMenu */,
82F9D32F2BFE3A75009EDFAF /* History */,
C205A2BD2BF373380097BD93 /* Preview Assets.xcassets */, C205A2BD2BF373380097BD93 /* Preview Assets.xcassets */,
); );
path = Views; path = Views;
@ -277,6 +296,7 @@
C2F394092C04636C0070B4F6 /* Visuals */ = { C2F394092C04636C0070B4F6 /* Visuals */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
1607D9CD2C09CFD3000AB3F2 /* ItemCollectionParty.swift */,
C2F3940A2C0463940070B4F6 /* ProfileComponent.swift */, C2F3940A2C0463940070B4F6 /* ProfileComponent.swift */,
C24DAB612C062DBC00681CD0 /* ProfileEdit.swift */, C24DAB612C062DBC00681CD0 /* ProfileEdit.swift */,
); );
@ -369,6 +389,7 @@
knownRegions = ( knownRegions = (
en, en,
Base, Base,
fr,
); );
mainGroup = C205A2AA2BF373360097BD93; mainGroup = C205A2AA2BF373360097BD93;
productRefGroup = C205A2B42BF373360097BD93 /* Products */; productRefGroup = C205A2B42BF373360097BD93 /* Products */;
@ -387,7 +408,9 @@
isa = PBXResourcesBuildPhase; isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
168CD4FC2C0625A400419510 /* en.lproj in Resources */,
C205A2BE2BF373380097BD93 /* Preview Assets.xcassets in Resources */, C205A2BE2BF373380097BD93 /* Preview Assets.xcassets in Resources */,
168CD4FB2C0625A400419510 /* fr.lproj in Resources */,
C205A2BB2BF373380097BD93 /* Assets.xcassets in Resources */, C205A2BB2BF373380097BD93 /* Assets.xcassets in Resources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
@ -416,25 +439,37 @@
C205A2B92BF373360097BD93 /* ContentView.swift in Sources */, C205A2B92BF373360097BD93 /* ContentView.swift in Sources */,
82CE59EF2C0460E500ADEE24 /* SpriteMoople.swift in Sources */, 82CE59EF2C0460E500ADEE24 /* SpriteMoople.swift in Sources */,
82CE59E92C045D1100ADEE24 /* GameScene.swift in Sources */, 82CE59E92C045D1100ADEE24 /* GameScene.swift in Sources */,
<<<<<<< HEAD
C2F015062C09C384000F7221 /* EditImageComponent.swift in Sources */, C2F015062C09C384000F7221 /* EditImageComponent.swift in Sources */,
82F9D3312BFE3A9F009EDFAF /* HistoryGameDetail.swift in Sources */, 82F9D3312BFE3A9F009EDFAF /* HistoryGameDetail.swift in Sources */,
=======
>>>>>>> 40ae735863a246c32eefd036739aa3e93055aaf4
C24659E92BF60FAA004E80D5 /* ButtonComponent.swift in Sources */, C24659E92BF60FAA004E80D5 /* ButtonComponent.swift in Sources */,
C24DAB5E2C061E3A00681CD0 /* Language.swift in Sources */, C24DAB5E2C061E3A00681CD0 /* Language.swift in Sources */,
C2F394082C0462400070B4F6 /* PhotoButtonComponent.swift in Sources */, C2F394082C0462400070B4F6 /* PhotoButtonComponent.swift in Sources */,
C24659E52BF5FE09004E80D5 /* MainMenu.swift in Sources */, C24659E52BF5FE09004E80D5 /* MainMenu.swift in Sources */,
82F9D3362BFE3B3C009EDFAF /* HistoryView.swift in Sources */,
C20310D82BFCC2410031657D /* GeneralParametersMenuView.swift in Sources */, C20310D82BFCC2410031657D /* GeneralParametersMenuView.swift in Sources */,
168CD4FF2C06265B00419510 /* LanguageSettings.swift in Sources */,
C2F3940B2C0463940070B4F6 /* ProfileComponent.swift in Sources */, C2F3940B2C0463940070B4F6 /* ProfileComponent.swift in Sources */,
C2F015042C09BC6B000F7221 /* KeyboardReadable.swift in Sources */, C2F015042C09BC6B000F7221 /* KeyboardReadable.swift in Sources */,
C205A2B72BF373360097BD93 /* ArkitDoushiQiApp.swift in Sources */, C205A2B72BF373360097BD93 /* ArkitDoushiQiApp.swift in Sources */,
1607D9CE2C09CFD3000AB3F2 /* ItemCollectionParty.swift in Sources */,
C24DAB5C2C061DC700681CD0 /* AI.swift in Sources */, C24DAB5C2C061DC700681CD0 /* AI.swift in Sources */,
<<<<<<< HEAD
C25220F32C00AF490026B71F /* EditTextComponent.swift in Sources */, C25220F32C00AF490026B71F /* EditTextComponent.swift in Sources */,
=======
C25220F32C00AF490026B71F /* EditComponent.swift in Sources */,
1607D9CB2C09CF4C000AB3F2 /* Stub.swift in Sources */,
>>>>>>> 40ae735863a246c32eefd036739aa3e93055aaf4
C20310D62BFCB5FB0031657D /* PickerComponent.swift in Sources */, C20310D62BFCB5FB0031657D /* PickerComponent.swift in Sources */,
82F9D3332BFE3B12009EDFAF /* HistoryHeader.swift in Sources */,
82CE59EB2C045E3800ADEE24 /* GameView.swift in Sources */, 82CE59EB2C045E3800ADEE24 /* GameView.swift in Sources */,
C20310DA2BFCC8600031657D /* ToggleComponent.swift in Sources */, C20310DA2BFCC8600031657D /* ToggleComponent.swift in Sources */,
C25220EE2C00AC7E0026B71F /* GameParametersMenuView.swift in Sources */, C25220EE2C00AC7E0026B71F /* GameParametersMenuView.swift in Sources */,
<<<<<<< HEAD
C24DAB622C062DBC00681CD0 /* ProfileEdit.swift in Sources */, C24DAB622C062DBC00681CD0 /* ProfileEdit.swift in Sources */,
=======
1607D9CC2C09CF4C000AB3F2 /* PartyEnregistery.swift in Sources */,
>>>>>>> 40ae735863a246c32eefd036739aa3e93055aaf4
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:/Users/jolachenal/Documents/Swift_Ark/WtaTennis/ArkitDoushiQi.xcodeproj">
</FileRef>
</Workspace>

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>ArkitDoushiQi.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>

Binary file not shown.

@ -17,10 +17,16 @@ enum Theme {
struct ArkitDoushiQiApp: App { struct ArkitDoushiQiApp: App {
@AppStorage("isDarkMode") private var isDarkMode = false @AppStorage("isDarkMode") private var isDarkMode = false
@StateObject private var languageSettings = LanguageSettings(selectedLanguage: .English)
var body: some Scene { var body: some Scene {
WindowGroup { WindowGroup {
MainMenu(playButtonText: "Jouer", registeredGamesButtonText: "Parties enregistrées",ParametersButtontText: "Paramètres") MainMenu(
.preferredColorScheme(isDarkMode ? .dark : .light) playButtonText: "Play",
registeredGamesButtonText: "Registered Games",
parametersButtonText: "Parameters"
)
.environmentObject(languageSettings)
} }
} }
} }

@ -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
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 KiB

@ -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
}
}

@ -8,11 +8,11 @@
import SwiftUI import SwiftUI
struct PickerComponent<EnumType: RawRepresentable & Identifiable & Hashable>: View where EnumType.RawValue == String { struct PickerComponent<EnumType: RawRepresentable & Identifiable & Hashable>: View where EnumType.RawValue == String {
let title: String let title: LocalizedStringKey
@Binding var selectedOption: EnumType @Binding var selectedOption: EnumType
let options: [EnumType] let options: [EnumType]
init(title: String, selectedOption: Binding<EnumType>, options: [EnumType]) { init(title: LocalizedStringKey, selectedOption: Binding<EnumType>, options: [EnumType]) {
self.title = title self.title = title
self._selectedOption = selectedOption self._selectedOption = selectedOption
self.options = options self.options = options
@ -25,6 +25,7 @@ struct PickerComponent<EnumType: RawRepresentable & Identifiable & Hashable>: Vi
Picker(title, selection: $selectedOption) { Picker(title, selection: $selectedOption) {
ForEach(options) { option in ForEach(options) { option in
Text(option.rawValue.description) Text(option.rawValue.description)
.tag(option)
.padding() .padding()
} }
} }
@ -49,16 +50,12 @@ struct PickerComponent<EnumType: RawRepresentable & Identifiable & Hashable>: Vi
} }
struct PickerComponent_Previews: PreviewProvider { struct PickerComponent_Previews: PreviewProvider {
@State static var selectedItem = AI.RandomAction @State static var selectedItem = Language.English
static var previews: some View { static var previews: some View {
PickerComponent( PickerComponent(
title: "Selectionne une IA :", title: "Select Language:",
selectedOption: $selectedItem, selectedOption: $selectedItem,
options: AI.allCases options: Language.allCases
) )
} }
} }

@ -8,11 +8,11 @@
import SwiftUI import SwiftUI
struct ToggleComponent: View { struct ToggleComponent: View {
let description: String let description: LocalizedStringKey
let booleanName: String let booleanName: String
@AppStorage private var boolean: Bool @AppStorage private var boolean: Bool
init(description: String, booleanName: String, booleanDefaultValue: Bool) { init(description: LocalizedStringKey, booleanName: String, booleanDefaultValue: Bool) {
self.description = description self.description = description
self.booleanName = booleanName self.booleanName = booleanName
_boolean = AppStorage(wrappedValue: booleanDefaultValue, booleanName) _boolean = AppStorage(wrappedValue: booleanDefaultValue, booleanName)
@ -30,7 +30,7 @@ struct ToggleComponent: View {
struct ToggleComponent_Previews: PreviewProvider { struct ToggleComponent_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
VStack { VStack {
ToggleComponent(description: "Dark mode", booleanName: "isDarkMode", booleanDefaultValue: false) ToggleComponent(description: LocalizedStringKey("Dark mode"), booleanName: "isDarkMode", booleanDefaultValue: false)
} }
} }
} }

@ -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()
}
}

@ -7,8 +7,19 @@
import Foundation import Foundation
enum Language: String, CaseIterable, Identifiable, Hashable { enum Language: String, CaseIterable, Identifiable {
case French = "Français" case English = "en"
case English = "English" case French = "fr"
var id: String { self.rawValue } var id: String { self.rawValue }
var localeIdentifier: String { self.rawValue }
var description: String {
switch self {
case .English:
return "English"
case .French:
return "Français"
}
}
} }

@ -8,52 +8,46 @@
import SwiftUI import SwiftUI
struct GeneralParametersMenuView: View { struct GeneralParametersMenuView: View {
@EnvironmentObject var languageSettings: LanguageSettings
@State private var selectedAIOption: AI @State private var selectedAIOption: AI
@State private var selectedLanguageOption: Language
@State private var selectedRulesOption: Rules @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) { let parametersTitle = LocalizedStringKey("ParametersTitle")
self.ParametersTitle = parametersTitle let darkModeDescription = LocalizedStringKey("DarkModeDescription")
self.selectedAIOption = selectedAIOption let darkModeBooleanName: String = "isDarkMode"
self.selectedLanguageOption = selectedLanguageOption let darkModeDefaultValue: Bool = false
self.selectedRulesOption = selectedRulesOption let languagePickerTitle = LocalizedStringKey("LanguagePickerTitle")
self.DarkModeDescription = DarkModeDescription
self.DarModeBooleanName = DarModeBooleanName init(selectedAIOption: AI, selectedRulesOption: Rules) {
self.DarkModeDefaultValue = DarkModeDefaultValue self._selectedAIOption = State(initialValue: selectedAIOption)
self.LanguagePickerTitle = LanguagePickerTitle self._selectedRulesOption = State(initialValue: selectedRulesOption)
} }
var body: some View { var body: some View {
VStack(alignment: .leading) { VStack(alignment: .leading) {
HStack(alignment: .center) { HStack(alignment: .center) {
Text(ParametersTitle).bold().font(.title) Text(parametersTitle).bold().font(.title)
}.frame(maxWidth: .infinity) }.frame(maxWidth: .infinity)
Spacer().frame(maxHeight: 30) Spacer().frame(maxHeight: 30)
ToggleComponent(description: "Dark mode", booleanName: "isDarkMode", booleanDefaultValue: false) ToggleComponent(description: darkModeDescription, booleanName: darkModeBooleanName, booleanDefaultValue: darkModeDefaultValue)
PickerComponent(title: "Sélectionne un langage :", PickerComponent(title: languagePickerTitle,
selectedOption: $selectedLanguageOption, selectedOption: $languageSettings.selectedLanguage,
options: Language.allCases) options: Language.allCases)
.onChange(of: languageSettings.selectedLanguage) { newLanguage in
}.frame(maxHeight: .infinity, alignment: .top) languageSettings.changeLanguage(to: newLanguage)
}
}
.frame(maxHeight: .infinity, alignment: .top)
} }
} }
struct GeneralParametersMenuView_Previews: PreviewProvider { struct GeneralParametersMenuView_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
let languageSettings = LanguageSettings(selectedLanguage: .French)
GeneralParametersMenuView( GeneralParametersMenuView(
parametersTitle: "Paramètres",
selectedAIOption: .RandomAction, selectedAIOption: .RandomAction,
selectedLanguageOption: .French, selectedRulesOption: .Regular
selectedRulesOption: .Regular,
DarkModeDescription: "Dark Mode",
DarModeBooleanName: "isDarkMode",
DarkModeDefaultValue: false,
LanguagePickerTitle: "Séléctionne un langage"
) )
.environmentObject(languageSettings)
} }
} }

@ -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)!))
}
}

@ -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()
}
}

@ -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()
}
}

@ -8,11 +8,14 @@
import SwiftUI import SwiftUI
struct MainMenu: View { struct MainMenu: View {
@EnvironmentObject var languageSettings: LanguageSettings
let playButtonText: String let playButtonText: String
let registeredGamesButtonText: String let registeredGamesButtonText: String
let ParametersButtontText : String let parametersButtonText: String
@State private var action: Int? = 0 @State private var action: Int? = 0
@AppStorage("isDarkMode") private var isDarkMode = false @AppStorage("isDarkMode") private var isDarkMode = false
@State private var reloadView = false // Déclarer reloadView ici
var body: some View { var body: some View {
ZStack { ZStack {
NavigationView { NavigationView {
@ -29,30 +32,30 @@ struct MainMenu: View {
{ GameParametersMenuView() } { GameParametersMenuView() }
Spacer().frame(height: 30) Spacer().frame(height: 30)
ButtonComponent(title: registeredGamesButtonText) ButtonComponent(title: registeredGamesButtonText)
{ Text("parties enregistrées page") } { PartyListView() }
Spacer().frame(height: 30) Spacer().frame(height: 30)
ButtonComponent(title: ParametersButtontText) ButtonComponent(title: parametersButtonText)
{ GeneralParametersMenuView( { GeneralParametersMenuView(
parametersTitle: "Paramètres",
selectedAIOption: .RandomAction, selectedAIOption: .RandomAction,
selectedLanguageOption: .French, selectedRulesOption: .Regular
selectedRulesOption: .Regular, ).id(reloadView) // Utilisez l'ID pour forcer le rechargement de la vue
DarkModeDescription: "Dark Mode", }
DarModeBooleanName: "isDarkMode",
DarkModeDefaultValue: false,
LanguagePickerTitle: "Séléctionne un langage"
) }
} }
Spacer() Spacer()
} }
.padding(EdgeInsets(top: 10, leading: 32, bottom: 10, trailing: 32)) .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 { struct MainMenu_Previews: PreviewProvider {
static var previews: some View { 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))
} }
} }

@ -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()
}
}

@ -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
}

@ -0,0 +1,11 @@
/*
Localizable.strings
ArkitDoushiQi
Created by Louis DUFOUR on 28/05/2024.
*/
"ParametersTitle" = "Parameters";
"DarkModeDescription" = "Dark Mode";
"LanguagePickerTitle" = "Language";

@ -0,0 +1,11 @@
/*
Localizable.strings
ArkitDoushiQi
Created by Louis DUFOUR on 28/05/2024.
*/
"ParametersTitle" = "Paramètres";
"DarkModeDescription" = "Mode sombre";
"LanguagePickerTitle" = "Langue";
Loading…
Cancel
Save