-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFullScreenLoader.js
More file actions
56 lines (51 loc) · 1.45 KB
/
FullScreenLoader.js
File metadata and controls
56 lines (51 loc) · 1.45 KB
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
import React from 'react';
import {View, StyleSheet, ActivityIndicator} 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 background = {backgroundColor: theme.brandColor[props.background]};
if (props.loading) {
return (
<View
style={StyleSheet.flatten([styles.container, background, props.style])} {...extractAccessibilityPropsFromProps(this.props)}>
<ActivityIndicator
style={styles.indicator}
color={props.indicatorColor}
size={props.size}
/>
{props.children}
</View>
);
} else {
return null;
}
};
FullScreenLoader.propTypes = {
loading: PropTypes.bool.isRequired,
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: '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;