Skip to content

Commit

Permalink
[🐴] Adjust press and hold delay on messages (#3918)
Browse files Browse the repository at this point in the history
* adjust press and hold delay on messages

* adjust hit slop
  • Loading branch information
haileyok authored May 8, 2024
1 parent 701e508 commit f62b045
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/components/dms/ActionsWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useCallback} from 'react'
import React from 'react'
import {Keyboard, Pressable, View} from 'react-native'
import Animated, {
cancelAnimation,
Expand All @@ -9,6 +9,7 @@ import Animated, {
} from 'react-native-reanimated'
import {ChatBskyConvoDefs} from '@atproto-labs/api'

import {HITSLOP_10} from 'lib/constants'
import {useHaptics} from 'lib/haptics'
import {atoms as a} from '#/alf'
import {MessageMenu} from '#/components/dms/MessageMenu'
Expand Down Expand Up @@ -37,12 +38,12 @@ export function ActionsWrapper({

// Reanimated's `runOnJS` doesn't like refs, so we can't use `runOnJS(menuControl.open)()`. Instead, we'll use this
// function
const open = useCallback(() => {
const open = React.useCallback(() => {
Keyboard.dismiss()
menuControl.open()
}, [menuControl])

const shrink = useCallback(() => {
const shrink = React.useCallback(() => {
'worklet'
cancelAnimation(scale)
scale.value = withTiming(1, {duration: 200}, () => {
Expand All @@ -52,7 +53,7 @@ export function ActionsWrapper({

const grow = React.useCallback(() => {
'worklet'
scale.value = withTiming(1.05, {duration: 750}, finished => {
scale.value = withTiming(1.05, {duration: 450}, finished => {
if (!finished) return
animationDidComplete.value = true
runOnJS(playHaptic)()
Expand All @@ -74,7 +75,8 @@ export function ActionsWrapper({
style={animatedStyle}
unstable_pressDelay={200}
onPressIn={grow}
onTouchEnd={shrink}>
onTouchEnd={shrink}
hitSlop={HITSLOP_10}>
{children}
</AnimatedPressable>
<MessageMenu message={message} control={menuControl} hideTrigger={true} />
Expand Down

0 comments on commit f62b045

Please sign in to comment.