forked from guangqiang-liu/react-native-toastAndLoading
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Loading.js
52 lines (45 loc) · 1.09 KB
/
Loading.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
/**
* Created by guangqiang on 2017/12/12.
*/
import React, {Component} from 'react'
import {View, StyleSheet, ActivityIndicator, Dimensions} from 'react-native'
import RootSiblings from 'react-native-root-siblings'
const width = Dimensions.get('window').width
const height = Dimensions.get('window').height
let sibling = undefined
const Loading = {
show: () => {
sibling = new RootSiblings(
<View style={styles.maskStyle}>
<View style={styles.backViewStyle}>
<ActivityIndicator size="large" color="white" />
</View>
</View>
)
},
hidden: ()=> {
if (sibling instanceof RootSiblings) {
sibling.destroy()
}
}
}
const styles = StyleSheet.create({
maskStyle: {
position: 'absolute',
backgroundColor: 'rgba(0, 0, 0, 0.3)',
width: width,
height: height,
alignItems: 'center',
justifyContent: 'center'
},
backViewStyle: {
backgroundColor: '#111',
width: 120,
height: 100,
justifyContent: 'center',
alignItems: 'center',
borderRadius: 5,
}
}
)
export {Loading}