diff options
Diffstat (limited to 'components/HapticTab.tsx')
-rw-r--r-- | components/HapticTab.tsx | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/components/HapticTab.tsx b/components/HapticTab.tsx new file mode 100644 index 0000000..7f3981c --- /dev/null +++ b/components/HapticTab.tsx @@ -0,0 +1,18 @@ +import { BottomTabBarButtonProps } from '@react-navigation/bottom-tabs'; +import { PlatformPressable } from '@react-navigation/elements'; +import * as Haptics from 'expo-haptics'; + +export function HapticTab(props: BottomTabBarButtonProps) { + return ( + <PlatformPressable + {...props} + onPressIn={(ev) => { + if (process.env.EXPO_OS === 'ios') { + // Add a soft haptic feedback when pressing down on the tabs. + Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light); + } + props.onPressIn?.(ev); + }} + /> + ); +} |