@jescon-technologies/react-native-ui-kit 0.0.14 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,182 +0,0 @@
1
- import React, { useState, useEffect } from 'react';
2
- import {
3
- StyleSheet,
4
- Dimensions,
5
- View,
6
- Modal,
7
- Animated,
8
- Easing,
9
- Text,
10
- Image,
11
- Platform,
12
- } from 'react-native';
13
- import { normalize } from '../CommonStyle/componentStyle';
14
- import { APIURL } from '../../../../../src/Common/apiConstants';
15
-
16
- export default function Loader({
17
- visible = true,
18
- overlayColor = 'rgba(0,0,0,0.4)',
19
- loaderColor = 'lightblue',
20
- size = Platform.OS !== 'web' ? 30 : 50,
21
- gifSource = { uri: `${APIURL}file/getCommonFile/image/heartpulse.gif` },
22
- message = '',
23
- messageStyle = {},
24
- animationType = 'fade',
25
- hasBackground = true,
26
- borderRadius = 20,
27
- shadow = true,
28
- }) {
29
- const [rotation] = useState(new Animated.Value(0));
30
- const [pulse] = useState(new Animated.Value(1));
31
- const [fade] = useState(new Animated.Value(0));
32
-
33
- // Rotation animation
34
- useEffect(() => {
35
- if (!gifSource) { // Only animate if not using a GIF
36
- Animated.loop(
37
- Animated.timing(rotation, {
38
- toValue: 1,
39
- duration: 1500,
40
- easing: Easing.linear,
41
- useNativeDriver: true,
42
- })
43
- ).start();
44
- }
45
-
46
- // Pulse animation
47
- Animated.loop(
48
- Animated.sequence([
49
- Animated.timing(pulse, {
50
- toValue: 1.1,
51
- duration: 800,
52
- useNativeDriver: true,
53
- }),
54
- Animated.timing(pulse, {
55
- toValue: 1,
56
- duration: 800,
57
- useNativeDriver: true,
58
- }),
59
- ])
60
- ).start();
61
-
62
- // Fade in animation
63
- Animated.timing(fade, {
64
- toValue: 1,
65
- duration: 300,
66
- useNativeDriver: true,
67
- }).start();
68
- }, []);
69
-
70
- const spin = rotation.interpolate({
71
- inputRange: [0, 1],
72
- outputRange: ['0deg', '360deg'],
73
- });
74
-
75
- const loaderContent = gifSource ? (
76
- <Image
77
- style={[styles.icon_style, { width: normalize(size), height: normalize(size) }]}
78
- source={gifSource}
79
- resizeMode="contain"
80
- />
81
- ) : (
82
- <Animated.View style={[
83
- styles.defaultLoader,
84
- {
85
- borderColor: loaderColor,
86
- transform: [{ rotate: spin }, { scale: pulse }],
87
- width: normalize(size),
88
- height: normalize(size),
89
- borderWidth: normalize(size / 10),
90
- },
91
- ]}>
92
- <View style={[
93
- styles.innerCircle,
94
- {
95
- backgroundColor: loaderColor,
96
- width: normalize(size / 2),
97
- height: normalize(size / 2),
98
- },
99
- ]} />
100
- </Animated.View>
101
- );
102
-
103
-
104
-
105
-
106
- return (
107
- <Modal
108
- animationType={animationType}
109
- transparent={true}
110
- visible={visible}
111
- onRequestClose={() => { }}
112
- >
113
- <Animated.View style={[
114
- styles.modalContainer,
115
- {
116
- backgroundColor: overlayColor,
117
- opacity: fade,
118
- },
119
- ]}>
120
- <Animated.View style={[
121
- styles.loaderContainer,
122
- {
123
- backgroundColor: hasBackground ? 'white' : 'transparent',
124
- borderRadius: normalize(borderRadius),
125
- transform: [{ scale: pulse }],
126
- ...(shadow && styles.shadowStyle),
127
- },
128
- ]}>
129
- {loaderContent}
130
- {message ? (
131
- <Text style={[styles.messageText, messageStyle]}>
132
- {message}
133
- </Text>
134
- ) : null}
135
- </Animated.View>
136
- </Animated.View>
137
- </Modal>
138
- );
139
- }
140
-
141
- const styles = StyleSheet.create({
142
-
143
-
144
- modalContainer: {
145
- flex: 1,
146
- justifyContent: 'center',
147
- alignItems: 'center',
148
- },
149
- loaderContainer: {
150
- padding: normalize(20),
151
- justifyContent: 'center',
152
- alignItems: 'center',
153
- },
154
- icon_style: {
155
- justifyContent: 'center',
156
- alignItems: 'center',
157
- },
158
- defaultLoader: {
159
- borderRadius: normalize(100),
160
- justifyContent: 'center',
161
- alignItems: 'center',
162
- },
163
- innerCircle: {
164
- borderRadius: normalize(100),
165
- },
166
- messageText: {
167
- marginTop: normalize(15),
168
- fontSize: normalize(14),
169
- color: '#555',
170
- textAlign: 'center',
171
- },
172
- shadowStyle: {
173
- shadowColor: '#000',
174
- shadowOffset: {
175
- width: 0,
176
- height: 2,
177
- },
178
- shadowOpacity: 0.25,
179
- shadowRadius: 3.84,
180
- elevation: 5,
181
- },
182
- });