//
//  SettingsView.swift
//  LeCountdown
//
//  Created by Laurent Morvillier on 10/03/2023.
//

import SwiftUI

struct SettingsView: View {
    
    @State var confirmationSound = Preferences.playConfirmationSound
    
    @State var showMailView: Bool = false
    
    var body: some View {
        
        Form {
            Toggle("Play confirmation sound", isOn: self.$confirmationSound).onChange(of: self.confirmationSound) { newValue in
                Preferences.playConfirmationSound = newValue
            }
            Button {
                self.showMailView = true
            } label: {
                Text("Contact us")
            }
        }.sheet(isPresented: $showMailView) {
            MailView(isShowing: $showMailView)
        }
        
    }
    
}

struct SettingsView_Previews: PreviewProvider {
    static var previews: some View {
        SettingsView()
    }
}
