-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathFullScreenLoader.js
64 lines (59 loc) · 1.51 KB
/
FullScreenLoader.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
import React from 'react';
import {View, StyleSheet, ActivityIndicator, Text} from 'react-native';
import PropTypes from 'prop-types';
import {useThemeContext} from '../util/ThemeProvider';
import {extractAccessibilityPropsFromProps} from '../util/accessibility';
const FullScreenLoader = props => {
const theme = useThemeContext();
const backgroundStyles = {
backgroundColor: theme.colors[props.background],
};
if (props.loading) {
return (
<View
{...extractAccessibilityPropsFromProps(props)}
style={StyleSheet.flatten([
styles.container,
backgroundStyles,
props.style,
])}>
<ActivityIndicator
style={styles.indicator}
color={props.indicatorColor}
size={props.size}
/>
{props.children}
</View>
);
} else {
return null;
}
};
FullScreenLoader.propTypes = {
loading: PropTypes.bool,
style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
children: PropTypes.element,
indicatorColor: PropTypes.string,
background: PropTypes.string,
size: PropTypes.oneOf(['small', 'large']),
};
FullScreenLoader.defaultProps = {
size: 'large',
background: 'bg300',
indicatorColor: '#1e88e5',
loading: true,
};
const styles = StyleSheet.create({
container: {
position: 'absolute',
zIndex: 1000,
width: '100%',
height: '100%',
justifyContent: 'center',
alignItems: 'center',
},
indicator: {
padding: 10,
},
});
export default FullScreenLoader;