related-ui-components 1.7.1 → 1.7.3
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.
- package/lib/commonjs/app.js +95 -1
- package/lib/commonjs/app.js.map +1 -1
- package/lib/commonjs/components/Popup/Popup.js +68 -45
- package/lib/commonjs/components/Popup/Popup.js.map +1 -1
- package/lib/commonjs/components/UnlockRewards/UnlockRewards.js +4 -2
- package/lib/commonjs/components/UnlockRewards/UnlockRewards.js.map +1 -1
- package/lib/commonjs/index.js +5 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/app.js +96 -2
- package/lib/module/app.js.map +1 -1
- package/lib/module/components/Popup/Popup.js +66 -45
- package/lib/module/components/Popup/Popup.js.map +1 -1
- package/lib/module/components/UnlockRewards/UnlockRewards.js +2 -2
- package/lib/module/components/UnlockRewards/UnlockRewards.js.map +1 -1
- package/lib/module/index.js +4 -7
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/app.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/Popup/Popup.d.ts +1 -2
- package/lib/typescript/commonjs/components/Popup/Popup.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/UnlockRewards/UnlockRewards.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +1 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/module/app.d.ts.map +1 -1
- package/lib/typescript/module/components/Popup/Popup.d.ts +1 -2
- package/lib/typescript/module/components/Popup/Popup.d.ts.map +1 -1
- package/lib/typescript/module/components/UnlockRewards/UnlockRewards.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +1 -0
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/app.tsx +75 -2
- package/src/components/Popup/Popup.tsx +68 -39
- package/src/components/UnlockRewards/UnlockRewards.tsx +2 -2
- package/src/index.ts +4 -4
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useTheme, ThemeType } from "../../theme";
|
|
2
|
-
import React, { FC, ReactNode } from "react";
|
|
2
|
+
import React, { FC, ReactNode, useEffect, useRef, useState } from "react";
|
|
3
3
|
import {
|
|
4
|
+
Modal,
|
|
4
5
|
View,
|
|
5
6
|
Text,
|
|
6
7
|
TouchableOpacity,
|
|
@@ -15,21 +16,12 @@ import {
|
|
|
15
16
|
TextStyle,
|
|
16
17
|
ViewStyle,
|
|
17
18
|
ImageStyle,
|
|
19
|
+
Animated,
|
|
20
|
+
Easing,
|
|
18
21
|
} from "react-native";
|
|
19
22
|
import CloseIcon from "../CloseIcon/CloseIcon";
|
|
20
|
-
import Modal, { ModalProps } from "react-native-modal";
|
|
21
23
|
|
|
22
|
-
interface PopupProps
|
|
23
|
-
extends Partial<Pick<
|
|
24
|
-
ModalProps,
|
|
25
|
-
| "animationIn"
|
|
26
|
-
| "animationOut"
|
|
27
|
-
| "animationInTiming"
|
|
28
|
-
| "animationOutTiming"
|
|
29
|
-
| "backdropTransitionInTiming"
|
|
30
|
-
| "backdropTransitionOutTiming"
|
|
31
|
-
| "onBackdropPress"
|
|
32
|
-
>> {
|
|
24
|
+
interface PopupProps {
|
|
33
25
|
visible: boolean;
|
|
34
26
|
onClose: () => void;
|
|
35
27
|
backgroundImage?: ImageSourcePropType;
|
|
@@ -65,6 +57,7 @@ interface PopupProps
|
|
|
65
57
|
overlay?: ReactNode;
|
|
66
58
|
customContent?: ReactNode;
|
|
67
59
|
}
|
|
60
|
+
const { height: screenHeight } = Dimensions.get("window");
|
|
68
61
|
|
|
69
62
|
const Popup: FC<PopupProps> = ({
|
|
70
63
|
visible,
|
|
@@ -101,18 +94,35 @@ const Popup: FC<PopupProps> = ({
|
|
|
101
94
|
modalStyle,
|
|
102
95
|
overlay,
|
|
103
96
|
customContent,
|
|
104
|
-
animationIn = "slideInUp",
|
|
105
|
-
animationInTiming,
|
|
106
|
-
animationOut = "slideOutDown",
|
|
107
|
-
animationOutTiming,
|
|
108
|
-
backdropTransitionInTiming,
|
|
109
|
-
backdropTransitionOutTiming,
|
|
110
|
-
onBackdropPress
|
|
111
97
|
}) => {
|
|
112
98
|
const { theme, isRTL: rtl } = useTheme();
|
|
113
99
|
isRTL = rtl;
|
|
114
100
|
const styles = createStyles(theme); // Create styles using theme
|
|
115
101
|
|
|
102
|
+
const [modalRendered, setModalRendered] = useState(visible);
|
|
103
|
+
const slideAnim = useRef(new Animated.Value(screenHeight)).current;
|
|
104
|
+
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
if (visible) {
|
|
107
|
+
setModalRendered(true);
|
|
108
|
+
Animated.timing(slideAnim, {
|
|
109
|
+
toValue: 0,
|
|
110
|
+
duration: 300,
|
|
111
|
+
easing: Easing.out(Easing.ease),
|
|
112
|
+
useNativeDriver: true,
|
|
113
|
+
}).start();
|
|
114
|
+
} else {
|
|
115
|
+
Animated.timing(slideAnim, {
|
|
116
|
+
toValue: screenHeight,
|
|
117
|
+
duration: 300,
|
|
118
|
+
easing: Easing.in(Easing.ease),
|
|
119
|
+
useNativeDriver: true,
|
|
120
|
+
}).start(() => {
|
|
121
|
+
setModalRendered(false);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}, [visible, slideAnim, 300]);
|
|
125
|
+
|
|
116
126
|
const PopupContent = () => (
|
|
117
127
|
<View style={[children == null && styles.popupContainer, containerStyle]}>
|
|
118
128
|
<CloseIcon
|
|
@@ -162,7 +172,7 @@ const Popup: FC<PopupProps> = ({
|
|
|
162
172
|
<Text
|
|
163
173
|
style={[
|
|
164
174
|
styles.title,
|
|
165
|
-
{ color: theme.text, textAlign: "center" },
|
|
175
|
+
{ color: theme.text, textAlign: "center" },
|
|
166
176
|
titleStyle,
|
|
167
177
|
]}
|
|
168
178
|
>
|
|
@@ -174,7 +184,7 @@ const Popup: FC<PopupProps> = ({
|
|
|
174
184
|
<Text
|
|
175
185
|
style={[
|
|
176
186
|
styles.subtitle,
|
|
177
|
-
{ color: theme.text, textAlign: "center" },
|
|
187
|
+
{ color: theme.text, textAlign: "center" },
|
|
178
188
|
subtitleStyle,
|
|
179
189
|
]}
|
|
180
190
|
>
|
|
@@ -186,7 +196,7 @@ const Popup: FC<PopupProps> = ({
|
|
|
186
196
|
<Text
|
|
187
197
|
style={[
|
|
188
198
|
styles.content,
|
|
189
|
-
{ color: theme.text, textAlign: "center" },
|
|
199
|
+
{ color: theme.text, textAlign: "center" },
|
|
190
200
|
contentStyle,
|
|
191
201
|
]}
|
|
192
202
|
>
|
|
@@ -207,7 +217,7 @@ const Popup: FC<PopupProps> = ({
|
|
|
207
217
|
<TouchableOpacity
|
|
208
218
|
style={[
|
|
209
219
|
styles.secondaryButton,
|
|
210
|
-
{ borderColor: theme.primary },
|
|
220
|
+
{ borderColor: theme.primary },
|
|
211
221
|
secondaryButtonStyle,
|
|
212
222
|
isRTL
|
|
213
223
|
? { marginLeft: 12, marginRight: 0 }
|
|
@@ -218,7 +228,7 @@ const Popup: FC<PopupProps> = ({
|
|
|
218
228
|
<Text
|
|
219
229
|
style={[
|
|
220
230
|
styles.secondaryButtonText,
|
|
221
|
-
{ color: theme.primary },
|
|
231
|
+
{ color: theme.primary },
|
|
222
232
|
secondaryButtonTextStyle,
|
|
223
233
|
]}
|
|
224
234
|
>
|
|
@@ -231,7 +241,7 @@ const Popup: FC<PopupProps> = ({
|
|
|
231
241
|
<TouchableOpacity
|
|
232
242
|
style={[
|
|
233
243
|
styles.primaryButton,
|
|
234
|
-
{ backgroundColor: theme.primary },
|
|
244
|
+
{ backgroundColor: theme.primary },
|
|
235
245
|
primaryButtonStyle,
|
|
236
246
|
]}
|
|
237
247
|
onPress={onPrimaryButtonPress}
|
|
@@ -239,7 +249,7 @@ const Popup: FC<PopupProps> = ({
|
|
|
239
249
|
<Text
|
|
240
250
|
style={[
|
|
241
251
|
styles.primaryButtonText,
|
|
242
|
-
{ color: theme.onPrimary },
|
|
252
|
+
{ color: theme.onPrimary },
|
|
243
253
|
primaryButtonTextStyle,
|
|
244
254
|
]}
|
|
245
255
|
>
|
|
@@ -254,21 +264,32 @@ const Popup: FC<PopupProps> = ({
|
|
|
254
264
|
|
|
255
265
|
return (
|
|
256
266
|
<Modal
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
backdropTransitionOutTiming={backdropTransitionOutTiming}
|
|
262
|
-
animationInTiming={animationInTiming}
|
|
263
|
-
animationOutTiming={animationOutTiming}
|
|
264
|
-
onBackdropPress={onBackdropPress}
|
|
267
|
+
transparent
|
|
268
|
+
visible={modalRendered}
|
|
269
|
+
animationType="none"
|
|
270
|
+
onRequestClose={onClose}
|
|
265
271
|
statusBarTranslucent
|
|
266
272
|
style={modalStyle}
|
|
267
273
|
>
|
|
268
274
|
<View style={styles.modalOverlay}>
|
|
269
|
-
|
|
270
|
-
<
|
|
271
|
-
|
|
275
|
+
{closeOnBackdropPress && (
|
|
276
|
+
<TouchableWithoutFeedback onPress={onClose}>
|
|
277
|
+
<View style={StyleSheet.absoluteFill} />
|
|
278
|
+
</TouchableWithoutFeedback>
|
|
279
|
+
)}
|
|
280
|
+
<Animated.View
|
|
281
|
+
style={[
|
|
282
|
+
{
|
|
283
|
+
transform: [{ translateY: slideAnim }],
|
|
284
|
+
},
|
|
285
|
+
styles.animatedContainer,
|
|
286
|
+
]}
|
|
287
|
+
pointerEvents="box-none"
|
|
288
|
+
>
|
|
289
|
+
<TouchableWithoutFeedback>
|
|
290
|
+
<PopupContent />
|
|
291
|
+
</TouchableWithoutFeedback>
|
|
292
|
+
</Animated.View>
|
|
272
293
|
</View>
|
|
273
294
|
</Modal>
|
|
274
295
|
);
|
|
@@ -282,11 +303,17 @@ const createStyles = (theme: ThemeType) =>
|
|
|
282
303
|
StyleSheet.create({
|
|
283
304
|
modalOverlay: {
|
|
284
305
|
flex: 1,
|
|
285
|
-
|
|
306
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)", // Keep overlay color
|
|
286
307
|
justifyContent: "center",
|
|
287
308
|
alignItems: "center",
|
|
288
309
|
paddingTop: Platform.OS === "android" ? StatusBar.currentHeight : 0,
|
|
289
310
|
},
|
|
311
|
+
animatedContainer: {
|
|
312
|
+
alignItems: "center",
|
|
313
|
+
width: "100%",
|
|
314
|
+
justifyContent: "center",
|
|
315
|
+
flexGrow: 1,
|
|
316
|
+
},
|
|
290
317
|
popupContainer: {
|
|
291
318
|
width: popupWidth,
|
|
292
319
|
maxHeight: "80%",
|
|
@@ -331,6 +358,8 @@ const createStyles = (theme: ThemeType) =>
|
|
|
331
358
|
padding: 24,
|
|
332
359
|
alignItems: "center",
|
|
333
360
|
justifyContent: "center",
|
|
361
|
+
// flex: 1,
|
|
362
|
+
// alignSelf:"stretch",
|
|
334
363
|
borderRadius: 16,
|
|
335
364
|
},
|
|
336
365
|
illustrationContainer: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
2
|
import {
|
|
3
3
|
View,
|
|
4
4
|
Text,
|
|
@@ -107,7 +107,7 @@ const UnlockRewards: React.FC<UnlockRewardsProps> = ({
|
|
|
107
107
|
}) => {
|
|
108
108
|
const { theme, isRTL: rtl } = useTheme();
|
|
109
109
|
isRTL = isRTL || rtl;
|
|
110
|
-
const styles = themedStyles(theme);
|
|
110
|
+
const styles = useMemo(()=> themedStyles(theme), [ theme]);
|
|
111
111
|
|
|
112
112
|
const topBackgroundColor = topBackgroundColorProp ?? theme.surface;
|
|
113
113
|
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { registerRootComponent } from 'expo';
|
|
2
|
+
import "react-native-reanimated";
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import App from "./app";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
registerRootComponent(App);
|
|
8
8
|
|
|
9
9
|
export * from "./theme"
|
|
10
10
|
export * from "./components";
|