-
Notifications
You must be signed in to change notification settings - Fork 427
/
Copy pathLoadingModal.js
78 lines (68 loc) · 1.96 KB
/
LoadingModal.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
* Created by guoshuyu on 2017/11/12.
*/
import React, {Component} from 'react';
import {
Text,
View,
BackHandler
} from 'react-native';
import PropTypes from 'prop-types';
import styles, {screenWidth, screenHeight} from "../../style/index"
import I18n from '../../style/i18n'
import Modal from './ModalBox';
import Spinner from 'react-native-spinkit-fix-new';
import {Actions} from "react-native-router-flux";
/**
* 加载中Modal
*/
class LoadingModal extends Component {
constructor(props) {
super(props);
this.onClose = this.onClose.bind(this);
}
componentDidMount() {
if (this.refs.loginModal) {
this.refs.loginModal.open();
}
this.handle = BackHandler.addEventListener('loaddingBack', this.onClose)
}
componentWillUnmount() {
if (this.handle) {
this.handle.remove();
}
}
onClose() {
Actions.pop();
return true;
}
render() {
return (
<Modal ref={"loginModal"}
style={[{height: screenHeight, width: screenWidth, backgroundColor: "#F0000000"}]}
position={"center"}
backButtonClose={false}
swipeToClose={this.props.backExit}
backdropOpacity={0.8}>
<View style={[styles.centered, {flex: 1}]}>
<View>
<Spinner style={[styles.centered]}
isVisible={true}
size={50} type="9CubeGrid"
color="#FFFFFF"/>
<Text style={styles.normalTextWhite}>{this.props.text}</Text>
</View>
</View>
</Modal>
)
}
}
LoadingModal.propTypes = {
text: PropTypes.string,
backExit: PropTypes.bool,
};
LoadingModal.defaultProps = {
text: I18n('loading'),
backExit: true,
};
export default LoadingModal;