diff --git a/src/components/Discover/TrendingTokens.tsx b/src/components/Discover/TrendingTokens.tsx index 223a8041981..d8a597c8208 100644 --- a/src/components/Discover/TrendingTokens.tsx +++ b/src/components/Discover/TrendingTokens.tsx @@ -17,10 +17,8 @@ import { FarcasterUser, TrendingToken, useTrendingTokens } from '@/resources/tre import { useNavigationStore } from '@/state/navigation/navigationStore'; import { swapsStore } from '@/state/swaps/swapsStore'; import { sortFilters, timeFilters, useTrendingTokensStore } from '@/state/trendingTokens/trendingTokens'; -import { colors } from '@/styles'; -import { darkModeThemeColors } from '@/styles/colors'; import { useCallback, useEffect, useMemo } from 'react'; -import React, { Dimensions, FlatList, View } from 'react-native'; +import React, { FlatList, View } from 'react-native'; import LinearGradient from 'react-native-linear-gradient'; import Animated, { runOnJS, useSharedValue } from 'react-native-reanimated'; import { ButtonPressAnimation } from '../animations'; @@ -31,6 +29,7 @@ import { useAccountSettings } from '@/hooks'; import { getColorWorklet, getMixedColor, opacity } from '@/__swaps__/utils/swaps'; import { THICK_BORDER_WIDTH } from '@/__swaps__/screens/Swap/constants'; import { IS_IOS } from '@/env'; +import { DEVICE_WIDTH } from '@/utils/deviceUtils'; const t = i18n.l.trending_tokens; @@ -72,18 +71,24 @@ function FilterButton({ end={{ x: 0.5, y: 1 }} start={{ x: 0.5, y: 0 }} style={{ - flexDirection: 'row', alignItems: 'center', + borderColor, + borderRadius: 18, + borderWidth: THICK_BORDER_WIDTH, + flexDirection: 'row', gap: 4, height: 36, paddingHorizontal: 12 - THICK_BORDER_WIDTH, - borderRadius: 18, - borderWidth: THICK_BORDER_WIDTH, - borderColor, }} > {typeof icon === 'string' ? ( - + {icon} ) : ( @@ -209,7 +214,7 @@ function CategoryFilterButton({ @@ -240,15 +245,16 @@ function FriendPfp({ pfp_url }: { pfp_url: string }) { const backgroundColor = useBackgroundColor('surfacePrimary'); return ( ); @@ -259,18 +265,18 @@ function FriendHolders({ friends }: { friends: FarcasterUser[] }) { const separator = howManyOthers === 1 && friends.length === 2 ? ` ${i18n.t(t.and)} ` : ', '; return ( - - + + {friends[1] && } - - + + {friends[0].username} {friends[1] && ( <> - + {separator} {friends[1].username} @@ -278,7 +284,7 @@ function FriendHolders({ friends }: { friends: FarcasterUser[] }) { )} {friends.length > 2 && ( - + {' '} {i18n.t(t.and_others[howManyOthers === 1 ? 'one' : 'other'], { count: howManyOthers })} @@ -289,75 +295,21 @@ function FriendHolders({ friends }: { friends: FarcasterUser[] }) { } function TrendingTokenLoadingRow() { - const backgroundColor = useBackgroundColor('surfacePrimary'); - const { isDarkMode } = useColorMode(); return ( - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + - - - - - - - - - + + + @@ -371,7 +323,7 @@ function getPriceChangeColor(priceChange: number) { } function TrendingTokenRow({ token }: { token: TrendingToken }) { - const separatorColor = useForegroundColor('separator'); + const separatorSecondary = useForegroundColor('separatorSecondary'); const price = formatCurrency(token.price); const marketCap = formatNumber(token.marketCap, { useOrderSuffix: true, decimals: 1, style: '$' }); @@ -400,7 +352,15 @@ function TrendingTokenRow({ token }: { token: TrendingToken }) { return ( - + 0 ? 48 : 40, + alignItems: 'center', + }} + > - + {token.name} - + {token.symbol} - + {price} @@ -445,20 +405,18 @@ function TrendingTokenRow({ token }: { token: TrendingToken }) { VOL - + {volume} - - | - + MCAP - + {marketCap} @@ -512,16 +470,14 @@ function NoResults() { } function NetworkFilter() { - const { isDarkMode } = useColorMode(); - - const selected = useSharedValue(undefined); const chainId = useTrendingTokensStore(state => state.chainId); + const selected = useSharedValue(chainId); + + const chainColor = useBackendNetworksStore(state => state.getColorsForChainId(chainId || ChainId.mainnet, false)); const setChainId = useTrendingTokensStore(state => state.setChainId); const { icon, label, lightenedNetworkColor } = useMemo(() => { if (!chainId) return { icon: '􀤆', label: i18n.t(t.all), lightenedNetworkColor: undefined }; - const lightenedNetworkColor = useBackendNetworksStore.getState().getColorsForChainId(chainId, isDarkMode); - return { icon: ( @@ -529,11 +485,9 @@ function NetworkFilter() { ), label: useBackendNetworksStore.getState().getChainsLabel()[chainId], - lightenedNetworkColor: lightenedNetworkColor - ? getMixedColor(lightenedNetworkColor, globalColors.white100, isDarkMode ? 0.55 : 0.6) - : undefined, + lightenedNetworkColor: chainColor ? getMixedColor(chainColor, globalColors.white100, 0.6) : undefined, }; - }, [chainId, isDarkMode]); + }, [chainColor, chainId]); const setSelected = useCallback( (chainId: ChainId | undefined) => { @@ -564,7 +518,7 @@ function NetworkFilter() { function TimeFilter() { const timeframe = useTrendingTokensStore(state => state.timeframe); - const shouldAbbreviate = timeframe === Timeframe.H24 || timeframe === Timeframe.H12; + const shouldAbbreviate = timeframe === Timeframe.H12 || timeframe === Timeframe.H24; return ( state.sort); const selected = sort !== TrendingSort.Recommended; - const iconColor = useForegroundColor(selected ? 'labelSecondary' : 'labelTertiary'); + const iconColor = getColorWorklet(selected ? 'labelSecondary' : 'labelTertiary', selected ? false : isDarkMode); const sortLabel = useMemo(() => { if (sort === TrendingSort.Recommended) return i18n.t(t.filters.sort.RECOMMENDED.label); @@ -621,9 +575,15 @@ function SortFilter() { highlightedBackgroundColor={undefined} label={sortLabel} icon={ - + 􀄬 - + } /> @@ -634,7 +594,7 @@ function TrendingTokensLoader() { const { trending_tokens_limit } = useRemoteConfig(); return ( - + {Array.from({ length: trending_tokens_limit }).map((_, index) => ( ))} @@ -648,8 +608,8 @@ function TrendingTokenData() { return ( } data={trendingTokens} renderItem={({ item }) => }