Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into wallet-sync
- Loading branch information
Showing
65 changed files
with
407 additions
and
250 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,32 @@ | ||
import {useNavigation} from '@react-navigation/native' | ||
import React from 'react' | ||
import {StyleSheet} from 'react-native' | ||
import {TouchableOpacity} from 'react-native' | ||
|
||
import iconQR from '../assets/img/qr_code.png' | ||
import {Button} from '../components' | ||
import {Icon} from '../components' | ||
|
||
export const ScannerButton = () => { | ||
const navigation = useNavigation() | ||
const navigateTo = useNavigateTo() | ||
|
||
return ( | ||
<Button | ||
style={styles.scannerButton} | ||
onPress={() => { | ||
navigation.navigate('app-root', { | ||
screen: 'main-wallet-routes', | ||
params: { | ||
screen: 'history', | ||
params: { | ||
screen: 'address-reader-qr', | ||
}, | ||
}, | ||
}) | ||
}} | ||
iconImage={iconQR} | ||
title="" | ||
withoutBackground | ||
/> | ||
<TouchableOpacity onPress={navigateTo.reader}> | ||
<Icon.Qr color="black" size={30} /> | ||
</TouchableOpacity> | ||
) | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
scannerButton: { | ||
height: '80%', | ||
}, | ||
}) | ||
const useNavigateTo = () => { | ||
const navigation = useNavigation() | ||
|
||
return { | ||
reader: () => | ||
navigation.navigate('app-root', { | ||
screen: 'main-wallet-routes', | ||
params: { | ||
screen: 'history', | ||
params: { | ||
screen: 'address-reader-qr', | ||
}, | ||
}, | ||
}), | ||
} | ||
} |
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,30 @@ | ||
import {action} from '@storybook/addon-actions' | ||
import {storiesOf} from '@storybook/react-native' | ||
import React from 'react' | ||
import {Text, View} from 'react-native' | ||
|
||
import {mocks, QueryProvider} from '../../../../storybook' | ||
import {Spacer} from '../../../components' | ||
import {SelectedWalletProvider} from '../../../SelectedWallet' | ||
import {AssetItem} from './AssetItem' | ||
|
||
storiesOf('AssetItem', module).add('Gallery', () => ( | ||
<QueryProvider> | ||
<SelectedWalletProvider wallet={mocks.wallet}> | ||
<View style={{flex: 1, justifyContent: 'center', padding: 16}}> | ||
<Text>Fungible primary token</Text> | ||
|
||
<AssetItem tokenInfo={mocks.wallet.primaryTokenInfo} onPress={action('onPress')} /> | ||
|
||
<Spacer height={40} /> | ||
|
||
<Text>Fungible non-primary token</Text> | ||
|
||
<AssetItem | ||
tokenInfo={mocks.tokenInfos['698a6ea0ca99f315034072af31eaac6ec11fe8558d3f48e9775aab9d.7444524950']} | ||
onPress={action('onPress')} | ||
/> | ||
</View> | ||
</SelectedWalletProvider> | ||
</QueryProvider> | ||
)) |
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,114 @@ | ||
import * as React from 'react' | ||
import {Image, StyleSheet, TouchableOpacity, View, ViewProps} from 'react-native' | ||
|
||
import NoImage from '../../../assets/img/asset_no_image.png' | ||
import {Icon} from '../../../components' | ||
import {Text} from '../../../components/Text' | ||
import {useBalance} from '../../../hooks' | ||
import {useSelectedWallet} from '../../../SelectedWallet' | ||
import {COLORS} from '../../../theme' | ||
import {TokenInfo} from '../../../yoroi-wallets/types' | ||
import {Quantities} from '../../../yoroi-wallets/utils' | ||
import {PairedBalance} from '../../PairedBalance' | ||
|
||
type AssetItemProps = { | ||
tokenInfo: TokenInfo | ||
onPress?(): void | ||
} | ||
export const AssetItem = ({tokenInfo, onPress}: AssetItemProps) => { | ||
const wallet = useSelectedWallet() | ||
const balance = useBalance({wallet, tokenId: tokenInfo.id}) | ||
|
||
const isPrimary = tokenInfo.id === wallet.primaryTokenInfo.id | ||
const name = tokenInfo.ticker ?? tokenInfo.name ?? '-' | ||
const detail = isPrimary ? tokenInfo.description : tokenInfo.fingerprint | ||
const quantity = Quantities.denominated(balance, tokenInfo.decimals) | ||
|
||
return ( | ||
<TouchableOpacity onPress={onPress} style={styles.button} testID="assetItem"> | ||
<Left>{isPrimary ? <PrimaryTokenIcon /> : <TokenIcon source={NoImage} />}</Left> | ||
|
||
<Middle> | ||
<Text numberOfLines={1} ellipsizeMode="middle" style={styles.name} testID="tokenInfoText"> | ||
{name} | ||
</Text> | ||
|
||
<Text numberOfLines={1} ellipsizeMode="middle" style={styles.detail} testID="tokenFingerprintText"> | ||
{detail} | ||
</Text> | ||
</Middle> | ||
|
||
<Right> | ||
<Text style={styles.quantity} testID="tokenAmountText"> | ||
{quantity} | ||
</Text> | ||
|
||
{isPrimary && <PairedBalance primaryAmount={{quantity: balance, tokenId: tokenInfo.id}} />} | ||
</Right> | ||
</TouchableOpacity> | ||
) | ||
} | ||
|
||
const Left = ({style, ...props}: ViewProps) => <View style={[style, {padding: 4}]} {...props} /> | ||
const Middle = ({style, ...props}: ViewProps) => ( | ||
<View style={[style, {flex: 1, justifyContent: 'center', padding: 4}]} {...props} /> | ||
) | ||
const Right = ({style, ...props}: ViewProps) => <View style={[style, {padding: 4}]} {...props} /> | ||
|
||
type IconProps = { | ||
source: {uri: string} | ||
} | ||
const TokenIcon = ({source}: IconProps) => <Image source={source} style={styles.tokenIcon} /> | ||
const PrimaryTokenIcon = () => ( | ||
<View style={styles.primaryTokenIcon}> | ||
<Icon.Cardano color="white" height={35} width={35} /> | ||
</View> | ||
) | ||
|
||
const styles = StyleSheet.create({ | ||
primaryTokenIcon: { | ||
width: 40, | ||
height: 40, | ||
borderRadius: 8, | ||
backgroundColor: COLORS.SHELLEY_BLUE, | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}, | ||
tokenIcon: { | ||
width: 40, | ||
height: 40, | ||
borderRadius: 8, | ||
backgroundColor: 'transparent', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}, | ||
button: { | ||
flexDirection: 'row', | ||
justifyContent: 'space-between', | ||
borderRadius: 8, | ||
elevation: 2, | ||
shadowOffset: {width: 0, height: -2}, | ||
shadowRadius: 10, | ||
shadowOpacity: 0.08, | ||
shadowColor: '#181a1e', | ||
backgroundColor: '#fff', | ||
paddingHorizontal: 12, | ||
paddingVertical: 12, | ||
}, | ||
name: { | ||
color: COLORS.DARK_TEXT, | ||
fontSize: 14, | ||
lineHeight: 22, | ||
fontWeight: '500', | ||
fontFamily: 'Rubik-Medium', | ||
}, | ||
detail: { | ||
color: COLORS.TEXT_INPUT, | ||
fontSize: 12, | ||
lineHeight: 18, | ||
}, | ||
quantity: { | ||
color: COLORS.DARK_TEXT, | ||
textAlign: 'right', | ||
}, | ||
}) |
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 @@ | ||
export * from './AssetItem' |
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
Oops, something went wrong.