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

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,234 @@
1
+ import React from 'react';
2
+ import {
3
+ StyleSheet,
4
+ View,
5
+ ImageBackground,
6
+ Platform,
7
+ Dimensions,
8
+ ViewStyle,
9
+ ImageStyle,
10
+ TextStyle,
11
+ } from 'react-native';
12
+ import { Global } from '../../../../../src/Common/Global';
13
+ // import CSwipeCard from '../Components/CSwipeCard';
14
+ import { normalize } from '../CommonStyle/ComponentFunctions';
15
+ import { useNavigation } from '../Navigation/PageNavigation';
16
+ // ---------------------------------------------------------------------------
17
+ // Types
18
+ // ---------------------------------------------------------------------------
19
+
20
+ export interface CDetailViewProps {
21
+ children?: React.ReactNode;
22
+ /** Overrides the default white background. */
23
+ backgroundColor?: string;
24
+ /** Remote image URL to display as background. */
25
+ bgimage?: string;
26
+ /** Hides the CSwipeCard header when true. */
27
+ hideCard?: boolean;
28
+ }
29
+
30
+ interface UserOption {
31
+ suoption?: number;
32
+ optiondetail?: Array<{
33
+ suoptiondetail?: number;
34
+ component?: string;
35
+ [key: string]: unknown;
36
+ }>;
37
+ [key: string]: unknown;
38
+ }
39
+
40
+ interface PatientDetails {
41
+ EditStatus?: boolean;
42
+ suavailability?: number;
43
+ type?: string | number;
44
+ keycode?: string | number;
45
+ [key: string]: unknown;
46
+ }
47
+
48
+ interface SwipeValue {
49
+ keyid?: string | number;
50
+ functionid?: string | number;
51
+ row?: string | number;
52
+ [key: string]: unknown;
53
+ }
54
+
55
+ // ---------------------------------------------------------------------------
56
+ // Styles (static — dynamic backgroundColor is applied at usage site)
57
+ // ---------------------------------------------------------------------------
58
+
59
+ const styles = StyleSheet.create({
60
+ CDetailView: {
61
+ flex: 1,
62
+ shadowColor: '#000',
63
+ shadowOffset: { width: 0, height: 2 },
64
+ shadowOpacity: 0.8,
65
+ shadowRadius: 2,
66
+ borderTopLeftRadius: 20,
67
+ borderTopRightRadius: 20,
68
+ width: '100%',
69
+ } as ViewStyle,
70
+ image: {
71
+ flex: 1,
72
+ width: Platform.OS === 'web' ? '88%' : '100%',
73
+ alignSelf: 'center',
74
+ } as ViewStyle,
75
+ productHeaderCard: {
76
+ flexDirection: 'row',
77
+ alignItems: 'center',
78
+ paddingVertical: 2,
79
+ } as ViewStyle,
80
+ productImageContainer: {
81
+ width: normalize(50),
82
+ height: normalize(50),
83
+ borderRadius: 8,
84
+ backgroundColor: '#f8f9fa',
85
+ justifyContent: 'center',
86
+ alignItems: 'center',
87
+ borderWidth: 1,
88
+ borderColor: Global.AppTheme.primary_color + '40',
89
+ borderStyle: 'dashed',
90
+ overflow: 'hidden',
91
+ } as ViewStyle,
92
+ productImage: {
93
+ width: '100%',
94
+ height: '100%',
95
+ borderRadius: 6,
96
+ } as ImageStyle,
97
+ imagePlaceholder: {
98
+ justifyContent: 'center',
99
+ alignItems: 'center',
100
+ } as ViewStyle,
101
+ imageAddText: {
102
+ fontSize: normalize(6),
103
+ fontWeight: '700',
104
+ color: Global.AppTheme.primary_color,
105
+ marginTop: normalize(2),
106
+ } as TextStyle,
107
+ productInfoSection: {
108
+ flex: 1,
109
+ marginLeft: normalize(8),
110
+ justifyContent: 'center',
111
+ } as ViewStyle,
112
+ productMainTitle: {
113
+ fontSize: normalize(13),
114
+ fontWeight: '700',
115
+ color: '#1a1a2e',
116
+ marginBottom: 2,
117
+ lineHeight: normalize(16),
118
+ } as TextStyle,
119
+ productMetaRow: {
120
+ flexDirection: 'row',
121
+ alignItems: 'center',
122
+ marginBottom: 1,
123
+ } as ViewStyle,
124
+ productMetaText: {
125
+ fontSize: normalize(10),
126
+ color: '#64748b',
127
+ marginLeft: normalize(4),
128
+ flex: 1,
129
+ fontWeight: '500',
130
+ } as TextStyle,
131
+ actionButton: {
132
+ borderRadius: 8,
133
+ borderWidth: 0.5,
134
+ height:
135
+ Platform.OS !== 'web'
136
+ ? Dimensions.get('screen').height * 0.04
137
+ : Dimensions.get('screen').height * 0.06,
138
+ width: Dimensions.get('screen').width * 0.06,
139
+ backgroundColor: '#fff',
140
+ justifyContent: 'center',
141
+ alignItems: 'center',
142
+ marginHorizontal: '1%',
143
+ borderColor: Global.AppTheme.primary_color,
144
+ } as ViewStyle,
145
+ optionText: {
146
+ fontSize: normalize(8),
147
+ fontWeight: 'bold',
148
+ color: Global.AppTheme.primary_color,
149
+ textAlign: 'center',
150
+ } as TextStyle,
151
+ });
152
+
153
+ // ---------------------------------------------------------------------------
154
+ // Component
155
+ // ---------------------------------------------------------------------------
156
+
157
+ const CDetailView: React.FC<CDetailViewProps> = ({
158
+ children,
159
+ backgroundColor,
160
+ bgimage,
161
+ hideCard,
162
+ }) => {
163
+ const navigation = useNavigation();
164
+
165
+ const handleSwipeCallback = (val: SwipeValue, item: PatientDetails): void => {
166
+ Global.PatientDetails = item;
167
+
168
+ const productSection = (Global.userOptionList as UserOption[] | undefined)?.find(
169
+ (section) => section.suoption === 31900
170
+ );
171
+ const filteredDetails = productSection?.optiondetail?.filter(
172
+ (option) => option.suoptiondetail === val.keyid
173
+ );
174
+
175
+ console.log('Swipe Callback Value:', JSON.stringify(val));
176
+ console.log('Filtered Details', JSON.stringify(filteredDetails));
177
+
178
+ // NOTE: `val.functionid || val.row` is compared to string cases 'L'/'R'.
179
+ // If the API ever returns numeric row (e.g. 1), this will always fall to
180
+ // `default`. Consider coercing: `String(val.functionid ?? val.row)`.
181
+ switch (val.functionid || val.row) {
182
+ case 'L':
183
+ navigation.navigate('WrappedComponent', {
184
+ component: filteredDetails?.[0]?.component,
185
+ data: filteredDetails?.[0],
186
+ itemdata: item,
187
+ });
188
+ break;
189
+ case 'R':
190
+ navigation.navigate('DetailsOverlay', { data: item, code: val });
191
+ break;
192
+ default:
193
+ console.log('Not Available', JSON.stringify(val));
194
+ }
195
+ };
196
+
197
+ const patient = Global.PatientDetails as PatientDetails | null | undefined;
198
+ const userData = Global.userData as { suuser?: number } | null | undefined;
199
+
200
+ return (
201
+ <View
202
+ style={[
203
+ styles.CDetailView,
204
+ { backgroundColor: backgroundColor ?? 'white' },
205
+ ]}
206
+ >
207
+ <ImageBackground
208
+ source={
209
+ bgimage != undefined
210
+ ? { uri: bgimage }
211
+ : null
212
+ }
213
+ resizeMode={bgimage != undefined ? 'stretch' : 'contain'}
214
+ imageStyle={bgimage != undefined ? { opacity: 1 } : { opacity: 0.1 }}
215
+ style={styles.image}
216
+ >
217
+ {/* {patient != null && !hideCard ? (
218
+ <CSwipeCard
219
+ edited={patient?.EditStatus}
220
+ availability={patient?.suavailability}
221
+ data={patient}
222
+ style={Global?.optiondata}
223
+ rightButtonsapi={`${APIURL}invget/invcommonget/rnproductdescription ${userData?.suuser},${patient?.type},${patient?.keycode}`}
224
+ leftButtonsapi={`${APIURL}invget/invcommonget/rninsuproductdescription ${patient?.keycode},${userData?.suuser}`}
225
+ callback={(val: SwipeValue) => handleSwipeCallback(val, patient)}
226
+ />
227
+ ) : null} */}
228
+ {children}
229
+ </ImageBackground>
230
+ </View>
231
+ );
232
+ };
233
+
234
+ export default CDetailView;
@@ -0,0 +1,86 @@
1
+ import React from 'react';
2
+ import {
3
+ Dimensions,
4
+ Platform,
5
+ View,
6
+ ScrollView,
7
+ StyleSheet,
8
+ StyleProp,
9
+ ViewStyle,
10
+ } from 'react-native';
11
+
12
+ // ---------------------------------------------------------------------------
13
+ // Types
14
+ // ---------------------------------------------------------------------------
15
+
16
+ export interface CFooterViewProps {
17
+ /** Extra style merged onto the outer container. */
18
+ style?: StyleProp<ViewStyle>;
19
+ /** Footer content (usually a row of buttons / icons). */
20
+ children?: React.ReactNode;
21
+ }
22
+
23
+ // ---------------------------------------------------------------------------
24
+ // Styles
25
+ // ---------------------------------------------------------------------------
26
+
27
+ const styles = StyleSheet.create({
28
+ base: {
29
+ backgroundColor: 'white',
30
+ },
31
+ content: {
32
+ alignItems: 'center',
33
+ },
34
+ webContent: {
35
+ flexDirection: 'column',
36
+ paddingVertical: '1%',
37
+ },
38
+ mobileContent: {
39
+ flexDirection: 'row',
40
+ paddingHorizontal: '1%',
41
+ },
42
+ });
43
+
44
+ // ---------------------------------------------------------------------------
45
+ // Component
46
+ // ---------------------------------------------------------------------------
47
+
48
+ const CFooterView: React.FC<CFooterViewProps> = ({ style, children }) => {
49
+ const isWeb = Platform.OS === 'web';
50
+
51
+ const containerStyle: ViewStyle = isWeb
52
+ ? {
53
+ position: 'absolute',
54
+ right: 0,
55
+ bottom: 0,
56
+ width: 80,
57
+ borderLeftWidth: 1,
58
+ borderLeftColor: 'lightgrey',
59
+ zIndex: 10,
60
+ elevation: 10,
61
+ maxHeight: '90%',
62
+ }
63
+ : {
64
+ borderTopWidth: 1,
65
+ borderTopColor: 'lightgrey',
66
+ };
67
+
68
+ return (
69
+ <View style={[styles.base, containerStyle, style]}>
70
+ <ScrollView
71
+ horizontal={!isWeb}
72
+ showsHorizontalScrollIndicator={false}
73
+ showsVerticalScrollIndicator={false}
74
+ bounces={false}
75
+ contentContainerStyle={[
76
+ styles.content,
77
+ isWeb ? styles.webContent : styles.mobileContent,
78
+ ]}
79
+ >
80
+ {children}
81
+ </ScrollView>
82
+ </View>
83
+ );
84
+ };
85
+
86
+ export default CFooterView;
@@ -0,0 +1,172 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import { View, Text, StyleSheet } from 'react-native';
3
+ import NetInfo, { NetInfoState, NetInfoStateType } from '@react-native-community/netinfo';
4
+ import { normalize } from '../CommonStyle/componentStyle';
5
+ import HIcons from '../Hoc/HIcons';
6
+ import ABlink from '../Alerts/ABlink';
7
+
8
+ // ---------------------------------------------------------------------------
9
+ // Types
10
+ // ---------------------------------------------------------------------------
11
+
12
+ interface NetworkInfo {
13
+ isConnected?: boolean | null;
14
+ isInternetReachable?: boolean | null;
15
+ connectionType?: NetInfoStateType;
16
+ effectiveType?: string | null;
17
+ isExpensive?: boolean | null;
18
+ details?: unknown;
19
+ }
20
+
21
+ // ---------------------------------------------------------------------------
22
+ // Component
23
+ // ---------------------------------------------------------------------------
24
+
25
+ const CNetworkStatus: React.FC = () => {
26
+ const [networkInfo, setNetworkInfo] = useState<NetworkInfo>({});
27
+
28
+ useEffect(() => {
29
+ const unsubscribe = NetInfo.addEventListener((state: NetInfoState) => {
30
+ setNetworkInfo({
31
+ isConnected: state.isConnected,
32
+ isInternetReachable: state.isInternetReachable,
33
+ connectionType: state.type,
34
+ effectiveType: state.type, // state has no `effectiveType`; kept as-is to match original mapping intent
35
+ isExpensive: state.isExpensive,
36
+ details: state.details,
37
+ });
38
+ });
39
+
40
+ return () => unsubscribe();
41
+ }, []);
42
+
43
+ /**
44
+ * Renders a labeled icon.
45
+ * NOTE: currently unused — all `IconButton(...)` call sites are commented out.
46
+ */
47
+ const IconButton = (
48
+ icongroup: number,
49
+ iconname: string,
50
+ text: string
51
+ ): React.ReactElement => (
52
+ <View style={{ justifyContent: 'center', alignItems: 'center' }}>
53
+ <HIcons.Icons
54
+ icongroup={icongroup}
55
+ name={iconname}
56
+ size={normalize(15)}
57
+ color={'white'}
58
+ style={{
59
+ textShadowColor: '#ffffff',
60
+ textShadowOffset: { width: 1, height: 1 },
61
+ textShadowRadius: 1,
62
+ }}
63
+ />
64
+ <Text
65
+ style={{
66
+ color: 'white',
67
+ fontSize: normalize(7),
68
+ textShadowColor: '#ffffff',
69
+ textShadowOffset: { width: 0.5, height: 0.5 },
70
+ textShadowRadius: 0.5,
71
+ textAlign: 'center',
72
+ }}
73
+ >
74
+ {text}
75
+ </Text>
76
+ </View>
77
+ );
78
+
79
+ const NetWorkIcons = (): React.ReactElement => {
80
+ if (networkInfo.isConnected) {
81
+ // All connected branches return an empty <View /> — the "connected"
82
+ // indicator is intentionally suppressed (see commented blocks above).
83
+ if (networkInfo.connectionType === 'cellular') {
84
+ if (networkInfo.isInternetReachable) {
85
+ return <View />;
86
+ }
87
+ return <View />;
88
+ }
89
+ if (networkInfo.connectionType === 'wifi') {
90
+ if (networkInfo.isInternetReachable) {
91
+ return <View />;
92
+ }
93
+ return <View />;
94
+ }
95
+ return <View />;
96
+ }
97
+
98
+ return (
99
+ <ABlink>
100
+ <View
101
+ style={{
102
+ justifyContent: 'center',
103
+ alignItems: 'center',
104
+ backgroundColor: 'white',
105
+ borderRadius: 10,
106
+ padding: normalize(4),
107
+ }}
108
+ >
109
+ <View style={{ flexDirection: 'row' }}>
110
+ <HIcons.Icons
111
+ icongroup={3}
112
+ name={'wifi-off'}
113
+ size={normalize(20)}
114
+ color={'red'}
115
+ style={{
116
+ textShadowColor: '#ffffff',
117
+ textShadowOffset: { width: 1, height: 1 },
118
+ textShadowRadius: 1,
119
+ }}
120
+ />
121
+ <HIcons.Icons
122
+ icongroup={3}
123
+ name={'signal-off'}
124
+ size={normalize(20)}
125
+ color={'red'}
126
+ style={{
127
+ textShadowColor: '#ffffff',
128
+ textShadowOffset: { width: 1, height: 1 },
129
+ textShadowRadius: 1,
130
+ }}
131
+ />
132
+ </View>
133
+ <Text
134
+ style={{
135
+ color: 'red',
136
+ fontSize: normalize(9),
137
+ textShadowColor: '#ffffff',
138
+ textShadowOffset: { width: 0.5, height: 0.5 },
139
+ textShadowRadius: 0.5,
140
+ }}
141
+ >
142
+ NO NETWORK
143
+ </Text>
144
+ </View>
145
+ </ABlink>
146
+ );
147
+ };
148
+
149
+ return (
150
+ <View style={{ flexDirection: 'row' }}>
151
+ {NetWorkIcons()}
152
+ </View>
153
+ );
154
+ };
155
+
156
+ // ---------------------------------------------------------------------------
157
+ // Styles (kept for parity; currently unused by the active component)
158
+ // ---------------------------------------------------------------------------
159
+
160
+ const styles = StyleSheet.create({
161
+ container: {},
162
+ title: {
163
+ fontSize: 24,
164
+ fontWeight: 'bold',
165
+ marginBottom: 20,
166
+ },
167
+ infoText: {
168
+ fontSize: 16,
169
+ },
170
+ });
171
+
172
+ export default CNetworkStatus;
@@ -0,0 +1,111 @@
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 '../../../../../src/Common/Global';
14
+ ;
15
+ import HIcons from '../Hoc/HIcons';
16
+
17
+ // ---------------------------------------------------------------------------
18
+ // Types
19
+ // ---------------------------------------------------------------------------
20
+
21
+ /** Props the HOC injects into the wrapped component. */
22
+ export interface COverlayInjectedProps {
23
+ /** Called when the overlay is dismissed. */
24
+ visibility?: (val: boolean) => void;
25
+ }
26
+
27
+ /**
28
+ * Full props accepted by the returned component:
29
+ * whatever the wrapped component needs, plus the injected `visibility`.
30
+ */
31
+ export type COverlayProps<W extends object> = W & COverlayInjectedProps;
32
+
33
+ // ---------------------------------------------------------------------------
34
+ // HOC
35
+ // ---------------------------------------------------------------------------
36
+
37
+ const COverlay = <W extends object>(
38
+ WrapComponent: React.ComponentType<W & COverlayInjectedProps>
39
+ ): React.FC<COverlayProps<W>> => {
40
+ const Overlay: React.FC<COverlayProps<W>> = (props) => {
41
+ const [overlay, setOverlay] = useState<boolean>(true);
42
+
43
+ const closeOverlay = (): void => {
44
+ setOverlay(false);
45
+ props?.visibility?.(false);
46
+ };
47
+
48
+ const popupContainerStyle: ViewStyle = {
49
+ position: 'absolute',
50
+ bottom: 0,
51
+ top: Dimensions.get('screen').height * 0.1,
52
+ width: Dimensions.get('screen').width,
53
+ backgroundColor: '#fff',
54
+ borderTopLeftRadius: 20,
55
+ borderTopRightRadius: 20,
56
+ borderWidth: 2,
57
+ borderColor: '#e0e0e0',
58
+ paddingHorizontal: normalize(5),
59
+ };
60
+
61
+ return (
62
+ <Modal
63
+ visible={overlay}
64
+ transparent
65
+ animationType="slide"
66
+ onRequestClose={closeOverlay}
67
+ >
68
+ <Pressable style={styles.backdrop} onPress={closeOverlay} />
69
+
70
+ <View style={popupContainerStyle}>
71
+ <View style={styles.closeButton}>
72
+ <TouchableOpacity onPress={closeOverlay}>
73
+ <HIcons.FontAwesome5
74
+ name="angle-double-down"
75
+ size={normalize(20)}
76
+ color={Global.AppTheme.primary_color}
77
+ />
78
+ </TouchableOpacity>
79
+ </View>
80
+
81
+ <WrapComponent {...(props as COverlayProps<W>)} />
82
+ </View>
83
+ </Modal>
84
+ );
85
+ };
86
+
87
+ Overlay.displayName = `COverlay(${
88
+ WrapComponent.displayName || WrapComponent.name || 'Component'
89
+ })`;
90
+
91
+ return Overlay;
92
+ };
93
+
94
+ export default COverlay;
95
+
96
+ // ---------------------------------------------------------------------------
97
+ // Styles
98
+ // ---------------------------------------------------------------------------
99
+
100
+ const styles = StyleSheet.create({
101
+ backdrop: {
102
+ flex: 1,
103
+ backgroundColor: 'rgba(0, 0, 0, 0.20)',
104
+ },
105
+ closeButton: {
106
+ position: 'absolute',
107
+ right: 10,
108
+ top: 10,
109
+ zIndex: 10,
110
+ },
111
+ });