diff --git a/.changeset/mean-mangos-compete.md b/.changeset/mean-mangos-compete.md new file mode 100644 index 000000000000..af5740d90014 --- /dev/null +++ b/.changeset/mean-mangos-compete.md @@ -0,0 +1,5 @@ +--- +"live-mobile": minor +--- + +Update ledgerlive://account deeplink to navigate to the new ui. Create ledgerlive://assets deeplink to redirect to new assets list screen diff --git a/apps/ledger-live-mobile/src/navigation/DeeplinksProvider.tsx b/apps/ledger-live-mobile/src/navigation/DeeplinksProvider.tsx index 20b16b62029a..03b8a986fa7f 100644 --- a/apps/ledger-live-mobile/src/navigation/DeeplinksProvider.tsx +++ b/apps/ledger-live-mobile/src/navigation/DeeplinksProvider.tsx @@ -162,83 +162,6 @@ const linkingOptions = () => ({ }, }, [ScreenName.Recover]: "recover/:platform", - [NavigatorName.Main]: { - initialRouteName: ScreenName.Portfolio, - screens: { - /** - * ie: "ledgerlive://portfolio" -> will redirect to the portfolio - */ - - [NavigatorName.Portfolio]: { - screens: { - [NavigatorName.PortfolioAccounts]: { - screens: { - /** - * "ledgerlive://accounts" opens the main portfolio screen of accounts. - */ - [ScreenName.Accounts]: "accounts", - }, - }, - [NavigatorName.WalletTab]: { - screens: { - [ScreenName.Portfolio]: "portfolio", - [ScreenName.WalletNftGallery]: "nftgallery", - [NavigatorName.Market]: { - screens: { - /** - * ie: "ledgerlive://market" will open the market screen - */ - [ScreenName.MarketList]: "market", - }, - }, - }, - }, - }, - }, - [NavigatorName.Earn]: { - screens: { - /** - * ie: "ledgerlive://earn" will open earn dashboard page - * - * @params ?action: string - * ie: "ledgerlive://earn?action=stake" will open staking flow - * - * * @params ?action: string - * * @params &accountId: string - * ie: "ledgerlive://earn?action=stake-account&accountId=XXXX" will open staking flow with specific account - * - * * @params ?action: string - * * @params ?currencyId: string - * ie: "ledgerlive://earn?action=get-funds¤cyId=ethereum" will open buy drawer with currency - * - */ - [ScreenName.Earn]: "earn", - }, - }, - [NavigatorName.Discover]: { - screens: { - /** - * ie: "ledgerlive://discover" will open the catalog - */ - [ScreenName.PlatformCatalog]: "discover", - }, - }, - [NavigatorName.MyLedger]: { - screens: { - /** - * ie: "ledgerlive://myledger" will open MyLedger page - * - * @params ?installApp: string - * ie: "ledgerlive://myledger?installApp=bitcoin" will open myledger with "bitcoin" prefilled in the search input - * - * * @params ?searchQuery: string - * ie: "ledgerlive://myledger?searchQuery=bitcoin" will open myledger with "bitcoin" prefilled in the search input - */ - [ScreenName.MyLedgerChooseDevice]: "myledger", - }, - }, - }, - }, [NavigatorName.PostOnboarding]: { screens: { /** @@ -274,18 +197,6 @@ const linkingOptions = () => ({ [ScreenName.SendCoin]: "send", }, }, - /** "ledgerlive://account" will open the list of all accounts, where the redirection logic is. */ - [NavigatorName.Accounts]: { - screens: { - /** - * @params ?currency: string - * @params ?address: string - * ie: "ledgerlive://account?currency=ethereum&address={{eth_account_address}} will open that account's assets screen. - * Currency param alone e.g. "ledgerlive://account?currency=tezos" will open the Tezos Assets screen. - */ - [ScreenName.Accounts]: "account", - }, - }, /** * ie: "ledgerlive://buy" -> will redirect to the main exchange page */ @@ -432,10 +343,15 @@ export const DeeplinksProvider = ({ const storylyContext = useStorylyContext(); const buySellUiFlag = useFeature("buySellUi"); const llmNetworkBasedAddAccountFlow = useFeature("llmNetworkBasedAddAccountFlow"); + const llmAccountListUI = useFeature("llmAccountListUI"); const buySellUiManifestId = buySellUiFlag?.params?.manifestId; const AddAccountNavigatorEntryPoint = llmNetworkBasedAddAccountFlow?.enabled ? NavigatorName.AssetSelection : NavigatorName.AddAccounts; // both navigators share the same ScreenName.AddAccountsSelectCrypto screen + const AccountsListScreenName = llmAccountListUI?.enabled + ? ScreenName.AccountsList + : ScreenName.Accounts; + const linking = useMemo>( () => ({ @@ -463,6 +379,127 @@ export const DeeplinksProvider = ({ [ScreenName.AddAccountsSelectCrypto]: "add-account", }, }, + /** "ledgerlive://assets will open assets screen. */ + ...(llmAccountListUI?.enabled && { + [NavigatorName.Assets]: { + screens: { + /** + * @params ?showHeader: boolean + * @params ?isSyncEnabled: boolean + * @params ?sourceScreenName: string + * ie: "ledgerlive://assets?showHeader=true will open assets screen with header + * ie "ledgerlive://assets?isSyncEnabled=true will open assets screen with sync enabled + * ie "ledgerlive://assets?sourceScreenName=Portfolio will open assets screen with source screen name Portfolio for tracking inside the screen + */ + [ScreenName.AssetsList]: "assets", + }, + }, + }), + [NavigatorName.Main]: { + initialRouteName: ScreenName.Portfolio, + screens: { + /** + * ie: "ledgerlive://portfolio" -> will redirect to the portfolio + */ + + [NavigatorName.Portfolio]: { + screens: { + ...(!llmAccountListUI?.enabled && { + [NavigatorName.PortfolioAccounts]: { + screens: { + /** + * "ledgerlive://accounts" opens the main portfolio screen of accounts. + */ + [ScreenName.Accounts]: "accounts", + }, + }, + }), + [NavigatorName.WalletTab]: { + screens: { + [ScreenName.Portfolio]: "portfolio", + [ScreenName.WalletNftGallery]: "nftgallery", + [NavigatorName.Market]: { + screens: { + /** + * ie: "ledgerlive://market" will open the market screen + */ + [ScreenName.MarketList]: "market", + }, + }, + }, + }, + }, + }, + [NavigatorName.Earn]: { + screens: { + /** + * ie: "ledgerlive://earn" will open earn dashboard page + * + * @params ?action: string + * ie: "ledgerlive://earn?action=stake" will open staking flow + * + * * @params ?action: string + * * @params &accountId: string + * ie: "ledgerlive://earn?action=stake-account&accountId=XXXX" will open staking flow with specific account + * + * * @params ?action: string + * * @params ?currencyId: string + * ie: "ledgerlive://earn?action=get-funds¤cyId=ethereum" will open buy drawer with currency + * + */ + [ScreenName.Earn]: "earn", + }, + }, + [NavigatorName.Discover]: { + screens: { + /** + * ie: "ledgerlive://discover" will open the catalog + */ + [ScreenName.PlatformCatalog]: "discover", + }, + }, + [NavigatorName.MyLedger]: { + screens: { + /** + * ie: "ledgerlive://myledger" will open MyLedger page + * + * @params ?installApp: string + * ie: "ledgerlive://myledger?installApp=bitcoin" will open myledger with "bitcoin" prefilled in the search input + * + * * @params ?searchQuery: string + * ie: "ledgerlive://myledger?searchQuery=bitcoin" will open myledger with "bitcoin" prefilled in the search input + */ + [ScreenName.MyLedgerChooseDevice]: "myledger", + }, + }, + }, + }, + [NavigatorName.Accounts]: { + screens: { + /** + * "ledgerlive://accounts" opens the main portfolio screen of accounts. + */ + /** + * if llmAccountListUI is enabled + * @params ?showHeader: boolean + * @params ?canAddAccount: boolean + * @params ?isSyncEnabled: boolean + * @params ?sourceScreenName: string + * ie: "ledgerlive://accounts?showHeader=true will open accounts screen with header + * ie "ledgerlive://accounts?canAddAccount=true will open accounts screen with add account button + * ie "ledgerlive://accounts?isSyncEnabled=true will open accounts screen with sync enabled + * ie "ledgerlive://accounts?sourceScreenName=Portfolio will open accounts screen with source screen name Portfolio for tracking inside the screen + */ + [AccountsListScreenName]: "accounts", + /** + * @params ?currency: string + * @params ?address: string + * ie: "ledgerlive://account?currency=ethereum&address={{eth_account_address}} will open that account's assets screen. + * Currency param alone e.g. "ledgerlive://account?currency=tezos" will open the Tezos Assets screen. + */ + [ScreenName.Accounts]: "account", + }, + }, }, }, }, @@ -600,13 +637,15 @@ export const DeeplinksProvider = ({ }) as LinkingOptions, [ hasCompletedOnboarding, + llmAccountListUI?.enabled, + AddAccountNavigatorEntryPoint, + AccountsListScreenName, userAcceptedTerms, + buySellUiManifestId, dispatch, storylyContext, liveAppProviderInitialized, manifests, - buySellUiManifestId, - AddAccountNavigatorEntryPoint, ], ); const [isReady, setIsReady] = React.useState(false); diff --git a/apps/ledger-live-mobile/src/newArch/features/Accounts/screens/AccountsList/index.tsx b/apps/ledger-live-mobile/src/newArch/features/Accounts/screens/AccountsList/index.tsx index 7bd7edee5953..c9b441b710b9 100644 --- a/apps/ledger-live-mobile/src/newArch/features/Accounts/screens/AccountsList/index.tsx +++ b/apps/ledger-live-mobile/src/newArch/features/Accounts/screens/AccountsList/index.tsx @@ -25,15 +25,18 @@ import { useGroupedCurrenciesByProvider } from "@ledgerhq/live-common/deposit/in import { LoadingBasedGroupedCurrencies, LoadingStatus } from "@ledgerhq/live-common/deposit/type"; import { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets"; import { TrackingEvent } from "../../enums"; +import { parseBoolean } from "LLM/utils/parseBoolean"; type Props = StackNavigatorProps; export default function AccountsList({ route }: Props) { const { params } = route; const { t } = useTranslation(); - const canAddAccount = params?.canAddAccount; - const showHeader = params?.showHeader; + + const canAddAccount = params?.canAddAccount ? parseBoolean(params?.canAddAccount) : false; + const showHeader = params?.showHeader ? parseBoolean(params?.showHeader) : false; + const isSyncEnabled = params?.isSyncEnabled ? parseBoolean(params?.isSyncEnabled) : false; const sourceScreenName = params?.sourceScreenName; - const isSyncEnabled = params?.isSyncEnabled; + const specificAccounts = params?.specificAccounts; const navigation = useNavigation(); const llmNetworkBasedAddAccountFlow = useFeature("llmNetworkBasedAddAccountFlow"); diff --git a/apps/ledger-live-mobile/src/newArch/features/Accounts/screens/AccountsList/types.ts b/apps/ledger-live-mobile/src/newArch/features/Accounts/screens/AccountsList/types.ts index 405cac907e22..529fc098eb5f 100644 --- a/apps/ledger-live-mobile/src/newArch/features/Accounts/screens/AccountsList/types.ts +++ b/apps/ledger-live-mobile/src/newArch/features/Accounts/screens/AccountsList/types.ts @@ -4,9 +4,9 @@ import { ScreenName } from "~/const"; export type AccountsListNavigator = { [ScreenName.AccountsList]: { sourceScreenName: ScreenName; - showHeader?: boolean; - canAddAccount?: boolean; - isSyncEnabled?: boolean; + showHeader?: boolean | string; + canAddAccount?: boolean | string; + isSyncEnabled?: boolean | string; specificAccounts?: Account[] | TokenAccount[]; }; }; diff --git a/apps/ledger-live-mobile/src/newArch/features/Assets/screens/AssetsList/index.tsx b/apps/ledger-live-mobile/src/newArch/features/Assets/screens/AssetsList/index.tsx index bf4ffbb6dbe5..481e1259521a 100644 --- a/apps/ledger-live-mobile/src/newArch/features/Assets/screens/AssetsList/index.tsx +++ b/apps/ledger-live-mobile/src/newArch/features/Assets/screens/AssetsList/index.tsx @@ -13,15 +13,16 @@ import { isUpToDateSelector } from "~/reducers/accounts"; import { useGlobalSyncState } from "@ledgerhq/live-common/bridge/react/useGlobalSyncState"; import { RefreshMedium } from "@ledgerhq/icons-ui/nativeLegacy"; import Spinning from "~/components/Spinning"; +import { parseBoolean } from "LLM/utils/parseBoolean"; type Props = StackNavigatorProps; export default function AssetsList({ route }: Props) { const { params } = route; const { t } = useTranslation(); - const showHeader = params?.showHeader; + const showHeader = params?.showHeader ? parseBoolean(params?.showHeader) : false; + const isSyncEnabled = params?.isSyncEnabled ? parseBoolean(params?.isSyncEnabled) : false; const sourceScreenName = params?.sourceScreenName; - const isSyncEnabled = params?.isSyncEnabled; const isUpToDate = useSelector(isUpToDateSelector); const globalSyncState = useGlobalSyncState(); diff --git a/apps/ledger-live-mobile/src/newArch/features/Assets/screens/AssetsList/types.ts b/apps/ledger-live-mobile/src/newArch/features/Assets/screens/AssetsList/types.ts index e1fe8a6e9bb5..00450df49ce6 100644 --- a/apps/ledger-live-mobile/src/newArch/features/Assets/screens/AssetsList/types.ts +++ b/apps/ledger-live-mobile/src/newArch/features/Assets/screens/AssetsList/types.ts @@ -3,7 +3,7 @@ import { ScreenName } from "~/const"; export type AssetsListNavigator = { [ScreenName.AssetsList]: { sourceScreenName: ScreenName; - showHeader?: boolean; - isSyncEnabled?: boolean; + showHeader?: boolean | string; + isSyncEnabled?: boolean | string; }; }; diff --git a/apps/ledger-live-mobile/src/newArch/utils/parseBoolean.ts b/apps/ledger-live-mobile/src/newArch/utils/parseBoolean.ts new file mode 100644 index 000000000000..b0f8012ae344 --- /dev/null +++ b/apps/ledger-live-mobile/src/newArch/utils/parseBoolean.ts @@ -0,0 +1,2 @@ +export const parseBoolean = (value: string | boolean): boolean => + typeof value === "string" ? value === "true" : value;