Increase copied animation lingering time for reduced motion (#6220)
* increase copied animation lingering time for reduced motion * flip the condition --------- Co-authored-by: dan <dan.abramov@gmail.com>
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
import React, {useCallback, useEffect, useState} from 'react'
|
||||
import {GestureResponderEvent, View} from 'react-native'
|
||||
import Animated, {FadeOutUp, ZoomIn} from 'react-native-reanimated'
|
||||
import Animated, {
|
||||
FadeOutUp,
|
||||
useReducedMotion,
|
||||
ZoomIn,
|
||||
} from 'react-native-reanimated'
|
||||
import * as Clipboard from 'expo-clipboard'
|
||||
import {Trans} from '@lingui/macro'
|
||||
|
||||
@@ -16,13 +20,17 @@ export function CopyButton({
|
||||
}: ButtonProps & {value: string}) {
|
||||
const [hasBeenCopied, setHasBeenCopied] = useState(false)
|
||||
const t = useTheme()
|
||||
const isReducedMotionEnabled = useReducedMotion()
|
||||
|
||||
useEffect(() => {
|
||||
if (hasBeenCopied) {
|
||||
const timeout = setTimeout(() => setHasBeenCopied(false), 100)
|
||||
const timeout = setTimeout(
|
||||
() => setHasBeenCopied(false),
|
||||
isReducedMotionEnabled ? 2000 : 100,
|
||||
)
|
||||
return () => clearTimeout(timeout)
|
||||
}
|
||||
}, [hasBeenCopied])
|
||||
}, [hasBeenCopied, isReducedMotionEnabled])
|
||||
|
||||
const onPress = useCallback(
|
||||
(evt: GestureResponderEvent) => {
|
||||
|
||||
Reference in New Issue
Block a user