Something went wrong. Try again.
Bluesky app fork with some witchin' additions 💫 forked from jollywhoppers.com/witchsky.app
Something went wrong. Try again.
916 B · 31 lines
TypeScript
at main
1234567891011121314151617181920212223242526272829303132import React from 'react'import * as Device from 'expo-device'import {impactAsync, ImpactFeedbackStyle} from 'expo-haptics'
import {useHapticsDisabled} from '#/state/preferences/disable-haptics'import {IS_IOS, IS_WEB} from '#/env'
export function useHaptics() { const isHapticsDisabled = useHapticsDisabled()
return React.useCallback( (strength: 'Light' | 'Medium' | 'Heavy' = 'Medium') => { if (isHapticsDisabled || IS_WEB) { return }
// Users said the medium impact was too strong on Android; see APP-537s const style = IS_IOS ? ImpactFeedbackStyle[strength] : ImpactFeedbackStyle.Light impactAsync(style)
// DEV ONLY - show a toast when a haptic is meant to fire on simulator if (__DEV__ && !Device.isDevice) { // disabled because it's annoying // Toast.show(`Buzzz!`) } }, [isHapticsDisabled], )}