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

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,331 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import {
3
+ View,
4
+ StatusBar,
5
+ Text,
6
+ Image,
7
+ Platform,
8
+ TouchableOpacity,
9
+ Dimensions,
10
+ StyleSheet,
11
+ ScrollView,
12
+ TouchableWithoutFeedback,
13
+ Linking,
14
+ BackHandler,
15
+ } from 'react-native';
16
+ import RNFetchBlob from 'react-native-blob-util';
17
+ import { Global } from '../../../../../src/Common/Global';
18
+ import RNExitApp from 'react-native-exit-app';
19
+ import HView from '@jescon-technologies/react-native-ui-kit/src/Hoc/HView';
20
+ import { APIURL } from '../../../../../src/Common/apiConstants';
21
+ import { HIcons, useNavigation, normalize, isNU, Loader } from '@jescon-technologies/react-native-ui-kit';
22
+
23
+ // Type definitions for props
24
+ interface LoginProps {
25
+ // Add any props that might be passed to this component
26
+ // For example:
27
+ // route?: any;
28
+ // navigation?: any;
29
+ }
30
+
31
+ // Type for the HView component's loader callback
32
+ type LoaderCallback = (val: boolean | undefined) => void;
33
+
34
+ // Interface for footer icon item (if needed later)
35
+ interface FooterIconItem {
36
+ displaytext: string;
37
+ color: string;
38
+ iconname: string;
39
+ }
40
+
41
+ /**
42
+ * Login Component
43
+ *
44
+ * Handles the main login screen functionality of the application
45
+ *
46
+ * @param {LoginProps} props - Component props passed from parent
47
+ * @returns {React.ReactElement} Rendered login screen
48
+ */
49
+ function Login(props: LoginProps): React.ReactElement {
50
+ const [isLoading, setIsLoading] = useState<boolean>(false);
51
+ const navigation = useNavigation();
52
+
53
+ // Handle back button press to exit app
54
+ useEffect(() => {
55
+ const backAction = (): boolean => {
56
+ RNExitApp.exitApp();
57
+ return true;
58
+ };
59
+
60
+ const backHandler = BackHandler.addEventListener(
61
+ 'hardwareBackPress',
62
+ backAction,
63
+ );
64
+
65
+ return () => backHandler.remove();
66
+ }, [navigation]);
67
+
68
+ /**
69
+ * Get file extension from filename
70
+ * @param {string} filename - The file name to extract extension from
71
+ * @returns {string | undefined} - The file extension
72
+ */
73
+ const getExtention = (filename: string): string | undefined => {
74
+ return /[.]/.exec(filename) ? /[^.]+$/.exec(filename)?.[0] : undefined;
75
+ };
76
+
77
+ /**
78
+ * Downloads an image from URL to device storage
79
+ */
80
+ const downloadImage = (): void => {
81
+ let date = new Date();
82
+ let image_URL = 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png';
83
+ let ext = getExtention(image_URL);
84
+ ext = '.' + ext?.[0];
85
+
86
+ const { config, fs } = RNFetchBlob;
87
+ let PictureDir = fs.dirs.PictureDir;
88
+
89
+ let options = {
90
+ fileCache: true,
91
+ addAndroidDownloads: {
92
+ useDownloadManager: true,
93
+ notification: true,
94
+ path: PictureDir + '/image_' + Math.floor(date.getTime() + date.getSeconds() / 2) + ext,
95
+ description: 'Image',
96
+ },
97
+ };
98
+
99
+ config(options)
100
+ .fetch('GET', image_URL)
101
+ .then((res: any) => {
102
+ console.log('res -> ', JSON.stringify(res));
103
+ alert('Image Downloaded Successfully.');
104
+ });
105
+ };
106
+
107
+ const hospitalBgImage: string = Global.HospitalData?.bgimage || 'https://i.ibb.co/jvj0wdH/Adams-Neilson.jpg';
108
+
109
+ return (
110
+ <View style={styles.container}>
111
+ <StatusBar
112
+ translucent
113
+ backgroundColor="transparent"
114
+ barStyle={Platform.OS === 'ios' ? 'light-content' : 'dark-content'} />
115
+
116
+ <TouchableWithoutFeedback>
117
+ <View style={styles.container}>
118
+ {/* App Title */}
119
+ <Text
120
+ style={[
121
+ styles.titleText,
122
+ {
123
+ paddingHorizontal: 30,
124
+ textShadowColor: Global.AppTheme.primary_color,
125
+ textShadowOffset: { width: normalize(5), height: normalize(5) },
126
+ textShadowRadius: normalize(15),
127
+ textAlign: 'center',
128
+ },
129
+ ]}
130
+ >
131
+ {'HOMES'}
132
+ </Text>
133
+
134
+ <ScrollView keyboardShouldPersistTaps="handled">
135
+ <View style={styles.contentContainer}>
136
+ {/* Header Image */}
137
+ <View>
138
+ <Image
139
+ style={styles.headerImage}
140
+ source={{ uri: hospitalBgImage }}
141
+ />
142
+
143
+ {/* Customer Service Button */}
144
+ <TouchableOpacity
145
+ style={styles.customerServiceButton}
146
+ onPress={() => Linking.openURL(`tel:${Global.HospitalData?.customercare}`)}
147
+ >
148
+ <HIcons.AntDesign
149
+ name="customerservice"
150
+ color="#fff"
151
+ size={normalize(17)}
152
+ />
153
+ </TouchableOpacity>
154
+ </View>
155
+
156
+ {/* Login Form */}
157
+ <View style={styles.bottomView}>
158
+ <HView
159
+ component={'LoginLayout'}
160
+ loader={(val: boolean | undefined): void | null =>
161
+ val === undefined ? null : setIsLoading(val)
162
+ }
163
+ />
164
+ </View>
165
+ </View>
166
+
167
+ {/* Company Logo Section */}
168
+ <View style={styles.companyLogoSection}>
169
+ <TouchableOpacity
170
+ onPress={() => Linking.openURL('http://jescontechnologies.com/')}
171
+ style={styles.footer_container}
172
+ >
173
+ <View style={styles.companyinfo_container}>
174
+ <Image
175
+ style={styles.companyLogo}
176
+ source={{ uri: 'https://i.ibb.co/dkNbcDN/jesconnewlogo.jpg' }}
177
+ />
178
+ <Image
179
+ style={styles.company_icon}
180
+ source={{ uri: `${APIURL}insurancefile/getCommonFile/image/companyaddress_transparent.png` }}
181
+ />
182
+ </View>
183
+ </TouchableOpacity>
184
+ </View>
185
+ </ScrollView>
186
+
187
+ {/* App Version Display */}
188
+ <View style={styles.versionContainer}>
189
+ {Platform.OS !== 'ios' && (
190
+ <Text style={styles.versionText}>
191
+ {Global.CodePushVersion}
192
+ </Text>
193
+ )}
194
+ <Text style={styles.versionText}>
195
+ {isNU(Global.version) ? `V ${Global.version}` : null}
196
+ </Text>
197
+ </View>
198
+
199
+ {/* Footer Icons - Commented out for now */}
200
+ {/* <View style={styles.footerIconsContainer}>
201
+ <View style={styles.footerIconsRow}>
202
+ {data?.loginfootericons?.map((item: FooterIconItem, i: number) => (
203
+ <CVectorIcon
204
+ key={i}
205
+ data={{
206
+ disabled: false,
207
+ displaytext: item.displaytext,
208
+ fontcolor: item.color,
209
+ fontWeight: 'bold',
210
+ size: 12,
211
+ iconname: item.iconname,
212
+ iconcolor: item.color,
213
+ iconsize: 22,
214
+ functionid: 'DF01',
215
+ }}
216
+ callBack={(val: any) =>
217
+ val === undefined
218
+ ? null
219
+ : props.navigation.navigate('WebPage', { data: item })
220
+ }
221
+ />
222
+ ))}
223
+ </View>
224
+ </View> */}
225
+
226
+ {/* Loading Indicator */}
227
+ {isLoading && <Loader displaytext={true} />}
228
+ </View>
229
+ </TouchableWithoutFeedback>
230
+ </View>
231
+ );
232
+ }
233
+
234
+ export default Login;
235
+
236
+ const styles = StyleSheet.create({
237
+ container: {
238
+ flex: 1,
239
+ },
240
+ contentContainer: {
241
+ flex: 1,
242
+ marginBottom: Platform.OS !== 'web' ? normalize(100) : normalize(50),
243
+ },
244
+ titleText: {
245
+ position: 'absolute',
246
+ top: Dimensions.get('screen').height * 0.05,
247
+ alignSelf: 'center',
248
+ color: '#fff',
249
+ zIndex: 1,
250
+ elevation: 5,
251
+ fontWeight: 'bold',
252
+ fontSize: normalize(40),
253
+ },
254
+ headerImage: {
255
+ height: Dimensions.get('screen').height * 0.25,
256
+ width: '100%',
257
+ opacity: 0.7,
258
+ },
259
+ customerServiceButton: {
260
+ position: 'absolute',
261
+ top: normalize(60),
262
+ right: normalize(20),
263
+ backgroundColor: Global.AppTheme.primary_color,
264
+ padding: normalize(5),
265
+ borderRadius: 1000,
266
+ },
267
+ bottomView: {
268
+ backgroundColor: '#fff',
269
+ opacity: 0.95,
270
+ marginTop: normalize(-50),
271
+ borderRadius: normalize(20),
272
+ marginHorizontal: normalize(7),
273
+ paddingHorizontal: normalize(15),
274
+ },
275
+ companyLogoSection: {
276
+ position: Platform.OS !== 'web' ? 'absolute' : undefined,
277
+ bottom: normalize(50),
278
+ backgroundColor: '#fff',
279
+ },
280
+ footer_container: {
281
+ marginBottom: '1%',
282
+ alignItems: 'center',
283
+ width: '100%',
284
+ },
285
+ companyinfo_container: {
286
+ flexDirection: 'row',
287
+ height: normalize(45),
288
+ width: '100%',
289
+ justifyContent: 'flex-start',
290
+ alignItems: 'flex-start',
291
+ },
292
+ companyLogo: {
293
+ width: '47%',
294
+ height: '100%',
295
+ borderRadius: 0,
296
+ margin: 5,
297
+ resizeMode: 'cover',
298
+ },
299
+ company_icon: {
300
+ width: '47%',
301
+ height: '100%',
302
+ borderRadius: 0,
303
+ margin: 5,
304
+ resizeMode: 'contain',
305
+ },
306
+ versionContainer: {
307
+ position: 'absolute',
308
+ bottom: 0,
309
+ zIndex: 1,
310
+ alignSelf: 'center',
311
+ },
312
+ versionText: {
313
+ color: Global.AppTheme.secondary_color,
314
+ fontSize: normalize(10),
315
+ alignSelf: 'center',
316
+ fontWeight: 'bold',
317
+ },
318
+ footerIconsContainer: {
319
+ position: 'absolute',
320
+ bottom: 0,
321
+ backgroundColor: '#fff',
322
+ width: '100%',
323
+ height: normalize(45),
324
+ justifyContent: 'center',
325
+ },
326
+ footerIconsRow: {
327
+ flexDirection: 'row',
328
+ justifyContent: 'space-between',
329
+ paddingHorizontal: normalize(15),
330
+ },
331
+ });