-
Notifications
You must be signed in to change notification settings - Fork 318
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] Create the llmMarketQuickActions
feature flag
#7558
Changes from 4 commits
5ee5ac1
cff104b
146eb05
3c173c7
91c99f1
5f01f0a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
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 useQuickActions from "../../hooks/useQuickActions"; | ||
|
||
export const MarketQuickActions = () => { | ||
const { t } = useTranslation(); | ||
const navigation = useNavigation<StackNavigationProp<Record<string, object | undefined>>>(); | ||
const { quickActionsList } = useQuickActions(); | ||
|
||
const quickActionsData: QuickActionButtonProps[] = useMemo( | ||
() => | ||
QUICK_ACTIONS.flatMap(key => { | ||
const action = quickActionsList[key]; | ||
if (!action) return []; | ||
|
||
return { | ||
variant: "small", | ||
textVariant: "small", | ||
Icon: action.icon, | ||
children: t(QUICK_ACTION_DATA[key].name), | ||
onPress: () => navigation.navigate(...(action.route as [string, object?])), | ||
disabled: action.disabled, | ||
}; | ||
}), | ||
[quickActionsList, t, navigation], | ||
); | ||
|
||
return <QuickActionList data={quickActionsData} numColumns={5} id="asset_five_columns" />; | ||
}; | ||
|
||
const QUICK_ACTIONS = ["SEND", "RECEIVE", "BUY", "SWAP", "STAKE"] as const; | ||
const QUICK_ACTION_DATA = { | ||
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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we optimize this to only define once SEND, RECEIVE, etc... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I did this but it required an extra type casting because the |
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.
Should works :)