-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Initial Token Selector with dummy tokens
- Loading branch information
Showing
12 changed files
with
674 additions
and
129 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from 'react'; | ||
import { StyleSheet, View } from 'react-native'; | ||
import { colors } from '../../styles/common'; | ||
import Device from '../../util/Device'; | ||
|
||
const styles = StyleSheet.create({ | ||
draggerWrapper: { | ||
width: '100%', | ||
height: 33, | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
borderBottomWidth: StyleSheet.hairlineWidth, | ||
borderColor: colors.grey100 | ||
}, | ||
dragger: { | ||
width: 48, | ||
height: 5, | ||
borderRadius: 4, | ||
backgroundColor: colors.grey400, | ||
opacity: Device.isAndroid() ? 0.6 : 0.5 | ||
} | ||
}); | ||
|
||
function ModalDragger() { | ||
return ( | ||
<View style={styles.draggerWrapper}> | ||
<View style={styles.dragger} /> | ||
</View> | ||
); | ||
} | ||
|
||
export default ModalDragger; |
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,11 @@ | ||
import { useState } from 'react'; | ||
function useModalHandler(initialState = false) { | ||
const [isVisible, setVisible] = useState(initialState); | ||
|
||
const showModal = () => setVisible(true); | ||
const hideModal = () => setVisible(true); | ||
const toggleModal = () => setVisible(!isVisible); | ||
|
||
return [isVisible, toggleModal, showModal, hideModal]; | ||
} | ||
export default useModalHandler; |
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,78 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { StyleSheet, View } from 'react-native'; | ||
|
||
import RemoteImage from '../../../Base/RemoteImage'; | ||
import Text from '../../../Base/Text'; | ||
import { colors } from '../../../../styles/common'; | ||
|
||
// eslint-disable-next-line import/no-commonjs | ||
const ethLogo = require('../../../../images/eth-logo.png'); | ||
|
||
const styles = StyleSheet.create({ | ||
icon: { | ||
width: 24, | ||
height: 24 | ||
}, | ||
iconMedium: { | ||
width: 36, | ||
height: 36 | ||
}, | ||
emptyIcon: { | ||
borderRadius: 12, | ||
backgroundColor: colors.grey200, | ||
alignItems: 'center', | ||
justifyContent: 'center' | ||
}, | ||
emptyIconMedium: { | ||
borderRadius: 18 | ||
}, | ||
tokenSymbol: { | ||
fontSize: 16, | ||
textAlign: 'center', | ||
textAlignVertical: 'center' | ||
}, | ||
tokenSymbolMedium: { | ||
fontSize: 22 | ||
} | ||
}); | ||
|
||
const EmptyIcon = ({ medium, ...props }) => ( | ||
<View | ||
style={[ | ||
styles.icon, | ||
props.medium && styles.iconMedium, | ||
styles.emptyIcon, | ||
props.medium && styles.emptyIconMedium | ||
]} | ||
{...props} | ||
/> | ||
); | ||
|
||
EmptyIcon.propTypes = { | ||
medium: PropTypes.bool | ||
}; | ||
|
||
function TokenIcon({ symbol, icon, medium }) { | ||
if (symbol === 'ETH') { | ||
return <RemoteImage fadeIn source={ethLogo} style={[styles.icon, medium && styles.iconMedium]} />; | ||
} else if (icon) { | ||
return <RemoteImage fadeIn source={{ uri: icon }} style={[styles.icon, medium && styles.iconMedium]} />; | ||
} else if (symbol) { | ||
return ( | ||
<EmptyIcon medium={medium}> | ||
<Text style={[styles.tokenSymbol, medium && styles.tokenSymbolMedium]}>{symbol[0].toUpperCase()}</Text> | ||
</EmptyIcon> | ||
); | ||
} | ||
|
||
return <EmptyIcon medium={medium} />; | ||
} | ||
|
||
TokenIcon.propTypes = { | ||
symbol: PropTypes.string, | ||
icon: PropTypes.string, | ||
medium: PropTypes.bool | ||
}; | ||
|
||
export default TokenIcon; |
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,35 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import TokenIcon from './TokenIcon'; | ||
|
||
describe('TokenIcon component', () => { | ||
it('should Render correctly', () => { | ||
const empty = shallow(<TokenIcon />); | ||
expect(empty).toMatchSnapshot(); | ||
const eth = shallow(<TokenIcon symbol="ETH" />); | ||
expect(eth).toMatchSnapshot(); | ||
const symbol = shallow(<TokenIcon symbol="cDAI" />); | ||
expect(symbol).toMatchSnapshot(); | ||
const icon = shallow( | ||
<TokenIcon | ||
symbol="DAI" | ||
icon="https://cloudflare-ipfs.com/ipfs/QmNYVMm3iC7HEoxfvxsZbRoapdjDHj9EREFac4BPeVphSJ" | ||
/> | ||
); | ||
expect(icon).toMatchSnapshot(); | ||
const emptyMedium = shallow(<TokenIcon medium />); | ||
expect(emptyMedium).toMatchSnapshot(); | ||
const ethMedium = shallow(<TokenIcon medium symbol="ETH" />); | ||
expect(ethMedium).toMatchSnapshot(); | ||
const symbolMedium = shallow(<TokenIcon medium symbol="cDAI" />); | ||
expect(symbolMedium).toMatchSnapshot(); | ||
const iconMedium = shallow( | ||
<TokenIcon | ||
medium | ||
symbol="DAI" | ||
icon="https://cloudflare-ipfs.com/ipfs/QmNYVMm3iC7HEoxfvxsZbRoapdjDHj9EREFac4BPeVphSJ" | ||
/> | ||
); | ||
expect(iconMedium).toMatchSnapshot(); | ||
}); | ||
}); |
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.