-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b53bc94
commit 1c2414b
Showing
14 changed files
with
258 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
.../newArch/features/Accounts/screens/AddAccount/components/SelectAddAccountMethod/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import React from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import useSelectAddAccountMethodViewModel from "./useSelectAddAccountMethod"; | ||
import { Flex, Icons, Text } from "@ledgerhq/native-ui"; | ||
import ActionRow from "LLM/components/ActionRow"; | ||
import { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets"; | ||
|
||
type ViewProps = { | ||
isWalletSyncEnabled: boolean | undefined; | ||
isReadOnlyModeEnabled: boolean; | ||
doesNotHaveAccount?: boolean; | ||
onClickAdd: () => void; | ||
onClickImport: () => void; | ||
setWalletSyncDrawerVisible?: () => void; | ||
}; | ||
|
||
type AddAccountScreenProps = { | ||
currency?: CryptoCurrency | TokenCurrency | null; | ||
doesNotHaveAccount?: boolean; | ||
onClose?: () => void; | ||
setWalletSyncDrawerVisible?: () => void; | ||
}; | ||
|
||
function View({ | ||
isWalletSyncEnabled, | ||
isReadOnlyModeEnabled, | ||
onClickAdd, | ||
onClickImport, | ||
setWalletSyncDrawerVisible, | ||
doesNotHaveAccount, | ||
}: ViewProps) { | ||
const { t } = useTranslation(); | ||
const rows = []; | ||
|
||
if (!isReadOnlyModeEnabled) { | ||
rows.push({ | ||
titleKey: "addAccountsModal.drawer.add.title", | ||
descriptionKey: "addAccountsModal.drawer.add.description", | ||
onPress: onClickAdd, | ||
icon: <Icons.LedgerDevices color={"primary.c80"} />, | ||
testID: "add-accounts-modal-add-button", | ||
}); | ||
} | ||
if (isWalletSyncEnabled) { | ||
rows.push({ | ||
titleKey: "addAccountsModal.drawer.walletSync.title", | ||
descriptionKey: "addAccountsModal.drawer.walletSync.description", | ||
onPress: setWalletSyncDrawerVisible, | ||
icon: <Icons.QrCode color={"primary.c80"} />, | ||
}); | ||
} else { | ||
rows.push({ | ||
titleKey: "addAccountsModal.drawer.import.title", | ||
descriptionKey: "addAccountsModal.drawer.import.description", | ||
onPress: onClickImport, | ||
icon: <Icons.QrCode color={"primary.c80"} />, | ||
}); | ||
} | ||
|
||
return ( | ||
<> | ||
<Text variant="h4" fontWeight="semiBold" fontSize="24px" mb={16}> | ||
{doesNotHaveAccount | ||
? t("addAccountsModal.title") | ||
: t("addAccountsModal.drawer.drawerTitleHasAccount")} | ||
</Text> | ||
<Text variant="large" fontWeight="medium" fontSize="14px" color="neutral.c70" mb="32px"> | ||
{t("addAccountsModal.drawer.drawerSubTitle")} | ||
</Text> | ||
<Flex flexDirection="column" rowGap={16}> | ||
{rows.map((row, index) => ( | ||
<ActionRow | ||
key={index} | ||
title={t(row.titleKey)} | ||
description={t(row.descriptionKey)} | ||
onPress={row.onPress} | ||
icon={row.icon} | ||
testID={row.testID} | ||
/> | ||
))} | ||
</Flex> | ||
</> | ||
); | ||
} | ||
|
||
const SelectAddAccountMethod = (props: AddAccountScreenProps) => { | ||
return <View {...useSelectAddAccountMethodViewModel(props)} {...props} />; | ||
}; | ||
|
||
export default SelectAddAccountMethod; |
74 changes: 74 additions & 0 deletions
74
...counts/screens/AddAccount/components/SelectAddAccountMethod/useSelectAddAccountMethod.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { useSelector } from "react-redux"; | ||
import { BaseNavigation } from "~/components/RootNavigator/types/helpers"; | ||
import { readOnlyModeEnabledSelector } from "~/reducers/settings"; | ||
import { useNavigation } from "@react-navigation/native"; | ||
import { NavigatorName } from "~/const"; | ||
import { useCallback, useMemo, useState } from "react"; | ||
import { track } from "~/analytics"; | ||
import { useFeature } from "@ledgerhq/live-common/featureFlags/index"; | ||
import { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets"; | ||
|
||
type AddAccountScreenProps = { | ||
currency?: CryptoCurrency | TokenCurrency | null; | ||
onClose?: () => void; | ||
}; | ||
|
||
const useSelectAddAccountMethodViewModel = ({ currency, onClose }: AddAccountScreenProps) => { | ||
const navigation = useNavigation<BaseNavigation>(); | ||
const walletSyncFeatureFlag = useFeature("llmWalletSync"); | ||
|
||
const isReadOnlyModeEnabled = useSelector(readOnlyModeEnabledSelector); | ||
const isWalletSyncEnabled = walletSyncFeatureFlag?.enabled; | ||
const hasCurrency = !!currency; | ||
|
||
const [isWalletSyncDrawerVisible, setWalletSyncDrawerVisible] = useState(false); | ||
|
||
const navigationParams = useMemo(() => { | ||
return hasCurrency | ||
? currency.type === "TokenCurrency" | ||
? { token: currency } | ||
: { currency } | ||
: {}; | ||
}, [hasCurrency, currency]); | ||
|
||
const trackButtonClick = useCallback((button: string) => { | ||
track("button_clicked", { | ||
button, | ||
drawer: "AddAccountsModal", | ||
}); | ||
}, []); | ||
|
||
const onClickImport = useCallback(() => { | ||
trackButtonClick("Import from Desktop"); | ||
onClose?.(); | ||
navigation.navigate(NavigatorName.ImportAccounts); | ||
}, [navigation, trackButtonClick, onClose]); | ||
|
||
const onClickAdd = useCallback(() => { | ||
trackButtonClick("With your Ledger"); | ||
onClose?.(); | ||
navigation.navigate(NavigatorName.AddAccounts, navigationParams); | ||
}, [navigation, navigationParams, trackButtonClick, onClose]); | ||
|
||
const onClickWalletSync = useCallback(() => { | ||
trackButtonClick("With Wallet Sync"); | ||
onClose?.(); | ||
setWalletSyncDrawerVisible(true); | ||
}, [trackButtonClick, setWalletSyncDrawerVisible, onClose]); | ||
|
||
const onCloseWalletSyncDrawer = useCallback(() => { | ||
setWalletSyncDrawerVisible(false); | ||
}, [setWalletSyncDrawerVisible]); | ||
|
||
return { | ||
isWalletSyncEnabled, | ||
isReadOnlyModeEnabled, | ||
isWalletSyncDrawerVisible, | ||
onClickAdd, | ||
onClickImport, | ||
onClickWalletSync, | ||
onCloseWalletSyncDrawer, | ||
}; | ||
}; | ||
|
||
export default useSelectAddAccountMethodViewModel; |
67 changes: 67 additions & 0 deletions
67
apps/ledger-live-mobile/src/newArch/features/Accounts/screens/AddAccount/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import React, { useState } from "react"; | ||
import useAddAccountViewModel from "./useAddAccountViewModel"; | ||
import QueuedDrawer from "~/components/QueuedDrawer"; | ||
import { TrackScreen } from "~/analytics"; | ||
import SelectAddAccountMethod from "./components/SelectAddAccountMethod"; | ||
import Drawer from "LLM/components/Dummy/Drawer"; | ||
import { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets"; | ||
|
||
type ViewProps = { | ||
isAddAccountDrawerVisible: boolean; | ||
doesNotHaveAccount?: boolean; | ||
currency?: CryptoCurrency | TokenCurrency | null; | ||
onCloseAddAccountDrawer: () => void; | ||
reopenDrawer: () => void; | ||
}; | ||
|
||
type AddAccountProps = { | ||
isOpened: boolean; | ||
currency?: CryptoCurrency | TokenCurrency | null; | ||
doesNotHaveAccount?: boolean; | ||
onClose: () => void; | ||
reopenDrawer: () => void; | ||
}; | ||
|
||
function View({ | ||
isAddAccountDrawerVisible, | ||
doesNotHaveAccount, | ||
currency, | ||
onCloseAddAccountDrawer, | ||
reopenDrawer, | ||
}: ViewProps) { | ||
const [isWalletSyncDrawerVisible, setWalletSyncDrawerVisible] = useState(false); | ||
|
||
const onRequestToOpenWalletSyncDrawer = () => { | ||
onCloseAddAccountDrawer(); | ||
setWalletSyncDrawerVisible(true); | ||
}; | ||
|
||
const onCloseWalletSyncDrawer = () => { | ||
setWalletSyncDrawerVisible(false); | ||
reopenDrawer(); | ||
}; | ||
|
||
return ( | ||
<> | ||
<QueuedDrawer | ||
isRequestingToBeOpened={isAddAccountDrawerVisible} | ||
onClose={onCloseAddAccountDrawer} | ||
> | ||
<TrackScreen category="Add/Import accounts" type="drawer" /> | ||
<SelectAddAccountMethod | ||
doesNotHaveAccount={doesNotHaveAccount} | ||
currency={currency} | ||
onClose={onCloseAddAccountDrawer} | ||
setWalletSyncDrawerVisible={onRequestToOpenWalletSyncDrawer} | ||
/> | ||
</QueuedDrawer> | ||
<Drawer isOpen={isWalletSyncDrawerVisible} handleClose={onCloseWalletSyncDrawer} /> | ||
</> | ||
); | ||
} | ||
|
||
const AddAccount = (props: AddAccountProps) => { | ||
return <View {...useAddAccountViewModel(props)} {...props} />; | ||
}; | ||
|
||
export default AddAccount; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 0 additions & 93 deletions
93
apps/ledger-live-mobile/src/newArch/features/WalletSync/drawers/addAccount/index.tsx
This file was deleted.
Oops, something went wrong.
Empty file.
Oops, something went wrong.