Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/components/home-card/HomeCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ interface HomeCardProps {
footer?: ReactNode;
onCTAPress?: () => void;
backgroundImg?: () => ReactElement;
cardHeight?: number;
}

const CardBodyHeader = styled(BaseText)`
Expand Down Expand Up @@ -98,8 +99,14 @@ export const NeedBackupText = styled(BaseText)`

export const HOME_CARD_HEIGHT = 143;
export const HOME_CARD_WIDTH = 170;

const HomeCard: React.FC<HomeCardProps> = ({body, footer, onCTAPress}) => {
export const IMPORT_CARD_HEIGHT = 185;

const HomeCard: React.FC<HomeCardProps> = ({
body,
footer,
onCTAPress,
cardHeight = HOME_CARD_HEIGHT,
}) => {
const {t} = useTranslation();
const theme = useTheme();
const {
Expand All @@ -116,6 +123,9 @@ const HomeCard: React.FC<HomeCardProps> = ({body, footer, onCTAPress}) => {

const BodyComp = (
<View>
{cardHeight > HOME_CARD_HEIGHT && (
<View style={{height: cardHeight - HOME_CARD_HEIGHT}} />
)}
{title && <CardBodyHeader>{title}</CardBodyHeader>}
{needsBackup && !pendingTssSession ? (
<Row>
Expand Down Expand Up @@ -164,7 +174,7 @@ const HomeCard: React.FC<HomeCardProps> = ({body, footer, onCTAPress}) => {
backgroundColor: theme.dark ? CharcoalBlack : White,
borderColor: theme.dark ? LightBlack : Slate30,
borderWidth: 1,
height: HOME_CARD_HEIGHT,
height: cardHeight,
width: HOME_CARD_WIDTH,
}}
/>
Expand Down
14 changes: 14 additions & 0 deletions src/managers/OngoingProcessManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,20 @@ const getCount = (data?: OngoingProcessData): number =>
? data
: 0;

export const getOngoingProcessMessage = (
key: OnGoingProcessMessages,
data?: OngoingProcessData,
): string => translations[key]?.(data) ?? i18n.t('Loading');

export const IMPORT_PROGRESS_VISIBLE_EVENTS: readonly string[] = [
'findingCopayers',
'foundCopayers',
'gettingStatuses',
'gatheringWalletsInfos',
'walletInfo.gatheringTokens',
'IMPORT_SCANNING_FUNDS',
];

const translations: Record<
OnGoingProcessMessages,
(data?: OngoingProcessData) => string
Expand Down
70 changes: 41 additions & 29 deletions src/navigation/tabs/home/HomeRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
ScrollView,
View,
} from 'react-native';
import styled from 'styled-components/native';
import {BaseText} from '../../../components/styled/Text';
import {
EXCHANGE_RATES_CURRENCIES,
STATIC_CONTENT_CARDS_ENABLED,
Expand Down Expand Up @@ -111,6 +113,8 @@ const HomeRoot: React.FC<HomeScreenProps> = ({route, navigation}) => {
);
const showPortfolioValue = useAppSelector(selectShowPortfolioValue);
const portfolioChartsRequested = showPortfolioValue === true;
const pendingImport = useAppSelector(({APP}) => APP.pendingImport);
const importIsFirstKey = useAppSelector(({APP}) => APP.importIsFirstKey);
const hasKeys = Object.values(keys).length;

const portfolioAllocationTotalFiat = useMemo(() => {
Expand Down Expand Up @@ -403,36 +407,42 @@ const HomeRoot: React.FC<HomeScreenProps> = ({route, navigation}) => {
/>
}>
{/* ////////////////////////////// PORTFOLIO BALANCE */}
<HomeSection style={{marginTop: 20, marginBottom: 20}}>
<HomeSection style={{marginTop: 5, marginBottom: 20}}>
<PortfolioBalance />
</HomeSection>

{/* ////////////////////////////// CTA BUY SWAP RECEIVE SEND BUTTONS */}
{hasKeys ? (
<HomeSection style={{marginBottom: 25}}>
<LinkingButtons
receive={{
cta: () => {
dispatch(
Analytics.track('Clicked Receive Crypto', {
context: 'HomeRoot',
}),
);
dispatch(receiveCrypto(navigation, 'HomeRoot'));
},
}}
send={{
cta: () => {
dispatch(
Analytics.track('Clicked Send Crypto', {
context: 'HomeRoot',
}),
);
dispatch(sendCrypto('HomeRoot'));
},
}}
/>
</HomeSection>
{hasKeys || (pendingImport && importIsFirstKey) ? (
<View
style={{opacity: pendingImport && importIsFirstKey ? 0.4 : 1}}
pointerEvents={
pendingImport && importIsFirstKey ? 'none' : 'auto'
}>
<HomeSection style={{marginBottom: 25}}>
<LinkingButtons
receive={{
cta: () => {
dispatch(
Analytics.track('Clicked Receive Crypto', {
context: 'HomeRoot',
}),
);
dispatch(receiveCrypto(navigation, 'HomeRoot'));
},
}}
send={{
cta: () => {
dispatch(
Analytics.track('Clicked Send Crypto', {
context: 'HomeRoot',
}),
);
dispatch(sendCrypto('HomeRoot'));
},
}}
/>
</HomeSection>
</View>
) : null}

{/* ////////////////////////////// MARKETING */}
Expand All @@ -444,13 +454,13 @@ const HomeRoot: React.FC<HomeScreenProps> = ({route, navigation}) => {

{/* ////////////////////////////// CRYPTO */}
<HomeSection>
<Crypto />
<Crypto scrollRef={scrollViewRef} />
</HomeSection>

{/* ////////////////////////////// SECURE WITH PASSKEY */}
<SecurePasskeyBannerGate />

{hasKeys ? (
{hasKeys || (pendingImport && importIsFirstKey) ? (
<HomeSection>
<View
ref={homeAssetsSectionRef}
Expand All @@ -465,7 +475,9 @@ const HomeRoot: React.FC<HomeScreenProps> = ({route, navigation}) => {
</HomeSection>
) : null}

{showPortfolioValue && showPortfolioAllocationSection ? (
{showPortfolioValue &&
(showPortfolioAllocationSection ||
(pendingImport && importIsFirstKey)) ? (
<HomeSection>
<AllocationSection />
</HomeSection>
Expand Down
7 changes: 6 additions & 1 deletion src/navigation/tabs/home/components/AllocationSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,8 @@ const AllocationSection: React.FC = () => {
const keys = useAppSelector(({WALLET}) => WALLET.keys) as Record<string, Key>;
const {defaultAltCurrency} = useAppSelector(({APP}) => APP);
const homeCarouselConfig = useAppSelector(({APP}) => APP.homeCarouselConfig);
const pendingImport = useAppSelector(({APP}) => APP.pendingImport);
const importIsFirstKey = useAppSelector(({APP}) => APP.importIsFirstKey);

const visibleWallets = useMemo(
() => getVisibleWalletsFromKeys(keys, homeCarouselConfig),
Expand Down Expand Up @@ -485,7 +487,10 @@ const AllocationSection: React.FC = () => {
<AllocationDonutLegendCard
legendItems={allocationData.legendItems}
slices={allocationData.slices}
isLoading={hasAnyVisibleWalletBalance && !allocationData.rows?.length}
isLoading={
(pendingImport && importIsFirstKey) ||
(hasAnyVisibleWalletBalance && !allocationData.rows?.length)
}
/>
</TouchableOpacity>
</Container>
Expand Down
3 changes: 2 additions & 1 deletion src/navigation/tabs/home/components/AssetRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ const AssetRow: React.FC<Props> = ({
const [loadingDelayElapsed, setLoadingDelayElapsed] = useState(false);
const preservedEntry = lastSettledItemRef.current;
const preservedItem =
preservedEntry?.presentationResetToken === presentationResetToken
preservedEntry !== undefined &&
preservedEntry.presentationResetToken === presentationResetToken
? preservedEntry.item
: undefined;

Expand Down
11 changes: 7 additions & 4 deletions src/navigation/tabs/home/components/AssetsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ const AssetsSection: React.FC<AssetsSectionProps> = ({enabled = true}) => {
const defaultAltCurrency = useAppSelector(({APP}) => APP.defaultAltCurrency);
const showPortfolioValue = useAppSelector(selectShowPortfolioValue);
const homeCarouselConfig = useAppSelector(({APP}) => APP.homeCarouselConfig);
const pendingImport = useAppSelector(({APP}) => APP.pendingImport);
const importIsFirstKey = useAppSelector(({APP}) => APP.importIsFirstKey);
const keys = useAppSelector(({WALLET}) => WALLET.keys) as Record<string, Key>;
const focusRefreshToken = useScreenFocusRefreshToken();
const portfolioChartsEnabled = showPortfolioValue === true;
Expand Down Expand Up @@ -236,10 +238,11 @@ const AssetsSection: React.FC<AssetsSectionProps> = ({enabled = true}) => {
visibleItems,
]);
const shouldShowActivationPlaceholder =
portfolioChartsEnabled &&
hasAnyVisibleWalletBalance &&
!items.length &&
(!!visibleWallets.length || !!portfolio.populateStatus?.inProgress);
(pendingImport && importIsFirstKey) ||
(portfolioChartsEnabled &&
hasAnyVisibleWalletBalance &&
!items.length &&
(!!visibleWallets.length || !!portfolio.populateStatus?.inProgress));

if (shouldShowActivationPlaceholder) {
return (
Expand Down
Loading
Loading