Add(GameParametersMenuView): add photo component to test on IOS phones, the

app now launches on the MainMenu and other things were done
pull/17/head
Johan LACHENAL 11 months ago
parent 2357de3c3e
commit 08e1b83027

BIN
.DS_Store vendored

Binary file not shown.

Binary file not shown.

@ -24,6 +24,10 @@
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 */; };
C2F394062C045E800070B4F6 /* DSQ.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2F4176D2BFE2FBD00CFF0B3 /* DSQ.xcframework */; };
C2F394082C0462400070B4F6 /* PhotoButtonComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2F394072C0462400070B4F6 /* PhotoButtonComponent.swift */; };
C2F3940B2C0463940070B4F6 /* ProfileComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2F3940A2C0463940070B4F6 /* ProfileComponent.swift */; };
C2F3940E2C04643A0070B4F6 /* GameView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2F3940D2C04643A0070B4F6 /* GameView.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 */; };
@ -67,6 +71,9 @@
C24659E82BF60FAA004E80D5 /* ButtonComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonComponent.swift; sourceTree = "<group>"; };
C25220ED2C00AC7E0026B71F /* GameParametersMenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameParametersMenuView.swift; sourceTree = "<group>"; };
C25220F22C00AF490026B71F /* EditComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditComponent.swift; sourceTree = "<group>"; };
C2F394072C0462400070B4F6 /* PhotoButtonComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotoButtonComponent.swift; sourceTree = "<group>"; };
C2F3940A2C0463940070B4F6 /* ProfileComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileComponent.swift; sourceTree = "<group>"; };
C2F3940D2C04643A0070B4F6 /* GameView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameView.swift; sourceTree = "<group>"; };
C2F4176C2BFE2FBD00CFF0B3 /* howto.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = howto.md; sourceTree = "<group>"; };
C2F4176D2BFE2FBD00CFF0B3 /* DSQ.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; path = DSQ.xcframework; sourceTree = "<group>"; };
C2F4176E2BFE2FBD00CFF0B3 /* capture.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = capture.png; sourceTree = "<group>"; };
@ -78,6 +85,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
C2F394062C045E800070B4F6 /* DSQ.xcframework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -151,6 +159,7 @@
C205A2BC2BF373380097BD93 /* Views */ = {
isa = PBXGroup;
children = (
C2F3940C2C0464260070B4F6 /* Game */,
C25220F02C00AD7F0026B71F /* Components */,
C25220EC2C00AC530026B71F /* GameParametersMenu */,
C25220EB2C00A9230026B71F /* GeneralParametersMenu */,
@ -205,6 +214,7 @@
C25220F02C00AD7F0026B71F /* Components */ = {
isa = PBXGroup;
children = (
C2F394092C04636C0070B4F6 /* Visuals */,
C25220F12C00ADF70026B71F /* Controls */,
);
path = Components;
@ -217,10 +227,27 @@
C20310D92BFCC8600031657D /* ToggleComponent.swift */,
C24659E82BF60FAA004E80D5 /* ButtonComponent.swift */,
C25220F22C00AF490026B71F /* EditComponent.swift */,
C2F394072C0462400070B4F6 /* PhotoButtonComponent.swift */,
);
path = Controls;
sourceTree = "<group>";
};
C2F394092C04636C0070B4F6 /* Visuals */ = {
isa = PBXGroup;
children = (
C2F3940A2C0463940070B4F6 /* ProfileComponent.swift */,
);
path = Visuals;
sourceTree = "<group>";
};
C2F3940C2C0464260070B4F6 /* Game */ = {
isa = PBXGroup;
children = (
C2F3940D2C04643A0070B4F6 /* GameView.swift */,
);
path = Game;
sourceTree = "<group>";
};
C2F4176A2BFE2F8C00CFF0B3 /* Model */ = {
isa = PBXGroup;
children = (
@ -376,9 +403,12 @@
C205A2B92BF373360097BD93 /* ContentView.swift in Sources */,
82F9D3312BFE3A9F009EDFAF /* HistoryGameDetail.swift in Sources */,
C24659E92BF60FAA004E80D5 /* ButtonComponent.swift in Sources */,
C2F394082C0462400070B4F6 /* PhotoButtonComponent.swift in Sources */,
C2F3940E2C04643A0070B4F6 /* GameView.swift in Sources */,
C24659E52BF5FE09004E80D5 /* MainMenu.swift in Sources */,
82F9D3362BFE3B3C009EDFAF /* HistoryView.swift in Sources */,
C20310D82BFCC2410031657D /* GeneralParametersMenuView.swift in Sources */,
C2F3940B2C0463940070B4F6 /* ProfileComponent.swift in Sources */,
C205A2B72BF373360097BD93 /* ArkitDoushiQiApp.swift in Sources */,
C25220F32C00AF490026B71F /* EditComponent.swift in Sources */,
C20310D62BFCB5FB0031657D /* PickerComponent.swift in Sources */,

@ -12,7 +12,7 @@ struct ArkitDoushiQiApp: App {
@AppStorage("isDarkMode") private var isDarkMode = false
var body: some Scene {
WindowGroup {
ContentView()
MainMenu(playButtonText: "Jouer", registeredGamesButtonText: "Parties enregistrées",ParametersButtontText: "Paramètres")
.preferredColorScheme(isDarkMode ? .dark : .light)
}
}

@ -0,0 +1,73 @@
//
// PhotoButtonComponent.swift
// ArkitDoushiQi
//
// Created by Johan LACHENAL on 27/05/2024.
//
import SwiftUI
class Coordinator: NSObject, UINavigationControllerDelegate, UIImagePickerControllerDelegate {
var picker: accessCameraView
init(picker: accessCameraView) {
self.picker = picker
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
guard let selectedImage = info[.originalImage] as? UIImage else { return }
self.picker.selectedImage = selectedImage
self.picker.isPresented.wrappedValue.dismiss()
}
}
struct accessCameraView: UIViewControllerRepresentable {
@Binding var selectedImage: UIImage?
@Environment(\.presentationMode) var isPresented
func makeUIViewController(context: Context) -> 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")
}
}

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

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

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

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

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

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save