diff options
author | Hailey <me@haileyok.com> | 2024-09-24 00:44:47 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-24 00:44:47 -0700 |
commit | b57ddd0968ebc08e9d5fc80b2e93fdb8786aef7e (patch) | |
tree | 790dba415c1c15906e93b57b07b72bfbfdac0055 /src | |
parent | 53b095adeb235cdee0b2b883057900d64f9d51e7 (diff) | |
download | voidsky-b57ddd0968ebc08e9d5fc80b2e93fdb8786aef7e.tar.zst |
Revert change in FAB animation (#5465)
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/haptics.ts | 4 | ||||
-rw-r--r-- | src/view/com/util/fab/FABInner.tsx | 35 |
2 files changed, 14 insertions, 25 deletions
diff --git a/src/lib/haptics.ts b/src/lib/haptics.ts index 390b76a0e..f588808fc 100644 --- a/src/lib/haptics.ts +++ b/src/lib/haptics.ts @@ -1,8 +1,8 @@ import React from 'react' import {impactAsync, ImpactFeedbackStyle} from 'expo-haptics' -import {isIOS, isWeb} from 'platform/detection' -import {useHapticsDisabled} from 'state/preferences/disable-haptics' +import {isIOS, isWeb} from '#/platform/detection' +import {useHapticsDisabled} from '#/state/preferences/disable-haptics' export function useHaptics() { const isHapticsDisabled = useHapticsDisabled() diff --git a/src/view/com/util/fab/FABInner.tsx b/src/view/com/util/fab/FABInner.tsx index d1675b428..5d8aac81a 100644 --- a/src/view/com/util/fab/FABInner.tsx +++ b/src/view/com/util/fab/FABInner.tsx @@ -1,20 +1,16 @@ import React, {ComponentProps} from 'react' import {StyleSheet, TouchableWithoutFeedback} from 'react-native' -import Animated, { - Easing, - useAnimatedStyle, - withTiming, -} from 'react-native-reanimated' +import Animated, {useAnimatedStyle, withTiming} from 'react-native-reanimated' import {useSafeAreaInsets} from 'react-native-safe-area-context' import {LinearGradient} from 'expo-linear-gradient' +import {useHaptics} from '#/lib/haptics' import {useMinimalShellFabTransform} from '#/lib/hooks/useMinimalShellTransform' import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries' import {clamp} from '#/lib/numbers' import {gradients} from '#/lib/styles' import {isWeb} from '#/platform/detection' -import {useHaptics} from 'lib/haptics' -import {useHapticsDisabled} from 'state/preferences' +import {useHapticsDisabled} from '#/state/preferences' import {useInteractionState} from '#/components/hooks/useInteractionState' export interface FABProps @@ -26,14 +22,14 @@ export interface FABProps export function FABInner({testID, icon, onPress, ...props}: FABProps) { const insets = useSafeAreaInsets() const {isMobile, isTablet} = useWebMediaQueries() + const playHaptic = useHaptics() + const isHapticsDisabled = useHapticsDisabled() const fabMinimalShellTransform = useMinimalShellFabTransform() const { - state: isPressed, + state: pressed, onIn: onPressIn, onOut: onPressOut, } = useInteractionState() - const playHaptic = useHaptics() - const isHapticsDisabled = useHapticsDisabled() const size = isTablet ? styles.sizeLarge : styles.sizeRegular @@ -41,22 +37,17 @@ export function FABInner({testID, icon, onPress, ...props}: FABProps) { ? {right: 50, bottom: 50} : {right: 24, bottom: clamp(insets.bottom, 15, 60) + 15} - const animatedStyle = useAnimatedStyle(() => ({ - transform: [ - { - scale: withTiming(isPressed ? 1.1 : 1, { - duration: 250, - easing: Easing.out(Easing.quad), - }), - }, - ], + const scale = useAnimatedStyle(() => ({ + transform: [{scale: withTiming(pressed ? 0.95 : 1)}], })) return ( <TouchableWithoutFeedback testID={testID} + onPressIn={onPressIn} + onPressOut={onPressOut} onPress={e => { - playHaptic() + playHaptic('Light') setTimeout( () => { onPress?.(e) @@ -64,8 +55,6 @@ export function FABInner({testID, icon, onPress, ...props}: FABProps) { isHapticsDisabled ? 0 : 75, ) }} - onPressIn={onPressIn} - onPressOut={onPressOut} {...props}> <Animated.View style={[ @@ -74,7 +63,7 @@ export function FABInner({testID, icon, onPress, ...props}: FABProps) { tabletSpacing, isMobile && fabMinimalShellTransform, ]}> - <Animated.View style={animatedStyle}> + <Animated.View style={scale}> <LinearGradient colors={[gradients.blueLight.start, gradients.blueLight.end]} start={{x: 0, y: 0}} |