-
-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(suite-native): select coin modal UI
- Loading branch information
Showing
27 changed files
with
751 additions
and
132 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
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
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const { ...baseConfig } = require('../../jest.config.native'); | ||
|
||
module.exports = { | ||
...baseConfig, | ||
}; |
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
31 changes: 31 additions & 0 deletions
31
suite-native/module-trading/src/components/TradeableAssetsSheet/FavouriteIcon.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,31 @@ | ||
import { TouchableWithoutFeedback } from 'react-native'; | ||
|
||
import { Icon, IconColor, IconName } from '@suite-native/icons'; | ||
import { useTranslate } from '@suite-native/intl'; | ||
|
||
export type FavouriteIconProps = { | ||
isFavourite: boolean; | ||
onPress: () => void; | ||
}; | ||
|
||
export const FavouriteIcon = ({ isFavourite, onPress }: FavouriteIconProps) => { | ||
const { translate } = useTranslate(); | ||
|
||
const hint: string = isFavourite | ||
? translate('moduleTrading.tradeableAssetsSheet.favouritesRemove') | ||
: translate('moduleTrading.tradeableAssetsSheet.favouritesAdd'); | ||
const iconName: IconName = isFavourite ? 'starFilled' : 'star'; | ||
// TODO 16600 - do I really want to use backgroundAlertYellowBold here? | ||
// TODO outline? | ||
const iconColor: IconColor = isFavourite ? 'backgroundAlertYellowBold' : 'textSubdued'; | ||
|
||
return ( | ||
<TouchableWithoutFeedback | ||
onPress={onPress} | ||
accessibilityRole="button" | ||
accessibilityHint={hint} | ||
> | ||
<Icon name={iconName} color={iconColor} /> | ||
</TouchableWithoutFeedback> | ||
); | ||
}; |
66 changes: 66 additions & 0 deletions
66
suite-native/module-trading/src/components/TradeableAssetsSheet/TradeableAssetListItem.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,66 @@ | ||
import { ReactNode } from 'react'; | ||
import { Pressable } from 'react-native'; | ||
|
||
import { HStack, VStack, Text, Badge } from '@suite-native/atoms'; | ||
import { prepareNativeStyle, useNativeStyles } from '@trezor/styles'; | ||
|
||
import { FavouriteIcon } from './FavouriteIcon'; | ||
|
||
export type AssetListItemProps = { | ||
assetName: ReactNode; | ||
displaySymbol: ReactNode; | ||
fiatRate: ReactNode; | ||
|
||
icon: ReactNode; | ||
priceChange?: ReactNode; | ||
onPress: () => void; | ||
isFavourite?: boolean; | ||
onFavouritePress: () => void; | ||
}; | ||
|
||
const vStackStyle = prepareNativeStyle(utils => ({ | ||
height: 68, | ||
paddingVertical: utils.spacings.sp8, | ||
flex: 1, | ||
spacing: 0, | ||
})); | ||
|
||
export const TradeableAssetListItem = ({ | ||
assetName, | ||
icon, | ||
displaySymbol, | ||
fiatRate, | ||
priceChange, | ||
onPress, | ||
onFavouritePress, | ||
isFavourite = false, | ||
}: AssetListItemProps) => { | ||
const { applyStyle } = useNativeStyles(); | ||
|
||
return ( | ||
<Pressable onPress={onPress}> | ||
<HStack alignItems="center" spacing="sp12"> | ||
<VStack justifyContent="center">{icon}</VStack> | ||
<VStack style={applyStyle(vStackStyle)} spacing={0}> | ||
<HStack alignItems="center" justifyContent="space-between"> | ||
<Text variant="body" color="textDefault"> | ||
{assetName} | ||
</Text> | ||
<Text variant="body" color="textDefault"> | ||
{fiatRate} | ||
</Text> | ||
</HStack> | ||
<HStack alignItems="center" justifyContent="space-between"> | ||
<Text variant="hint" color="textSubdued"> | ||
{displaySymbol} | ||
</Text> | ||
<Badge label={priceChange}></Badge> | ||
</HStack> | ||
</VStack> | ||
<VStack justifyContent="center"> | ||
<FavouriteIcon isFavourite={isFavourite} onPress={onFavouritePress} /> | ||
</VStack> | ||
</HStack> | ||
</Pressable> | ||
); | ||
}; |
29 changes: 29 additions & 0 deletions
29
suite-native/module-trading/src/components/TradeableAssetsSheet/TradeableAssetsList.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,29 @@ | ||
import { NetworkSymbol } from '@suite-common/wallet-config'; | ||
import { Card, Text, VStack } from '@suite-native/atoms'; | ||
import { Translation } from '@suite-native/intl'; | ||
|
||
import { TradeableNetworkListItem } from './TradeableNetworkListItem'; | ||
|
||
export type TradeableAssetsListProps = { | ||
onItemSelected: (item: NetworkSymbol) => void; | ||
}; | ||
|
||
export const TradeableAssetsList = ({ onItemSelected }: TradeableAssetsListProps) => ( | ||
<VStack flex={1}> | ||
<Text> | ||
<Translation id="moduleTrading.tradeableAssetsSheet.assetsTitle" /> | ||
</Text> | ||
<Card> | ||
<TradeableNetworkListItem | ||
symbol="btc" | ||
onPress={() => onItemSelected('btc')} | ||
onFavouritePress={() => {}} | ||
/> | ||
<TradeableNetworkListItem | ||
symbol="ada" | ||
onPress={() => onItemSelected('ada')} | ||
onFavouritePress={() => {}} | ||
/> | ||
</Card> | ||
</VStack> | ||
); |
39 changes: 39 additions & 0 deletions
39
suite-native/module-trading/src/components/TradeableAssetsSheet/TradeableAssetsSheet.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,39 @@ | ||
import { NetworkSymbol } from '@suite-common/wallet-config'; | ||
import { BottomSheet, VStack } from '@suite-native/atoms'; | ||
import { Translation } from '@suite-native/intl'; | ||
|
||
import { PickerCloseButton } from '../general/PickerCloseButton'; | ||
import { PickerHeader } from '../general/PickerHeader'; | ||
import { TradeableAssetsList } from './TradeableAssetsList'; | ||
|
||
export type TradeableAssetsSheetProps = { | ||
isVisible: boolean; | ||
onClose: () => void; | ||
onAssetSelect: (symbol: NetworkSymbol) => void; | ||
}; | ||
|
||
export const TradeableAssetsSheet = ({ | ||
isVisible, | ||
onClose, | ||
onAssetSelect, | ||
}: TradeableAssetsSheetProps) => { | ||
const onAssetSelectCallback = (symbol: NetworkSymbol) => { | ||
onAssetSelect(symbol); | ||
onClose(); | ||
}; | ||
|
||
return ( | ||
<BottomSheet isVisible={isVisible} onClose={onClose} isCloseDisplayed={false}> | ||
<VStack spacing="sp16"> | ||
<PickerHeader | ||
title={<Translation id="moduleTrading.tradeableAssetsSheet.title" />} | ||
withSearch | ||
onSearchInputChange={() => {}} | ||
withBackButton | ||
/> | ||
<TradeableAssetsList onItemSelected={onAssetSelectCallback} /> | ||
<PickerCloseButton onPress={onClose} /> | ||
</VStack> | ||
</BottomSheet> | ||
); | ||
}; |
Oops, something went wrong.