You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
2.2 KiB

//
// GameParametersMenuView.swift
// ArkitDoushiQi
//
// Created by Johan LACHENAL on 24/05/2024.
//
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, KeyboardReadable {
@State private var selectedAIOption: AIT = .RandomAction
@State private var selectedRulesOption: Rules = .Regular
@State private var isKeyboardVisible = false
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)
ProfileEdit(color: Color(.red), profileWidth: 100, profileHeight: 100, defaultImage: Image("profil"), imageTextChange: "changer l'avatar du joueur 1")
ProfileEdit(color: Color(.blue), profileWidth: 100, profileHeight: 100, defaultImage: Image("profil"), imageTextChange: "changer l'avatar du joueur 2")
if !isKeyboardVisible
{
ButtonComponent(title: "Lancer la partie") {
GameView()
}.padding(EdgeInsets(top: 10, leading: 32, bottom: 10, trailing: 32))
}
}
.onReceive(keyboardPublisher) { value in isKeyboardVisible = value }
.frame(maxHeight: .infinity, alignment: .top)
}
}
}
struct GameParametersMenuView_Previews: PreviewProvider {
static var previews: some View {
GameParametersMenuView()
}
}