Skip to content

Commit

Permalink
add activity indicator in send screen (#1202)
Browse files Browse the repository at this point in the history
* add activity indicator in send screen

* PR feedback
  • Loading branch information
v-almonacid authored Feb 26, 2021
1 parent c35de43 commit a86d5c0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/components/Send/SendScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, {Component} from 'react'
import {BigNumber} from 'bignumber.js'
import {compose} from 'redux'
import {connect} from 'react-redux'
import {ScrollView, View} from 'react-native'
import {ScrollView, View, ActivityIndicator} from 'react-native'
import _ from 'lodash'
import SafeAreaView from 'react-native-safe-area-view'
import {injectIntl, defineMessages} from 'react-intl'
Expand Down Expand Up @@ -176,6 +176,12 @@ const messages = defineMessages({
},
})

const Indicator = () => (
<View style={styles.indicator}>
<ActivityIndicator size="large" />
</View>
)

const getMinAda = async (selectedToken: Token, defaultAsset: DefaultAsset) => {
const fakeAmount = new BigNumber('0') // amount doesn't matter for calculating min UTXO amount
const fakeMultitoken = new MultiToken(
Expand Down Expand Up @@ -453,6 +459,10 @@ class SendScreen extends Component<Props, State> {
}

async revalidate({utxos, address, amount, sendAll, selectedAsset}) {
this.setState({
fee: null,
balanceAfter: null,
})
const {defaultAsset, availableAssets, tokenBalance} = this.props
if (availableAssets[selectedAsset.identifier] == null) {
throw new Error(
Expand Down Expand Up @@ -750,12 +760,14 @@ class SendScreen extends Component<Props, State> {
assetsMetadata={availableAssets}
unselectEnabled={false}
/>
{this.state.fee == null &&
!!this.state.amount && <Indicator />}
</ScrollView>
<View style={styles.actions}>
<Button
onPress={this.handleConfirm}
title={intl.formatMessage(messages.continueButton)}
disabled={!isValid}
disabled={!isValid || this.state.fee == null}
/>
</View>
</SafeAreaView>
Expand Down
3 changes: 3 additions & 0 deletions src/components/Send/styles/SendScreen.style.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ const styles = StyleSheet.create({
marginHorizontal: 16,
marginBottom: 16,
},
indicator: {
marginTop: 26,
},
})

export default styles

0 comments on commit a86d5c0

Please sign in to comment.