Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .Jules/palette.md
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.
Comment on lines +1 to +3
Copy link

Copilot AI Apr 8, 2026

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.md note 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).

Copilot uses AI. Check for mistakes.
51 changes: 24 additions & 27 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/screens/FlightScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haptics.impactAsync(...) returns a Promise, but it’s being fired-and-forgotten inside onPanResponderMove. If the call rejects (e.g., unsupported platform/runtime), this can surface as an unhandled promise rejection. Consider explicitly swallowing/handling errors (e.g., attach .catch(() => {}) or wrap in a safe helper) so gesture handling can’t trigger runtime warnings/crashes.

Suggested change
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light).catch(() => {});

Copilot uses AI. Check for mistakes.
hasTriggeredHaptic.current = true;
} else if (g.dx > -SWIPE_THRESHOLD && hasTriggeredHaptic.current) {
hasTriggeredHaptic.current = false;
}
},
onPanResponderRelease: (_, g) => {
hasTriggeredHaptic.current = false;
if (g.dx < -SWIPE_THRESHOLD) {
Animated.timing(translateX, { toValue: -SWIPE_THRESHOLD, duration: 100, useNativeDriver: true }).start(() => {
onToggleRef.current();
Expand All @@ -88,6 +97,7 @@ function SwipeableFlightCard({
}
},
onPanResponderTerminate: () => {
hasTriggeredHaptic.current = false;
Animated.spring(translateX, { toValue: 0, useNativeDriver: true }).start();
},
}), []);
Expand Down
Loading