Merge pull request 'ParametersMenuView' (#11) from ParametersMenuView into dev

Reviewed-on: #11
pull/14/head^2
Johan LACHENAL 11 months ago
commit a1fc645b81

@ -7,8 +7,9 @@
objects = {
/* Begin PBXBuildFile section */
8203E9072BF60118005F5C4A /* DSQ.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8203E9062BF60118005F5C4A /* DSQ.xcframework */; };
8203E9082BF60118005F5C4A /* DSQ.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 8203E9062BF60118005F5C4A /* DSQ.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
C20310D62BFCB5FB0031657D /* DoushiQiPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = C20310D52BFCB5FB0031657D /* DoushiQiPicker.swift */; };
C20310D82BFCC2410031657D /* ParametersMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C20310D72BFCC2410031657D /* ParametersMenuView.swift */; };
C20310DA2BFCC8600031657D /* ToggleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C20310D92BFCC8600031657D /* ToggleView.swift */; };
C205A2B72BF373360097BD93 /* ArkitDoushiQiApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = C205A2B62BF373360097BD93 /* ArkitDoushiQiApp.swift */; };
C205A2B92BF373360097BD93 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C205A2B82BF373360097BD93 /* ContentView.swift */; };
C205A2BB2BF373380097BD93 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C205A2BA2BF373380097BD93 /* Assets.xcassets */; };
@ -17,6 +18,7 @@
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 /* MainMenuButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = C24659E82BF60FAA004E80D5 /* MainMenuButton.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -51,7 +53,13 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
<<<<<<< HEAD
C20310D52BFCB5FB0031657D /* DoushiQiPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DoushiQiPicker.swift; sourceTree = "<group>"; };
C20310D72BFCC2410031657D /* ParametersMenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParametersMenuView.swift; sourceTree = "<group>"; };
C20310D92BFCC8600031657D /* ToggleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToggleView.swift; sourceTree = "<group>"; };
=======
8203E9062BF60118005F5C4A /* DSQ.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; path = DSQ.xcframework; sourceTree = "<group>"; };
>>>>>>> b8e1f34acd3b08194d2681099a92f8b403a47687
C205A2B32BF373360097BD93 /* ArkitDoushiQi.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ArkitDoushiQi.app; sourceTree = BUILT_PRODUCTS_DIR; };
C205A2B62BF373360097BD93 /* ArkitDoushiQiApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArkitDoushiQiApp.swift; sourceTree = "<group>"; };
C205A2B82BF373360097BD93 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
@ -63,6 +71,7 @@
C205A2D12BF373380097BD93 /* WtaTennisUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WtaTennisUITests.swift; sourceTree = "<group>"; };
C205A2D32BF373380097BD93 /* WtaTennisUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WtaTennisUITestsLaunchTests.swift; sourceTree = "<group>"; };
C24659E42BF5FE09004E80D5 /* MainMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenu.swift; sourceTree = "<group>"; };
C24659E82BF60FAA004E80D5 /* MainMenuButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenuButton.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -136,6 +145,10 @@
children = (
C205A2BD2BF373380097BD93 /* Preview Assets.xcassets */,
C24659E42BF5FE09004E80D5 /* MainMenu.swift */,
C24659E82BF60FAA004E80D5 /* MainMenuButton.swift */,
C20310D52BFCB5FB0031657D /* DoushiQiPicker.swift */,
C20310D72BFCC2410031657D /* ParametersMenuView.swift */,
C20310D92BFCC8600031657D /* ToggleView.swift */,
);
path = "Preview Content";
sourceTree = "<group>";
@ -289,8 +302,12 @@
buildActionMask = 2147483647;
files = (
C205A2B92BF373360097BD93 /* ContentView.swift in Sources */,
C24659E92BF60FAA004E80D5 /* MainMenuButton.swift in Sources */,
C24659E52BF5FE09004E80D5 /* MainMenu.swift in Sources */,
C20310D82BFCC2410031657D /* ParametersMenuView.swift in Sources */,
C205A2B72BF373360097BD93 /* ArkitDoushiQiApp.swift in Sources */,
C20310D62BFCB5FB0031657D /* DoushiQiPicker.swift in Sources */,
C20310DA2BFCC8600031657D /* ToggleView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

@ -9,9 +9,11 @@ import SwiftUI
@main
struct ArkitDoushiQiApp: App {
@AppStorage("isDarkMode") private var isDarkMode = false
var body: some Scene {
WindowGroup {
ContentView()
.preferredColorScheme(isDarkMode ? .dark : .light)
}
}
}

@ -0,0 +1,38 @@
{
"colors" : [
{
"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
}
}

@ -0,0 +1,71 @@
//
// DoushiQiPicker.swift
// ArkitDoushiQi
//
// Created by Johan LACHENAL on 21/05/2024.
//
import SwiftUI
struct DoushiQiPicker<EnumType: RawRepresentable & Identifiable & Hashable>: View where EnumType.RawValue == String {
let title: String
@Binding var selectedOption: EnumType
let options: [EnumType]
init(title: String, selectedOption: Binding<EnumType>, options: [EnumType]) {
self.title = title
self._selectedOption = selectedOption
self.options = options
}
var body: some View {
VStack(spacing: 0) {
Divider().background(Color.gray)
Menu {
Picker(title, selection: $selectedOption) {
ForEach(options) { option in
Text(option.rawValue.description)
.padding()
}
}
.labelsHidden()
.pickerStyle(InlinePickerStyle())
} label: {
HStack {
Text(title)
.foregroundColor(.black)
.padding()
Spacer() // .frame(width : (20 - CGFloat(title.count)))
Text(selectedOption.rawValue.description)
.foregroundColor(.black)
.padding()
}
.frame(maxWidth: .infinity)
.padding(EdgeInsets(top: 0, leading: 32, bottom: 0, trailing: 32))
}
Divider().background(Color.gray)
}
}
}
struct DoushiQiPicker_Previews: PreviewProvider {
enum AI: String, CaseIterable, Identifiable, Hashable {
case RandomAction = "IA Random"
case EasyTrainedAI = "IA Facile"
case MediumTrainedAI = "IA Intermédiaire"
var id: String { self.rawValue }
}
@State static var selectedItem = AI.RandomAction
static var previews: some View {
DoushiQiPicker(
title: "Selectionne une IA :",
selectedOption: $selectedItem,
options: AI.allCases
)
}
}

@ -8,8 +8,33 @@
import SwiftUI
struct MainMenu: View {
@State private var action: Int? = 0
@AppStorage("isDarkMode") private var isDarkMode = false
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
VStack {
NavigationView {
VStack(alignment: .trailing) {
HStack(alignment: .top) {
Text("DouShiQi").frame(maxHeight: .infinity)
.bold()
.font(.title)
}.frame(maxWidth: .infinity,maxHeight: .infinity)
Spacer().frame(maxWidth: .infinity,maxHeight: .infinity)
Spacer().frame(height: 20)
MainMenuButton(title: "jouer")
{ Text("jeu page") }
MainMenuButton(title: "parties enregistrées")
{ Text("parties enregistrées page") }
Spacer().frame(height: 20)
MainMenuButton(title: "paramètres")
{ ParametersMenuView() }
Spacer()
}
.fixedSize(horizontal: false, vertical: true)
.padding(EdgeInsets(top: 10, leading: 32, bottom: 10, trailing: 32))
.frame(maxWidth: .infinity,maxHeight: .infinity)
}.frame(maxWidth: .infinity,maxHeight: .infinity)
}.frame(maxWidth: .infinity,maxHeight: .infinity)
}
}

@ -0,0 +1,46 @@
//
// MainMenuButton.swift
// ArkitDoushiQi
//
// Created by Johan LACHENAL on 16/05/2024.
//
import SwiftUI
struct MainMenuButton<Content : View>: View {
let content: Content
let title: String
init(title: String, @ViewBuilder content: () -> Content) {
self.title = title
self.content = content()
}
var body: some View {
NavigationLink(title){
// ici mettre la vue sur les parties enregistrées à la place du texte n'hésite pas à tester sur la preview la navigation ça marche, faire pareil pour les autres
content
}
.frame(maxWidth: .infinity)
.padding(EdgeInsets(top: 10, leading: 32, bottom: 10, trailing: 32))
.buttonStyle(.bordered)
.controlSize(.large)
.foregroundColor(.white)
.background(.black)
.buttonBorderShape(.roundedRectangle)
.clipShape(Capsule())
Spacer().frame(height: 50)
}
}
struct MainMenuButton_Previews: PreviewProvider {
static var previews: some View {
NavigationView {
VStack {
MainMenuButton(title: "Parties enregistrées") {
Text("Je suis un test")
}
}
}
}
}

@ -0,0 +1,59 @@
//
// ParametersMenuView.swift
// ArkitDoushiQi
//
// Created by Johan LACHENAL on 21/05/2024.
//
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 ParametersMenuView: View {
@State private var selectedAIOption: AIT = .RandomAction
@State private var selectedLanguageOption: Language = .French
@State private var selectedRulesOption: Rules = .Regular
var body: some View {
VStack(alignment: .leading) {
HStack(alignment: .center) {
Text("Paramètres").bold().font(.title)
}.frame(maxWidth: .infinity)
Spacer().frame(maxHeight: 30)
ToggleView()
DoushiQiPicker(title: "Sélectionne une IA :",
selectedOption: $selectedAIOption,
options: AIT.allCases)
DoushiQiPicker(title: "Sélectionne un langage :",
selectedOption: $selectedLanguageOption,
options: Language.allCases)
DoushiQiPicker(title: "Sélectionne les règles :",
selectedOption: $selectedRulesOption,
options: Rules.allCases)
}.frame(maxHeight: .infinity, alignment: .top)
}
}
struct ParametersMenuView_Previews: PreviewProvider {
static var previews: some View {
ParametersMenuView()
}
}

@ -0,0 +1,27 @@
//
// ToggleView.swift
// ArkitDoushiQi
//
// Created by Johan LACHENAL on 21/05/2024.
//
import SwiftUI
struct ToggleView: View {
@AppStorage("isDarkMode") private var isDarkMode = false
var body: some View {
Divider().background(Color.gray).padding(.vertical, 1)
Toggle("Dark Mode", isOn: $isDarkMode)
.toggleStyle(SwitchToggleStyle(tint: .blue))
.padding(EdgeInsets(top: 0, leading: 48, bottom: 0, trailing: 48))
Divider().background(Color.gray).padding(.vertical, 1)
}
}
struct ToggleView_Previews: PreviewProvider {
static var previews: some View {
VStack{
ToggleView()
}
}
}

@ -0,0 +1,20 @@
/
// Picker.swift
// ArkitDoushiQi
//
// Created by Johan LACHENAL on 21/05/2024.
//
import SwiftUI
struct Picker: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
struct Picker_Previews: PreviewProvider {
static var previews: some View {
Picker()
}
}
Loading…
Cancel
Save