//
//  SettingsView.swift
//  JustScanIt
//
//  Created by Pradyun Setti on 03/07/2024.
//

import SwiftUI

struct SettingsView: View {
    @Environment(\.dismiss) var dismiss
    
    @AppStorage(Prefs.autoLaunchCamera) var autoLaunchCamera = false
    @AppStorage(Prefs.autoCopy) var autoCopy = false
    
    var body: some View {
        NavigationView {
            List {
                generalSettings
                aboutApp
            }
            .toolbar {
                ToolbarItem(placement: .topBarTrailing) {
                    Button("Done") { dismiss() }
                }
            }
        }
    }
    
    var generalSettings: some View {
        Section {
            Toggle("Launch Camera on Startup", isOn: $autoLaunchCamera)
            Toggle("Auto-Copy on Save", isOn: $autoCopy)
        } header: { Text("General") } footer: { Text("Due to iOS limitations, only the first photo in a capture will be copied.") }
    }
    
    var aboutApp: some View {
        Section {
            LabeledContent("Version", value: "1.0.0")
            
        } header: { Text("About") } footer: { Text("Made by bread! 🇳🇿") }

    }
}

#Preview {
    SettingsView()
}
