-
Notifications
You must be signed in to change notification settings - Fork 315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(llm): new add account drawer on assets screen with WS entrypoint #7064
Merged
Merged
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a08e123
feat(llm): new add account drawer on assets screen with WS entrypoint
LucasWerey 6c0a74b
feat(llm): generalize the new add account drawer to every parts of thβ¦
LucasWerey f9aa552
feat(llm): fix e2e test
LucasWerey b53bc94
feat(llm): conditionnal wording if no account
LucasWerey 1c2414b
feat(llm): change components archi
LucasWerey 43e89f1
feat(llm): add unit test to check the conditionnal render with WS feaβ¦
LucasWerey d6ecc39
feat(llm): add integration test for add accounts flow
LucasWerey 4938d10
feat(llm): fix missing mock for jest integrations tests
LucasWerey 0e1d53a
feat(llm): add missing integration test for the select import accountβ¦
LucasWerey 4b97812
feat(llm): clean up hooks
LucasWerey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"live-mobile": patch | ||
--- | ||
|
||
Create a new drawer component on add account. This new drawer has new UI and an entry point to walletSync. This entrypoint is hidden under a feature flag. Also update translations related to WS. |
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: 93 additions & 0 deletions
93
apps/ledger-live-mobile/src/newArch/features/WalletSync/drawers/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,93 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
import React from "react"; | ||
import useAddAccountDrawer from "LLM/features/WalletSync/hooks/useAddAccountDrawer"; | ||
import DummyDrawer from "../DummyDrawer"; | ||
import ActionRow from "../components/ActionRow"; | ||
import QueuedDrawer from "~/components/QueuedDrawer"; | ||
import { useTranslation } from "react-i18next"; | ||
import { TrackScreen } from "~/analytics"; | ||
import { Flex, Icons, Text } from "@ledgerhq/native-ui"; | ||
import { AddAccountDrawerProps } from "LLM/features/WalletSync/types/addAccountDrawer"; | ||
|
||
const AddAccountDrawer = ({ | ||
isOpened, | ||
currency, | ||
doesNotHaveAccount, | ||
onClose, | ||
reopenDrawer, | ||
}: AddAccountDrawerProps) => { | ||
const { t } = useTranslation(); | ||
const rows = []; | ||
|
||
const { | ||
isWalletSyncEnabled, | ||
isReadOnlyModeEnabled, | ||
isAddAccountDrawerVisible, | ||
isWalletSyncDrawerVisible, | ||
onClickAdd, | ||
onClickImport, | ||
onClickWalletSync, | ||
onCloseAddAccountDrawer, | ||
onCloseWalletSyncDrawer, | ||
} = useAddAccountDrawer({ isOpened, currency, onClose, reopenDrawer }); | ||
|
||
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: onClickWalletSync, | ||
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 ( | ||
<> | ||
<QueuedDrawer | ||
isRequestingToBeOpened={isAddAccountDrawerVisible} | ||
onClose={onCloseAddAccountDrawer} | ||
> | ||
<TrackScreen category="Add/Import accounts" type="drawer" /> | ||
<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> | ||
</QueuedDrawer> | ||
<DummyDrawer isOpen={isWalletSyncDrawerVisible} handleClose={onCloseWalletSyncDrawer} /> | ||
</> | ||
); | ||
}; | ||
|
||
export default AddAccountDrawer; |
45 changes: 45 additions & 0 deletions
45
apps/ledger-live-mobile/src/newArch/features/WalletSync/drawers/components/ActionRow.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,45 @@ | ||
import { Flex, Text } from "@ledgerhq/native-ui"; | ||
import React from "react"; | ||
import Touchable from "~/components/Touchable"; | ||
import styled from "styled-components/native"; | ||
import { AddAccountDrawerRowProps } from "LLM/features/WalletSync/types/addAccountDrawer"; | ||
|
||
const TouchableCard = styled(Touchable)` | ||
background-color: ${p => p.theme.colors.opacityDefault.c05}; | ||
border-radius: 8px; | ||
padding: 16px; | ||
align-items: center; | ||
gap: 12px; | ||
flex-direction: row; | ||
align-self: stretch; | ||
`; | ||
|
||
const CardTitle = styled(Text)` | ||
font-size: 16px; | ||
color: ${p => p.theme.colors.neutral.c100}; | ||
`; | ||
|
||
const CardDescription = styled(Text)` | ||
font-size: 14px; | ||
color: ${p => p.theme.colors.neutral.c70}; | ||
line-height: 18.2px; | ||
`; | ||
|
||
const ActionRow: React.FC<AddAccountDrawerRowProps> = ({ | ||
title, | ||
description, | ||
icon, | ||
testID, | ||
onPress, | ||
}: AddAccountDrawerRowProps) => { | ||
return ( | ||
<TouchableCard onPress={onPress} testID={testID}> | ||
{icon} | ||
<Flex flexDirection={"column"} rowGap={4} flex={1}> | ||
<CardTitle>{title}</CardTitle> | ||
{description && <CardDescription>{description}</CardDescription>} | ||
</Flex> | ||
</TouchableCard> | ||
); | ||
}; | ||
export default ActionRow; |
Empty file.
82 changes: 82 additions & 0 deletions
82
apps/ledger-live-mobile/src/newArch/features/WalletSync/hooks/useAddAccountDrawer.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,82 @@ | ||
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 { AddAccountDrawerProps } from "LLM/features/WalletSync/types/addAccountDrawer"; | ||
|
||
const useAddAccountDrawer = ({ | ||
isOpened, | ||
currency, | ||
onClose, | ||
reopenDrawer, | ||
}: AddAccountDrawerProps) => { | ||
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, onClose, trackButtonClick]); | ||
|
||
const onClickAdd = useCallback(() => { | ||
trackButtonClick("With your Ledger"); | ||
onClose(); | ||
navigation.navigate(NavigatorName.AddAccounts, navigationParams); | ||
}, [navigation, navigationParams, onClose, trackButtonClick]); | ||
|
||
const onClickWalletSync = useCallback(() => { | ||
trackButtonClick("With Wallet Sync"); | ||
onClose(); | ||
setWalletSyncDrawerVisible(true); | ||
}, [trackButtonClick, onClose]); | ||
|
||
const onCloseAddAccountDrawer = useCallback(() => { | ||
trackButtonClick("Close 'x'"); | ||
onClose(); | ||
}, [trackButtonClick, onClose]); | ||
|
||
const onCloseWalletSyncDrawer = useCallback(() => { | ||
setWalletSyncDrawerVisible(false); | ||
reopenDrawer(); | ||
}, [setWalletSyncDrawerVisible, reopenDrawer]); | ||
|
||
return { | ||
isWalletSyncEnabled, | ||
isReadOnlyModeEnabled, | ||
isAddAccountDrawerVisible: isOpened, | ||
isWalletSyncDrawerVisible, | ||
onClickAdd, | ||
onClickImport, | ||
onClickWalletSync, | ||
onCloseAddAccountDrawer, | ||
onCloseWalletSyncDrawer, | ||
}; | ||
}; | ||
|
||
export default useAddAccountDrawer; |
18 changes: 18 additions & 0 deletions
18
apps/ledger-live-mobile/src/newArch/features/WalletSync/types/addAccountDrawer.ts
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,18 @@ | ||
import { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets"; | ||
import Touchable from "~/components/Touchable"; | ||
|
||
export type AddAccountDrawerProps = { | ||
isOpened: boolean; | ||
currency?: CryptoCurrency | TokenCurrency | null; | ||
doesNotHaveAccount?: boolean; | ||
onClose: () => void; | ||
reopenDrawer: () => void; | ||
}; | ||
|
||
export type AddAccountDrawerRowProps = { | ||
title: string; | ||
description?: string; | ||
icon: React.ReactNode; | ||
testID?: string; | ||
onPress: React.ComponentProps<typeof Touchable>["onPress"]; | ||
}; |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we follow the guidelines we can't add a
drawers
folder here.We should put AddAccount (PascalCase) under
screens
orcomponents
folder.https://ledgerhq.atlassian.net/wiki/spaces/WXP/pages/4508058220/Code+Guidelines+-+React+Native#Folder-organization