From 9d6e262f207b3dbacc4ab888b3e6bf00bb11f69b Mon Sep 17 00:00:00 2001 From: "johan.lachenal" Date: Fri, 24 May 2024 13:25:05 +0200 Subject: [PATCH 1/5] create(GameParametersMenuView): add edit component so the players can choose their names --- .../ArkitDoushiQi.xcodeproj/project.pbxproj | 44 ++++++++++++++++--- .../Controls/ButtonComponent.swift} | 6 +-- .../Components/Controls/EditComponent.swift | 25 +++++++++++ .../Controls}/PickerComponent.swift | 0 .../Controls}/ToggleComponent.swift | 0 .../GameParametersMenuView.swift | 20 +++++++++ .../Views/MainMenu/MainMenu.swift | 6 +-- 7 files changed, 89 insertions(+), 12 deletions(-) rename ArkitDoushiQi/ArkitDoushiQi/Views/{MainMenu/MainMenuButtonComponent.swift => Components/Controls/ButtonComponent.swift} (85%) create mode 100644 ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/EditComponent.swift rename ArkitDoushiQi/ArkitDoushiQi/Views/{GeneralParametersMenu => Components/Controls}/PickerComponent.swift (100%) rename ArkitDoushiQi/ArkitDoushiQi/Views/{GeneralParametersMenu => Components/Controls}/ToggleComponent.swift (100%) create mode 100644 ArkitDoushiQi/ArkitDoushiQi/Views/GameParametersMenu/GameParametersMenuView.swift diff --git a/ArkitDoushiQi/ArkitDoushiQi.xcodeproj/project.pbxproj b/ArkitDoushiQi/ArkitDoushiQi.xcodeproj/project.pbxproj index 3b3a615..c1b333f 100644 --- a/ArkitDoushiQi/ArkitDoushiQi.xcodeproj/project.pbxproj +++ b/ArkitDoushiQi/ArkitDoushiQi.xcodeproj/project.pbxproj @@ -21,7 +21,9 @@ C205A2D22BF373380097BD93 /* WtaTennisUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C205A2D12BF373380097BD93 /* WtaTennisUITests.swift */; }; C205A2D42BF373380097BD93 /* WtaTennisUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C205A2D32BF373380097BD93 /* WtaTennisUITestsLaunchTests.swift */; }; C24659E52BF5FE09004E80D5 /* MainMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = C24659E42BF5FE09004E80D5 /* MainMenu.swift */; }; - C24659E92BF60FAA004E80D5 /* MainMenuButtonComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = C24659E82BF60FAA004E80D5 /* MainMenuButtonComponent.swift */; }; + C24659E92BF60FAA004E80D5 /* ButtonComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = C24659E82BF60FAA004E80D5 /* ButtonComponent.swift */; }; + C25220EE2C00AC7E0026B71F /* GameParametersMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C25220ED2C00AC7E0026B71F /* GameParametersMenuView.swift */; }; + C25220F32C00AF490026B71F /* EditComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = C25220F22C00AF490026B71F /* EditComponent.swift */; }; C2F417702BFE2FBE00CFF0B3 /* howto.md in Resources */ = {isa = PBXBuildFile; fileRef = C2F4176C2BFE2FBD00CFF0B3 /* howto.md */; }; C2F417722BFE2FBE00CFF0B3 /* capture.png in Resources */ = {isa = PBXBuildFile; fileRef = C2F4176E2BFE2FBD00CFF0B3 /* capture.png */; }; C2F417732BFE2FBE00CFF0B3 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = C2F4176F2BFE2FBD00CFF0B3 /* README.md */; }; @@ -62,7 +64,9 @@ C205A2D12BF373380097BD93 /* WtaTennisUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WtaTennisUITests.swift; sourceTree = ""; }; C205A2D32BF373380097BD93 /* WtaTennisUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WtaTennisUITestsLaunchTests.swift; sourceTree = ""; }; C24659E42BF5FE09004E80D5 /* MainMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenu.swift; sourceTree = ""; }; - C24659E82BF60FAA004E80D5 /* MainMenuButtonComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenuButtonComponent.swift; sourceTree = ""; }; + C24659E82BF60FAA004E80D5 /* ButtonComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonComponent.swift; sourceTree = ""; }; + C25220ED2C00AC7E0026B71F /* GameParametersMenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameParametersMenuView.swift; sourceTree = ""; }; + C25220F22C00AF490026B71F /* EditComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditComponent.swift; sourceTree = ""; }; C2F4176C2BFE2FBD00CFF0B3 /* howto.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = howto.md; sourceTree = ""; }; C2F4176D2BFE2FBD00CFF0B3 /* DSQ.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; path = DSQ.xcframework; sourceTree = ""; }; C2F4176E2BFE2FBD00CFF0B3 /* capture.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = capture.png; sourceTree = ""; }; @@ -147,6 +151,8 @@ C205A2BC2BF373380097BD93 /* Views */ = { isa = PBXGroup; children = ( + C25220F02C00AD7F0026B71F /* Components */, + C25220EC2C00AC530026B71F /* GameParametersMenu */, C25220EB2C00A9230026B71F /* GeneralParametersMenu */, C25220EA2C00A9010026B71F /* MainMenu */, 82F9D32F2BFE3A75009EDFAF /* History */, @@ -175,7 +181,6 @@ C25220EA2C00A9010026B71F /* MainMenu */ = { isa = PBXGroup; children = ( - C24659E82BF60FAA004E80D5 /* MainMenuButtonComponent.swift */, C24659E42BF5FE09004E80D5 /* MainMenu.swift */, ); path = MainMenu; @@ -184,13 +189,38 @@ C25220EB2C00A9230026B71F /* GeneralParametersMenu */ = { isa = PBXGroup; children = ( - C20310D92BFCC8600031657D /* ToggleComponent.swift */, - C20310D52BFCB5FB0031657D /* PickerComponent.swift */, C20310D72BFCC2410031657D /* GeneralParametersMenuView.swift */, ); path = GeneralParametersMenu; sourceTree = ""; }; + C25220EC2C00AC530026B71F /* GameParametersMenu */ = { + isa = PBXGroup; + children = ( + C25220ED2C00AC7E0026B71F /* GameParametersMenuView.swift */, + ); + path = GameParametersMenu; + sourceTree = ""; + }; + C25220F02C00AD7F0026B71F /* Components */ = { + isa = PBXGroup; + children = ( + C25220F12C00ADF70026B71F /* Controls */, + ); + path = Components; + sourceTree = ""; + }; + C25220F12C00ADF70026B71F /* Controls */ = { + isa = PBXGroup; + children = ( + C20310D52BFCB5FB0031657D /* PickerComponent.swift */, + C20310D92BFCC8600031657D /* ToggleComponent.swift */, + C24659E82BF60FAA004E80D5 /* ButtonComponent.swift */, + C25220F22C00AF490026B71F /* EditComponent.swift */, + ); + path = Controls; + sourceTree = ""; + }; C2F4176A2BFE2F8C00CFF0B3 /* Model */ = { isa = PBXGroup; children = ( @@ -345,14 +375,16 @@ files = ( C205A2B92BF373360097BD93 /* ContentView.swift in Sources */, 82F9D3312BFE3A9F009EDFAF /* HistoryGameDetail.swift in Sources */, - C24659E92BF60FAA004E80D5 /* MainMenuButtonComponent.swift in Sources */, + C24659E92BF60FAA004E80D5 /* ButtonComponent.swift in Sources */, C24659E52BF5FE09004E80D5 /* MainMenu.swift in Sources */, 82F9D3362BFE3B3C009EDFAF /* HistoryView.swift in Sources */, C20310D82BFCC2410031657D /* GeneralParametersMenuView.swift in Sources */, C205A2B72BF373360097BD93 /* ArkitDoushiQiApp.swift in Sources */, + C25220F32C00AF490026B71F /* EditComponent.swift in Sources */, C20310D62BFCB5FB0031657D /* PickerComponent.swift in Sources */, 82F9D3332BFE3B12009EDFAF /* HistoryHeader.swift in Sources */, C20310DA2BFCC8600031657D /* ToggleComponent.swift in Sources */, + C25220EE2C00AC7E0026B71F /* GameParametersMenuView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/MainMenu/MainMenuButtonComponent.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/ButtonComponent.swift similarity index 85% rename from ArkitDoushiQi/ArkitDoushiQi/Views/MainMenu/MainMenuButtonComponent.swift rename to ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/ButtonComponent.swift index 01f1ca6..85c14c9 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/MainMenu/MainMenuButtonComponent.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/ButtonComponent.swift @@ -7,7 +7,7 @@ import SwiftUI -struct MainMenuButtonComponent: View { +struct ButtonComponent: View { let content: Content let title: String @@ -33,11 +33,11 @@ struct MainMenuButtonComponent: View { } } -struct MainMenuButtonComponent_Previews: PreviewProvider { +struct ButtonComponent_Previews: PreviewProvider { static var previews: some View { NavigationView { VStack { - MainMenuButtonComponent(title: "Parties enregistrées") { + ButtonComponent(title: "Parties enregistrées") { Text("Je suis un test") } } diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/EditComponent.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/EditComponent.swift new file mode 100644 index 0000000..b08524e --- /dev/null +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/EditComponent.swift @@ -0,0 +1,25 @@ +// +// EditComponent.swift +// ArkitDoushiQi +// +// Created by Johan LACHENAL on 24/05/2024. +// + +import SwiftUI + +struct EditComponent: View { + @State private var name = "Joueur 1" + var body: some View { + Form { + Section(header : Text("Nom du joueur 1")) { + TextField("Joueur 1", text : $name) + } + } + } +} + +struct EditComponent_Previews: PreviewProvider { + static var previews: some View { + EditComponent() + } +} diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/GeneralParametersMenu/PickerComponent.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/PickerComponent.swift similarity index 100% rename from ArkitDoushiQi/ArkitDoushiQi/Views/GeneralParametersMenu/PickerComponent.swift rename to ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/PickerComponent.swift diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/GeneralParametersMenu/ToggleComponent.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/ToggleComponent.swift similarity index 100% rename from ArkitDoushiQi/ArkitDoushiQi/Views/GeneralParametersMenu/ToggleComponent.swift rename to ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/ToggleComponent.swift diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/GameParametersMenu/GameParametersMenuView.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/GameParametersMenu/GameParametersMenuView.swift new file mode 100644 index 0000000..adfe6d2 --- /dev/null +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/GameParametersMenu/GameParametersMenuView.swift @@ -0,0 +1,20 @@ +// +// GameParametersMenuView.swift +// ArkitDoushiQi +// +// Created by Johan LACHENAL on 24/05/2024. +// + +import SwiftUI + +struct GameParametersMenuView: View { + var body: some View { + Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + } +} + +struct GameParametersMenuView_Previews: PreviewProvider { + static var previews: some View { + GameParametersMenuView() + } +} diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/MainMenu/MainMenu.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/MainMenu/MainMenu.swift index b23b30e..39b4cf3 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/MainMenu/MainMenu.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/MainMenu/MainMenu.swift @@ -25,13 +25,13 @@ struct MainMenu: View { } Spacer().frame(height: 40) VStack(alignment: .leading) { - MainMenuButtonComponent(title: playButtonText) + ButtonComponent(title: playButtonText) { Text("jeu page") } Spacer().frame(height: 30) - MainMenuButtonComponent(title: registeredGamesButtonText) + ButtonComponent(title: registeredGamesButtonText) { Text("parties enregistrées page") } Spacer().frame(height: 30) - MainMenuButtonComponent(title: ParametersButtontText) + ButtonComponent(title: ParametersButtontText) { GeneralParametersMenuView() } } Spacer() From 2357de3c3e2c38d230eafd3f795d43ea4a3980a2 Mon Sep 17 00:00:00 2001 From: "johan.lachenal" Date: Mon, 27 May 2024 08:15:56 +0200 Subject: [PATCH 2/5] Add Edit component --- .../Components/Controls/EditComponent.swift | 8 ++-- .../GameParametersMenuView.swift | 43 +++++++++++-------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/EditComponent.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/EditComponent.swift index b08524e..64540c9 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/EditComponent.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/EditComponent.swift @@ -8,11 +8,13 @@ import SwiftUI struct EditComponent: View { + let explanation : String + let value : String @State private var name = "Joueur 1" var body: some View { Form { - Section(header : Text("Nom du joueur 1")) { - TextField("Joueur 1", text : $name) + Section(header : Text(explanation)) { + TextField("Value", text : $name) } } } @@ -20,6 +22,6 @@ struct EditComponent: View { struct EditComponent_Previews: PreviewProvider { static var previews: some View { - EditComponent() + EditComponent(explanation: "Nom du joueur 1", value : "Joueur 1") } } diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/GameParametersMenu/GameParametersMenuView.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/GameParametersMenu/GameParametersMenuView.swift index adfe6d2..b7ba71c 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/GameParametersMenu/GameParametersMenuView.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/GameParametersMenu/GameParametersMenuView.swift @@ -1,20 +1,29 @@ +//// +//// GameParametersMenuView.swift +//// ArkitDoushiQi +//// +//// Created by Johan LACHENAL on 24/05/2024. +//// // -// GameParametersMenuView.swift -// ArkitDoushiQi +//import SwiftUI // -// Created by Johan LACHENAL on 24/05/2024. +//struct GameParametersMenuView: View { +//// enum Rules: String, CaseIterable, Identifiable, Hashable { +//// case Easy = "Simplifié" +//// case Regular = "Normal" +//// var id: String { self.rawValue } +//// } +// var body: some View { // - -import SwiftUI - -struct GameParametersMenuView: View { - var body: some View { - Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) - } -} - -struct GameParametersMenuView_Previews: PreviewProvider { - static var previews: some View { - GameParametersMenuView() - } -} +//// PickerComponent(title: "Sélectionne les règles :", +//// selectedOption: $selectedRulesOption, +//// options: Rules.allCases) +// } +// +//} +// +//struct GameParametersMenuView_Previews: PreviewProvider { +// static var previews: some View { +// GameParametersMenuView() +// } +//} From 08e1b830272f255d7945a5ca0c758b92cbb9dec1 Mon Sep 17 00:00:00 2001 From: "johan.lachenal" Date: Mon, 27 May 2024 08:51:16 +0200 Subject: [PATCH 3/5] Add(GameParametersMenuView): add photo component to test on IOS phones, the app now launches on the MainMenu and other things were done --- .DS_Store | Bin 6148 -> 6148 bytes ArkitDoushiQi/.DS_Store | Bin 6148 -> 6148 bytes .../ArkitDoushiQi.xcodeproj/project.pbxproj | 30 +++++++ .../ArkitDoushiQi/ArkitDoushiQiApp.swift | 2 +- .../Controls/PhotoButtonComponent.swift | 73 ++++++++++++++++ .../Components/Visuals/ProfileComponent.swift | 20 +++++ .../ArkitDoushiQi/Views/Game/GameView.swift | 20 +++++ .../GameParametersMenuView.swift | 78 ++++++++++++------ .../GeneralParametersMenuView.swift | 20 ----- .../Views/MainMenu/MainMenu.swift | 2 +- ArkitDoushiQi/Model/.DS_Store | Bin 0 -> 6148 bytes ArkitDoushiQi/Model/XCFramework/.DS_Store | Bin 0 -> 6148 bytes .../XCFramework/DSQ.xcframework/.DS_Store | Bin 0 -> 6148 bytes 13 files changed, 197 insertions(+), 48 deletions(-) create mode 100644 ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/PhotoButtonComponent.swift create mode 100644 ArkitDoushiQi/ArkitDoushiQi/Views/Components/Visuals/ProfileComponent.swift create mode 100644 ArkitDoushiQi/ArkitDoushiQi/Views/Game/GameView.swift create mode 100644 ArkitDoushiQi/Model/.DS_Store create mode 100644 ArkitDoushiQi/Model/XCFramework/.DS_Store create mode 100644 ArkitDoushiQi/Model/XCFramework/DSQ.xcframework/.DS_Store diff --git a/.DS_Store b/.DS_Store index 1467c31699eb2dfa80370c9e9c65c91d14f141cf..cccd18acbb30e571e79408b1ef058db81fa3f2ce 100644 GIT binary patch delta 21 ccmZoMXffFEgo(q{%tS}Q)Yx+K8zu=+08D)bVE_OC delta 21 ccmZoMXffFEgo#7f)KW*m*wAA08zu=+08AVPSO5S3 diff --git a/ArkitDoushiQi/.DS_Store b/ArkitDoushiQi/.DS_Store index f39ec858a3f9d875ef7dfe9561ed452dc4df2da0..6dbb068bdde6b067e11746a89bf855050107c4b5 100644 GIT binary patch delta 338 zcmZoMXfc=|#>B!ku~2NHo+2aH#(>?7i$5?kF>+1jVM=D)F}Z-LkXxd<+SJTMN5RzC za`G!CX~wR}Y|QeE-9Qy`0%gHPc{%xc=?n}Ej6f_tS%68(fI*L;f+3k9pCN@Im7##4 z2*}Fv%*jtq%E?axDiQ$V^+2rm9}E~6CI>M0JF+tPLUrVzs%89%tQN>dQkhg7)nsx!IVDv0`ttx>>T_Yz!2N~koi0F VWPTAx4xqo8faWu7ju2VH3;_6TRn-6h delta 107 zcmZoMXfc=|#>B)qu~2NHo+2ab#(>?7jI5J+SdtmHO)g+5 UIImagePickerController { + let imagePicker = UIImagePickerController() + imagePicker.sourceType = .camera + imagePicker.allowsEditing = true + imagePicker.delegate = context.coordinator + return imagePicker + } + + func updateUIViewController(_ uiViewController: UIImagePickerController, context: Context) { + + } + + func makeCoordinator() -> Coordinator { + return Coordinator(picker: self) + } +} + +struct PhotoButtonComponent: View { + let Text : String + @State private var showCamera = false + @State private var selectedImage: UIImage? + @State var image: UIImage? + var body: some View { + VStack { + if let selectedImage{ + Image(uiImage: selectedImage) + .resizable() + .scaledToFit() + } + + Button("Open camera") { + self.showCamera.toggle() + } + .fullScreenCover(isPresented: self.$showCamera) { + accessCameraView(selectedImage: self.$selectedImage) + } + } + } +} + +struct PhotoButtonComponent_Previews: PreviewProvider { + static var previews: some View { + PhotoButtonComponent(Text : "Prendre Photo") + } +} diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Visuals/ProfileComponent.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Visuals/ProfileComponent.swift new file mode 100644 index 0000000..4f12d75 --- /dev/null +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Visuals/ProfileComponent.swift @@ -0,0 +1,20 @@ +// +// ProfileComponent.swift +// ArkitDoushiQi +// +// Created by Johan LACHENAL on 27/05/2024. +// + +import SwiftUI + +struct ProfileComponent: View { + var body: some View { + Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + } +} + +struct ProfileComponent_Previews: PreviewProvider { + static var previews: some View { + ProfileComponent() + } +} diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/Game/GameView.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/Game/GameView.swift new file mode 100644 index 0000000..dd07a44 --- /dev/null +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/Game/GameView.swift @@ -0,0 +1,20 @@ +// +// GameView.swift +// ArkitDoushiQi +// +// Created by Johan LACHENAL on 27/05/2024. +// + +import SwiftUI + +struct GameView: View { + var body: some View { + Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + } +} + +struct GameView_Previews: PreviewProvider { + static var previews: some View { + GameView() + } +} diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/GameParametersMenu/GameParametersMenuView.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/GameParametersMenu/GameParametersMenuView.swift index b7ba71c..4bd66a4 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/GameParametersMenu/GameParametersMenuView.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/GameParametersMenu/GameParametersMenuView.swift @@ -1,29 +1,55 @@ -//// -//// GameParametersMenuView.swift -//// ArkitDoushiQi -//// -//// Created by Johan LACHENAL on 24/05/2024. -//// // -//import SwiftUI +// GameParametersMenuView.swift +// ArkitDoushiQi // -//struct GameParametersMenuView: View { -//// enum Rules: String, CaseIterable, Identifiable, Hashable { -//// case Easy = "Simplifié" -//// case Regular = "Normal" -//// var id: String { self.rawValue } -//// } -// var body: some View { +// Created by Johan LACHENAL on 24/05/2024. // -//// PickerComponent(title: "Sélectionne les règles :", -//// selectedOption: $selectedRulesOption, -//// options: Rules.allCases) -// } -// -//} -// -//struct GameParametersMenuView_Previews: PreviewProvider { -// static var previews: some View { -// GameParametersMenuView() -// } -//} + +import SwiftUI +import PhotosUI + +enum AIT: String, CaseIterable, Identifiable, Hashable { + case RandomAction = "IA Random" + case EasyTrainedAI = "IA Facile" + case MediumTrainedAI = "IA Intermédiaire" + + var id: String { self.rawValue } +} + +enum Rules: String, CaseIterable, Identifiable, Hashable { + case Easy = "Simplifié" + case Regular = "Normal" + var id: String { self.rawValue } +} + +struct GameParametersMenuView: View { + @State private var selectedAIOption: AIT = .RandomAction + @State private var selectedRulesOption: Rules = .Regular + var body: some View { + NavigationView { + VStack(alignment: .leading) { + HStack(alignment: .center) { + Text("Paramètres de partie").bold().font(.title) + }.frame(maxWidth: .infinity) + PickerComponent(title: "Sélectionne les règles :", + selectedOption: $selectedRulesOption, + options: Rules.allCases) + PickerComponent(title: "Sélectionne une IA :", + selectedOption: $selectedAIOption, + options: AIT.allCases) + EditComponent(explanation: "Nom du joueur 1", value: "Joueur 1") + EditComponent(explanation: "Nom du joueur 2",value: "Joueur 2") + ButtonComponent(title: "Lancer la partie") { + GameView() + } + }.frame(maxHeight: .infinity, alignment: .top) + } + } + +} + +struct GameParametersMenuView_Previews: PreviewProvider { + static var previews: some View { + GameParametersMenuView() + } +} diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/GeneralParametersMenu/GeneralParametersMenuView.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/GeneralParametersMenu/GeneralParametersMenuView.swift index a9eb598..6a6de1b 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/GeneralParametersMenu/GeneralParametersMenuView.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/GeneralParametersMenu/GeneralParametersMenuView.swift @@ -7,26 +7,12 @@ import SwiftUI -enum AIT: String, CaseIterable, Identifiable, Hashable { - case RandomAction = "IA Random" - case EasyTrainedAI = "IA Facile" - case MediumTrainedAI = "IA Intermédiaire" - - var id: String { self.rawValue } -} - enum Language: String, CaseIterable, Identifiable, Hashable { case French = "Français" case English = "English" var id: String { self.rawValue } } -enum Rules: String, CaseIterable, Identifiable, Hashable { - case Easy = "Simplifié" - case Regular = "Normal" - var id: String { self.rawValue } -} - struct GeneralParametersMenuView: View { @State private var selectedAIOption: AIT = .RandomAction @State private var selectedLanguageOption: Language = .French @@ -38,15 +24,9 @@ struct GeneralParametersMenuView: View { }.frame(maxWidth: .infinity) Spacer().frame(maxHeight: 30) ToggleComponent() - PickerComponent(title: "Sélectionne une IA :", - selectedOption: $selectedAIOption, - options: AIT.allCases) PickerComponent(title: "Sélectionne un langage :", selectedOption: $selectedLanguageOption, options: Language.allCases) - PickerComponent(title: "Sélectionne les règles :", - selectedOption: $selectedRulesOption, - options: Rules.allCases) }.frame(maxHeight: .infinity, alignment: .top) } diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/MainMenu/MainMenu.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/MainMenu/MainMenu.swift index 39b4cf3..b1ce79c 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/MainMenu/MainMenu.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/MainMenu/MainMenu.swift @@ -26,7 +26,7 @@ struct MainMenu: View { Spacer().frame(height: 40) VStack(alignment: .leading) { ButtonComponent(title: playButtonText) - { Text("jeu page") } + { GameParametersMenuView() } Spacer().frame(height: 30) ButtonComponent(title: registeredGamesButtonText) { Text("parties enregistrées page") } diff --git a/ArkitDoushiQi/Model/.DS_Store b/ArkitDoushiQi/Model/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5ec6b63225bd16c5065d47232f8e0a91ee23170f GIT binary patch literal 6148 zcmeHKOH0E*5T3176N=D-g2x4~Me7s9ORQD!;KhgvDm5`hgE3qBFo#meS$~XIe~Eub zXLh$@se&gJnSt4Fc6YvP@@?1$0Ek*IS_UWsfP+q0aIyHrsGoey3bv()DD*Q9U>6qQ z4x;^JESnqtq5?E`E*#>#Z9^SC%%8dn6BS}F{Tkcoi?7-+0w}>L?7$whA;8&gLIw)s z+x=vO_4GYfm~~oqtmm+m#GP)n`XUMw#mT8@XWA(_7ygaP{BF?gb!tKTjA} zH&?0^xwg777`V>d!qV1Z<2JcV)r0U zfED;H1?+m{lz!_4cwAP175K9X(E1?J2|bIsLA`Wfp|1dlbd1!7F&!9*BQ1IsbA#A} zCJYtPP=&o>2t&tqY4bdbxj{n*VJ{!Tjx6jAMd;D-`BJBY@CMYc0v$yQ0PS%@EY1^e?alFP2-_QUC~38xZ92G(#=jtHr+x9>{teL=tYW)$BO;?si-4Z0*h4YPR>H(^lJCyYqQNK6$qJ@=gCN8|M0pRe=P)d}|LqUcpxcw`g=8 zj`K|CC&)CbNIHdfCF-D|>X4E}4aHOBT(1DSY^(q)zzW<+0l#y}=AGC~Vg*=%`>cT3 z9~9hR;IVROw+=M+3IMEQ*cxK4A?v(?TZp`FW4u4S)*rOP^<|tl=Tf?|A0Wk1bIm8Hze*~-y+^_=wRDqxVN_&U^ literal 0 HcmV?d00001 diff --git a/ArkitDoushiQi/Model/XCFramework/DSQ.xcframework/.DS_Store b/ArkitDoushiQi/Model/XCFramework/DSQ.xcframework/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a6188c40559ac3142cddc5437cd2642a801e70c1 GIT binary patch literal 6148 zcmeHKL2KJE6n<*c)oB^zutF&e1iPkfwx*$_7dPt;z0RXOY{RpcY%_DLU^~ko1bl9P zOt1YV`#anBBn6hHqcFx8s~$Xk&yv1p^kF?&L?pVS-czCm5qWUN+8UZ$jK|p*Y{~Yl z0EN!6Lqkd_p@PbV*{;JW;1u}R6yUwPMyHg~2U7IY{yk0A`#4oG#<@5g!*{-GLqt@^ zE?3y++Z0hw1L{!w2IJ}mV{4H?A$_F-a6{%JSAjVL8li?ns33~+`JCeMpU4@Hi=kcF zbv#UyqHMLkiKXS*%7ayJ)m!)82A|Y8D5G*zbff$=KfO{ajc0KbpC$cq*m(3@Wo49P z{ah20ULRB5oF`dNjk{`;^$N`m%z#(->S1GZGTHC6n{t2eaN3lU!)L9gZ0~iZ)4I3u zWcTQ0_&FV9>VhRkQAJhN_R!)CE)o2eo?n7IOI7v}{8{c-TNpZoN(c zr@);GaD9+)M&Dv(P?rug`U(K7p<5eb{#{^>wCG!`3}OT(3>9do!d@|ip`%~gdA`NU zprMnnmk(jzEbI+M=(i)k)YD1$23_kEa0<*TuxuV1eEz@q_5FXI!yvm@aps~lX4)`eEglof? Date: Mon, 27 May 2024 09:51:06 +0200 Subject: [PATCH 4/5] Add colors(GameparametersMenuView): still needs to implement them everywhere --- .../ArkitDoushiQi/ArkitDoushiQiApp.swift | 7 +++ .../Contents.json | 15 ++++- .../Quaternary.colorset/Contents.json | 56 +++++++++++++++++++ .../Secundary.colorset/Contents.json | 56 +++++++++++++++++++ .../Tertiary.colorset/Contents.json | 51 +++++++++++++++++ .../Components/Controls/ButtonComponent.swift | 4 +- .../Controls/PhotoButtonComponent.swift | 6 +- .../Components/Controls/PickerComponent.swift | 2 - .../GameParametersMenuView.swift | 5 +- 9 files changed, 192 insertions(+), 10 deletions(-) rename ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/{Color.colorset => Primary.colorset}/Contents.json (73%) create mode 100644 ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/Quaternary.colorset/Contents.json create mode 100644 ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/Secundary.colorset/Contents.json create mode 100644 ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/Tertiary.colorset/Contents.json diff --git a/ArkitDoushiQi/ArkitDoushiQi/ArkitDoushiQiApp.swift b/ArkitDoushiQi/ArkitDoushiQi/ArkitDoushiQiApp.swift index b42874f..cfe6191 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/ArkitDoushiQiApp.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/ArkitDoushiQiApp.swift @@ -7,7 +7,14 @@ import SwiftUI +enum Theme { + static let primary = Color("Primary") + static let secondary = Color("Secondary") + static let tertiary = Color("Tertiary") +} + @main + struct ArkitDoushiQiApp: App { @AppStorage("isDarkMode") private var isDarkMode = false var body: some Scene { diff --git a/ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/Color.colorset/Contents.json b/ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/Primary.colorset/Contents.json similarity index 73% rename from ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/Color.colorset/Contents.json rename to ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/Primary.colorset/Contents.json index 22c4bb0..6ea0e4d 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/Color.colorset/Contents.json +++ b/ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/Primary.colorset/Contents.json @@ -16,7 +16,7 @@ "appearances" : [ { "appearance" : "luminosity", - "value" : "dark" + "value" : "light" } ], "color" : { @@ -29,6 +29,19 @@ } }, "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "platform" : "ios", + "reference" : "darkTextColor" + }, + "idiom" : "universal" } ], "info" : { diff --git a/ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/Quaternary.colorset/Contents.json b/ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/Quaternary.colorset/Contents.json new file mode 100644 index 0000000..af7fd25 --- /dev/null +++ b/ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/Quaternary.colorset/Contents.json @@ -0,0 +1,56 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "1.000", + "green" : "1.000", + "red" : "1.000" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "light" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "1.000", + "green" : "1.000", + "red" : "1.000" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "1.000", + "green" : "1.000", + "red" : "1.000" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/Secundary.colorset/Contents.json b/ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/Secundary.colorset/Contents.json new file mode 100644 index 0000000..af7fd25 --- /dev/null +++ b/ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/Secundary.colorset/Contents.json @@ -0,0 +1,56 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "1.000", + "green" : "1.000", + "red" : "1.000" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "light" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "1.000", + "green" : "1.000", + "red" : "1.000" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "1.000", + "green" : "1.000", + "red" : "1.000" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/Tertiary.colorset/Contents.json b/ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/Tertiary.colorset/Contents.json new file mode 100644 index 0000000..de56107 --- /dev/null +++ b/ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/Tertiary.colorset/Contents.json @@ -0,0 +1,51 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "1.000", + "green" : "1.000", + "red" : "1.000" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "light" + } + ], + "color" : { + "platform" : "ios", + "reference" : "darkTextColor" + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "1.000", + "green" : "1.000", + "red" : "1.000" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/ButtonComponent.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/ButtonComponent.swift index 85c14c9..ed86c3f 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/ButtonComponent.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/ButtonComponent.swift @@ -25,11 +25,11 @@ struct ButtonComponent: View { .frame(maxWidth: .infinity) .padding(EdgeInsets(top: 10, leading: 32, bottom: 10, trailing: 32)) .controlSize(.large) - .foregroundColor(.white) + .foregroundColor(Color(UIColor(named: "Primary") ?? .black)) } .buttonBorderShape(.roundedRectangle) .buttonStyle(.borderedProminent) - .tint(.black) + .tint(Color(UIColor(named: "Tertiary") ?? .white)) } } diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/PhotoButtonComponent.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/PhotoButtonComponent.swift index a4011fd..68abd33 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/PhotoButtonComponent.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/PhotoButtonComponent.swift @@ -44,7 +44,7 @@ struct accessCameraView: UIViewControllerRepresentable { } struct PhotoButtonComponent: View { - let Text : String + let Value : String @State private var showCamera = false @State private var selectedImage: UIImage? @State var image: UIImage? @@ -56,7 +56,7 @@ struct PhotoButtonComponent: View { .scaledToFit() } - Button("Open camera") { + Button(Value) { self.showCamera.toggle() } .fullScreenCover(isPresented: self.$showCamera) { @@ -68,6 +68,6 @@ struct PhotoButtonComponent: View { struct PhotoButtonComponent_Previews: PreviewProvider { static var previews: some View { - PhotoButtonComponent(Text : "Prendre Photo") + PhotoButtonComponent(Value : "Prendre Photo") } } diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/PickerComponent.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/PickerComponent.swift index f81cf0e..dfcbc15 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/PickerComponent.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/PickerComponent.swift @@ -33,11 +33,9 @@ struct PickerComponent: Vi } label: { HStack { Text(title) - .foregroundColor(.black) .padding() Spacer() Text(selectedOption.rawValue.description) - .foregroundColor(.black) .padding() } .frame(maxWidth: .infinity) diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/GameParametersMenu/GameParametersMenuView.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/GameParametersMenu/GameParametersMenuView.swift index 4bd66a4..79893b5 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/GameParametersMenu/GameParametersMenuView.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/GameParametersMenu/GameParametersMenuView.swift @@ -41,8 +41,9 @@ struct GameParametersMenuView: View { EditComponent(explanation: "Nom du joueur 2",value: "Joueur 2") ButtonComponent(title: "Lancer la partie") { GameView() - } - }.frame(maxHeight: .infinity, alignment: .top) + }.padding(EdgeInsets(top: 10, leading: 32, bottom: 10, trailing: 32)) + } + .frame(maxHeight: .infinity, alignment: .top) } } From 02b26d144286134092f687d40606a3a40c9ad1e2 Mon Sep 17 00:00:00 2001 From: "johan.lachenal" Date: Mon, 27 May 2024 09:58:09 +0200 Subject: [PATCH 5/5] Update(gameParametersView): dark mode now avilable --- .../Quaternary.colorset/Contents.json | 9 ++------- .../Secundary.colorset/Contents.json | 18 ++++-------------- .../Components/Controls/PickerComponent.swift | 2 ++ 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/Quaternary.colorset/Contents.json b/ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/Quaternary.colorset/Contents.json index af7fd25..6ea0e4d 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/Quaternary.colorset/Contents.json +++ b/ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/Quaternary.colorset/Contents.json @@ -38,13 +38,8 @@ } ], "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "1.000", - "green" : "1.000", - "red" : "1.000" - } + "platform" : "ios", + "reference" : "darkTextColor" }, "idiom" : "universal" } diff --git a/ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/Secundary.colorset/Contents.json b/ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/Secundary.colorset/Contents.json index af7fd25..e894812 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/Secundary.colorset/Contents.json +++ b/ArkitDoushiQi/ArkitDoushiQi/Assets.xcassets/Secundary.colorset/Contents.json @@ -20,13 +20,8 @@ } ], "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "1.000", - "green" : "1.000", - "red" : "1.000" - } + "platform" : "universal", + "reference" : "labelColor" }, "idiom" : "universal" }, @@ -38,13 +33,8 @@ } ], "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "1.000", - "green" : "1.000", - "red" : "1.000" - } + "platform" : "universal", + "reference" : "systemGrayColor" }, "idiom" : "universal" } diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/PickerComponent.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/PickerComponent.swift index dfcbc15..72a816d 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/PickerComponent.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/PickerComponent.swift @@ -34,9 +34,11 @@ struct PickerComponent: Vi HStack { Text(title) .padding() + .foregroundColor(.primary) Spacer() Text(selectedOption.rawValue.description) .padding() + .foregroundColor(.primary) } .frame(maxWidth: .infinity) .padding(EdgeInsets(top: 0, leading: 32, bottom: 0, trailing: 32))