@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.
@@ -1,342 +0,0 @@
1
- import React, { useState, useEffect } from 'react';
2
- import {
3
- View,
4
- Text,
5
- StatusBar,
6
- Dimensions,
7
- ImageBackground,
8
- TouchableOpacity,
9
- TouchableHighlight,
10
- TextInput,
11
- } from 'react-native';
12
-
13
- import { APIURL } from '../../../../../src/Common/apiConstants';
14
- import { Global } from '../../../../../src/Common/Global';
15
- import axios from 'axios';
16
- import { HIcons, normalize, getLoading, NetworkServiceCall, notifyMessage, ValueCheck, Loader } from '@jescon-technologies/react-native-ui-kit';
17
-
18
- const image = {
19
- uri: 'https://t4.ftcdn.net/jpg/05/19/65/81/360_F_519658132_FkvYwAjuJ8q67PGQUgYLrumVymaJtlZj.jpg',
20
- };
21
-
22
- /* ---------------- CUSTOM INPUT ---------------- */
23
- const CustomInput = ({
24
- value,
25
- onChangeText,
26
- placeholder,
27
- secureTextEntry,
28
- keyboardType,
29
- autoFocus,
30
- leftIcon,
31
- rightIcon,
32
- onRightIconPress,
33
- onEndEditing,
34
- style,
35
- }) => {
36
- return (
37
- <View
38
- style={[
39
- {
40
- width: Dimensions.get('screen').width * 0.9,
41
- borderWidth: 1,
42
- borderColor: '#aaa',
43
- borderRadius: 6,
44
- flexDirection: 'row',
45
- alignItems: 'center',
46
- paddingHorizontal: 10,
47
- backgroundColor: '#fff',
48
- height: normalize(45),
49
- },
50
- style,
51
- ]}
52
- >
53
- {leftIcon && <View style={{ marginRight: 8 }}>{leftIcon}</View>}
54
-
55
- <TextInput
56
- style={{ flex: 1, color: '#000' }}
57
- placeholder={placeholder}
58
- placeholderTextColor="#777"
59
- value={value}
60
- onChangeText={onChangeText}
61
- secureTextEntry={secureTextEntry}
62
- keyboardType={keyboardType}
63
- autoFocus={autoFocus}
64
- onEndEditing={onEndEditing}
65
- />
66
-
67
- {rightIcon && (
68
- <TouchableOpacity onPress={onRightIconPress}>
69
- {rightIcon}
70
- </TouchableOpacity>
71
- )}
72
- </View>
73
- );
74
- };
75
-
76
- /* ---------------- MAIN COMPONENT ---------------- */
77
- export default function ForgotPassword({ navigation }) {
78
- const [stage, setStage] = useState(1);
79
- const [text, setText] = useState('');
80
- const [msg, setMsg] = useState('');
81
- const [isLoading, setIsLoading] = useState(false);
82
-
83
- const [password, setPassword] = useState({
84
- oldpass: '',
85
- newpass: '',
86
- confirmpass: '',
87
- });
88
-
89
- const [isPasswordSecure, setIsPasswordSecure] = useState(true);
90
- const [isPasswordSecureTwo, setIsPasswordSecureTwo] = useState(true);
91
-
92
- useEffect(() => {
93
- setPassword({ oldpass: '', newpass: '', confirmpass: '' });
94
- setMsg('');
95
- }, [stage]);
96
-
97
- /* ---------------- AUTH JWT ---------------- */
98
- function actionJWT() {
99
- if (password.oldpass && text) {
100
- let buttonapi = APIURL + 'auth/authenticate';
101
- let PostArr = {
102
- username: text,
103
- password: password.oldpass,
104
- };
105
-
106
- axios
107
- .post(buttonapi, PostArr)
108
- .then(res => {
109
- if (res.status === 200) {
110
- Global.JWTToken = res.data;
111
- } else {
112
- notifyMessage('Please check old password', 2);
113
- }
114
- })
115
- .catch(() => notifyMessage('Authentication failed', 3));
116
- }
117
- }
118
-
119
- /* ---------------- UPDATE PASSWORD ---------------- */
120
- function getUpdate() {
121
- if (!password.newpass || !password.confirmpass) {
122
- notifyMessage('Please fill out passwords', 3);
123
- return;
124
- }
125
-
126
- if (password.newpass !== password.confirmpass) {
127
- notifyMessage('Passwords do not match', 4);
128
- return;
129
- }
130
-
131
- const ReqJson = {
132
- groups: {
133
- procedurename: 'suuserforgetpassword1',
134
- userid: text,
135
- ...password,
136
- },
137
- };
138
-
139
- let buttonapi = APIURL + 'commontemplatesave/RnCommonTemplateSave';
140
- setIsLoading(true);
141
-
142
- NetworkServiceCall('post', buttonapi, ReqJson, Global.JWTToken).then(res => {
143
- if (res?.httpstatus === 200 && res?.data?.code > 0) {
144
- notifyMessage('Password Updated !!!', 1);
145
- setStage(3);
146
- } else {
147
- notifyMessage('Password Not Updated', 2);
148
- }
149
- setIsLoading(false);
150
- });
151
-
152
- getLoading(() => setIsLoading(false));
153
- }
154
-
155
- /* ---------------- PASSWORD STRENGTH ---------------- */
156
- function checkPasswordStrength(pass) {
157
- let strength = 0;
158
- let tips = '';
159
-
160
- if (pass.length >= 8) { strength++; }
161
- else { tips += 'Minimum 8 characters. '; }
162
-
163
- if (/[a-z]/.test(pass) && /[A-Z]/.test(pass)) { strength++; }
164
- else { tips += 'Use upper & lower case. '; }
165
-
166
- if (/\d/.test(pass)) { strength++; }
167
- else { tips += 'Add a number. '; }
168
-
169
- if (/[^a-zA-Z\d]/.test(pass)) { strength++; }
170
- else { tips += 'Add a special character. '; }
171
-
172
- if (strength < 2) { setMsg('Easy'); }
173
- else if (strength === 2) { setMsg('Medium'); }
174
- else if (strength === 3) { setMsg('Strong'); }
175
- else { setMsg('Very Strong'); }
176
-
177
- tips && notifyMessage(tips, 5);
178
- }
179
-
180
- /* ---------------- UI ---------------- */
181
- return (
182
- <View style={{ flex: 1, marginTop: StatusBar.currentHeight }}>
183
- <StatusBar translucent backgroundColor="transparent" barStyle="dark-content" />
184
-
185
- <ImageBackground source={image} style={{ flex: 1 }}>
186
- <TouchableOpacity
187
- style={{ padding: 20 }}
188
- onPress={() => (stage === 1 ? navigation.goBack() : setStage(stage - 1))}
189
- >
190
- <HIcons.FontAwesome5 name="arrow-left" size={normalize(20)} />
191
- </TouchableOpacity>
192
-
193
- {/* -------- STAGE 1 -------- */}
194
- {stage === 1 && (
195
- <View style={{ alignItems: 'center' }}>
196
- <HIcons.FontAwesome5 name="lock" size={normalize(50)} />
197
- <Text style={{ fontSize: normalize(24), fontWeight: 'bold' }}>
198
- CHANGE PASSWORD
199
- </Text>
200
-
201
- <CustomInput
202
- placeholder="Enter User ID"
203
- keyboardType="numeric"
204
- value={text}
205
- autoFocus
206
- onChangeText={setText}
207
- leftIcon={
208
- <HIcons.MaterialCommunityIcons
209
- name="clock-time-five-outline"
210
- size={normalize(20)}
211
- color="purple"
212
- />
213
- }
214
- style={{ marginTop: normalize(20) }}
215
- />
216
-
217
- <TouchableHighlight
218
- onPress={() =>
219
- ValueCheck(text)
220
- ? setStage(2)
221
- : notifyMessage('Enter User ID', 3)
222
- }
223
- style={{
224
- marginTop: normalize(15),
225
- width: Dimensions.get('screen').width * 0.9,
226
- height: normalize(40),
227
- backgroundColor: '#FADF00',
228
- alignItems: 'center',
229
- justifyContent: 'center',
230
- }}
231
- >
232
- <Text style={{ fontWeight: 'bold' }}>NEXT</Text>
233
- </TouchableHighlight>
234
- </View>
235
- )}
236
-
237
- {/* -------- STAGE 2 -------- */}
238
- {stage === 2 && (
239
- <View style={{ alignItems: 'center' }}>
240
- <Text style={{ fontWeight: 'bold', fontSize: normalize(18) }}>
241
- New Credentials
242
- </Text>
243
-
244
- <CustomInput
245
- placeholder="Old Password"
246
- secureTextEntry={isPasswordSecure}
247
- value={password.oldpass}
248
- onChangeText={t => setPassword({ ...password, oldpass: t })}
249
- onEndEditing={actionJWT}
250
- leftIcon={<HIcons.FontAwesome5 name="lock" size={18} />}
251
- rightIcon={
252
- <HIcons.FontAwesome5
253
- name={isPasswordSecure ? 'eye-slash' : 'eye'}
254
- size={18}
255
- />
256
- }
257
- onRightIconPress={() => setIsPasswordSecure(!isPasswordSecure)}
258
- style={{ marginTop: normalize(15) }}
259
- />
260
-
261
- <Text style={{ alignSelf: 'flex-end', color: 'red' }}>{msg}</Text>
262
-
263
- <CustomInput
264
- placeholder="New Password"
265
- secureTextEntry={isPasswordSecure}
266
- value={password.newpass}
267
- onChangeText={t => setPassword({ ...password, newpass: t })}
268
- onEndEditing={() => checkPasswordStrength(password.newpass)}
269
- leftIcon={<HIcons.FontAwesome5 name="lock" size={18} />}
270
- rightIcon={
271
- <HIcons.FontAwesome5
272
- name={isPasswordSecure ? 'eye-slash' : 'eye'}
273
- size={18}
274
- />
275
- }
276
- onRightIconPress={() => setIsPasswordSecure(!isPasswordSecure)}
277
- style={{ marginTop: normalize(15) }}
278
- />
279
-
280
- <CustomInput
281
- placeholder="Confirm Password"
282
- secureTextEntry={isPasswordSecureTwo}
283
- value={password.confirmpass}
284
- onChangeText={t => setPassword({ ...password, confirmpass: t })}
285
- leftIcon={<HIcons.FontAwesome5 name="lock" size={18} />}
286
- rightIcon={
287
- <HIcons.FontAwesome5
288
- name={isPasswordSecureTwo ? 'eye-slash' : 'eye'}
289
- size={18}
290
- />
291
- }
292
- onRightIconPress={() =>
293
- setIsPasswordSecureTwo(!isPasswordSecureTwo)
294
- }
295
- style={{ marginTop: normalize(15) }}
296
- />
297
-
298
- <TouchableHighlight
299
- onPress={getUpdate}
300
- style={{
301
- marginTop: normalize(15),
302
- width: Dimensions.get('screen').width * 0.9,
303
- height: normalize(40),
304
- backgroundColor: '#FADF00',
305
- alignItems: 'center',
306
- justifyContent: 'center',
307
- }}
308
- >
309
- <Text style={{ fontWeight: 'bold' }}>UPDATE</Text>
310
- </TouchableHighlight>
311
- </View>
312
- )}
313
-
314
- {/* -------- STAGE 3 -------- */}
315
- {stage === 3 && (
316
- <View style={{ alignItems: 'center' }}>
317
- <HIcons.EvilIcons name="check" size={normalize(100)} color="green" />
318
- <Text style={{ color: 'green', fontWeight: 'bold' }}>
319
- Password Updated
320
- </Text>
321
-
322
- <TouchableHighlight
323
- onPress={() => navigation.goBack()}
324
- style={{
325
- marginTop: normalize(15),
326
- width: Dimensions.get('screen').width * 0.9,
327
- height: normalize(40),
328
- backgroundColor: '#FADF00',
329
- alignItems: 'center',
330
- justifyContent: 'center',
331
- }}
332
- >
333
- <Text style={{ fontWeight: 'bold' }}>LOGIN</Text>
334
- </TouchableHighlight>
335
- </View>
336
- )}
337
- </ImageBackground>
338
-
339
- {isLoading && <Loader displaytext />}
340
- </View>
341
- );
342
- }
@@ -1,331 +0,0 @@
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
- });