@jescon-technologies/react-native-ui-kit 0.0.12 → 0.0.13
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/index.d.ts +5 -1
- package/index.js +5 -1
- package/package.json +1 -1
- package/src/Layout/LoginLayout.tsx +711 -0
- package/src/Screens/ForgotPassword.tsx +342 -0
- package/src/Screens/Login.tsx +331 -0
- package/src/Screens/Splash.tsx +782 -0
|
@@ -0,0 +1,782 @@
|
|
|
1
|
+
import React, { useContext, useEffect, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
StatusBar,
|
|
5
|
+
Text,
|
|
6
|
+
Image,
|
|
7
|
+
TouchableOpacity,
|
|
8
|
+
KeyboardAvoidingView,
|
|
9
|
+
BackHandler,
|
|
10
|
+
Modal,
|
|
11
|
+
Dimensions,
|
|
12
|
+
Platform,
|
|
13
|
+
StyleSheet,
|
|
14
|
+
} from 'react-native';
|
|
15
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
16
|
+
import RNExitApp from 'react-native-exit-app';
|
|
17
|
+
import RNFS from 'react-native-fs';
|
|
18
|
+
import { Global } from '../../../../../src/Common/Global';
|
|
19
|
+
import { APIURL } from '../../../../../src/Common/apiConstants';
|
|
20
|
+
import ApkInstaller from 'react-native-installer';
|
|
21
|
+
import { HIcons, useNavigation, NetworkServiceCall, CBackHandler, normalize, isNU, isNUQ, notifyMessage } from '@jescon-technologies/react-native-ui-kit';
|
|
22
|
+
// Type definitions
|
|
23
|
+
interface ThemeColor {
|
|
24
|
+
primary_color: string;
|
|
25
|
+
secondary_color: string;
|
|
26
|
+
text_color: string;
|
|
27
|
+
heading_text_color: string;
|
|
28
|
+
bg_button: string;
|
|
29
|
+
icon_color: string;
|
|
30
|
+
selected_color: string;
|
|
31
|
+
blur_color: string;
|
|
32
|
+
error_color: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface HospitalData {
|
|
36
|
+
APIP: string;
|
|
37
|
+
PortNumber: string;
|
|
38
|
+
ApiLink: string;
|
|
39
|
+
ApiVersion: string;
|
|
40
|
+
ValidationStatus: boolean;
|
|
41
|
+
hospitalInfo?: any;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface InstallationData {
|
|
45
|
+
key: string;
|
|
46
|
+
hospitaldata: HospitalData;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface VersionCheckResponse {
|
|
50
|
+
version: string;
|
|
51
|
+
bundleUrl: string;
|
|
52
|
+
apkUrl?: string;
|
|
53
|
+
descriptions: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface NetworkResponse {
|
|
57
|
+
httpstatus: number;
|
|
58
|
+
data?: any;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
interface ValidationResponse {
|
|
62
|
+
ValidationStatus: boolean;
|
|
63
|
+
hospitalInfo?: any;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
interface SplashProps {
|
|
67
|
+
// Add any props if needed, otherwise empty
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const ThemeColors: ThemeColor[] = [
|
|
71
|
+
{
|
|
72
|
+
primary_color: '#094485',
|
|
73
|
+
secondary_color: 'black',
|
|
74
|
+
text_color: '#fff',
|
|
75
|
+
heading_text_color: 'darkblue',
|
|
76
|
+
bg_button: '#fff',
|
|
77
|
+
icon_color: 'darkblue',
|
|
78
|
+
selected_color: '#d7ffbc',
|
|
79
|
+
blur_color: 'rgba(255,255,255,0.6)',
|
|
80
|
+
error_color: '#D32F2F',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
primary_color: 'black',
|
|
84
|
+
secondary_color: 'black',
|
|
85
|
+
text_color: '#fff',
|
|
86
|
+
heading_text_color: 'black',
|
|
87
|
+
bg_button: 'black',
|
|
88
|
+
icon_color: '#fff',
|
|
89
|
+
selected_color: '#d7ffbc',
|
|
90
|
+
blur_color: 'rgba(255,255,255,0.6)',
|
|
91
|
+
error_color: '#D32F2F',
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
primary_color: '#00008B',
|
|
95
|
+
secondary_color: 'black',
|
|
96
|
+
text_color: '#fff',
|
|
97
|
+
heading_text_color: '#00008B',
|
|
98
|
+
bg_button: '#fff',
|
|
99
|
+
icon_color: '#00008B',
|
|
100
|
+
selected_color: '#d7ffbc',
|
|
101
|
+
blur_color: 'rgba(255,255,255,0.6)',
|
|
102
|
+
error_color: '#D32F2F',
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
primary_color: '#e54495',
|
|
106
|
+
secondary_color: 'black',
|
|
107
|
+
text_color: '#fff',
|
|
108
|
+
heading_text_color: '#fc5dac',
|
|
109
|
+
bg_button: '#fff',
|
|
110
|
+
icon_color: '#fc5dac',
|
|
111
|
+
selected_color: '#d7ffbc',
|
|
112
|
+
blur_color: 'rgba(255,255,255,0.6)',
|
|
113
|
+
error_color: '#D32F2F',
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
primary_color: 'purple',
|
|
117
|
+
secondary_color: 'purple',
|
|
118
|
+
text_color: '#fff',
|
|
119
|
+
heading_text_color: 'purple',
|
|
120
|
+
bg_button: 'purple',
|
|
121
|
+
icon_color: '#fff',
|
|
122
|
+
selected_color: '#d7ffbc',
|
|
123
|
+
blur_color: 'rgba(255,255,255,0.6)',
|
|
124
|
+
error_color: '#D32F2F',
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
primary_color: '#0d910d',
|
|
128
|
+
secondary_color: '#0d910d',
|
|
129
|
+
text_color: '#fff',
|
|
130
|
+
heading_text_color: '#0d910d',
|
|
131
|
+
bg_button: '#fff',
|
|
132
|
+
icon_color: '#fff',
|
|
133
|
+
selected_color: '#d7ffbc',
|
|
134
|
+
blur_color: 'rgba(255,255,255,0.6)',
|
|
135
|
+
error_color: '#D32F2F',
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
primary_color: '#f70404',
|
|
139
|
+
secondary_color: '#f70404',
|
|
140
|
+
text_color: '#fff',
|
|
141
|
+
heading_text_color: '#f70404',
|
|
142
|
+
bg_button: '#fff',
|
|
143
|
+
icon_color: '#fff',
|
|
144
|
+
selected_color: '#d7ffbc',
|
|
145
|
+
blur_color: 'rgba(255,255,255,0.6)',
|
|
146
|
+
error_color: '#D32F2F',
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
primary_color: '#3489a8',
|
|
150
|
+
secondary_color: '#3489a8',
|
|
151
|
+
text_color: '#fff',
|
|
152
|
+
heading_text_color: '#3489a8',
|
|
153
|
+
bg_button: '#fff',
|
|
154
|
+
icon_color: '#fff',
|
|
155
|
+
selected_color: '#d7ffbc',
|
|
156
|
+
blur_color: 'rgba(255,255,255,0.6)',
|
|
157
|
+
error_color: '#D32F2F',
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
primary_color: 'grey',
|
|
161
|
+
secondary_color: 'grey',
|
|
162
|
+
text_color: '#fff',
|
|
163
|
+
heading_text_color: 'grey',
|
|
164
|
+
bg_button: '#fff',
|
|
165
|
+
icon_color: '#fff',
|
|
166
|
+
selected_color: '#d7ffbc',
|
|
167
|
+
blur_color: 'rgba(255,255,255,0.6)',
|
|
168
|
+
error_color: '#D32F2F',
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
primary_color: '#bab10e',
|
|
172
|
+
secondary_color: '#bab10e',
|
|
173
|
+
text_color: '#fff',
|
|
174
|
+
heading_text_color: '#bab10e',
|
|
175
|
+
bg_button: '#fff',
|
|
176
|
+
icon_color: '#fff',
|
|
177
|
+
selected_color: '#d7ffbc',
|
|
178
|
+
blur_color: 'rgba(255,255,255,0.6)',
|
|
179
|
+
error_color: '#D32F2F',
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
primary_color: '#9e331e',
|
|
183
|
+
secondary_color: '#9e331e',
|
|
184
|
+
text_color: '#fff',
|
|
185
|
+
heading_text_color: '#9e331e',
|
|
186
|
+
bg_button: '#fff',
|
|
187
|
+
icon_color: '#fff',
|
|
188
|
+
selected_color: '#d7ffbc',
|
|
189
|
+
blur_color: 'rgba(255,255,255,0.6)',
|
|
190
|
+
error_color: '#D32F2F',
|
|
191
|
+
},
|
|
192
|
+
];
|
|
193
|
+
|
|
194
|
+
export default function Splash(props: SplashProps): React.JSX.Element {
|
|
195
|
+
const [loading, setLoading] = useState<boolean>(false);
|
|
196
|
+
const [backHandler, setBackHandler] = useState<boolean>(false);
|
|
197
|
+
const [refresh, setRefresh] = useState<number>(0);
|
|
198
|
+
const [progress, setProgress] = useState<number | null>(null);
|
|
199
|
+
const [isLoading, setIsLoading] = useState<boolean>(false);
|
|
200
|
+
const [showText, setShowText] = useState<string | undefined>();
|
|
201
|
+
const [updateVersion, setUpdateVersion] = useState<string | undefined>();
|
|
202
|
+
const [retry, setRetry] = useState<boolean>(false);
|
|
203
|
+
const navigation = useNavigation();
|
|
204
|
+
|
|
205
|
+
useEffect((): void => {
|
|
206
|
+
if (process.env.NODE_ENV === 'development') {
|
|
207
|
+
getData();
|
|
208
|
+
} else {
|
|
209
|
+
if (Platform.OS === 'android') {
|
|
210
|
+
getApiVersionCheck();
|
|
211
|
+
} else if (Platform.OS === 'web') {
|
|
212
|
+
// Electron production logic
|
|
213
|
+
getData();
|
|
214
|
+
} else {
|
|
215
|
+
// Web / iOS production
|
|
216
|
+
getData();
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}, []);
|
|
220
|
+
|
|
221
|
+
useEffect((): (() => void) | void => {
|
|
222
|
+
if (Platform.OS === 'web') return;
|
|
223
|
+
|
|
224
|
+
const backAction = (): boolean => {
|
|
225
|
+
RNExitApp.exitApp();
|
|
226
|
+
return true;
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
const backHandler = BackHandler.addEventListener('hardwareBackPress', backAction);
|
|
230
|
+
return () => backHandler.remove();
|
|
231
|
+
}, []);
|
|
232
|
+
|
|
233
|
+
const isValidUrl = (string: string): boolean => {
|
|
234
|
+
try {
|
|
235
|
+
new URL(string);
|
|
236
|
+
return true;
|
|
237
|
+
} catch (err) {
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
const goBackFunction = (showText: string | undefined, retry: boolean, isLoading: boolean): void => {
|
|
243
|
+
if (isNU(showText) && !retry && isLoading) {
|
|
244
|
+
RNExitApp.exitApp();
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
const getApiVersionCheck = (): void => {
|
|
249
|
+
setIsLoading(true);
|
|
250
|
+
setShowText(undefined);
|
|
251
|
+
setUpdateVersion(undefined);
|
|
252
|
+
setRetry(false);
|
|
253
|
+
setProgress(null);
|
|
254
|
+
|
|
255
|
+
const buttonapi = APIURL + 'invget/invcommonget/rnbundleversioncheck ' + Global.hospitalcode;
|
|
256
|
+
console.log('getApiVersionCheck buttonapi ', JSON.stringify(buttonapi));
|
|
257
|
+
|
|
258
|
+
NetworkServiceCall('get', buttonapi).then(function (response: NetworkResponse): void {
|
|
259
|
+
if (
|
|
260
|
+
response.httpstatus === 200 &&
|
|
261
|
+
isNU(response.data) &&
|
|
262
|
+
isNUQ(response.data.version) &&
|
|
263
|
+
isNUQ(response.data.bundleUrl) &&
|
|
264
|
+
isValidUrl(response.data.bundleUrl) &&
|
|
265
|
+
isNU(response.data.descriptions)
|
|
266
|
+
) {
|
|
267
|
+
if (Global.version === response.data.version) {
|
|
268
|
+
getData();
|
|
269
|
+
} else {
|
|
270
|
+
setUpdateVersion(response.data.version);
|
|
271
|
+
downloadBundleWithProgress(
|
|
272
|
+
(p: number) => setProgress(p),
|
|
273
|
+
response.data.apkUrl,
|
|
274
|
+
response.data.version,
|
|
275
|
+
response.data.descriptions,
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
} else {
|
|
279
|
+
setIsLoading(false);
|
|
280
|
+
setRetry(true);
|
|
281
|
+
notifyMessage('Network Error.Please try again.', 2);
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
const downloadBundleWithProgress = async (
|
|
287
|
+
onProgressUpdate: (percentage: number) => void,
|
|
288
|
+
url: string,
|
|
289
|
+
newversion: string,
|
|
290
|
+
desc: string
|
|
291
|
+
): Promise<boolean> => {
|
|
292
|
+
return new Promise((resolve, reject) => {
|
|
293
|
+
const downloadDest = `${RNFS.ExternalDirectoryPath}/update.apk`;
|
|
294
|
+
const download = RNFS.downloadFile({
|
|
295
|
+
fromUrl: url,
|
|
296
|
+
toFile: downloadDest,
|
|
297
|
+
progressInterval: 500,
|
|
298
|
+
progress: (res: RNFS.DownloadProgressCallbackResult) => {
|
|
299
|
+
const percentage = Math.floor((res.bytesWritten / res.contentLength) * 100);
|
|
300
|
+
console.log(`[OTA] Download progress: ${percentage}%`);
|
|
301
|
+
onProgressUpdate?.(percentage);
|
|
302
|
+
},
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
download.promise
|
|
306
|
+
.then(async (res: RNFS.DownloadResult): Promise<void> => {
|
|
307
|
+
console.log('[OTA] Download complete! Moving file...');
|
|
308
|
+
try {
|
|
309
|
+
ApkInstaller.install(downloadDest);
|
|
310
|
+
console.log('[OTA] File moved to final destination!');
|
|
311
|
+
setShowText(desc);
|
|
312
|
+
resolve(true);
|
|
313
|
+
RNExitApp.exitApp();
|
|
314
|
+
} catch (moveErr: any) {
|
|
315
|
+
console.warn('[OTA] Failed to move file:', moveErr.message);
|
|
316
|
+
reject(moveErr);
|
|
317
|
+
setRetry(true);
|
|
318
|
+
}
|
|
319
|
+
})
|
|
320
|
+
.catch((err: Error): void => {
|
|
321
|
+
console.warn('[OTA] Download failed:', err.message);
|
|
322
|
+
reject(err);
|
|
323
|
+
setRetry(true);
|
|
324
|
+
});
|
|
325
|
+
});
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
const removeValue = async (): Promise<void> => {
|
|
329
|
+
try {
|
|
330
|
+
await AsyncStorage.removeItem(Global.asyncStorageAppKey);
|
|
331
|
+
} catch (e) {
|
|
332
|
+
// remove error
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
const getLoginPageData = (object: HospitalData, key: string): void => {
|
|
337
|
+
setLoading(true);
|
|
338
|
+
let buttonapi = 'http://' + object.APIP + ':' + object.PortNumber + '/' + object.ApiLink + " '" + 'His@amala' + "'," + object.ApiVersion;
|
|
339
|
+
console.log('getLoginPageData buttonpai ', JSON.stringify(buttonapi));
|
|
340
|
+
NetworkServiceCall('get', buttonapi, '').then(function (response: NetworkResponse): void {
|
|
341
|
+
console.log('Response ', JSON.stringify(response));
|
|
342
|
+
if (response.httpstatus === 200) {
|
|
343
|
+
if (object.ValidationStatus === true) {
|
|
344
|
+
Global.HospitalData = response.data.hospitalInfo;
|
|
345
|
+
Global.InstallationKey = key;
|
|
346
|
+
navigation.navigate('Login', { data: response.data });
|
|
347
|
+
setLoading(false);
|
|
348
|
+
} else {
|
|
349
|
+
setBackHandler(false);
|
|
350
|
+
notifyMessage('Install validation failed...', 3);
|
|
351
|
+
setLoading(false);
|
|
352
|
+
}
|
|
353
|
+
} else {
|
|
354
|
+
setBackHandler(false);
|
|
355
|
+
notifyMessage('Network Error... ', 4);
|
|
356
|
+
setLoading(false);
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
const getValidation = (otp: string): void => {
|
|
362
|
+
const buttonapi = 'http://his.amalaims.org:9090/hislicensevalidation/licensedata/licensevalidation\'his@amala\'';
|
|
363
|
+
console.log('getValidation buttonapi', buttonapi);
|
|
364
|
+
|
|
365
|
+
setLoading(true);
|
|
366
|
+
NetworkServiceCall('get', buttonapi, '').then(function (response: NetworkResponse): void {
|
|
367
|
+
console.log('getValidation response @@@@@@@@@@@', JSON.stringify(response));
|
|
368
|
+
|
|
369
|
+
if (response.httpstatus === 200) {
|
|
370
|
+
if (response.data?.ValidationStatus === true) {
|
|
371
|
+
setBackHandler(false);
|
|
372
|
+
storeData(otp, response.data);
|
|
373
|
+
getLoginPageData(response.data, otp);
|
|
374
|
+
} else {
|
|
375
|
+
setLoading(false);
|
|
376
|
+
setBackHandler(false);
|
|
377
|
+
notifyMessage('Validation Failed...Please enter right key', 3);
|
|
378
|
+
}
|
|
379
|
+
} else {
|
|
380
|
+
setLoading(false);
|
|
381
|
+
notifyMessage('Network Error... ', 4);
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
const storeData = async (value: string, response: HospitalData): Promise<void> => {
|
|
387
|
+
try {
|
|
388
|
+
const newValue: InstallationData = {
|
|
389
|
+
key: value,
|
|
390
|
+
hospitaldata: response,
|
|
391
|
+
};
|
|
392
|
+
const jsonValue = JSON.stringify(newValue);
|
|
393
|
+
await AsyncStorage.setItem(Global.asyncStorageAppKey, jsonValue);
|
|
394
|
+
} catch (e) {
|
|
395
|
+
// saving error
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
const setTheme = async (item: ThemeColor): Promise<void> => {
|
|
400
|
+
try {
|
|
401
|
+
const jsonValue = JSON.stringify(item);
|
|
402
|
+
await AsyncStorage.setItem(Global.asyncStorageThemeKey, jsonValue);
|
|
403
|
+
Global.AppTheme = item;
|
|
404
|
+
setRefresh(refresh + 1);
|
|
405
|
+
} catch (e) {
|
|
406
|
+
// saving error
|
|
407
|
+
}
|
|
408
|
+
removeValue();
|
|
409
|
+
setBackHandler(false);
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
const getStorageItem = async (key: string): Promise<string | null> => {
|
|
413
|
+
if (Platform.OS === 'web' || Platform.OS === 'windows' || Platform.OS === 'macos') {
|
|
414
|
+
// Check if we're in Electron
|
|
415
|
+
if (window && window.process && window.process.type === 'renderer') {
|
|
416
|
+
// For Electron renderer process
|
|
417
|
+
console.log('Getting from localStorage for key (Electron):', key);
|
|
418
|
+
return localStorage.getItem(key);
|
|
419
|
+
}
|
|
420
|
+
return localStorage.getItem(key);
|
|
421
|
+
} else {
|
|
422
|
+
const AsyncStorageModule = require('@react-native-async-storage/async-storage').default;
|
|
423
|
+
return await AsyncStorageModule.getItem(key);
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
const getData = async (): Promise<void> => {
|
|
428
|
+
try {
|
|
429
|
+
const jsonValue = await getStorageItem(Global.asyncStorageAppKey);
|
|
430
|
+
console.log('Retrieved value:', jsonValue);
|
|
431
|
+
|
|
432
|
+
if (!jsonValue) {
|
|
433
|
+
return getValidation(Global.preinstallationkey);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
const InstallationData: InstallationData = JSON.parse(jsonValue);
|
|
437
|
+
console.log('installation', JSON.stringify(InstallationData));
|
|
438
|
+
|
|
439
|
+
setBackHandler(false);
|
|
440
|
+
return getLoginPageData(InstallationData.hospitaldata, InstallationData.key);
|
|
441
|
+
} catch (e) {
|
|
442
|
+
console.error('Error in getData:', e);
|
|
443
|
+
return getValidation(Global.preinstallationkey);
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
const renderUpdateModal = (): React.JSX.Element => (
|
|
448
|
+
<Modal
|
|
449
|
+
animationType="none"
|
|
450
|
+
transparent={true}
|
|
451
|
+
visible={isLoading}
|
|
452
|
+
onRequestClose={() => goBackFunction(showText, retry, isLoading)}
|
|
453
|
+
style={styles.modal}
|
|
454
|
+
>
|
|
455
|
+
<View style={styles.modalContainer}>
|
|
456
|
+
<View style={styles.modalContent}>
|
|
457
|
+
{retry ? (
|
|
458
|
+
<View style={styles.retryContainer}>
|
|
459
|
+
<TouchableOpacity
|
|
460
|
+
onPress={getApiVersionCheck}
|
|
461
|
+
style={styles.retryButton}
|
|
462
|
+
>
|
|
463
|
+
<HIcons.MaterialCommunityIcons
|
|
464
|
+
name={'reload'}
|
|
465
|
+
color={'red'}
|
|
466
|
+
size={normalize(30)}
|
|
467
|
+
style={styles.retryIcon}
|
|
468
|
+
/>
|
|
469
|
+
<Text style={styles.retryText}>Retry</Text>
|
|
470
|
+
</TouchableOpacity>
|
|
471
|
+
</View>
|
|
472
|
+
) : (
|
|
473
|
+
<View style={styles.downloadContainer}>
|
|
474
|
+
{!showText && (
|
|
475
|
+
<Image
|
|
476
|
+
style={styles.downloadGif}
|
|
477
|
+
source={{ uri: APIURL + 'file/getCommonFile/image/transfer.gif' }}
|
|
478
|
+
/>
|
|
479
|
+
)}
|
|
480
|
+
{!showText && (
|
|
481
|
+
<Text style={styles.progressText}>
|
|
482
|
+
{isNU(progress) ? `${progress} % Downloading` : null}
|
|
483
|
+
</Text>
|
|
484
|
+
)}
|
|
485
|
+
{showText && (
|
|
486
|
+
<View style={styles.descriptionContainer}>
|
|
487
|
+
<Text style={styles.descriptionText}>
|
|
488
|
+
{showText}
|
|
489
|
+
</Text>
|
|
490
|
+
</View>
|
|
491
|
+
)}
|
|
492
|
+
{updateVersion && (
|
|
493
|
+
<Text style={styles.versionText}>
|
|
494
|
+
<Text style={styles.versionLabel}>Latest Version: </Text>
|
|
495
|
+
{updateVersion}
|
|
496
|
+
</Text>
|
|
497
|
+
)}
|
|
498
|
+
</View>
|
|
499
|
+
)}
|
|
500
|
+
{!showText && (
|
|
501
|
+
<View>
|
|
502
|
+
<Text style={styles.currentVersionText}>
|
|
503
|
+
<Text style={styles.versionLabel}>Current Version: </Text>
|
|
504
|
+
{Global.version}
|
|
505
|
+
</Text>
|
|
506
|
+
</View>
|
|
507
|
+
)}
|
|
508
|
+
</View>
|
|
509
|
+
</View>
|
|
510
|
+
</Modal>
|
|
511
|
+
);
|
|
512
|
+
|
|
513
|
+
const renderThemeSelector = (): React.JSX.Element => (
|
|
514
|
+
<View style={styles.themeContainer}>
|
|
515
|
+
<Text style={[styles.themeLabel, { color: Global.AppTheme.text_color }]}>
|
|
516
|
+
Choose Theme:
|
|
517
|
+
</Text>
|
|
518
|
+
<View style={styles.themeRow}>
|
|
519
|
+
{ThemeColors.map((item: ThemeColor, i: number) => (
|
|
520
|
+
<TouchableOpacity
|
|
521
|
+
key={i}
|
|
522
|
+
onPress={() => setTheme(item)}
|
|
523
|
+
style={styles.themeButton}
|
|
524
|
+
>
|
|
525
|
+
<HIcons.FontAwesome
|
|
526
|
+
name="circle"
|
|
527
|
+
color={item.primary_color}
|
|
528
|
+
size={normalize(20)}
|
|
529
|
+
/>
|
|
530
|
+
</TouchableOpacity>
|
|
531
|
+
))}
|
|
532
|
+
</View>
|
|
533
|
+
</View>
|
|
534
|
+
);
|
|
535
|
+
|
|
536
|
+
const renderSocialIcons = (): React.JSX.Element => (
|
|
537
|
+
<View style={styles.socialContainer}>
|
|
538
|
+
{(['facebook', 'web', 'linkedin'] as const).map((item, i: number) => (
|
|
539
|
+
<TouchableOpacity
|
|
540
|
+
key={i}
|
|
541
|
+
onPress={removeValue}
|
|
542
|
+
hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}
|
|
543
|
+
>
|
|
544
|
+
<HIcons.MaterialCommunityIcons
|
|
545
|
+
name={item}
|
|
546
|
+
color={Global.AppTheme.text_color}
|
|
547
|
+
size={normalize(15)}
|
|
548
|
+
/>
|
|
549
|
+
</TouchableOpacity>
|
|
550
|
+
))}
|
|
551
|
+
</View>
|
|
552
|
+
);
|
|
553
|
+
|
|
554
|
+
const renderAppLogo = (): React.JSX.Element => (
|
|
555
|
+
<TouchableOpacity onPress={() => setBackHandler(false)}>
|
|
556
|
+
<View style={styles.logoContainer}>
|
|
557
|
+
<Image
|
|
558
|
+
style={styles.logo}
|
|
559
|
+
source={require('../../../../../android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png')}
|
|
560
|
+
/>
|
|
561
|
+
<Text style={styles.appName}>
|
|
562
|
+
{Global.SplashHeading || 'HOMES'}
|
|
563
|
+
</Text>
|
|
564
|
+
</View>
|
|
565
|
+
</TouchableOpacity>
|
|
566
|
+
);
|
|
567
|
+
|
|
568
|
+
const renderCompanyInfo = (): React.JSX.Element => (
|
|
569
|
+
<View style={styles.companyContainer}>
|
|
570
|
+
<Text style={styles.fromText}>from,</Text>
|
|
571
|
+
<Text style={styles.companyName}>JESCON TECHNOLOGIES PVT LTD</Text>
|
|
572
|
+
|
|
573
|
+
{renderSocialIcons()}
|
|
574
|
+
|
|
575
|
+
{Platform.OS !== 'ios' && (
|
|
576
|
+
<View style={styles.versionContainer}>
|
|
577
|
+
<Text style={styles.codePushVersion}>
|
|
578
|
+
{Global.CodePushVersion}
|
|
579
|
+
</Text>
|
|
580
|
+
</View>
|
|
581
|
+
)}
|
|
582
|
+
|
|
583
|
+
<Text style={styles.versionText}>
|
|
584
|
+
{isNU(Global.version) ? `V ${Global.version}` : null}
|
|
585
|
+
</Text>
|
|
586
|
+
|
|
587
|
+
<TouchableOpacity
|
|
588
|
+
disabled={loading}
|
|
589
|
+
onPress={() => Platform.OS === 'android' ? getApiVersionCheck() : getData()}
|
|
590
|
+
style={styles.refreshButton}
|
|
591
|
+
>
|
|
592
|
+
<HIcons.FontAwesome name={'refresh'} color={'#fff'} size={normalize(25)} />
|
|
593
|
+
<Text style={styles.refreshText}>Refresh</Text>
|
|
594
|
+
</TouchableOpacity>
|
|
595
|
+
</View>
|
|
596
|
+
);
|
|
597
|
+
|
|
598
|
+
return (
|
|
599
|
+
<KeyboardAvoidingView
|
|
600
|
+
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
601
|
+
style={[styles.container, { backgroundColor: Global.AppTheme.primary_color }]}
|
|
602
|
+
>
|
|
603
|
+
<StatusBar
|
|
604
|
+
backgroundColor={Global.AppTheme.primary_color}
|
|
605
|
+
barStyle={Platform.OS === 'ios' ? 'dark-content' : 'light-content'}
|
|
606
|
+
/>
|
|
607
|
+
|
|
608
|
+
{isLoading && renderUpdateModal()}
|
|
609
|
+
|
|
610
|
+
{renderAppLogo()}
|
|
611
|
+
{renderCompanyInfo()}
|
|
612
|
+
{renderThemeSelector()}
|
|
613
|
+
|
|
614
|
+
{backHandler && (
|
|
615
|
+
<CBackHandler
|
|
616
|
+
type={1}
|
|
617
|
+
close={(val: boolean) => val && setBackHandler(val)}
|
|
618
|
+
callBack={(val: string) => val && getValidation(val)}
|
|
619
|
+
/>
|
|
620
|
+
)}
|
|
621
|
+
</KeyboardAvoidingView>
|
|
622
|
+
);
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
const styles = StyleSheet.create({
|
|
626
|
+
container: {
|
|
627
|
+
flex: 1,
|
|
628
|
+
alignItems: 'center',
|
|
629
|
+
justifyContent: 'center',
|
|
630
|
+
},
|
|
631
|
+
// Modal Styles
|
|
632
|
+
modal: {
|
|
633
|
+
alignSelf: 'center',
|
|
634
|
+
padding: 0,
|
|
635
|
+
},
|
|
636
|
+
modalContainer: {
|
|
637
|
+
height: Dimensions.get('window').height,
|
|
638
|
+
width: Dimensions.get('screen').width,
|
|
639
|
+
justifyContent: 'center',
|
|
640
|
+
alignItems: 'center',
|
|
641
|
+
paddingBottom: normalize(50),
|
|
642
|
+
},
|
|
643
|
+
modalContent: {
|
|
644
|
+
backgroundColor: 'white',
|
|
645
|
+
borderWidth: 1,
|
|
646
|
+
elevation: 5,
|
|
647
|
+
borderColor: 'grey',
|
|
648
|
+
borderRadius: 3,
|
|
649
|
+
alignItems: 'center',
|
|
650
|
+
alignSelf: 'center',
|
|
651
|
+
justifyContent: 'center',
|
|
652
|
+
height: Dimensions.get('screen').height * 0.2,
|
|
653
|
+
minWidth: Dimensions.get('screen').width * 0.8,
|
|
654
|
+
},
|
|
655
|
+
retryContainer: {
|
|
656
|
+
flex: 1,
|
|
657
|
+
justifyContent: 'center',
|
|
658
|
+
alignItems: 'center',
|
|
659
|
+
},
|
|
660
|
+
retryButton: {
|
|
661
|
+
justifyContent: 'center',
|
|
662
|
+
alignItems: 'center',
|
|
663
|
+
},
|
|
664
|
+
retryIcon: {
|
|
665
|
+
marginHorizontal: normalize(8),
|
|
666
|
+
},
|
|
667
|
+
retryText: {
|
|
668
|
+
fontSize: normalize(12),
|
|
669
|
+
fontWeight: 'bold',
|
|
670
|
+
color: 'red',
|
|
671
|
+
},
|
|
672
|
+
downloadContainer: {
|
|
673
|
+
flex: 1,
|
|
674
|
+
justifyContent: 'center',
|
|
675
|
+
alignItems: 'center',
|
|
676
|
+
},
|
|
677
|
+
downloadGif: {
|
|
678
|
+
width: normalize(150),
|
|
679
|
+
height: normalize(100),
|
|
680
|
+
},
|
|
681
|
+
progressText: {
|
|
682
|
+
color: 'black',
|
|
683
|
+
},
|
|
684
|
+
descriptionContainer: {
|
|
685
|
+
flex: 1,
|
|
686
|
+
justifyContent: 'center',
|
|
687
|
+
alignItems: 'center',
|
|
688
|
+
},
|
|
689
|
+
descriptionText: {
|
|
690
|
+
color: '#cf1818',
|
|
691
|
+
fontSize: normalize(12),
|
|
692
|
+
textAlign: 'center',
|
|
693
|
+
},
|
|
694
|
+
versionText: {
|
|
695
|
+
color: Global.AppTheme.primary_color,
|
|
696
|
+
fontSize: normalize(10),
|
|
697
|
+
},
|
|
698
|
+
currentVersionText: {
|
|
699
|
+
color: Global.AppTheme.primary_color,
|
|
700
|
+
fontSize: normalize(10),
|
|
701
|
+
},
|
|
702
|
+
versionLabel: {
|
|
703
|
+
color: 'black',
|
|
704
|
+
fontSize: normalize(10),
|
|
705
|
+
},
|
|
706
|
+
// Logo Styles
|
|
707
|
+
logoContainer: {
|
|
708
|
+
alignItems: 'center',
|
|
709
|
+
justifyContent: 'center',
|
|
710
|
+
},
|
|
711
|
+
logo: {
|
|
712
|
+
width: normalize(70),
|
|
713
|
+
height: normalize(70),
|
|
714
|
+
resizeMode: 'contain',
|
|
715
|
+
borderRadius: normalize(30),
|
|
716
|
+
},
|
|
717
|
+
appName: {
|
|
718
|
+
color: Global.AppTheme.text_color,
|
|
719
|
+
fontWeight: 'bold',
|
|
720
|
+
fontSize: normalize(25),
|
|
721
|
+
textAlign: 'center',
|
|
722
|
+
},
|
|
723
|
+
// Company Info Styles
|
|
724
|
+
companyContainer: {
|
|
725
|
+
paddingTop: normalize(40),
|
|
726
|
+
alignItems: 'center',
|
|
727
|
+
justifyContent: 'center',
|
|
728
|
+
},
|
|
729
|
+
fromText: {
|
|
730
|
+
color: Global.AppTheme.text_color,
|
|
731
|
+
paddingBottom: normalize(8),
|
|
732
|
+
},
|
|
733
|
+
companyName: {
|
|
734
|
+
color: Global.AppTheme.text_color,
|
|
735
|
+
fontWeight: 'bold',
|
|
736
|
+
fontSize: normalize(16),
|
|
737
|
+
},
|
|
738
|
+
versionContainer: {
|
|
739
|
+
alignItems: 'center',
|
|
740
|
+
},
|
|
741
|
+
codePushVersion: {
|
|
742
|
+
color: 'white',
|
|
743
|
+
fontSize: normalize(16),
|
|
744
|
+
paddingTop: normalize(20),
|
|
745
|
+
},
|
|
746
|
+
refreshButton: {
|
|
747
|
+
marginTop: normalize(20),
|
|
748
|
+
alignItems: 'center',
|
|
749
|
+
},
|
|
750
|
+
refreshText: {
|
|
751
|
+
color: '#fff',
|
|
752
|
+
fontSize: normalize(7),
|
|
753
|
+
},
|
|
754
|
+
// Social HIcons Styles
|
|
755
|
+
socialContainer: {
|
|
756
|
+
flexDirection: 'row',
|
|
757
|
+
width: normalize(90),
|
|
758
|
+
paddingTop: normalize(10),
|
|
759
|
+
justifyContent: 'space-between',
|
|
760
|
+
},
|
|
761
|
+
// Theme Selector Styles
|
|
762
|
+
themeContainer: {
|
|
763
|
+
paddingTop: normalize(50),
|
|
764
|
+
alignSelf: 'flex-start',
|
|
765
|
+
paddingHorizontal: normalize(20),
|
|
766
|
+
},
|
|
767
|
+
themeLabel: {
|
|
768
|
+
paddingBottom: normalize(2),
|
|
769
|
+
fontSize: normalize(14),
|
|
770
|
+
fontWeight: '500',
|
|
771
|
+
},
|
|
772
|
+
themeRow: {
|
|
773
|
+
flexDirection: 'row',
|
|
774
|
+
paddingTop: normalize(4),
|
|
775
|
+
alignItems: 'center',
|
|
776
|
+
flexWrap: 'wrap',
|
|
777
|
+
},
|
|
778
|
+
themeButton: {
|
|
779
|
+
paddingLeft: normalize(10),
|
|
780
|
+
paddingBottom: normalize(5),
|
|
781
|
+
},
|
|
782
|
+
});
|