diff --git a/src/lib/custom-animations/PressableScale.tsx b/src/lib/custom-animations/PressableScale.tsx index 68315a9783..d6eabf8b22 100644 --- a/src/lib/custom-animations/PressableScale.tsx +++ b/src/lib/custom-animations/PressableScale.tsx @@ -1,5 +1,5 @@ import React from 'react' -import {Pressable, PressableProps} from 'react-native' +import {Pressable, PressableProps, StyleProp, ViewStyle} from 'react-native' import Animated, { cancelAnimation, runOnJS, @@ -16,14 +16,17 @@ const DEFAULT_TARGET_SCALE = isNative || isTouchDevice ? 0.98 : 1 export function PressableScale({ targetScale = DEFAULT_TARGET_SCALE, children, + contentContainerStyle, + onPressIn, + onPressOut, ...rest -}: {targetScale?: number} & Exclude< - PressableProps, - 'onPressIn' | 'onPressOut' ->) { +}: { + targetScale?: number + contentContainerStyle?: StyleProp +} & Exclude) { const scale = useSharedValue(1) - const style = useAnimatedStyle(() => ({ + const animatedStyle = useAnimatedStyle(() => ({ transform: [{scale: scale.value}], })) @@ -32,22 +35,24 @@ export function PressableScale({ accessibilityRole="button" onPressIn={e => { 'worklet' - if (rest.onPressIn) { - runOnJS(rest.onPressIn)(e) + if (onPressIn) { + runOnJS(onPressIn)(e) } cancelAnimation(scale) scale.value = withTiming(targetScale, {duration: 100}) }} onPressOut={e => { 'worklet' - if (rest.onPressOut) { - runOnJS(rest.onPressOut)(e) + if (onPressOut) { + runOnJS(onPressOut)(e) } cancelAnimation(scale) scale.value = withTiming(1, {duration: 100}) }} {...rest}> - {children as React.ReactNode} + + {children as React.ReactNode} + ) } diff --git a/src/view/shell/bottom-bar/BottomBar.tsx b/src/view/shell/bottom-bar/BottomBar.tsx index f6d16ae8e5..02d9427330 100644 --- a/src/view/shell/bottom-bar/BottomBar.tsx +++ b/src/view/shell/bottom-bar/BottomBar.tsx @@ -1,5 +1,5 @@ import React, {ComponentProps} from 'react' -import {GestureResponderEvent, TouchableOpacity, View} from 'react-native' +import {GestureResponderEvent, View} from 'react-native' import Animated from 'react-native-reanimated' import {useSafeAreaInsets} from 'react-native-safe-area-context' import {msg, Trans} from '@lingui/macro' @@ -8,6 +8,7 @@ import {BottomTabBarProps} from '@react-navigation/bottom-tabs' import {StackActions} from '@react-navigation/native' import {useAnalytics} from '#/lib/analytics/analytics' +import {PressableScale} from '#/lib/custom-animations/PressableScale' import {useHaptics} from '#/lib/haptics' import {useDedupe} from '#/lib/hooks/useDedupe' import {useMinimalShellFooterTransform} from '#/lib/hooks/useMinimalShellTransform' @@ -29,6 +30,7 @@ import {Text} from '#/view/com/util/text/Text' import {UserAvatar} from '#/view/com/util/UserAvatar' import {Logo} from '#/view/icons/Logo' import {Logotype} from '#/view/icons/Logotype' +import {atoms as a} from '#/alf' import {useDialogControl} from '#/components/Dialog' import {SwitchAccountDialog} from '#/components/dialogs/SwitchAccount' import { @@ -326,7 +328,7 @@ export function BottomBar({navigation}: BottomTabBarProps) { interface BtnProps extends Pick< - ComponentProps, + ComponentProps, | 'accessible' | 'accessibilityRole' | 'accessibilityHint' @@ -350,7 +352,7 @@ function Btn({ accessibilityLabel, }: BtnProps) { return ( - + accessibilityHint={accessibilityHint} + targetScale={0.8} + contentContainerStyle={[a.flex_1]}> {icon} {notificationCount ? ( - + {notificationCount} ) : undefined} - + ) }