-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(llm): new add account drawer on assets screen with WS entrypoint
- Loading branch information
1 parent
cb6a975
commit a08e123
Showing
8 changed files
with
251 additions
and
10 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
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 on assets screen. This new drawer has new UI and an entry point to walletSync. This entrypoint is hidden under a feature flag |
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
47 changes: 47 additions & 0 deletions
47
...er-live-mobile/src/newArch/features/WalletSync/drawers/addAccount/AddAccountDrawerRow.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,47 @@ | ||
import { Flex, Text } from "@ledgerhq/native-ui"; | ||
import React from "react"; | ||
import Touchable from "~/components/Touchable"; | ||
import styled from "styled-components/native"; | ||
|
||
const Card = styled(Flex)` | ||
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; | ||
`; | ||
|
||
type AddAccountDrawerRowProps = { | ||
title: string; | ||
description: string; | ||
icon?: React.ReactNode; | ||
onPress?: React.ComponentProps<typeof Touchable>["onPress"]; | ||
}; | ||
|
||
const AddAccountDrawerRow = ({ title, description, icon, onPress }: AddAccountDrawerRowProps) => { | ||
return ( | ||
<Touchable onPress={onPress}> | ||
<Card> | ||
{icon} | ||
<Flex flexDirection={"column"} rowGap={4} flex={1}> | ||
<CardTitle>{title}</CardTitle> | ||
<CardDescription>{description}</CardDescription> | ||
</Flex> | ||
</Card> | ||
</Touchable> | ||
); | ||
}; | ||
export default AddAccountDrawerRow; |
90 changes: 90 additions & 0 deletions
90
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,90 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
import React from "react"; | ||
import useAddAccountDrawer from "LLM/features/WalletSync/hooks/useAddAccountDrawer"; | ||
import DummyDrawer from "../DummyDrawer"; | ||
import AddAccountDrawerRow from "./AddAccountDrawerRow"; | ||
import QueuedDrawer from "~/components/QueuedDrawer"; | ||
import { useTranslation } from "react-i18next"; | ||
import { TrackScreen } from "~/analytics"; | ||
import { Flex, Icons, Text } from "@ledgerhq/native-ui"; | ||
|
||
/** This drawer component should be only used in assets screen */ | ||
|
||
type AddAccountDrawerProps = { | ||
isOpened: boolean; | ||
onClose: () => void; | ||
reopenDrawer: () => void; | ||
}; | ||
|
||
const AddAccountDrawer = ({ isOpened, onClose, reopenDrawer }: AddAccountDrawerProps) => { | ||
const { t } = useTranslation(); | ||
const rows = []; | ||
|
||
const { | ||
isWalletSyncEnabled, | ||
isReadOnlyModeEnabled, | ||
isAddAccountDrawerVisible, | ||
isWalletSyncDrawerVisible, | ||
onClickAdd, | ||
onClickImport, | ||
onClickWalletSync, | ||
onCloseAddAccountDrawer, | ||
onCloseWalletSyncDrawer, | ||
} = useAddAccountDrawer({ isOpened, onClose, reopenDrawer }); | ||
|
||
if (!isReadOnlyModeEnabled) { | ||
rows.push({ | ||
titleKey: "addAccountsModal.assetsScreen.add.title", | ||
descriptionKey: "addAccountsModal.assetsScreen.add.description", | ||
onPress: onClickAdd, | ||
icon: <Icons.LedgerDevices color={"primary.c80"} />, | ||
}); | ||
} | ||
|
||
if (isWalletSyncEnabled) { | ||
rows.push({ | ||
titleKey: "addAccountsModal.assetsScreen.walletSync.title", | ||
descriptionKey: "addAccountsModal.assetsScreen.walletSync.description", | ||
onPress: onClickWalletSync, | ||
icon: <Icons.QrCode color={"primary.c80"} />, | ||
}); | ||
} else { | ||
rows.push({ | ||
titleKey: "addAccountsModal.import.title", | ||
descriptionKey: "addAccountsModal.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}> | ||
{t("addAccountsModal.assetsScreen.drawerTitle")} | ||
</Text> | ||
<Text variant="large" fontWeight="medium" fontSize="14px" color="neutral.c70" mb="32px"> | ||
{t("addAccountsModal.assetsScreen.drawerSubTitle")} | ||
</Text> | ||
<Flex flexDirection="column" rowGap={16}> | ||
{rows.map((row, index) => ( | ||
<AddAccountDrawerRow | ||
key={index} | ||
title={t(row.titleKey)} | ||
description={t(row.descriptionKey)} | ||
onPress={row.onPress} | ||
icon={row.icon} | ||
/> | ||
))} | ||
</Flex> | ||
</QueuedDrawer> | ||
<DummyDrawer isOpen={isWalletSyncDrawerVisible} handleClose={onCloseWalletSyncDrawer} /> | ||
</> | ||
); | ||
}; | ||
|
||
export default AddAccountDrawer; |
Empty file.
73 changes: 73 additions & 0 deletions
73
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,73 @@ | ||
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, useState } from "react"; | ||
import { track } from "~/analytics"; | ||
import { useFeature } from "@ledgerhq/live-common/featureFlags/index"; | ||
|
||
type AddAccountDrawerProps = { | ||
isOpened: boolean; | ||
onClose: () => void; | ||
reopenDrawer: () => void; | ||
}; | ||
|
||
const useAddAccountDrawer = ({ isOpened, onClose, reopenDrawer }: AddAccountDrawerProps) => { | ||
const navigation = useNavigation<BaseNavigation>(); | ||
const walletSyncFeatureFlag = useFeature("llmWalletSync"); | ||
|
||
const isReadOnlyModeEnabled = useSelector(readOnlyModeEnabledSelector); | ||
const isWalletSyncEnabled = walletSyncFeatureFlag?.enabled; | ||
|
||
const [isWalletSyncDrawerVisible, setWalletSyncDrawerVisible] = useState(false); | ||
|
||
const trackButtonClick = useCallback((button: string) => { | ||
track("button_clicked", { | ||
button, | ||
drawer: "AddAccountsModal", | ||
}); | ||
}, []); | ||
|
||
const onClickImport = useCallback(() => { | ||
trackButtonClick("Import from Desktop"); | ||
onClose(); | ||
navigation.navigate(NavigatorName.ImportAccounts); | ||
}, [trackButtonClick, navigation, onClose]); | ||
|
||
const onClickAdd = useCallback(() => { | ||
trackButtonClick("With your Ledger"); | ||
onClose(); | ||
navigation.navigate(NavigatorName.AddAccounts); | ||
}, [trackButtonClick, navigation, onClose]); | ||
|
||
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; |
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