Skip to content

Commit 3f5c9ba

Browse files
fixed active button gap + sorting animation delay
1 parent 34c0567 commit 3f5c9ba

File tree

4 files changed

+50
-89
lines changed

4 files changed

+50
-89
lines changed

packages/core-mobile/app/new/common/components/WalletCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ const WalletCard = ({
156156
flexDirection: 'row',
157157
alignItems: 'center',
158158
justifyContent: 'space-between',
159-
height: HEADER_HEIGHT
159+
height: HEADER_HEIGHT,
160+
gap: 12
160161
}}>
161162
<View
162163
sx={{
@@ -193,7 +194,6 @@ const WalletCard = ({
193194
{wallet.name}
194195
</Text>
195196
<Text
196-
testID={`manage_accounts_wallet_name__${wallet.name}`}
197197
numberOfLines={1}
198198
style={{
199199
fontSize: 12,

packages/core-mobile/app/new/features/wallets/components/AccountBalance.tsx

Lines changed: 26 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -83,53 +83,38 @@ export const AccountBalance = ({
8383
return <ActivityIndicator size="small" sx={{ marginRight: 4 }} />
8484
}
8585

86-
if (!isBalanceAccurate) {
87-
return (
88-
<View
89-
sx={{
90-
flexDirection: 'row',
91-
alignItems: 'center',
92-
justifyContent: 'flex-start',
93-
flexShrink: 1,
94-
gap: 6
95-
}}>
86+
return (
87+
<View
88+
sx={{
89+
flexDirection: 'row',
90+
alignItems: 'center',
91+
justifyContent: 'flex-start',
92+
flexShrink: 1,
93+
gap: 6
94+
}}>
95+
{!accountBalance ? null : !isBalanceAccurate ? (
9696
<Pressable hitSlop={16} onPress={refetchBalance}>
9797
<Icons.Alert.Error
9898
color={colors.$textDanger}
9999
width={14}
100100
height={14}
101101
/>
102102
</Pressable>
103-
<AnimatedBalance
104-
variant="body1"
105-
balance={balance}
106-
shouldMask={isPrivacyModeEnabled}
107-
balanceSx={{
108-
color: isActive
109-
? colors.$textPrimary
110-
: alpha(colors.$textPrimary, 0.6),
111-
lineHeight: 16,
112-
textAlign: 'right'
113-
}}
114-
renderMaskView={renderMaskView}
115-
shouldAnimate={false}
116-
/>
117-
</View>
118-
)
119-
}
120-
121-
return (
122-
<AnimatedBalance
123-
variant="body1"
124-
balance={balance}
125-
shouldMask={isPrivacyModeEnabled}
126-
balanceSx={{
127-
color: isActive ? colors.$textPrimary : alpha(colors.$textPrimary, 0.6),
128-
lineHeight: 16,
129-
textAlign: 'right'
130-
}}
131-
renderMaskView={renderMaskView}
132-
shouldAnimate={false}
133-
/>
103+
) : null}
104+
<AnimatedBalance
105+
variant="body1"
106+
balance={balance}
107+
shouldMask={isPrivacyModeEnabled}
108+
balanceSx={{
109+
color: isActive
110+
? colors.$textPrimary
111+
: alpha(colors.$textPrimary, 0.6),
112+
lineHeight: 16,
113+
textAlign: 'right'
114+
}}
115+
renderMaskView={renderMaskView}
116+
shouldAnimate={false}
117+
/>
118+
</View>
134119
)
135120
}

packages/core-mobile/app/new/features/wallets/components/WalletBalance.tsx

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@ import {
22
ActivityIndicator,
33
alpha,
44
AnimatedBalance,
5-
Icons,
65
SxProp,
7-
useTheme,
8-
View
6+
useTheme
97
} from '@avalabs/k2-alpine'
108
import { HiddenBalanceText } from 'common/components/HiddenBalanceText'
119
import { useFormatCurrency } from 'common/hooks/useFormatCurrency'
1210
import { UNKNOWN_AMOUNT } from 'consts/amount'
1311
import React, { useCallback, useMemo } from 'react'
1412
import ContentLoader, { Rect } from 'react-content-loader/native'
15-
import { Pressable } from 'react-native'
1613
import { useSelector } from 'react-redux'
1714
import { selectIsPrivacyModeEnabled } from 'store/settings/securityPrivacy'
1815

@@ -33,11 +30,7 @@ export const WalletBalance = ({
3330

3431
// TODO: get wallet balance
3532
const walletBalance = 74235
36-
const isBalanceAccurate = true
3733
const isLoadingBalance = false
38-
const refetchBalance = useCallback(() => {
39-
// dispatch(refetchBalanceForAccount(account.id))
40-
}, [])
4134

4235
const balance = useMemo(() => {
4336
return walletBalance > 0
@@ -77,39 +70,6 @@ export const WalletBalance = ({
7770
return <ActivityIndicator size="small" />
7871
}
7972

80-
if (!isBalanceAccurate) {
81-
return (
82-
<View
83-
sx={{
84-
flexDirection: 'row',
85-
alignItems: 'center',
86-
justifyContent: 'flex-start',
87-
flexShrink: 1,
88-
gap: 6
89-
}}>
90-
<Pressable hitSlop={16} onPress={refetchBalance}>
91-
<Icons.Alert.Error
92-
color={colors.$textDanger}
93-
width={14}
94-
height={14}
95-
/>
96-
</Pressable>
97-
<AnimatedBalance
98-
variant="heading4"
99-
balance={balance}
100-
shouldMask={isPrivacyModeEnabled}
101-
balanceSx={{
102-
...balanceSx,
103-
lineHeight: 21,
104-
fontSize: 21,
105-
textAlign: 'right'
106-
}}
107-
renderMaskView={renderMaskView}
108-
/>
109-
</View>
110-
)
111-
}
112-
11373
return (
11474
<AnimatedBalance
11575
variant="heading4"

packages/core-mobile/app/new/features/wallets/components/WalletList.tsx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ export const WalletList = ({
6767
const accountCollection = useSelector(selectAccounts)
6868
const allWallets = useSelector(selectWallets)
6969
const activeAccount = useSelector(selectActiveAccount)
70+
71+
// TODO: check if any account on any wallet has balanceAccurate === false
7072
const balanceAccurate = useIsAccountBalanceAccurate(activeAccount)
7173
// TODO: Implement refresh
7274
const isRefreshing = false
@@ -77,9 +79,18 @@ export const WalletList = ({
7779
const { recentAccountIds } = useRecentAccounts()
7880

7981
const allAccountsArray = useMemo(() => {
80-
return recentAccountIds
81-
.map(id => accountCollection[id])
82-
.filter((account): account is Account => account !== undefined)
82+
const allAccounts = Object.values(accountCollection).filter(
83+
(account): account is Account => account !== undefined
84+
)
85+
86+
return allAccounts.sort((a, b) => {
87+
const indexA = recentAccountIds.indexOf(a.id)
88+
const indexB = recentAccountIds.indexOf(b.id)
89+
90+
if (indexA !== -1 && indexB !== -1) return indexA - indexB
91+
92+
return 0
93+
})
8394
}, [accountCollection, recentAccountIds])
8495

8596
useMemo(() => {
@@ -161,8 +172,13 @@ export const WalletList = ({
161172
}
162173
dispatch(setActiveAccount(accountId))
163174

164-
dismiss()
165-
dismiss()
175+
// Delay the dismiss to display the sorting list animation
176+
requestAnimationFrame(() => {
177+
setTimeout(() => {
178+
dismiss()
179+
dismiss()
180+
}, 300)
181+
})
166182
},
167183
[activeAccount?.id, dispatch, dismiss]
168184
)

0 commit comments

Comments
 (0)