forked from ant-design/ant-design-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.tsx
70 lines (65 loc) · 1.59 KB
/
index.tsx
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
import * as React from 'react';
import {
View,
Text,
Dimensions,
Platform,
ActivityIndicator,
} from 'react-native';
import styles from './style';
import PropTypes from './ActivityIndicatorPropTypes';
const { height } = Dimensions.get('window');
export default class RNActivityIndicator extends React.Component<PropTypes, any> {
static defaultProps = {
animating: true,
color: 'gray',
size: 'small',
panelColor: 'rgba(34,34,34,0.6)',
toast: false,
};
_renderToast() {
let containerStyle;
if (Platform.OS === 'android') {
containerStyle = [styles.container, { height }];
} else {
containerStyle = [styles.container];
}
return (
<View style={containerStyle}>
<View style={[styles.innerContainer]}>
<View style={[styles.wrapper]}>
<ActivityIndicator
color="white"
size="large"
/>
{ this.props.text && (<Text style={[styles.toast]}>{this.props.text}</Text>) }
</View>
</View>
</View>
);
}
_renderSpinner() {
return (
<View
style={[{
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
}]}
>
<ActivityIndicator
color={this.props.color}
size={this.props.size}
/>
{ this.props.text && (<Text style={[styles.tip]}>{this.props.text}</Text>) }
</View>
);
}
render() {
if (this.props.animating) {
return (
this.props.toast ? this._renderToast() : this._renderSpinner()
);
}
}
}