Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
quiple committed Nov 11, 2024
2 parents bf5cc29 + 57464a8 commit 5dd8b80
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/screens/Settings/components/CopyButton.tsx
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -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) => {
Expand Down

0 comments on commit 5dd8b80

Please sign in to comment.