-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
104 lines (96 loc) · 2.1 KB
/
index.js
File metadata and controls
104 lines (96 loc) · 2.1 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import React from "react";
import {
ActivityIndicator,
Modal,
StyleSheet,
Text,
useWindowDimensions,
View,
} from "react-native";
import PropTypes from "prop-types";
import colors from "./config/colors";
const ANIMATION = ["slide", "fade", "none"];
const DIRECTIONS = ["column", "row"];
const MODES = ["default", "fullscreen"];
const SIZES = ["large", "small"];
const Loading = ({
containerStyles,
textStyles,
color = "primary",
direction = DIRECTIONS[0],
height,
size = SIZES[0],
text,
...props
}) => {
return (
<View
style={[
styles.container,
{
height,
flexDirection: direction,
},
containerStyles,
]}>
<ActivityIndicator
size={size}
color={colors[color] || color}
{...props}
/>
{text && <Text style={[styles.text, textStyles]}>{text}</Text>}
</View>
);
};
function SimpleLoading({
animation = ANIMATION[0],
loading = false,
mode = MODES[0],
...props
}) {
const { height } = useWindowDimensions();
if (loading) {
if (mode === "fullscreen") {
return (
<Modal
animationType="slide"
onRequestClose={() => {}}
supportedOrientations={["landscape", "portrait"]}
transparent={false}
visible={loading}
statusBarTranslucent={true}>
<Loading height={height} {...props} />
</Modal>
);
} else {
return <Loading {...props} />;
}
} else {
return null;
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
alignItems: "center",
backgroundColor: colors.white,
},
text: {
padding: 10,
textAlign: "center",
color: colors.black,
},
});
SimpleLoading.propTypes = {
animation: PropTypes.oneOf(ANIMATION),
color: PropTypes.string,
containerStyles: PropTypes.object,
direction: PropTypes.oneOf(DIRECTIONS),
loading: PropTypes.bool.isRequired,
mode: PropTypes.oneOf(MODES),
size: PropTypes.oneOf(SIZES),
text: PropTypes.string,
textStyles: PropTypes.object,
};
export default SimpleLoading;