You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
LeCountdown/LeCountdown/Views/SettingsView.swift

68 lines
2.0 KiB

//
// SettingsView.swift
// LeCountdown
//
// Created by Laurent Morvillier on 10/03/2023.
//
import SwiftUI
struct SettingsView: View {
@State var confirmationSound = Preferences.playConfirmationSound
@State var cancellationSound = Preferences.playCancellationSound
@State var defaultVolume: Float = Preferences.defaultVolume
@State var showMailView: Bool = false
@State var showLogsSheet: Bool = false
var body: some View {
Form {
Toggle("Play confirmation sound", isOn: self.$confirmationSound)
.onChange(of: self.confirmationSound) { newValue in
Preferences.playConfirmationSound = newValue
}
Toggle("Play cancellation sound", isOn: self.$cancellationSound)
.onChange(of: self.cancellationSound) { newValue in
Preferences.playCancellationSound = newValue
}
HStack {
Text("Default Volume")
Spacer()
Slider(value: self.$defaultVolume)
.onChange(of: self.defaultVolume, perform: { newValue in
Preferences.defaultVolume = self.defaultVolume
})
.frame(width: 120.0)
}
Button {
self.showMailView = true
} label: {
Text("Contact us")
}
Button {
withAnimation {
self.showLogsSheet.toggle()
}
} label: {
Text("Logs")
}
.sheet(isPresented: self.$showLogsSheet, content: {
NavigationStack {
LogsView().navigationTitle("Logs")
}
})
}.sheet(isPresented: $showMailView) {
MailView(isShowing: $showMailView)
}
}
}
struct SettingsView_Previews: PreviewProvider {
static var previews: some View {
SettingsView()
}
}