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:
Khuddite
2024-11-11 05:40:47 -05:00
committed by GitHub
parent 9247407c70
commit 57464a8fe0
+11 -3
View File
@@ -1,6 +1,10 @@
import React, {useCallback, useEffect, useState} from 'react' import React, {useCallback, useEffect, useState} from 'react'
import {GestureResponderEvent, View} from 'react-native' 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 * as Clipboard from 'expo-clipboard'
import {Trans} from '@lingui/macro' import {Trans} from '@lingui/macro'
@@ -16,13 +20,17 @@ export function CopyButton({
}: ButtonProps & {value: string}) { }: ButtonProps & {value: string}) {
const [hasBeenCopied, setHasBeenCopied] = useState(false) const [hasBeenCopied, setHasBeenCopied] = useState(false)
const t = useTheme() const t = useTheme()
const isReducedMotionEnabled = useReducedMotion()
useEffect(() => { useEffect(() => {
if (hasBeenCopied) { if (hasBeenCopied) {
const timeout = setTimeout(() => setHasBeenCopied(false), 100) const timeout = setTimeout(
() => setHasBeenCopied(false),
isReducedMotionEnabled ? 2000 : 100,
)
return () => clearTimeout(timeout) return () => clearTimeout(timeout)
} }
}, [hasBeenCopied]) }, [hasBeenCopied, isReducedMotionEnabled])
const onPress = useCallback( const onPress = useCallback(
(evt: GestureResponderEvent) => { (evt: GestureResponderEvent) => {