@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.
@@ -0,0 +1,110 @@
1
+ import React, { useState } from 'react';
2
+ import {
3
+ View,
4
+ Dimensions,
5
+ TouchableOpacity,
6
+ Modal,
7
+ Pressable,
8
+ StyleSheet,
9
+ StyleProp,
10
+ ViewStyle,
11
+ } from 'react-native';
12
+ import { normalize } from '../CommonStyle/componentStyle';
13
+ import { Global } from '../Common/Global';
14
+ import HIcons from '../Hoc/HIcons';
15
+
16
+ // ---------------------------------------------------------------------------
17
+ // Types
18
+ // ---------------------------------------------------------------------------
19
+
20
+ /** Props the HOC injects into the wrapped component. */
21
+ export interface COverlayInjectedProps {
22
+ /** Called when the overlay is dismissed. */
23
+ visibility?: (val: boolean) => void;
24
+ }
25
+
26
+ /**
27
+ * Full props accepted by the returned component:
28
+ * whatever the wrapped component needs, plus the injected `visibility`.
29
+ */
30
+ export type COverlayProps<W extends object> = W & COverlayInjectedProps;
31
+
32
+ // ---------------------------------------------------------------------------
33
+ // HOC
34
+ // ---------------------------------------------------------------------------
35
+
36
+ const COverlay = <W extends object>(
37
+ WrapComponent: React.ComponentType<W & COverlayInjectedProps>
38
+ ): React.FC<COverlayProps<W>> => {
39
+ const Overlay: React.FC<COverlayProps<W>> = (props) => {
40
+ const [overlay, setOverlay] = useState<boolean>(true);
41
+
42
+ const closeOverlay = (): void => {
43
+ setOverlay(false);
44
+ props?.visibility?.(false);
45
+ };
46
+
47
+ const popupContainerStyle: ViewStyle = {
48
+ position: 'absolute',
49
+ bottom: 0,
50
+ top: Dimensions.get('screen').height * 0.1,
51
+ width: Dimensions.get('screen').width,
52
+ backgroundColor: '#fff',
53
+ borderTopLeftRadius: 20,
54
+ borderTopRightRadius: 20,
55
+ borderWidth: 2,
56
+ borderColor: '#e0e0e0',
57
+ paddingHorizontal: normalize(5),
58
+ };
59
+
60
+ return (
61
+ <Modal
62
+ visible={overlay}
63
+ transparent
64
+ animationType="slide"
65
+ onRequestClose={closeOverlay}
66
+ >
67
+ <Pressable style={styles.backdrop} onPress={closeOverlay} />
68
+
69
+ <View style={popupContainerStyle}>
70
+ <View style={styles.closeButton}>
71
+ <TouchableOpacity onPress={closeOverlay}>
72
+ <HIcons.FontAwesome5
73
+ name="angle-double-down"
74
+ size={normalize(20)}
75
+ color={Global.AppTheme.primary_color}
76
+ />
77
+ </TouchableOpacity>
78
+ </View>
79
+
80
+ <WrapComponent {...(props as COverlayProps<W>)} />
81
+ </View>
82
+ </Modal>
83
+ );
84
+ };
85
+
86
+ Overlay.displayName = `COverlay(${
87
+ WrapComponent.displayName || WrapComponent.name || 'Component'
88
+ })`;
89
+
90
+ return Overlay;
91
+ };
92
+
93
+ export default COverlay;
94
+
95
+ // ---------------------------------------------------------------------------
96
+ // Styles
97
+ // ---------------------------------------------------------------------------
98
+
99
+ const styles = StyleSheet.create({
100
+ backdrop: {
101
+ flex: 1,
102
+ backgroundColor: 'rgba(0, 0, 0, 0.20)',
103
+ },
104
+ closeButton: {
105
+ position: 'absolute',
106
+ right: 10,
107
+ top: 10,
108
+ zIndex: 10,
109
+ },
110
+ });