import SwiftUI

struct SettingsView: View {
    @AppStorage("haptics_enabled") private var hapticsEnabled = true
    @AppStorage("haptics_messages") private var messageHaptics = true
    @AppStorage("haptics_status") private var statusHaptics = true
    @AppStorage("sounds_enabled") private var soundsEnabled = true
    @AppStorage("sounds_global") private var globalSound = true
    @AppStorage("sounds_map") private var mapSound = true
    @AppStorage("sounds_dm") private var dmSound = true
    @AppStorage("sounds_background_buffers") private var backgroundBufferSounds = true

    var body: some View {
        Form {
            Section("Sounds") {
                Toggle("Sounds", isOn: $soundsEnabled)
                Toggle("Global Chat", isOn: $globalSound)
                    .disabled(!soundsEnabled)
                Toggle("Map Chat", isOn: $mapSound)
                    .disabled(!soundsEnabled)
                Toggle("Direct Messages", isOn: $dmSound)
                    .disabled(!soundsEnabled)
                Toggle("Other Buffers", isOn: $backgroundBufferSounds)
                    .disabled(!soundsEnabled)
            }

            Section("Haptics") {
                Toggle("Haptics", isOn: $hapticsEnabled)
                Toggle("Message Haptics", isOn: $messageHaptics)
                    .disabled(!hapticsEnabled)
                Toggle("Status Haptics", isOn: $statusHaptics)
                    .disabled(!hapticsEnabled)
            }

            Section {
                Link("Visit Website", destination: URL(string: "https://kpguild.games")!)
            }

            Section {
                Text("\(AppInfo.name) \(AppInfo.version) (\(AppInfo.build))")
                    .foregroundStyle(.secondary)
                    .frame(maxWidth: .infinity, alignment: .center)
            }
        }
        .navigationTitle("Settings")
    }
}
