Skip to content

Commit

Permalink
feat(suite-native): select coin modal UI
Browse files Browse the repository at this point in the history
  • Loading branch information
jbazant committed Jan 29, 2025
1 parent 0342e33 commit 620e0d6
Show file tree
Hide file tree
Showing 27 changed files with 751 additions and 132 deletions.
2 changes: 2 additions & 0 deletions suite-common/icons/generateIconFont.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ const usedIcons = [
'shieldWarning',
'shuffle',
'stack',
'star',
'starFilled',
'swap',
'trashSimple',
'treeStructure',
Expand Down
162 changes: 82 additions & 80 deletions suite-common/icons/iconFontsMobile/TrezorSuiteIcons.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,84 +20,86 @@
"treeStructure": 61715,
"trashSimple": 61716,
"swap": 61717,
"stack": 61718,
"shuffle": 61719,
"shieldWarning": 61720,
"shieldCheck": 61721,
"shareNetwork": 61722,
"question": 61723,
"qrCode": 61724,
"prohibit": 61725,
"plusCircle": 61726,
"plus": 61727,
"plugs": 61728,
"piggyBankFilled": 61729,
"piggyBank": 61730,
"pictureFrame": 61731,
"pencilSimpleLine": 61732,
"pencilSimple": 61733,
"pencil": 61734,
"password": 61735,
"palette": 61736,
"magnifyingGlass": 61737,
"lock": 61738,
"link": 61739,
"lightbulb": 61740,
"lifebuoy": 61741,
"info": 61742,
"image": 61743,
"houseFilled": 61744,
"house": 61745,
"handPalm": 61746,
"githubLogo": 61747,
"gearFilled": 61748,
"gear": 61749,
"flagCheckered": 61750,
"flag": 61751,
"fingerprintSimple": 61752,
"fingerprint": 61753,
"filePdf": 61754,
"facebookLogo": 61755,
"eyeSlash": 61756,
"eye": 61757,
"discoverFilled": 61758,
"discover": 61759,
"detective": 61760,
"database": 61761,
"cpu": 61762,
"copy": 61763,
"coins": 61764,
"coinVerticalCheck": 61765,
"code": 61766,
"clockClockwise": 61767,
"circleDashed": 61768,
"checks": 61769,
"checkCircleFilled": 61770,
"checkCircle": 61771,
"check": 61772,
"chatCircle": 61773,
"change": 61774,
"caretUpFilled": 61775,
"caretUpDown": 61776,
"caretUp": 61777,
"caretRight": 61778,
"caretLeft": 61779,
"caretDownFilled": 61780,
"caretDown": 61781,
"caretCircleRight": 61782,
"calendar": 61783,
"bugBeetle": 61784,
"bookmarkSimple": 61785,
"backspace": 61786,
"arrowsLeftRight": 61787,
"arrowsCounterClockwise": 61788,
"arrowUpRight": 61789,
"arrowUp": 61790,
"arrowURightDown": 61791,
"arrowSquareOut": 61792,
"arrowRight": 61793,
"arrowLineUpRight": 61794,
"arrowLineUp": 61795,
"arrowLineDown": 61796,
"arrowDown": 61797
"starFilled": 61718,
"star": 61719,
"stack": 61720,
"shuffle": 61721,
"shieldWarning": 61722,
"shieldCheck": 61723,
"shareNetwork": 61724,
"question": 61725,
"qrCode": 61726,
"prohibit": 61727,
"plusCircle": 61728,
"plus": 61729,
"plugs": 61730,
"piggyBankFilled": 61731,
"piggyBank": 61732,
"pictureFrame": 61733,
"pencilSimpleLine": 61734,
"pencilSimple": 61735,
"pencil": 61736,
"password": 61737,
"palette": 61738,
"magnifyingGlass": 61739,
"lock": 61740,
"link": 61741,
"lightbulb": 61742,
"lifebuoy": 61743,
"info": 61744,
"image": 61745,
"houseFilled": 61746,
"house": 61747,
"handPalm": 61748,
"githubLogo": 61749,
"gearFilled": 61750,
"gear": 61751,
"flagCheckered": 61752,
"flag": 61753,
"fingerprintSimple": 61754,
"fingerprint": 61755,
"filePdf": 61756,
"facebookLogo": 61757,
"eyeSlash": 61758,
"eye": 61759,
"discoverFilled": 61760,
"discover": 61761,
"detective": 61762,
"database": 61763,
"cpu": 61764,
"copy": 61765,
"coins": 61766,
"coinVerticalCheck": 61767,
"code": 61768,
"clockClockwise": 61769,
"circleDashed": 61770,
"checks": 61771,
"checkCircleFilled": 61772,
"checkCircle": 61773,
"check": 61774,
"chatCircle": 61775,
"change": 61776,
"caretUpFilled": 61777,
"caretUpDown": 61778,
"caretUp": 61779,
"caretRight": 61780,
"caretLeft": 61781,
"caretDownFilled": 61782,
"caretDown": 61783,
"caretCircleRight": 61784,
"calendar": 61785,
"bugBeetle": 61786,
"bookmarkSimple": 61787,
"backspace": 61788,
"arrowsLeftRight": 61789,
"arrowsCounterClockwise": 61790,
"arrowUpRight": 61791,
"arrowUp": 61792,
"arrowURightDown": 61793,
"arrowSquareOut": 61794,
"arrowRight": 61795,
"arrowLineUpRight": 61796,
"arrowLineUp": 61797,
"arrowLineDown": 61798,
"arrowDown": 61799
}
Binary file modified suite-common/icons/iconFontsMobile/TrezorSuiteIcons.ttf
Binary file not shown.
13 changes: 13 additions & 0 deletions suite-native/intl/src/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,19 @@ export const en = {
description: 'We currently support staking as view-only in Trezor Suite Lite.',
},
},
moduleTrading: {
selectCoin: {
buttonTitle: 'Select coin',
},
tradeableAssetsSheet: {
title: 'Coins',
popularTitle: 'Favourites',
assetsTitle: 'All assets',
favouritesAdd: 'Add to favourites',
favouritesRemove: 'Remove from favourites',
},
defaultSearchLabel: 'Search',
},
};

export type Translations = typeof en;
5 changes: 5 additions & 0 deletions suite-native/module-trading/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const { ...baseConfig } = require('../../jest.config.native');

module.exports = {
...baseConfig,
};
3 changes: 2 additions & 1 deletion suite-native/module-trading/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
"scripts": {
"depcheck": "yarn g:depcheck",
"type-check": "yarn g:tsc --build",
"test:unit": "yarn g:jest -c ../../jest.config.native.js"
"test:unit": "yarn g:jest"
},
"dependencies": {
"@react-navigation/native-stack": "6.11.0",
"@reduxjs/toolkit": "1.9.5",
"@suite-native/navigation": "workspace:*",
"@suite-native/test-utils": "workspace:*",
"expo-linear-gradient": "^14.0.1",
"react": "18.2.0",
"react-native": "0.76.1"
}
Expand Down
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>
);
};
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>
);
};
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>
);
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>
);
};
Loading

0 comments on commit 620e0d6

Please sign in to comment.