Skip to content
Draft
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 @@ -40,6 +40,7 @@ interface HomeCardProps {
footer?: ReactNode;
onCTAPress?: () => void;
backgroundImg?: () => ReactElement;
cardHeight?: number;
}

const CardBodyHeader = styled(BaseText)`
Expand Down Expand Up @@ -97,8 +98,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 @@ -114,6 +121,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 @@ -161,7 +171,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
26 changes: 25 additions & 1 deletion src/managers/OngoingProcessManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export type OngoingProcessObjectData = {
walletName?: string;
count?: number;
iteration?: number;
chainIteration?: number;
};

export type OngoingProcessData = number | OngoingProcessObjectData | undefined;
Expand All @@ -99,13 +100,30 @@ const getWalletName = (data?: OngoingProcessData): string | undefined =>
const getIteration = (data?: OngoingProcessData): number =>
typeof data === 'object' && data !== null ? data.iteration ?? 1 : 1;

const getChainIteration = (data?: OngoingProcessData): number =>
typeof data === 'object' && data !== null ? data.chainIteration ?? 1 : 1;

const getCount = (data?: OngoingProcessData): number =>
typeof data === 'object' && data !== null
? data.count ?? 0
: isNumberData(data)
? 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 Expand Up @@ -213,7 +231,13 @@ const translations: Record<
},
'walletInfo.gatheringTokens': data => {
const chain = getChain(data);
return i18n.t('Loading {{chain}} tokens...', {chain});
const chainIteration = getChainIteration(data);
return chainIteration > 1
? i18n.t('Loading {{chain}} tokens (account {{chainIteration}})...', {
chain,
chainIteration,
})
: i18n.t('Loading {{chain}} tokens...', {chain});
},
'walletInfo.gatheringTokens.error': () =>
i18n.t('Some tokens could not be loaded, continuing...'),
Expand Down
64 changes: 38 additions & 26 deletions src/navigation/tabs/home/HomeRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import {
AppStateStatus,
RefreshControl,
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 @@ -117,6 +120,8 @@ const HomeRoot: React.FC<HomeScreenProps> = ({route, navigation}) => {
({APP}) => APP.keyMigrationFailureModalHasBeenShown,
);
const showPortfolioValue = useAppSelector(({APP}) => APP.showPortfolioValue);
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 @@ -436,31 +441,38 @@ const HomeRoot: React.FC<HomeScreenProps> = ({route, navigation}) => {
) : null}

{/* ////////////////////////////// CTA BUY SWAP RECEIVE SEND BUTTONS */}
{hasKeys && showPortfolioValue ? (
<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)) &&
showPortfolioValue ? (
<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 @@ -472,7 +484,7 @@ const HomeRoot: React.FC<HomeScreenProps> = ({route, navigation}) => {

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

{/* ////////////////////////////// SECURE WITH PASSKEY */}
Expand Down
Loading
Loading