//
//  ParametersMenuView.swift
//  ArkitDoushiQi
//
//  Created by Johan LACHENAL on 21/05/2024.
//

import SwiftUI

struct GeneralParametersMenuView: View {
    @State private var selectedAIOption: AI
    @State private var selectedLanguageOption: Language
    @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) {
        self.ParametersTitle = parametersTitle
        self.selectedAIOption = selectedAIOption
        self.selectedLanguageOption = selectedLanguageOption
        self.selectedRulesOption = selectedRulesOption
        self.DarkModeDescription = DarkModeDescription
        self.DarModeBooleanName = DarModeBooleanName
        self.DarkModeDefaultValue = DarkModeDefaultValue
        self.LanguagePickerTitle = LanguagePickerTitle
    }
    
    var body: some View {
        VStack(alignment: .leading) {
            HStack(alignment: .center) {
                Text(ParametersTitle).bold().font(.title)
            }.frame(maxWidth: .infinity)
            Spacer().frame(maxHeight: 30)
            ToggleComponent(description: "Dark mode", booleanName: "isDarkMode", booleanDefaultValue: false)
            PickerComponent(title: "Sélectionne un langage :",
                           selectedOption: $selectedLanguageOption,
                           options: Language.allCases)
            
        }.frame(maxHeight: .infinity, alignment: .top)
    }
}

struct GeneralParametersMenuView_Previews: PreviewProvider {
    static var previews: some View {
        GeneralParametersMenuView(
            parametersTitle: "Paramètres",
            selectedAIOption: .RandomAction,
            selectedLanguageOption: .French,
            selectedRulesOption: .Regular,
            DarkModeDescription: "Dark Mode",
            DarModeBooleanName: "isDarkMode",
            DarkModeDefaultValue: false,
            LanguagePickerTitle: "Séléctionne un langage"
        )
    }
}
