Skip to content

Commit

Permalink
fix(ui-ux): hide Get DFI btn on empty portfolio screen (#4080)
Browse files Browse the repository at this point in the history
  • Loading branch information
fullstackninja864 authored Oct 19, 2023
1 parent feca52c commit 1a5b3d0
Showing 1 changed file with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ export function TokenSelectionScreen(): JSX.Element {

const [isSearchFocus, setIsSearchFocus] = useState(false);
const searchRef = useRef<TextInput>();
const isEvmDomain = domain === DomainType.EVM;

const filteredTokensByDomain = domain === DomainType.EVM ? evmTokens : tokens;
const filteredTokensByDomain = isEvmDomain ? evmTokens : tokens;

const tokensWithBalance = getTokensWithBalance(
filteredTokensByDomain,
Expand All @@ -80,9 +81,9 @@ export function TokenSelectionScreen(): JSX.Element {
}, [tokensWithBalance, debouncedSearchTerm]);

const hasFetchedDvmEvmTokens =
hasFetchedToken || (domain === DomainType.EVM && hasFetchedEvmTokens);
hasFetchedToken || (isEvmDomain && hasFetchedEvmTokens);
if (hasFetchedDvmEvmTokens && tokensWithBalance.length === 0) {
return <EmptyAsset navigation={navigation} />;
return <EmptyAsset navigation={navigation} isEvmDomain={isEvmDomain} />;
}

return (
Expand All @@ -97,7 +98,7 @@ export function TokenSelectionScreen(): JSX.Element {
return (
<TokenSelectionRow
item={item}
domain={domain}
isEvmDomain={isEvmDomain}
onPress={() => {
navigation.navigate({
name: "SendScreen",
Expand Down Expand Up @@ -195,13 +196,13 @@ export function TokenSelectionScreen(): JSX.Element {
interface TokenSelectionRowProps {
item: TokenSelectionItem;
onPress: any;
domain: DomainType;
isEvmDomain: boolean;
}

function TokenSelectionRow({
item,
onPress,
domain,
isEvmDomain,
}: TokenSelectionRowProps): JSX.Element {
return (
<ThemedTouchableOpacityV2
Expand All @@ -222,14 +223,14 @@ function TokenSelectionRow({
displaySymbol: item.token.displaySymbol,
id: item.tokenId,
}}
isEvmToken={domain === DomainType.EVM}
isEvmToken={isEvmDomain}
size={36}
/>
<TokenNameText
displaySymbol={item.token.displaySymbol}
name={item.token.name}
testID={item.token.displaySymbol}
isEvmDomain={domain === DomainType.EVM}
isEvmDomain={isEvmDomain}
/>
</View>
<View style={tailwind("flex flex-col items-end")}>
Expand Down Expand Up @@ -257,8 +258,10 @@ function TokenSelectionRow({

function EmptyAsset({
navigation,
isEvmDomain,
}: {
navigation: NavigationProp<PortfolioParamList>;
isEvmDomain: boolean;
}): JSX.Element {
return (
<ThemedScrollViewV2
Expand Down Expand Up @@ -293,11 +296,13 @@ function EmptyAsset({
)}
</ThemedTextV2>
</View>
<ButtonV2
onPress={() => navigation.navigate("GetDFIScreen" as any)}
styleProps="w-full mb-14 pb-1"
label={translate("screens/GetDFIScreen", "Get DFI")}
/>
{!isEvmDomain && (
<ButtonV2
onPress={() => navigation.navigate("GetDFIScreen" as any)}
styleProps="w-full mb-14 pb-1"
label={translate("screens/GetDFIScreen", "Get DFI")}
/>
)}
</ThemedScrollViewV2>
);
}
Expand Down

0 comments on commit 1a5b3d0

Please sign in to comment.