show a toast when a haptic is meant to fire while using simulator (#5481)

buzzz!
This commit is contained in:
Samuel Newman
2024-09-25 17:13:23 +01:00
committed by GitHub
parent 3293c5e0e0
commit 60b7443535
+7
View File
@@ -1,8 +1,10 @@
import React from 'react' import React from 'react'
import * as Device from 'expo-device'
import {impactAsync, ImpactFeedbackStyle} from 'expo-haptics' import {impactAsync, ImpactFeedbackStyle} from 'expo-haptics'
import {isIOS, isWeb} from '#/platform/detection' import {isIOS, isWeb} from '#/platform/detection'
import {useHapticsDisabled} from '#/state/preferences/disable-haptics' import {useHapticsDisabled} from '#/state/preferences/disable-haptics'
import * as Toast from '#/view/com/util/Toast'
export function useHaptics() { export function useHaptics() {
const isHapticsDisabled = useHapticsDisabled() const isHapticsDisabled = useHapticsDisabled()
@@ -18,6 +20,11 @@ export function useHaptics() {
? ImpactFeedbackStyle[strength] ? ImpactFeedbackStyle[strength]
: ImpactFeedbackStyle.Light : ImpactFeedbackStyle.Light
impactAsync(style) impactAsync(style)
// DEV ONLY - show a toast when a haptic is meant to fire on simulator
if (__DEV__ && !Device.isDevice) {
Toast.show(`Buzzz!`)
}
}, },
[isHapticsDisabled], [isHapticsDisabled],
) )