about summary refs log tree commit diff
path: root/src/lib/haptics.ts
diff options
context:
space:
mode:
authorHailey <me@haileyok.com>2024-09-23 13:06:22 -0700
committerGitHub <noreply@github.com>2024-09-23 13:06:22 -0700
commitb77031a074161f8c6cd7e666db324eea81a38af1 (patch)
tree1650c251c63b2e741d74058c345eca0c39f3c80f /src/lib/haptics.ts
parent0f36ffdc4386885f3ec4afcf18b1dfc4dc54d5d4 (diff)
downloadvoidsky-b77031a074161f8c6cd7e666db324eea81a38af1.tar.zst
invert the fab animation, play a haptic (#4309)
Diffstat (limited to 'src/lib/haptics.ts')
-rw-r--r--src/lib/haptics.ts24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/lib/haptics.ts b/src/lib/haptics.ts
index 02940f793..390b76a0e 100644
--- a/src/lib/haptics.ts
+++ b/src/lib/haptics.ts
@@ -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],
+  )
 }