invert the fab animation, play a haptic (#4309)
This commit is contained in:
+14
-10
@@ -4,17 +4,21 @@ import {impactAsync, ImpactFeedbackStyle} from 'expo-haptics'
|
||||
import {isIOS, isWeb} from 'platform/detection'
|
||||
import {useHapticsDisabled} from 'state/preferences/disable-haptics'
|
||||
|
||||
const hapticImpact: ImpactFeedbackStyle = isIOS
|
||||
? ImpactFeedbackStyle.Medium
|
||||
: ImpactFeedbackStyle.Light // Users said the medium impact was too strong on Android; see APP-537s
|
||||
|
||||
export function useHaptics() {
|
||||
const isHapticsDisabled = useHapticsDisabled()
|
||||
|
||||
return React.useCallback(() => {
|
||||
if (isHapticsDisabled || isWeb) {
|
||||
return
|
||||
}
|
||||
impactAsync(hapticImpact)
|
||||
}, [isHapticsDisabled])
|
||||
return React.useCallback(
|
||||
(strength: 'Light' | 'Medium' | 'Heavy' = 'Medium') => {
|
||||
if (isHapticsDisabled || isWeb) {
|
||||
return
|
||||
}
|
||||
|
||||
// Users said the medium impact was too strong on Android; see APP-537s
|
||||
const style = isIOS
|
||||
? ImpactFeedbackStyle[strength]
|
||||
: ImpactFeedbackStyle.Light
|
||||
impactAsync(style)
|
||||
},
|
||||
[isHapticsDisabled],
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user