-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚦 [FEAT] Create the
llmMarketQuickActions
feature flag (#7558)
* Create the llmMarketQuickActions feature flag * Introduce the MarketQuickActions component behind the FF * Update changelog * Fix type checking * Improve navigation routes type accuracy * Define the quick actions only once --------- Co-authored-by: Theophile Sandoz <Theophile Sandoz>
- Loading branch information
Showing
6 changed files
with
87 additions
and
7 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,7 @@ | ||
--- | ||
"@ledgerhq/types-live": minor | ||
"live-mobile": minor | ||
"@ledgerhq/live-common": minor | ||
--- | ||
|
||
Create the llmMarketQuickActions feature flag |
55 changes: 55 additions & 0 deletions
55
apps/ledger-live-mobile/src/components/MarketQuickActions/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,55 @@ | ||
import { useNavigation } from "@react-navigation/native"; | ||
import { StackNavigationProp } from "@react-navigation/stack"; | ||
import React, { useMemo } from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import { QuickActionButtonProps, QuickActionList } from "@ledgerhq/native-ui"; | ||
import { EntryOf } from "~/types/helpers"; | ||
import useQuickActions from "../../hooks/useQuickActions"; | ||
import { BaseNavigatorStackParamList } from "../RootNavigator/types/BaseNavigator"; | ||
|
||
export const MarketQuickActions = () => { | ||
const { t } = useTranslation(); | ||
const navigation = useNavigation<StackNavigationProp<BaseNavigatorStackParamList>>(); | ||
const { quickActionsList } = useQuickActions(); | ||
|
||
const quickActionsData: QuickActionButtonProps[] = useMemo( | ||
() => | ||
(Object.entries(QUICK_ACTIONS) as EntryOf<typeof QUICK_ACTIONS>[]).flatMap(([key, prop]) => { | ||
const action = quickActionsList[key]; | ||
if (!action) return []; | ||
|
||
return { | ||
variant: "small", | ||
textVariant: "small", | ||
Icon: action.icon, | ||
children: t(prop.name), | ||
onPress: () => | ||
navigation.navigate<keyof BaseNavigatorStackParamList>( | ||
...(action.route as EntryOf<BaseNavigatorStackParamList>), | ||
), | ||
disabled: action.disabled, | ||
}; | ||
}), | ||
[quickActionsList, t, navigation], | ||
); | ||
|
||
return <QuickActionList data={quickActionsData} numColumns={5} id="asset_five_columns" />; | ||
}; | ||
|
||
const QUICK_ACTIONS = { | ||
SEND: { | ||
name: "portfolio.quickActions.send", | ||
}, | ||
RECEIVE: { | ||
name: "portfolio.quickActions.deposit", | ||
}, | ||
BUY: { | ||
name: "portfolio.quickActions.buy", | ||
}, | ||
SWAP: { | ||
name: "portfolio.quickActions.swap", | ||
}, | ||
STAKE: { | ||
name: "portfolio.quickActions.stake", | ||
}, | ||
} as const; |
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
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