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

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 CHANGED
@@ -1,3 +1,11 @@
1
1
  export { default as ErrorBoundary } from './src/Common/ErrorBoundary';
2
- export { default as AAlertIOS } from './Alerts/AAlertIOS';
3
- export { default as AAlert } from './Alerts/AAlert';
2
+ export { default as AAlertIOS } from './src/Alerts/AAlertIOS';
3
+ export { default as AAlert } from './src/Alerts/AAlert';
4
+ export { default as ABlink } from './src/Alerts/ABlink';
5
+ export { default as HIcons } from './src/Hoc/HIcons';
6
+ export { default as NetworkServiceCall } from './src/Common/NetworkServiceCall';
7
+ export * from './src/Navigation/useNavigation';
8
+ export { default as CBackHandler } from './src/CustomComponents/CBackHandler';
9
+ export * from './src/CommonStyle/ComponentFunctions';
10
+ export * from './src/CommonStyle/commonStyle';
11
+ export { default as Loader } from './src/Custom/Loader';
package/index.js CHANGED
@@ -1,3 +1,11 @@
1
1
  export { default as ErrorBoundary } from './src/Common/ErrorBoundary';
2
2
  export { default as AAlertIOS } from './src/Alerts/AAlertIOS';
3
- export { default as AAlert } from './src/Alerts/AAlert';
3
+ export { default as AAlert } from './src/Alerts/AAlert';
4
+ export { default as ABlink } from './src/Alerts/ABlink';
5
+ export { default as HIcons } from './src/Hoc/HIcons';
6
+ export { default as NetworkServiceCall } from './src/Common/NetworkServiceCall';
7
+ export * from './src/Navigation/useNavigation';
8
+ export { default as CBackHandler } from './src/CustomComponents/CBackHandler';
9
+ export * from './src/CommonStyle/ComponentFunctions';
10
+ export * from './src/CommonStyle/commonStyle';
11
+ export { default as Loader } from './src/Custom/Loader';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jescon-technologies/react-native-ui-kit",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "A React Native module for Jescon Technologies that provides react-native-ui-kit",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -9,7 +9,7 @@ import {
9
9
  } from 'react-native';
10
10
 
11
11
  import { Global } from '../../../../../src/Common/Global';
12
- import Icons from '../Common/Icons';
12
+ import HIcons from '../Hoc/HIcons';
13
13
  import { ValueCheck } from '../CommonStyle/ComponentFunctions';
14
14
  import { normalize } from '../CommonStyle/componentStyle';
15
15
  import CModalOverlay from '../CustomComponents/CModalOverlay';
@@ -120,7 +120,7 @@ const AAlert: React.FC<Props> = (props) => {
120
120
  }}
121
121
  onPress={handleClose}
122
122
  >
123
- <Icons.AntDesign
123
+ <HIcons.AntDesign
124
124
  name="closecircleo"
125
125
  size={normalize(15)}
126
126
  color="#fff"
@@ -147,7 +147,7 @@ const AAlert: React.FC<Props> = (props) => {
147
147
  source={require('../../../../../android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png')}
148
148
  />
149
149
 
150
- <Icons.Entypo
150
+ <HIcons.Entypo
151
151
  color="#fff"
152
152
  name="info"
153
153
  size={normalize(15)}
@@ -8,7 +8,7 @@ import {
8
8
  } from 'react-native';
9
9
 
10
10
  import { Global } from '../../../../../src/Common/Global';
11
- import Icons from '../Common/Icons';
11
+ import HIcons from '../Hoc/HIcons';
12
12
  import { ValueCheck } from '../CommonStyle/ComponentFunctions';
13
13
  import { normalize } from '../CommonStyle/componentStyle';
14
14
 
@@ -108,7 +108,7 @@ const AAlertIOS: React.FC<Props> = (props) => {
108
108
  flex: 1,
109
109
  }}
110
110
  >
111
- <Icons.Entypo
111
+ <HIcons.Entypo
112
112
  color="#fff"
113
113
  name="info"
114
114
  size={normalize(15)}
