11import Button from '@components/common/button' ;
22import Text from '@components/common/text' ;
3- import React , { useEffect , useRef } from 'react' ;
3+ import React , { useEffect , useRef } from 'react' ;
44import Icon from '@react-native-vector-icons/ant-design' ;
5- import { View } from 'react-native' ;
5+ import { View } from 'react-native' ;
66import Animated , {
77 useAnimatedStyle ,
88 useSharedValue ,
99 withTiming ,
1010 withSpring ,
1111 withSequence ,
1212} from 'react-native-reanimated' ;
13- import { useLocalization } from '@fluent/react' ;
14- import { useColors } from '@styles/hooks' ;
15- import { useCart } from '@data/cart-context' ;
16- import { useProductQuantity } from '@data/hooks' ;
17- import { useNavigation } from '@react-navigation/native' ;
13+ import { useLocalization } from '@fluent/react' ;
14+ import { useColors } from '@styles/hooks' ;
15+ import { useCart } from '@data/cart-context' ;
16+ import { useProductQuantity } from '@data/hooks' ;
17+ import { useNavigation } from '@react-navigation/native' ;
1818import Badge from '@components/common/badge' ;
1919
2020type AnimatedCartButtonProps = {
@@ -32,8 +32,8 @@ const AnimatedCartButton = ({
3232 inStock,
3333 hasSelectedAllOptions = false ,
3434} : AnimatedCartButtonProps ) => {
35- const { l10n} = useLocalization ( ) ;
36- const { addToCart} = useCart ( ) ;
35+ const { l10n } = useLocalization ( ) ;
36+ const { addToCart } = useCart ( ) ;
3737 const [ adding , setAdding ] = React . useState ( false ) ;
3838 const productQuantityInCart = useProductQuantity ( productId ) ;
3939 const showViewCart = useSharedValue ( productQuantityInCart > 0 ) ;
@@ -90,8 +90,8 @@ const AnimatedCartButton = ({
9090 ) ;
9191} ;
9292
93- const ViewCart = ( { quantity} : { quantity : number } ) => {
94- const { l10n} = useLocalization ( ) ;
93+ const ViewCart = ( { quantity } : { quantity : number } ) => {
94+ const { l10n } = useLocalization ( ) ;
9595 const colors = useColors ( ) ;
9696 const navigation = useNavigation ( ) ;
9797 const scale = useSharedValue ( 1 ) ;
@@ -101,16 +101,16 @@ const ViewCart = ({quantity}: {quantity: number}) => {
101101 // Only animate when quantity increases
102102 if ( prevQuantity . current && quantity > prevQuantity . current ) {
103103 scale . value = withSequence (
104- withSpring ( 1.3 , { damping : 8 } ) ,
105- withSpring ( 1 , { damping : 8 } ) ,
104+ withSpring ( 1.3 , { damping : 8 } ) ,
105+ withSpring ( 1 , { damping : 8 } ) ,
106106 ) ;
107107 }
108108 prevQuantity . current = quantity ;
109109 } , [ quantity , scale ] ) ;
110110
111111 const badgeAnimatedStyle = useAnimatedStyle ( ( ) => {
112112 return {
113- transform : [ { scale : scale . value } ] ,
113+ transform : [ { scale : scale . value } ] ,
114114 } ;
115115 } ) ;
116116
@@ -122,20 +122,23 @@ const ViewCart = ({quantity}: {quantity: number}) => {
122122 < Button
123123 variant = "secondary"
124124 disabled = { quantity === 0 }
125- onPress = { navigateToCart } >
125+ onPress = { navigateToCart }
126+ >
126127 < View >
127128 < View className = "flex-row gap-1 items-center" >
128129 < View >
129130 < Icon name = "shopping-cart" size = { 18 } color = { colors . content } />
130131 < Animated . View
131132 className = "absolute -top-[8] -right-[8]"
132- style = { badgeAnimatedStyle } >
133+ style = { badgeAnimatedStyle }
134+ >
133135 < Badge quantity = { quantity } />
134136 </ Animated . View >
135137 </ View >
136138 < Text
137139 className = "ml-2 text-content font-content-bold"
138- numberOfLines = { 1 } >
140+ numberOfLines = { 1 }
141+ >
139142 { l10n . getString ( 'view-cart' ) }
140143 </ Text >
141144 </ View >
0 commit comments