Skip to content
This repository has been archived by the owner on Apr 28, 2023. It is now read-only.

feat: add loading state to swaptab #39

Merged
merged 2 commits into from
Dec 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions src/components/swaptab/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import Controls from '../controls';
import Text, { InfoText } from '../text';
import { MIN, MAX } from '../../constants/fees';

const boltz_logo = require('../../asset/icons/boltz_logo.png');

const styles = theme => ({
wrapper: {
margin: '15px',
Expand Down Expand Up @@ -64,6 +66,21 @@ const styles = theme => ({
text: {
fontSize: '20px',
},
loading: {
justifyContent: 'center',
alignItems: 'center',
height: '400px',
width: '600px',
backgroundColor: theme.colors.white,
'@media (min-width: 1500px)': {
width: '800px',
height: '600px',
},
},
loadingLogo: {
width: '200px',
height: '200px',
},
});

class SwapTab extends React.Component {
Expand Down Expand Up @@ -128,15 +145,25 @@ class SwapTab extends React.Component {
};

render() {
const { classes, rates, currencies } = this.props;
const { classes, rates, currencies, loading } = this.props;
let { error, base, quote, baseAmount, quoteAmount } = this.state;

if (quoteAmount === 0) {
this.quoteAmount = this.calculateQuoteAmount(baseAmount);
quoteAmount = this.quoteAmount;
}

return (
return loading ? (
<View className={classes.loading}>
<img
src={boltz_logo}
height={100}
width={100}
className={classes.loadingLogo}
alt="logo"
/>
</View>
) : (
<View className={classes.wrapper}>
<View className={classes.stats}>
<InfoText title="Min amount:" text={`${MIN}`} />
Expand Down Expand Up @@ -187,6 +214,7 @@ SwapTab.propTypes = {
onPress: PropTypes.func,
rates: PropTypes.object.isRequired,
currencies: PropTypes.array.isRequired,
loading: PropTypes.bool.isRequired,
};

export default injectSheet(styles)(SwapTab);
1 change: 1 addition & 0 deletions src/views/landingpage/landingpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class LandingPage extends React.Component {
<LinkButton text="WHY?" onPress={() => window.alert('WIP')} />
</View>
<SwapTab
loading={Object.keys(rates).length === 0 || currencies.length === 0}
onPress={state => {
const keys = generateKeys(
state.base === 'BTC' ? bitcoinNetwork : litecoinNetwork
Expand Down