Skip to content

Commit

Permalink
feat(suite-native): Create buy screen visual stub
Browse files Browse the repository at this point in the history
  • Loading branch information
jbazant committed Feb 5, 2025
1 parent 6e73a7c commit aba62ff
Show file tree
Hide file tree
Showing 11 changed files with 208 additions and 133 deletions.
1 change: 1 addition & 0 deletions suite-common/icons/generateIconFont.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const usedIcons = [
'arrowLineUpRight',
'arrowRight',
'arrowsCounterClockwise',
'arrowsDownUp',
'arrowsLeftRight',
'arrowSquareOut',
'arrowUp',
Expand Down
21 changes: 11 additions & 10 deletions suite-common/icons/iconFontsMobile/TrezorSuiteIcons.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,15 @@
"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
"arrowsDownUp": 61790,
"arrowsCounterClockwise": 61791,
"arrowUpRight": 61792,
"arrowUp": 61793,
"arrowURightDown": 61794,
"arrowSquareOut": 61795,
"arrowRight": 61796,
"arrowLineUpRight": 61797,
"arrowLineUp": 61798,
"arrowLineDown": 61799,
"arrowDown": 61800
}
Binary file modified suite-common/icons/iconFontsMobile/TrezorSuiteIcons.ttf
Binary file not shown.
5 changes: 5 additions & 0 deletions suite-native/intl/src/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1247,11 +1247,16 @@ export const en = {
},
moduleTrading: {
tradingScreen: {
buyTitle: 'Buy',
receiveAccount: 'Receive account',
paymentMethod: 'Payment method',
countryOfResidence: 'Country of residence',
provider: 'Provider',
continueButton: 'Continue',
footer: {
poweredBy: 'Powered by',
learnMore: 'Learn more',
},
},
selectCoin: {
buttonTitle: 'Select coin',
Expand Down
Binary file added suite-native/module-trading/assets/InvityLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 0 additions & 33 deletions suite-native/module-trading/src/components/buy/AmountCard.tsx

This file was deleted.

93 changes: 93 additions & 0 deletions suite-native/module-trading/src/components/buy/BuyCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import React from 'react';

import { useFormatters } from '@suite-common/formatters';
import { Card, HStack, Text, VStack } from '@suite-native/atoms';
import { Icon } from '@suite-native/icons';
import { Translation, useTranslate } from '@suite-native/intl';
import { prepareNativeStyle, useNativeStyles } from '@trezor/styles';

import { useTradeableAssetsSheetControls } from '../../hooks/useTradeableAssetsSheetControls';
import { SelectTradeableAssetButton } from '../general/SelectTradeableAssetButton';
import { TradeableAssetsSheet } from '../general/TradeableAssetsSheet/TradeableAssetsSheet';
import { TradingOverviewRow } from '../general/TradingOverviewRow';

const notImplementedCallback = () => {
// eslint-disable-next-line no-console
console.log('Not implemented');
};

const buySectionStyle = prepareNativeStyle(({ borders, colors, spacings }) => ({
borderBottomWidth: borders.widths.small,
borderBottomColor: colors.backgroundSurfaceElevation0,
padding: spacings.sp20,
}));

export const BuyCard = () => {
const { translate } = useTranslate();
const { FiatAmountFormatter, CryptoAmountFormatter } = useFormatters();
const { applyStyle } = useNativeStyles();

const {
isTradeableAssetsSheetVisible,
showTradeableAssetsSheet,
hideTradeableAssetsSheet,
selectedTradeableAsset,
setSelectedTradeableAsset,
} = useTradeableAssetsSheetControls();

return (
<Card noPadding>
<VStack style={applyStyle(buySectionStyle)}>
<Text variant="body" color="textDefault">
<Translation id="moduleTrading.tradingScreen.buyTitle" />
</Text>
<HStack justifyContent="space-between" alignItems="center">
<SelectTradeableAssetButton
onPress={showTradeableAssetsSheet}
selectedAsset={selectedTradeableAsset}
/>
<Text variant="titleMedium" color="textDisabled">
0.0
</Text>
</HStack>
<HStack justifyContent="space-between" alignItems="center">
<Text variant="body" color="textSubdued">
{selectedTradeableAsset?.symbol ? (
<CryptoAmountFormatter
value="0"
symbol={selectedTradeableAsset.symbol}
/>
) : (
'-'
)}
</Text>
<HStack>
<Text variant="body" color="textSubdued">
<FiatAmountFormatter value={0} />
</Text>
<Icon name="arrowsDownUp" color="iconSubdued" />
</HStack>
</HStack>
</VStack>
<TradingOverviewRow
title={translate('moduleTrading.tradingScreen.receiveAccount')}
onPress={notImplementedCallback}
noBottomBorder
>
<VStack spacing={0} paddingLeft="sp20">
<Text color="textSubdued" variant="body" textAlign="right">
Bitcoin Vault
</Text>
<Text color="textSubdued" variant="hint" ellipsizeMode="tail" numberOfLines={1}>
3QJmV3qfvL9SuYo34YihAf3sRCW3qSinyC
</Text>
</VStack>
</TradingOverviewRow>
<TradeableAssetsSheet
isVisible={isTradeableAssetsSheetVisible}
onClose={hideTradeableAssetsSheet}
onAssetSelect={setSelectedTradeableAsset}
/>
</Card>
);
};
47 changes: 47 additions & 0 deletions suite-native/module-trading/src/components/buy/PaymentCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Box, Button, Card, Text } from '@suite-native/atoms';
import { Translation, useTranslate } from '@suite-native/intl';

import { TradingOverviewRow } from '../general/TradingOverviewRow';

const notImplementedCallback = () => {
// eslint-disable-next-line no-console
console.log('Not implemented');
};

export const PaymentCard = () => {
const { translate } = useTranslate();

return (
<Card noPadding>
<TradingOverviewRow
title={translate('moduleTrading.tradingScreen.paymentMethod')}
onPress={notImplementedCallback}
>
<Text color="textSubdued" variant="body">
Credit card
</Text>
</TradingOverviewRow>
<TradingOverviewRow
title={translate('moduleTrading.tradingScreen.countryOfResidence')}
onPress={notImplementedCallback}
>
<Text color="textSubdued" variant="body">
Czech Republic
</Text>
</TradingOverviewRow>
<TradingOverviewRow
title={translate('moduleTrading.tradingScreen.provider')}
onPress={notImplementedCallback}
>
<Text color="textSubdued" variant="body">
Anycoin
</Text>
</TradingOverviewRow>
<Box padding="sp20">
<Button onPress={notImplementedCallback}>
<Translation id="moduleTrading.tradingScreen.continueButton" />
</Button>
</Box>
</Card>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { useMemo } from 'react';
import { TouchableOpacity } from 'react-native';

import { Button, HStack, Image, Text } from '@suite-native/atoms';
import { Translation } from '@suite-native/intl';
import { useOpenLink } from '@suite-native/link';

export const TradingFooter = () => {
const openLink = useOpenLink();

const imageSource = useMemo(() => require('../../../assets/InvityLogo.png'), []);
const openLinkToInvity = () => openLink('https://invity.io');

return (
<HStack justifyContent="space-between" alignItems="center">
<HStack alignItems="center" spacing="sp4">
<Text variant="label" color="textSubdued">
<Translation id="moduleTrading.tradingScreen.footer.poweredBy" />
</Text>
<TouchableOpacity onPress={openLinkToInvity}>
<Image source={imageSource} contentFit="contain" width={44} height={18} />
</TouchableOpacity>
</HStack>
<Button
colorScheme="tertiaryElevation0"
size="extraSmall"
onPress={openLinkToInvity}
viewRight="arrowUpRight"
>
<Translation id="moduleTrading.tradingScreen.footer.learnMore" />
</Button>
</HStack>
);
};

This file was deleted.

94 changes: 17 additions & 77 deletions suite-native/module-trading/src/screens/TradingScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,81 +1,21 @@
import React from 'react';

import { Box, Button, Card, Text, VStack } from '@suite-native/atoms';
import { Text, VStack } from '@suite-native/atoms';
import { DeviceManagerScreenHeader } from '@suite-native/device-manager';
import { Translation, useTranslate } from '@suite-native/intl';
import { Translation } from '@suite-native/intl';
import { Screen } from '@suite-native/navigation';

import { AmountCard } from '../components/buy/AmountCard';
import { TradingOverviewRow } from '../components/general/TradingOverviewRow';
import { TradingRowDivider } from '../components/general/TradingRowDivider';

const notImplementedCallback = () => {
// eslint-disable-next-line no-console
console.log('Not implemented');
};

export const TradingScreen = () => {
const { translate } = useTranslate();
import { BuyCard } from '../components/buy/BuyCard';
import { PaymentCard } from '../components/buy/PaymentCard';
import { TradingFooter } from '../components/general/TradingFooter';

return (
<Screen header={<DeviceManagerScreenHeader />}>
<VStack spacing="sp16">
<Text>Trading placeholder</Text>
<AmountCard />
<Card noPadding>
<TradingRowDivider />
<TradingOverviewRow
title={translate('moduleTrading.tradingScreen.receiveAccount')}
onPress={notImplementedCallback}
noBottomBorder
>
<VStack spacing={0} paddingLeft="sp20">
<Text color="textSubdued" variant="body" textAlign="right">
Bitcoin Vault
</Text>
<Text
color="textSubdued"
variant="hint"
ellipsizeMode="tail"
numberOfLines={1}
>
3QJmV3qfvL9SuYo34YihAf3sRCW3qSinyC
</Text>
</VStack>
</TradingOverviewRow>
</Card>
<Card noPadding>
<TradingOverviewRow
title={translate('moduleTrading.tradingScreen.paymentMethod')}
onPress={notImplementedCallback}
>
<Text color="textSubdued" variant="body">
Credit card
</Text>
</TradingOverviewRow>
<TradingOverviewRow
title={translate('moduleTrading.tradingScreen.countryOfResidence')}
onPress={notImplementedCallback}
>
<Text color="textSubdued" variant="body">
Czech Republic
</Text>
</TradingOverviewRow>
<TradingOverviewRow
title={translate('moduleTrading.tradingScreen.provider')}
onPress={notImplementedCallback}
>
<Text color="textSubdued" variant="body">
Anycoin
</Text>
</TradingOverviewRow>
<Box padding="sp20">
<Button onPress={notImplementedCallback}>
<Translation id="moduleTrading.tradingScreen.continueButton" />
</Button>
</Box>
</Card>
</VStack>
</Screen>
);
};
export const TradingScreen = () => (
<Screen header={<DeviceManagerScreenHeader />}>
<VStack spacing="sp16">
<Text variant="titleSmall" color="textDefault">
<Translation id="moduleTrading.tradingScreen.buyTitle" />
</Text>
<BuyCard />
<PaymentCard />
<TradingFooter />
</VStack>
</Screen>
);

0 comments on commit aba62ff

Please sign in to comment.