Skip to content

Commit

Permalink
Revert change in FAB animation (#5465)
Browse files Browse the repository at this point in the history
  • Loading branch information
haileyok authored Sep 24, 2024
1 parent 53b095a commit b57ddd0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/lib/haptics.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
35 changes: 12 additions & 23 deletions src/view/com/util/fab/FABInner.tsx
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -26,46 +22,39 @@ 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

const tabletSpacing = isTablet
? {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)
},
isHapticsDisabled ? 0 : 75,
)
}}
onPressIn={onPressIn}
onPressOut={onPressOut}
{...props}>
<Animated.View
style={[
Expand All @@ -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}}
Expand Down

0 comments on commit b57ddd0

Please sign in to comment.