Skip to content

Commit

Permalink
show a toast when a haptic is meant to fire while using simulator (#5481
Browse files Browse the repository at this point in the history
)

buzzz!
  • Loading branch information
mozzius authored Sep 25, 2024
1 parent 3293c5e commit 60b7443
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/lib/haptics.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React from 'react'
import * as Device from 'expo-device'
import {impactAsync, ImpactFeedbackStyle} from 'expo-haptics'

import {isIOS, isWeb} from '#/platform/detection'
import {useHapticsDisabled} from '#/state/preferences/disable-haptics'
import * as Toast from '#/view/com/util/Toast'

export function useHaptics() {
const isHapticsDisabled = useHapticsDisabled()
Expand All @@ -18,6 +20,11 @@ export function useHaptics() {
? ImpactFeedbackStyle[strength]
: ImpactFeedbackStyle.Light
impactAsync(style)

// DEV ONLY - show a toast when a haptic is meant to fire on simulator
if (__DEV__ && !Device.isDevice) {
Toast.show(`Buzzz!`)
}
},
[isHapticsDisabled],
)
Expand Down

0 comments on commit 60b7443

Please sign in to comment.