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