Bluesky app fork with some witchin' additions 馃挮
at bbab7695f92b9d0f5ec9d2c01ebe796a00df9068 31 lines 927 B view raw
1import React from 'react' 2import * as Device from 'expo-device' 3import {impactAsync, ImpactFeedbackStyle} from 'expo-haptics' 4 5import {isIOS, isWeb} from '#/platform/detection' 6import {useHapticsDisabled} from '#/state/preferences/disable-haptics' 7 8export function useHaptics() { 9 const isHapticsDisabled = useHapticsDisabled() 10 11 return React.useCallback( 12 (strength: 'Light' | 'Medium' | 'Heavy' = 'Medium') => { 13 if (isHapticsDisabled || isWeb) { 14 return 15 } 16 17 // Users said the medium impact was too strong on Android; see APP-537s 18 const style = isIOS 19 ? ImpactFeedbackStyle[strength] 20 : ImpactFeedbackStyle.Light 21 impactAsync(style) 22 23 // DEV ONLY - show a toast when a haptic is meant to fire on simulator 24 if (__DEV__ && !Device.isDevice) { 25 // disabled because it's annoying 26 // Toast.show(`Buzzz!`) 27 } 28 }, 29 [isHapticsDisabled], 30 ) 31}