Skip to content

Commit

Permalink
feat 👔 (llm): update and create deeplinks for new accounts list ui
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasWerey committed Jan 8, 2025
1 parent ca0fde8 commit c9e8296
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 101 deletions.
5 changes: 5 additions & 0 deletions .changeset/mean-mangos-compete.md
Original file line number Diff line number Diff line change
@@ -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
221 changes: 130 additions & 91 deletions apps/ledger-live-mobile/src/navigation/DeeplinksProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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&currencyId=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: {
/**
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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<LinkingOptions<ReactNavigation.RootParamList>>(
() =>
({
Expand Down Expand Up @@ -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&currencyId=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",
},
},
},
},
},
Expand Down Expand Up @@ -600,13 +637,15 @@ export const DeeplinksProvider = ({
}) as LinkingOptions<ReactNavigation.RootParamList>,
[
hasCompletedOnboarding,
llmAccountListUI?.enabled,
AddAccountNavigatorEntryPoint,
AccountsListScreenName,
userAcceptedTerms,
buySellUiManifestId,
dispatch,
storylyContext,
liveAppProviderInitialized,
manifests,
buySellUiManifestId,
AddAccountNavigatorEntryPoint,
],
);
const [isReady, setIsReady] = React.useState(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<AccountsListNavigator, ScreenName.AccountsList>;

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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -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<AssetsListNavigator, ScreenName.AssetsList>;

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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};
2 changes: 2 additions & 0 deletions apps/ledger-live-mobile/src/newArch/utils/parseBoolean.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const parseBoolean = (value: string | boolean): boolean =>
typeof value === "string" ? value === "true" : value;

0 comments on commit c9e8296

Please sign in to comment.