-
Notifications
You must be signed in to change notification settings - Fork 0
🎨 Palette: Add haptic feedback to flight card swipe #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ## 2026-04-08 - Haptic feedback for continuous gestures | ||
| **Learning:** When implementing haptic feedback with 'expo-haptics' in continuous gestures (like 'PanResponder'), use a 'useRef' toggle (e.g., 'hasTriggeredHaptic') to ensure the feedback triggers only once when a threshold is crossed. | ||
| **Action:** Always include a reset of the haptic trigger ref in both completion ('onPanResponderRelease') and cancellation ('onPanResponderTerminate') handlers. | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -6,6 +6,7 @@ import { | |||||
| } from 'react-native'; | ||||||
| import * as Calendar from 'expo-calendar'; | ||||||
| import * as Notifications from 'expo-notifications'; | ||||||
| import * as Haptics from 'expo-haptics'; | ||||||
| import AsyncStorage from '@react-native-async-storage/async-storage'; | ||||||
| import { MaterialIcons } from '@expo/vector-icons'; | ||||||
| import { useAppTheme, type ThemeColors } from '../context/ThemeContext'; | ||||||
|
|
@@ -70,14 +71,22 @@ function SwipeableFlightCard({ | |||||
| const translateX = useRef(new Animated.Value(0)).current; | ||||||
| const onToggleRef = useRef(onToggle); | ||||||
| onToggleRef.current = onToggle; | ||||||
| const hasTriggeredHaptic = useRef(false); | ||||||
|
|
||||||
| const panResponder = useMemo(() => PanResponder.create({ | ||||||
| onMoveShouldSetPanResponder: (_, g) => | ||||||
| Math.abs(g.dx) > 15 && Math.abs(g.dx) > Math.abs(g.dy) * 1.5, | ||||||
| onPanResponderMove: (_, g) => { | ||||||
| if (g.dx < 0) translateX.setValue(g.dx); | ||||||
| if (g.dx <= -SWIPE_THRESHOLD && !hasTriggeredHaptic.current) { | ||||||
| Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light); | ||||||
|
||||||
| Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light); | |
| Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light).catch(() => {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR adds a new
.Jules/palette.mdnote file that isn’t mentioned in the PR description and looks like automation/internal “learning” documentation. If this isn’t intended to ship with the app, consider removing it from the PR (or adding.Jules/to.gitignore/ moving this guidance into an appropriate docs location).