-
Notifications
You must be signed in to change notification settings - Fork 360
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: Scan & device accounts - add account v2 #8802
Changes from 4 commits
3a3ed21
b6be724
7d46809
7e50827
990c6bb
fab2226
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,5 @@ | ||
--- | ||
"live-mobile": minor | ||
--- | ||
|
||
Add account v2 : Device selection & Scan account step |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ import { Flex, Text } from "@ledgerhq/native-ui"; | |
import Swipeable from "react-native-gesture-handler/Swipeable"; | ||
|
||
import { StackNavigationProp } from "@react-navigation/stack"; | ||
import { ScreenName } from "~/const"; | ||
import { NavigatorName, ScreenName } from "~/const"; | ||
import { track } from "~/analytics"; | ||
import AccountCard from "./AccountCard"; | ||
import CheckBox from "./CheckBox"; | ||
|
@@ -28,6 +28,10 @@ import TouchHintCircle from "./TouchHintCircle"; | |
import Touchable from "./Touchable"; | ||
import { AccountSettingsNavigatorParamList } from "./RootNavigator/types/AccountSettingsNavigator"; | ||
import { AddAccountsNavigatorParamList } from "./RootNavigator/types/AddAccountsNavigator"; | ||
import AccountItem from "LLM/features/Accounts/components/AccountsListView/components/AccountItem"; | ||
import { useFeature } from "@ledgerhq/live-common/featureFlags/index"; | ||
|
||
const ANIMATION_DURATION = 200; | ||
|
||
const selectAllHitSlop = { | ||
top: 16, | ||
|
@@ -85,6 +89,85 @@ const SelectableAccountsList = ({ | |
}, [accounts, onUnselectAllProp]); | ||
|
||
const areAllSelected = accounts.every(a => selectedIds.indexOf(a.id) > -1); | ||
const translateY = useRef(new Animated.Value(50)).current; | ||
const opacity = useRef(new Animated.Value(0)).current; | ||
const scale = useRef(new Animated.Value(0.8)).current; | ||
const llmNetworkBasedAddAccountFlow = useFeature("llmNetworkBasedAddAccountFlow"); | ||
|
||
useEffect(() => { | ||
if (!llmNetworkBasedAddAccountFlow?.enabled) return; | ||
Animated.parallel([ | ||
Animated.timing(translateY, { | ||
toValue: 0, | ||
duration: ANIMATION_DURATION, | ||
useNativeDriver: true, | ||
}), | ||
Animated.timing(opacity, { | ||
toValue: 1, | ||
duration: ANIMATION_DURATION, | ||
useNativeDriver: true, | ||
}), | ||
Animated.timing(scale, { | ||
toValue: 1, | ||
duration: ANIMATION_DURATION, | ||
useNativeDriver: true, | ||
}), | ||
]).start(); | ||
}, [translateY, opacity, scale, llmNetworkBasedAddAccountFlow?.enabled]); | ||
|
||
const animatedSelectableAccount = useMemo( | ||
() => ({ | ||
transform: [{ translateY }, { scale }], | ||
opacity, | ||
}), | ||
[translateY, scale, opacity], | ||
); | ||
|
||
const renderSelectableAccount = useCallback( | ||
({ item, index }: { index: number; item: Account }) => | ||
llmNetworkBasedAddAccountFlow?.enabled ? ( | ||
<Animated.View style={[animatedSelectableAccount]}> | ||
<SelectableAccount | ||
navigation={navigation} | ||
showHint={!index && showHint} | ||
rowIndex={index} | ||
listIndex={listIndex} | ||
account={item} | ||
onAccountNameChange={onAccountNameChange} | ||
isSelected={forceSelected || selectedIds.indexOf(item.id) > -1} | ||
isDisabled={isDisabled} | ||
onPress={onPressAccount} | ||
useFullBalance={useFullBalance} | ||
/> | ||
</Animated.View> | ||
) : ( | ||
<SelectableAccount | ||
navigation={navigation} | ||
showHint={!index && showHint} | ||
rowIndex={index} | ||
listIndex={listIndex} | ||
account={item} | ||
onAccountNameChange={onAccountNameChange} | ||
isSelected={forceSelected || selectedIds.indexOf(item.id) > -1} | ||
isDisabled={isDisabled} | ||
onPress={onPressAccount} | ||
useFullBalance={useFullBalance} | ||
/> | ||
), | ||
[ | ||
navigation, | ||
showHint, | ||
listIndex, | ||
selectedIds, | ||
forceSelected, | ||
isDisabled, | ||
onAccountNameChange, | ||
onPressAccount, | ||
useFullBalance, | ||
animatedSelectableAccount, | ||
llmNetworkBasedAddAccountFlow?.enabled, | ||
], | ||
); | ||
|
||
return ( | ||
<Flex marginBottom={7} {...props}> | ||
|
@@ -99,21 +182,12 @@ const SelectableAccountsList = ({ | |
<FlatList | ||
data={accounts} | ||
keyExtractor={(item, index) => item.id + index} | ||
renderItem={({ item, index }) => ( | ||
<SelectableAccount | ||
navigation={navigation} | ||
showHint={!index && showHint} | ||
rowIndex={index} | ||
listIndex={listIndex} | ||
account={item} | ||
onAccountNameChange={onAccountNameChange} | ||
isSelected={forceSelected || selectedIds.indexOf(item.id) > -1} | ||
isDisabled={isDisabled} | ||
onPress={onPressAccount} | ||
useFullBalance={useFullBalance} | ||
/> | ||
renderItem={renderSelectableAccount} | ||
ListEmptyComponent={() => ( | ||
<Flex height="100%" flexDirection="row" justifyContent="center"> | ||
{emptyState || null} | ||
</Flex> | ||
)} | ||
ListEmptyComponent={() => <>{emptyState || null}</>} | ||
/> | ||
</Flex> | ||
); | ||
|
@@ -147,6 +221,7 @@ const SelectableAccount = ({ | |
useFullBalance, | ||
}: SelectableAccountProps) => { | ||
const [stopAnimation, setStopAnimation] = useState<boolean>(false); | ||
const llmNetworkBasedAddAccountFlow = useFeature("llmNetworkBasedAddAccountFlow"); | ||
|
||
const swipeableRow = useRef<Swipeable>(null); | ||
|
||
|
@@ -206,11 +281,24 @@ const SelectableAccount = ({ | |
if (!onAccountNameChange) return; | ||
|
||
swipedAccountSubject.next({ row: -1, list: -1 }); | ||
navigation.navigate(ScreenName.EditAccountName, { | ||
onAccountNameChange, | ||
account, | ||
}); | ||
}, [account, navigation, onAccountNameChange]); | ||
if (llmNetworkBasedAddAccountFlow?.enabled) { | ||
(navigation as StackNavigationProp<AccountSettingsNavigatorParamList>).navigate( | ||
NavigatorName.AccountSettings, | ||
{ | ||
screen: ScreenName.EditAccountName, | ||
params: { | ||
onAccountNameChange, | ||
account, | ||
}, | ||
}, | ||
); | ||
} else { | ||
navigation.navigate(ScreenName.EditAccountName, { | ||
onAccountNameChange, | ||
account, | ||
}); | ||
} | ||
}, [account, navigation, onAccountNameChange, llmNetworkBasedAddAccountFlow?.enabled]); | ||
|
||
const renderLeftActions = useCallback( | ||
( | ||
|
@@ -259,25 +347,41 @@ const SelectableAccount = ({ | |
opacity={isDisabled ? 0.4 : 1} | ||
backgroundColor="neutral.c30" | ||
> | ||
<Flex flex={1}> | ||
<AccountCard | ||
useFullBalance={useFullBalance} | ||
account={account} | ||
AccountSubTitle={ | ||
subAccountCount && !isDisabled ? ( | ||
<Flex marginTop={2}> | ||
<Text fontWeight="semiBold" variant="small" color="pillActiveForeground"> | ||
<Trans | ||
i18nKey={`selectableAccountsList.${isToken ? "tokenCount" : "subaccountCount"}`} | ||
count={subAccountCount} | ||
values={{ count: subAccountCount }} | ||
/> | ||
</Text> | ||
</Flex> | ||
) : null | ||
} | ||
/> | ||
</Flex> | ||
{llmNetworkBasedAddAccountFlow?.enabled ? ( | ||
<Flex | ||
flex={1} | ||
flexDirection="row" | ||
height={56} | ||
alignItems="center" | ||
backgroundColor="neutral.c30" | ||
borderRadius="12px" | ||
padding="8px" | ||
columnGap={8} | ||
> | ||
<AccountItem account={account as Account} balance={account.spendableBalance} /> | ||
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. same here 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. done β |
||
</Flex> | ||
) : ( | ||
<Flex flex={1}> | ||
<AccountCard | ||
useFullBalance={useFullBalance} | ||
account={account} | ||
AccountSubTitle={ | ||
subAccountCount && !isDisabled ? ( | ||
<Flex marginTop={2}> | ||
<Text fontWeight="semiBold" variant="small" color="pillActiveForeground"> | ||
<Trans | ||
i18nKey={`selectableAccountsList.${isToken ? "tokenCount" : "subaccountCount"}`} | ||
count={subAccountCount} | ||
values={{ count: subAccountCount }} | ||
/> | ||
</Text> | ||
</Flex> | ||
) : null | ||
} | ||
/> | ||
</Flex> | ||
)} | ||
|
||
{!isDisabled && ( | ||
<Flex marginLeft={4}> | ||
<CheckBox onChange={handlePress} isChecked={!!isSelected} /> | ||
|
@@ -317,14 +421,20 @@ type HeaderProps = { | |
|
||
const Header = ({ text, areAllSelected, onSelectAll, onUnselectAll }: HeaderProps) => { | ||
const shouldDisplaySelectAll = !!onSelectAll && !!onUnselectAll; | ||
const llmNetworkBasedAddAccountFlow = useFeature("llmNetworkBasedAddAccountFlow"); | ||
|
||
return ( | ||
<Flex paddingX={16} flexDirection="row" alignItems="center" paddingBottom={8}> | ||
<Flex | ||
paddingX={llmNetworkBasedAddAccountFlow?.enabled ? 16 : 22} | ||
flexDirection="row" | ||
alignItems="center" | ||
paddingBottom={llmNetworkBasedAddAccountFlow?.enabled ? 16 : 8} | ||
> | ||
<Text | ||
fontWeight="semiBold" | ||
flexShrink={1} | ||
variant="small" | ||
textTransform="uppercase" | ||
{...(!llmNetworkBasedAddAccountFlow?.enabled && { textTransform: "uppercase" })} | ||
color="neutral.c70" | ||
numberOfLines={1} | ||
> | ||
|
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. We don't have it in DS? 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. 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. If we're going to use the same icon for the LLD add account can we add it to the DS please ? I don't know if this doc is up to date 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. I'll do it in a separate ticket once needed by LLD. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from "react"; | ||
import Svg, { Path } from "react-native-svg"; | ||
|
||
type Props = { | ||
size?: number; | ||
color?: string; | ||
}; | ||
export default function PauseCircle({ size = 16, color }: Props) { | ||
return ( | ||
<Svg viewBox="0 0 16 16" width={size} height={size}> | ||
<Path | ||
fill={color} | ||
d="M8 14.3A6.3 6.3 0 1 0 8 1.7a6.3 6.3 0 0 0 0 12.6zm0 1.4A7.7 7.7 0 1 1 8 .3a7.7 7.7 0 0 1 0 15.4zm-2.1-5.6V5.9c0-.933 1.4-.933 1.4 0v4.2c0 .933-1.4.933-1.4 0zm2.8 0V5.9c0-.933 1.4-.933 1.4 0v4.2c0 .933-1.4.933-1.4 0z" | ||
/> | ||
</Svg> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -4002,6 +4002,8 @@ | |||||
"desc": "Are you sure you want to cancel adding accounts?" | ||||||
}, | ||||||
"imported": "Asset added successfully", | ||||||
"added": "Account added to your portfolio", | ||||||
"added_plural": "{{count}} Accounts added to your portfolio", | ||||||
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.
Suggested change
I'm not sure but should be lowercase imo 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. |
||||||
"sections": { | ||||||
"importable": { | ||||||
"title": "Add existing account" | ||||||
|
@@ -4058,6 +4060,32 @@ | |||||
"title": "Taproot", | ||||||
"desc": "Latest {{currency}} network upgrade. Will provide better privacy and cheaper fees once widespread. Still limited support from wallet and exchanges." | ||||||
} | ||||||
}, | ||||||
"scanDeviceAccounts": { | ||||||
"title": "Select the accounts you want to add", | ||||||
"ctaStopScan": "Stop scanning", | ||||||
"confirm": "Confirm", | ||||||
"scanningTitle": "Looking for any existing accounts on the Blockchain...", | ||||||
"sections": { | ||||||
"importable": { | ||||||
"title": "We found {{count}} account", | ||||||
"title_plural": "We found {{count}} accounts" | ||||||
}, | ||||||
"creatable": { | ||||||
"title": "New account" | ||||||
}, | ||||||
"imported": { | ||||||
"title": "Account already in the Portfolio ({{length}})", | ||||||
"title_plural": "Accounts already in the Portfolio ({{length}})" | ||||||
}, | ||||||
"migrate": { | ||||||
"title": "Accounts to update" | ||||||
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. should be singular also no? 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. no idea about this one, as i'm using the exact same wording of add account v1 , see the same object above 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. as there is no count there , i prefer leave it like add account v1 wording |
||||||
} | ||||||
} | ||||||
}, | ||||||
"addAccountsSuccess": { | ||||||
"ctaAddFunds": "Add funds to my account", | ||||||
"ctaClose": "Close" | ||||||
} | ||||||
}, | ||||||
"DeviceAction": { | ||||||
|
@@ -7159,7 +7187,9 @@ | |||||
"title": "Select Asset" | ||||||
}, | ||||||
"selectNetwork": { | ||||||
"title": "Select the blockchain network the asset belongs to" | ||||||
"title": "Select the blockchain network the asset belongs to", | ||||||
"detectedAccounts": "{{count}} account (detected)", | ||||||
"detectedAccounts_plural": "{{count}} accounts (detected)" | ||||||
} | ||||||
} | ||||||
} |
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.
Do we need this type assertion here ? Is there a way to avoid it ? We should avoid using type assertions as much as possible as they can introduce nasty and hard to debug errors