@@ -72,14 +72,13 @@ const createStyles = ({
7272 flex : 1 ,
7373 flexShrink : 1 ,
7474 minWidth : 0 ,
75- marginLeft : 12 ,
75+ marginLeft : 8 ,
7676 } ,
7777 container : {
7878 backgroundColor : vars . isSelected
7979 ? theme . colors . primary . muted
8080 : theme . colors . background . default ,
8181 paddingVertical : 4 ,
82- minHeight : 72 ,
8382 paddingLeft : 16 ,
8483 paddingRight : 10 ,
8584 } ,
@@ -95,7 +94,7 @@ const createStyles = ({
9594 itemWrapper : {
9695 flex : 1 ,
9796 flexDirection : 'row' ,
98- paddingVertical : 12 ,
97+ paddingVertical : 10 ,
9998 alignItems : 'flex-start' ,
10099 } ,
101100 tokenMainInfo : {
@@ -258,7 +257,28 @@ const TokenBalanceView = ({
258257 ) ;
259258} ;
260259
261- export const TokenSelectorItem : React . FC < TokenSelectorItemProps > = ( {
260+ const formatTokenBalance = ( balance : string ) : string => {
261+ const numericBalance = Number ( balance ) ;
262+ if ( numericBalance === 0 ) {
263+ return '0' ;
264+ }
265+ if ( numericBalance < 0.00001 ) {
266+ return '< 0.00001' ;
267+ }
268+ return parseAmount ( balance , 5 ) || balance ;
269+ } ;
270+
271+ const TOP_ROW_BALANCE_TEXT_STYLE = {
272+ textVariant : TextVariant . BodyMDMedium ,
273+ textColor : TextColor . Default ,
274+ } as const ;
275+
276+ const BOTTOM_ROW_BALANCE_TEXT_STYLE = {
277+ textVariant : TextVariant . BodyMD ,
278+ textColor : TextColor . Alternative ,
279+ } as const ;
280+
281+ const TokenSelectorItemInner : React . FC < TokenSelectorItemProps > = ( {
262282 token,
263283 onPress,
264284 networkName,
@@ -288,17 +308,6 @@ export const TokenSelectorItem: React.FC<TokenSelectorItemProps> = ({
288308
289309 const fiatValue = token . balanceFiat ;
290310
291- const formatTokenBalance = ( balance : string ) : string => {
292- const numericBalance = Number ( balance ) ;
293- if ( numericBalance === 0 ) {
294- return '0' ;
295- }
296- if ( numericBalance < 0.00001 ) {
297- return '< 0.00001' ;
298- }
299- return parseAmount ( balance , 5 ) || balance ;
300- } ;
301-
302311 const selectedVariant =
303312 variant ??
304313 TOKEN_SELECTOR_BALANCE_LAYOUT_VARIANTS [
@@ -315,27 +324,10 @@ export const TokenSelectorItem: React.FC<TokenSelectorItemProps> = ({
315324
316325 const isNative = token . address === ethers . constants . AddressZero ;
317326
318- // to check if the token is a stock by checking if the name includes 'ondo' or 'stock'
319327 const { isStockToken } = useRWAToken ( ) ;
320328
321329 const fiatBalance = shouldShowBalance ? fiatValue : undefined ;
322330 const tokenBalance = shouldShowBalance ? cryptoBalance : undefined ;
323- const topRowBalanceTextStyle = {
324- textVariant : TextVariant . BodyMDMedium ,
325- textColor : TextColor . Default ,
326- } ;
327- const bottomRowBalanceTextStyle = {
328- textVariant : TextVariant . BodySM ,
329- textColor : TextColor . Alternative ,
330- } ;
331- const topRowTokenBalanceTextStyle = {
332- ...topRowBalanceTextStyle ,
333- ...tokenBalanceTextProps ,
334- } ;
335- const bottomRowTokenBalanceTextStyle = {
336- ...bottomRowBalanceTextStyle ,
337- ...tokenBalanceTextProps ,
338- } ;
339331
340332 const label = token . accountType
341333 ? ACCOUNT_TYPE_LABELS [ token . accountType ]
@@ -360,6 +352,7 @@ export const TokenSelectorItem: React.FC<TokenSelectorItemProps> = ({
360352
361353 return (
362354 < Box
355+ accessible = { false }
363356 flexDirection = { FlexDirection . Row }
364357 alignItems = { AlignItems . center }
365358 style = { styles . container }
@@ -373,6 +366,7 @@ export const TokenSelectorItem: React.FC<TokenSelectorItemProps> = ({
373366 testID = { getAssetTestId ( `${ token . chainId } -${ token . symbol } ` ) }
374367 >
375368 < Box
369+ accessible = { false }
376370 flexDirection = { FlexDirection . Row }
377371 alignItems = { AlignItems . center }
378372 gap = { 4 }
@@ -396,19 +390,20 @@ export const TokenSelectorItem: React.FC<TokenSelectorItemProps> = ({
396390 tokenAvatar
397391 ) }
398392
399- { /* Token symbol/name on the left, balances on the right (extension layout pattern) */ }
400393 < Box
394+ accessible = { false }
401395 style = { styles . tokenInfo }
402396 flexDirection = { FlexDirection . Column }
403397 gap = { 4 }
404398 >
405399 < Box
400+ accessible = { false }
406401 flexDirection = { FlexDirection . Row }
407402 alignItems = { AlignItems . center }
408403 justifyContent = { JustifyContent . spaceBetween }
409404 >
410- < Box style = { styles . tokenMainInfo } gap = { 4 } >
411- < Box style = { styles . tokenSymbolRow } >
405+ < Box accessible = { false } style = { styles . tokenMainInfo } gap = { 4 } >
406+ < Box accessible = { false } style = { styles . tokenSymbolRow } >
412407 < Text
413408 variant = { TextVariant . BodyMDMedium }
414409 numberOfLines = { 1 }
@@ -462,19 +457,20 @@ export const TokenSelectorItem: React.FC<TokenSelectorItemProps> = ({
462457 balance = { tokenBalance }
463458 isSelected = { shouldShowSelectedStyle }
464459 textStyle = { styles . rightValue }
465- { ...topRowTokenBalanceTextStyle }
460+ { ...TOP_ROW_BALANCE_TEXT_STYLE }
466461 />
467462 ) : (
468463 < FiatBalanceView
469464 balance = { fiatBalance }
470465 isSelected = { shouldShowSelectedStyle }
471466 textStyle = { styles . rightValue }
472- { ...topRowBalanceTextStyle }
467+ { ...TOP_ROW_BALANCE_TEXT_STYLE }
473468 />
474469 ) }
475470 </ Box >
476471
477472 < Box
473+ accessible = { false }
478474 flexDirection = { FlexDirection . Row }
479475 alignItems = { AlignItems . center }
480476 justifyContent = { JustifyContent . spaceBetween }
@@ -503,14 +499,14 @@ export const TokenSelectorItem: React.FC<TokenSelectorItemProps> = ({
503499 balance = { fiatBalance }
504500 isSelected = { shouldShowSelectedStyle }
505501 textStyle = { styles . rightValue }
506- { ...bottomRowBalanceTextStyle }
502+ { ...BOTTOM_ROW_BALANCE_TEXT_STYLE }
507503 />
508504 ) : (
509505 < TokenBalanceView
510506 balance = { tokenBalance }
511507 isSelected = { shouldShowSelectedStyle }
512508 textStyle = { styles . rightValue }
513- { ...bottomRowTokenBalanceTextStyle }
509+ { ...BOTTOM_ROW_BALANCE_TEXT_STYLE }
514510 />
515511 ) }
516512 </ Box >
@@ -523,3 +519,17 @@ export const TokenSelectorItem: React.FC<TokenSelectorItemProps> = ({
523519 </ Box >
524520 ) ;
525521} ;
522+
523+ export const TokenSelectorItem = React . memo (
524+ TokenSelectorItemInner ,
525+ ( prev , next ) =>
526+ prev . onPress === next . onPress &&
527+ prev . token . address === next . token . address &&
528+ prev . token . chainId === next . token . chainId &&
529+ prev . token . balance === next . token . balance &&
530+ prev . token . balanceFiat === next . token . balanceFiat &&
531+ prev . isSelected === next . isSelected &&
532+ prev . isNoFeeAsset === next . isNoFeeAsset &&
533+ prev . shouldShowBalance === next . shouldShowBalance &&
534+ prev . networkName === next . networkName ,
535+ ) ;
0 commit comments