//
//  ThosPreferenceView.swift
//  Werkout_ios
//
//  Created by Trey Tartt on 6/16/24.
//

import SwiftUI

struct ThotPreferenceView: View {
    @ObservedObject var userStore = UserStore.shared
    @AppStorage(Constants.phoneThotStyle) private var phoneThotStyle: ThotStyle = .never
    @AppStorage(Constants.extThotStyle) private var extThotStyle: ThotStyle = .never
    @AppStorage(Constants.thotGenderOption) private var thotGenderOption: String = "female"
    
    var body: some View {
        if userStore.registeredUser?.NSFWValue ?? false {
            Group {
                Text("Phone THOT Style:")
                Picker("Phone THOT Style:", selection: $phoneThotStyle) {
                    ForEach(ThotStyle.allCases, id: \.self) { style in
                        Text(style.stringValue())
                            .tag(phoneThotStyle.rawValue)
                    }
                }
                .pickerStyle(.segmented)
                
                Divider()
                
                Text("External THOT Style:")
                Picker("External THOT Style:", selection: $extThotStyle) {
                    ForEach(ThotStyle.allCases, id: \.self) { style in
                        Text(style.stringValue())
                            .tag(extThotStyle.rawValue)
                    }
                }
                .pickerStyle(.segmented)
                
                if let genderOptions = DataStore.shared.nsfwGenderOptions {
                    Divider()
                    Text("Video Gender:")
                    Picker("Video Gender:", selection: $thotGenderOption) {
                        ForEach(genderOptions, id: \.self) { option in
                            Text(option.capitalized)
                                .tag(option.lowercased())
                        }
                    }
                    .pickerStyle(.segmented)
                }
            }
        }
    }
}

#Preview {
    ThotPreferenceView()
}