@@ -0,0 +1,56 @@
1
+ import React, { Component } from 'react';
2
+ import { Animated, View, ViewStyle, StyleProp } from 'react-native';
3
+
4
+ interface ABlinkProps {
5
+ duration?: number;
6
+ repeat_count?: number;
7
+ style?: StyleProp<ViewStyle>;
8
+ children?: React.ReactNode;
9
+ }
10
+
11
+ interface ABlinkState {
12
+ // No state needed, but keeping for consistency
13
+ }
14
+
15
+ export default class ABlink extends Component<ABlinkProps, ABlinkState> {
16
+ private fadeAnimation: Animated.Value;
17
+
18
+ constructor(props: ABlinkProps) {
19
+ super(props);
20
+ this.fadeAnimation = new Animated.Value(0);
21
+ }
22
+
23
+ componentDidMount(): void {
24
+ const { duration = 1000, repeat_count = -1 } = this.props;
25
+
26
+ Animated.loop(
27
+ Animated.sequence([
28
+ Animated.timing(this.fadeAnimation, {
29
+ toValue: 0,
30
+ duration: duration,
31
+ useNativeDriver: true,
32
+ }),
33
+ Animated.timing(this.fadeAnimation, {
34
+ toValue: 1,
35
+ duration: duration,
36
+ useNativeDriver: true,
37
+ }),
38
+ ]),
39
+ {
40
+ iterations: repeat_count,
41
+ }
42
+ ).start();
43
+ }
44
+
45
+ render(): React.JSX.Element {
46
+ const { style, children } = this.props;
47
+
48
+ return (
49
+ <View style={style}>
50
+ <Animated.View style={{ opacity: this.fadeAnimation }}>
51
+ {children}
52
+ </Animated.View>
53
+ </View>
54
+ );
55
+ }
56
+ }
@@ -0,0 +1,298 @@
1
+ import axios, { Method, AxiosResponse, AxiosError } from 'axios';
2
+ import { isConnected, notifyMessage, ValueCheck } from '../CommonStyle/ComponentFunctions';
3
+ import { Global } from '../../../../../src/Common/Global';
4
+ import { Platform } from 'react-native';
5
+
6
+ // Type definitions
7
+ export type HttpMethod = 'get' | 'post' | 'multiform';
8
+
9
+ export interface NetworkResponse {
10
+ data: any;
11
+ httpstatus: number;
12
+ }
13
+
14
+ export interface ErrorResponseData {
15
+ title: string;
16
+ subtitle: string;
17
+ alertdata: {
18
+ alertCaption: string;
19
+ alertMessage: string;
20
+ alertContent: string;
21
+ alertHttpstatus: number;
22
+ };
23
+ }
24
+
25
+ export interface ErrorResponse {
26
+ httpstatus: number;
27
+ data: ErrorResponseData;
28
+ }
29
+
30
+ // Type for electron API if available
31
+ declare global {
32
+ interface Window {
33
+ electronAPI?: {
34
+ networkCall: (method: string, url: string, params?: any) => Promise<NetworkResponse>;
35
+ };
36
+ }
37
+ }
38
+
39
+ type NetworkServiceCallFunction = (
40
+ method: HttpMethod | string,
41
+ url: string,
42
+ params?: any,
43
+ jwt?: string,
44
+ timeout?: number
45
+ ) => Promise<NetworkResponse | ErrorResponse>;
46
+
47
+ const NetworkServiceCall: NetworkServiceCallFunction = (method, url, params, jwt, timeout) => {
48
+ let jwtString = ValueCheck(Global.JWTToken) ? Global.JWTToken : jwt;
49
+ let dataset: NetworkResponse | ErrorResponse = {};
50
+
51
+ if (method.toLowerCase() === 'get') {
52
+ return axios({
53
+ method: 'get' as Method,
54
+ url: url,
55
+ timeout: timeout || 60000,
56
+ validateStatus: false,
57
+ // headers: {
58
+ // Authorization: `Bearer ${jwtString}`,
59
+ // }
60
+ })
61
+ .then(function (response: AxiosResponse): NetworkResponse | ErrorResponse {
62
+ if (response.data.httpstatus === 200) {
63
+ dataset = {
64
+ data: response.data.data,
65
+ httpstatus: response.data.httpstatus,
66
+ };
67
+ return dataset as NetworkResponse;
68
+ } else {
69
+ dataset = {
70
+ httpstatus: response.data.httpstatus,
71
+ data: {
72
+ title: 'ERROR',
73
+ subtitle: response.data.data !== undefined ? response.data.data.message : '',
74
+ alertdata: {
75
+ alertCaption: 'ERROR',
76
+ alertMessage: response.data.message,
77
+ alertContent: response.data.message,
78
+ alertHttpstatus: response.data.httpstatus,
79
+ },
80
+ },
81
+ };
82
+ return dataset as ErrorResponse;
83
+ }
84
+ })
85
+ .catch(function (error: AxiosError): ErrorResponse {
86
+ dataset = {
87
+ httpstatus: 404,
88
+ data: {
89
+ title: 'ERROR',
90
+ subtitle: '',
91
+ alertdata: {
92
+ alertCaption: 'ERROR',
93
+ alertMessage: error.message,
94
+ alertContent: error.message,
95
+ alertHttpstatus: 404,
96
+ },
97
+ },
98
+ };
99
+ return dataset as ErrorResponse;
100
+ });
101
+ }
102
+ else if (method.toLowerCase() === 'post' && Platform.OS !== 'web') {
103
+ return axios.post(url, params, {
104
+ // headers: {
105
+ // Authorization: `Bearer ${jwtString}`,
106
+ // }
107
+ })
108
+ .then(function (response: AxiosResponse): NetworkResponse | ErrorResponse {
109
+ if (response.data.httpstatus === 200) {
110
+ dataset = {
111
+ data: response.data.data,
112
+ httpstatus: response.data.httpstatus,
113
+ };
114
+ return dataset as NetworkResponse;
115
+ } else {
116
+ dataset = {
117
+ httpstatus: response.data.httpstatus,
118
+ data: {
119
+ title: 'ERROR',
120
+ subtitle: '',
121
+ alertdata: {
122
+ alertCaption: 'ERROR',
123
+ alertMessage: response.data.message,
124
+ alertContent: response.data.message,
125
+ alertHttpstatus: response.data.httpstatus,
126
+ },
127
+ },
128
+ };
129
+ return dataset as ErrorResponse;
130
+ }
131
+ })
132
+ .catch(function (error: AxiosError): ErrorResponse {
133
+ dataset = {
134
+ httpstatus: 404,
135
+ data: {
136
+ title: 'ERROR',
137
+ subtitle: '',
138
+ alertdata: {
139
+ alertCaption: 'ERROR',
140
+ alertMessage: error.message,
141
+ alertContent: error.message,
142
+ alertHttpstatus: 404,
143
+ },
144
+ },
145
+ };
146
+ return dataset as ErrorResponse;
147
+ });
148
+ }
149
+ else if (method.toLowerCase() === 'multiform' && Platform.OS !== 'web') {
150
+ console.log('JWT STRING', jwtString);
151
+
152
+ return axios({
153
+ url: url,
154
+ method: 'POST',
155
+ headers: {
156
+ 'Content-Type': 'multipart/form-data',
157
+ // Authorization: `Bearer ${jwtString}`,
158
+ },
159
+ data: params,
160
+ })
161
+ .then(function (response: AxiosResponse): NetworkResponse | ErrorResponse {
162
+ if (response.status === 200) {
163
+ dataset = {
164
+ data: response.data,
165
+ httpstatus: response.status,
166
+ };
167
+ return dataset as NetworkResponse;
168
+ } else {
169
+ dataset = {
170
+ httpstatus: response.status,
171
+ data: {
172
+ title: 'ERROR',
173
+ subtitle: '',
174
+ alertdata: {
175
+ alertCaption: 'ERROR',
176
+ alertMessage: response.data.message,
177
+ alertContent: response.data.message,
178
+ alertHttpstatus: response.data.httpstatus,
179
+ },
180
+ },
181
+ };
182
+ return dataset as ErrorResponse;
183
+ }
184
+ })
185
+ .catch((error: AxiosError): ErrorResponse => {
186
+ dataset = {
187
+ httpstatus: 404,
188
+ data: {
189
+ title: 'ERROR',
190
+ subtitle: '',
191
+ alertdata: {
192
+ alertCaption: 'ERROR',
193
+ alertMessage: error.message,
194
+ alertContent: error.message,
195
+ alertHttpstatus: 404,
196
+ },
197
+ },
198
+ };
199
+ return dataset as ErrorResponse;
200
+ });
201
+ }
202
+ else if (method.toLowerCase() === 'post' && Platform.OS === 'web') {
203
+ // Check if electronAPI is available
204
+ if (typeof window !== 'undefined' && window.electronAPI) {
205
+ return window.electronAPI.networkCall('post', url, params)
206
+ .then(function (response: NetworkResponse): NetworkResponse | ErrorResponse {
207
+ if (response.httpstatus === 200) {
208
+ dataset = {
209
+ data: response.data,
210
+ httpstatus: response.httpstatus,
211
+ };
212
+ return dataset as NetworkResponse;
213
+ } else {
214
+ dataset = {
215
+ httpstatus: response.httpstatus,
216
+ data: {
217
+ title: 'ERROR',
218
+ subtitle: '',
219
+ alertdata: {
220
+ alertCaption: 'ERROR',
221
+ alertMessage: (response as any).message || '',
222
+ alertContent: (response as any).message || '',
223
+ alertHttpstatus: response.httpstatus,
224
+ },
225
+ },
226
+ };
227
+ return dataset as ErrorResponse;
228
+ }
229
+ })
230
+ .catch(function (error: Error): ErrorResponse {
231
+ dataset = {
232
+ httpstatus: 404,
233
+ data: {
234
+ title: 'ERROR',
235
+ subtitle: '',
236
+ alertdata: {
237
+ alertCaption: 'ERROR',
238
+ alertMessage: error.message,
239
+ alertContent: error.message,
240
+ alertHttpstatus: 404,
241
+ },
242
+ },
243
+ };
244
+ return dataset as ErrorResponse;
245
+ });
246
+ } else {
247
+ // Fallback to regular axios if electronAPI is not available
248
+ return axios.post(url, params, {
249
+ timeout: timeout || 60000,
250
+ })
251
+ .then(function (response: AxiosResponse): NetworkResponse | ErrorResponse {
252
+ if (response.status === 200) {
253
+ dataset = {
254
+ data: response.data,
255
+ httpstatus: response.status,
256
+ };
257
+ return dataset as NetworkResponse;
258
+ } else {
259
+ dataset = {
260
+ httpstatus: response.status,
261
+ data: {
262
+ title: 'ERROR',
263
+ subtitle: '',
264
+ alertdata: {
265
+ alertCaption: 'ERROR',
266
+ alertMessage: response.data?.message || 'Request failed',
267
+ alertContent: response.data?.message || 'Request failed',
268
+ alertHttpstatus: response.status,
269
+ },
270
+ },
271
+ };
272
+ return dataset as ErrorResponse;
273
+ }
274
+ })
275
+ .catch(function (error: AxiosError): ErrorResponse {
276
+ dataset = {
277
+ httpstatus: 404,
278
+ data: {
279
+ title: 'ERROR',
280
+ subtitle: '',
281
+ alertdata: {
282
+ alertCaption: 'ERROR',
283
+ alertMessage: error.message,
284
+ alertContent: error.message,
285
+ alertHttpstatus: 404,
286
+ },
287
+ },
288
+ };
289
+ return dataset as ErrorResponse;
290
+ });
291
+ }
292
+ }
293
+
294
+ // Default return for unmatched conditions
295
+ return Promise.reject(new Error('Invalid method or platform combination'));
296
+ };
297
+
298
+ export default NetworkServiceCall;