-
-
Notifications
You must be signed in to change notification settings - Fork 276
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
29 changed files
with
771 additions
and
188 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> | ||
); | ||
}; |
57 changes: 57 additions & 0 deletions
57
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,57 @@ | ||
import { ReactNode } from 'react'; | ||
import { ScrollView } from 'react-native'; | ||
|
||
import { NetworkSymbol } from '@suite-common/wallet-config'; | ||
import { Box, Card, Text } from '@suite-native/atoms'; | ||
import { Translation } from '@suite-native/intl'; | ||
|
||
import { TradeableNetworkListItem } from './TradeableNetworkListItem'; | ||
|
||
export type TradeableAssetsListProps = { | ||
onItemSelected: (item: NetworkSymbol) => void; | ||
}; | ||
|
||
const TradeableAssetsListSectionHeader = ({ children }: { children: ReactNode }) => ( | ||
<Box paddingVertical="sp12"> | ||
<Text variant="hint" color="textSubdued"> | ||
{children} | ||
</Text> | ||
</Box> | ||
); | ||
|
||
export const TradeableAssetsList = ({ onItemSelected }: TradeableAssetsListProps) => { | ||
const favourites: NetworkSymbol[] = ['btc', 'ada', 'eth']; | ||
const all: NetworkSymbol[] = ['xrp', 'ltc', 'arb', 'base', 'doge', 'sol', 'dsol', 'etc']; | ||
|
||
return ( | ||
<ScrollView> | ||
<TradeableAssetsListSectionHeader> | ||
<Translation id="moduleTrading.tradeableAssetsSheet.favouritesTitle" /> | ||
</TradeableAssetsListSectionHeader> | ||
<Card> | ||
{favourites.map(symbol => ( | ||
<TradeableNetworkListItem | ||
key={symbol} | ||
symbol={symbol} | ||
onPress={() => onItemSelected(symbol)} | ||
onFavouritePress={() => {}} | ||
isFavourite | ||
/> | ||
))} | ||
</Card> | ||
<TradeableAssetsListSectionHeader> | ||
<Translation id="moduleTrading.tradeableAssetsSheet.allTitle" /> | ||
</TradeableAssetsListSectionHeader> | ||
<Card> | ||
{all.map(symbol => ( | ||
<TradeableNetworkListItem | ||
key={symbol} | ||
symbol={symbol} | ||
onPress={() => onItemSelected(symbol)} | ||
onFavouritePress={() => {}} | ||
/> | ||
))} | ||
</Card> | ||
</ScrollView> | ||
); | ||
}; |
Oops, something went wrong.