62 lines
2.8 KiB
Swift
62 lines
2.8 KiB
Swift
//
|
|
// https://mczachurski.dev
|
|
// Copyright © 2023 Marcin Czachurski and the repository contributors.
|
|
// Licensed under the MIT License.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct HapticsSectionView: View {
|
|
@EnvironmentObject var applicationState: ApplicationState
|
|
@Environment(\.colorScheme) var colorScheme
|
|
|
|
@State var hapticTabSelectionEnabled = true
|
|
@State var hapticButtonPressEnabled = true
|
|
@State var hapticRefreshEnabled = true
|
|
@State var hapticAnimationEnabled = true
|
|
@State var hapticNotificationEnabled = true
|
|
|
|
var body: some View {
|
|
Section("Haptics") {
|
|
|
|
Toggle("Tab selection", isOn: $hapticTabSelectionEnabled)
|
|
.onChange(of: hapticTabSelectionEnabled) { newValue in
|
|
self.applicationState.hapticTabSelectionEnabled = newValue
|
|
ApplicationSettingsHandler.shared.setHapticTabSelectionEnabled(value: newValue)
|
|
}
|
|
|
|
Toggle("Button press", isOn: $hapticButtonPressEnabled)
|
|
.onChange(of: hapticButtonPressEnabled) { newValue in
|
|
self.applicationState.hapticButtonPressEnabled = newValue
|
|
ApplicationSettingsHandler.shared.setHapticButtonPressEnabled(value: newValue)
|
|
}
|
|
|
|
Toggle("List refresh", isOn: $hapticRefreshEnabled)
|
|
.onChange(of: hapticRefreshEnabled) { newValue in
|
|
self.applicationState.hapticRefreshEnabled = newValue
|
|
ApplicationSettingsHandler.shared.setHapticRefreshEnabled(value: newValue)
|
|
}
|
|
|
|
Toggle("Animation finished", isOn: $hapticAnimationEnabled)
|
|
.onChange(of: hapticAnimationEnabled) { newValue in
|
|
self.applicationState.hapticAnimationEnabled = newValue
|
|
ApplicationSettingsHandler.shared.setHapticAnimationEnabled(value: newValue)
|
|
}
|
|
|
|
// Toggle("Notification", isOn: $hapticNotificationEnabled)
|
|
// .onChange(of: hapticNotificationEnabled) { newValue in
|
|
// self.applicationState.hapticNotificationEnabled = newValue
|
|
// ApplicationSettingsHandler.shared.setHapticNotificationEnabled(value: newValue)
|
|
// }
|
|
}
|
|
.onAppear {
|
|
let defaultSettings = ApplicationSettingsHandler.shared.getDefaultSettings()
|
|
self.hapticTabSelectionEnabled = defaultSettings.hapticTabSelectionEnabled
|
|
self.hapticButtonPressEnabled = defaultSettings.hapticButtonPressEnabled
|
|
self.hapticRefreshEnabled = defaultSettings.hapticRefreshEnabled
|
|
self.hapticAnimationEnabled = defaultSettings.hapticAnimationEnabled
|
|
self.hapticNotificationEnabled = defaultSettings.hapticNotificationEnabled
|
|
}
|
|
}
|
|
}
|