在提取数据之前,我无法加载activityIndicator
if(loanAmount == undefined) {
return (
<View style={styles.indicatorContainer}>
<ActivityIndicator size="large" color={ZW_BUTTON_COLOR} />
</View>
);
}
else{
return (
<View style={styles.container}>
<View style={styles.repaymentDialog}>
<View style={styles.imageContainer}>
<ZWListItemAvatar borrowerObj={selectedBorrower} onPress={this.onShowProfile} />
<LabelText style={styles.labelDialogName} fontSize={16} >
{defaultName}
</LabelText>
</View>
<View style={styles.inputContainer}>
<LabelText style={styles.labelDialogTitle} fontSize={16}>
{loanState === LOAN_REQUEST_SUBMITTED ?
t('repayment-dialog.fee-due') :
t('repayment-dialog.amount-repaid')}
</LabelText>
<View style={styles.inputSubContainer}>
<ZWNumericInput
defaultValue={defaultValue}
textAlign="right"
onChangeText={this.changeRepayment}
/>
<LabelText style={[styles.labelDialogTitle, { alignSelf: 'center' }]} fontSize={16}>
{t('repayment-dialog.kyat')}
</LabelText>
</View>
<LabelText style={styles.labelDialogPaid} fontSize={16}>
Already repaid today {defaultPaid}
</LabelText>
{loanState !== LOAN_REQUEST_SUBMITTED &&
<LabelText style={styles.labelDescription} fontSize={14}>
{dayLate} payments missed
</LabelText>
}
<LabelText style={styles.loanContainer} fontSize={16} >
LOAN: {loan}
</LabelText>
<LabelText style={styles.loanContainer} fontSize={16} >
LOAN AMOUNT: {loanAmount}
</LabelText>
{/* <Button title="done" onPress={()=> alert('done')}/>*/}
</View>
<View style={styles.actionContainer} >
<TouchableOpacity style={styles.buttonCancel} onPress={onCancel}>
<LabelText style={styles.labelCancel} fontSize={13}>
{t('repayment-dialog.cancel')}
</LabelText>
</TouchableOpacity>
<TouchableOpacity
style={styles.buttonOK}
onPress={() => onOK(this.state.repaymentAmount)}
>
<LabelText style={styles.labelOK} fontSize={13}>
{t('repayment-dialog.ok')}
</LabelText>
</TouchableOpacity>
</View>
</View>
</View>
);
答案 0 :(得分:0)
请遵循以下指标代码。
import React, { Component } from 'react'
import {
ActivityIndicator,
AppRegistry,
StyleSheet,
Text,
View,
} from 'react-native'
export default class App extends Component {
render() {
return (
<View style={[styles.yourStyle]}>
{this.state.isProgress && <ActivityIndicator size="large" color="#0000ff" />}
<your other stuff....>
</View>
)
}
}
您还可以将其用于HOC(高阶组件),并用作整个项目的通用类。 希望对您有帮助。