fix: issue #150 - add haptic feedback option
Automated fix by Tony CI v3. Refs #150 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,7 @@ struct AddMoodHeaderView: View {
|
||||
@AppStorage(UserDefaultsStore.Keys.moodTint.rawValue, store: GroupUserDefaults.groupDefaults) private var moodTint: MoodTints = .Default
|
||||
@AppStorage(UserDefaultsStore.Keys.votingLayoutStyle.rawValue, store: GroupUserDefaults.groupDefaults) private var votingLayoutStyle: Int = 0
|
||||
@AppStorage(UserDefaultsStore.Keys.celebrationAnimation.rawValue, store: GroupUserDefaults.groupDefaults) private var celebrationAnimationIndex: Int = 0
|
||||
@AppStorage(UserDefaultsStore.Keys.hapticFeedbackEnabled.rawValue, store: GroupUserDefaults.groupDefaults) private var hapticFeedbackEnabled = true
|
||||
|
||||
private var textColor: Color { theme.currentTheme.labelColor }
|
||||
|
||||
@@ -90,14 +91,16 @@ struct AddMoodHeaderView: View {
|
||||
}
|
||||
|
||||
private func addItem(withMood mood: Mood) {
|
||||
let impactFeedback = UIImpactFeedbackGenerator(style: .medium)
|
||||
impactFeedback.impactOccurred()
|
||||
|
||||
// Store mood, date, and use saved animation preference
|
||||
celebrationMood = mood
|
||||
celebrationDate = ShowBasedOnVoteLogics.getCurrentVotingDate(onboardingData: onboardingData)
|
||||
celebrationAnimation = CelebrationAnimationType.fromIndex(celebrationAnimationIndex)
|
||||
|
||||
// Play haptic feedback matching the selected animation
|
||||
if hapticFeedbackEnabled {
|
||||
HapticFeedbackManager.shared.play(for: celebrationAnimation)
|
||||
}
|
||||
|
||||
// Show celebration - mood will be saved when animation completes
|
||||
withAnimation(.easeInOut(duration: 0.3)) {
|
||||
showCelebration = true
|
||||
|
||||
@@ -38,6 +38,7 @@ struct SettingsContentView: View {
|
||||
|
||||
@AppStorage(UserDefaultsStore.Keys.deleteEnable.rawValue, store: GroupUserDefaults.groupDefaults) private var deleteEnabled = true
|
||||
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
|
||||
@AppStorage(UserDefaultsStore.Keys.hapticFeedbackEnabled.rawValue, store: GroupUserDefaults.groupDefaults) private var hapticFeedbackEnabled = true
|
||||
|
||||
private var textColor: Color { theme.currentTheme.labelColor }
|
||||
|
||||
@@ -53,6 +54,7 @@ struct SettingsContentView: View {
|
||||
// Settings section
|
||||
settingsSectionHeader
|
||||
reminderTimeButton
|
||||
hapticFeedbackToggle
|
||||
canDelete
|
||||
showOnboardingButton
|
||||
|
||||
@@ -1011,6 +1013,38 @@ struct SettingsContentView: View {
|
||||
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
||||
}
|
||||
|
||||
private var hapticFeedbackToggle: some View {
|
||||
HStack(spacing: 12) {
|
||||
Image(systemName: "waveform")
|
||||
.font(.title2)
|
||||
.foregroundColor(.purple)
|
||||
.frame(width: 32)
|
||||
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text(String(localized: "Haptic Feedback"))
|
||||
.foregroundColor(textColor)
|
||||
|
||||
Text(String(localized: "Vibrate when logging mood"))
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
Toggle("", isOn: $hapticFeedbackEnabled)
|
||||
.labelsHidden()
|
||||
.onChange(of: hapticFeedbackEnabled) { _, newValue in
|
||||
AnalyticsManager.shared.track(.hapticFeedbackToggled(enabled: newValue))
|
||||
}
|
||||
.accessibilityLabel(String(localized: "Haptic Feedback"))
|
||||
.accessibilityHint(String(localized: "Toggle vibration feedback when voting"))
|
||||
}
|
||||
.padding()
|
||||
.background(theme.currentTheme.secondaryBGColor)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
||||
}
|
||||
|
||||
private var canDelete: some View {
|
||||
VStack {
|
||||
Toggle(String(localized: "settings_use_delete_enable"),
|
||||
@@ -1205,6 +1239,7 @@ struct SettingsView: View {
|
||||
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
|
||||
@AppStorage(UserDefaultsStore.Keys.firstLaunchDate.rawValue, store: GroupUserDefaults.groupDefaults) private var firstLaunchDate = Date()
|
||||
@AppStorage(UserDefaultsStore.Keys.privacyLockEnabled.rawValue, store: GroupUserDefaults.groupDefaults) private var privacyLockEnabled = false
|
||||
@AppStorage(UserDefaultsStore.Keys.hapticFeedbackEnabled.rawValue, store: GroupUserDefaults.groupDefaults) private var hapticFeedbackEnabled = true
|
||||
|
||||
private var textColor: Color { theme.currentTheme.labelColor }
|
||||
|
||||
@@ -1226,6 +1261,7 @@ struct SettingsView: View {
|
||||
|
||||
// Settings section
|
||||
settingsSectionHeader
|
||||
hapticFeedbackToggle
|
||||
canDelete
|
||||
showOnboardingButton
|
||||
|
||||
@@ -1823,6 +1859,38 @@ struct SettingsView: View {
|
||||
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
||||
}
|
||||
|
||||
private var hapticFeedbackToggle: some View {
|
||||
HStack(spacing: 12) {
|
||||
Image(systemName: "waveform")
|
||||
.font(.title2)
|
||||
.foregroundColor(.purple)
|
||||
.frame(width: 32)
|
||||
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text(String(localized: "Haptic Feedback"))
|
||||
.foregroundColor(textColor)
|
||||
|
||||
Text(String(localized: "Vibrate when logging mood"))
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
Toggle("", isOn: $hapticFeedbackEnabled)
|
||||
.labelsHidden()
|
||||
.onChange(of: hapticFeedbackEnabled) { _, newValue in
|
||||
AnalyticsManager.shared.track(.hapticFeedbackToggled(enabled: newValue))
|
||||
}
|
||||
.accessibilityLabel(String(localized: "Haptic Feedback"))
|
||||
.accessibilityHint(String(localized: "Toggle vibration feedback when voting"))
|
||||
}
|
||||
.padding()
|
||||
.background(theme.currentTheme.secondaryBGColor)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
||||
}
|
||||
|
||||
private var canDelete: some View {
|
||||
VStack {
|
||||
Toggle(String(localized: "settings_use_delete_enable"),
|
||||
@@ -1837,7 +1905,7 @@ struct SettingsView: View {
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
||||
}
|
||||
|
||||
|
||||
private var exportData: some View {
|
||||
Button(action: {
|
||||
showingExporter.toggle()
|
||||
|
||||
Reference in New Issue
Block a user