react-native-timacare 3.1.16-beta → 3.1.18-beta

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.
Files changed (36) hide show
  1. package/lib/commonjs/screens/home/index.js +1 -1
  2. package/lib/commonjs/screens/home/index.js.flow +1 -1
  3. package/lib/commonjs/screens/toan-trinh-so/OCR.js +1 -1
  4. package/lib/commonjs/screens/toan-trinh-so/OCR.js.flow +69 -14
  5. package/lib/commonjs/screens/toan-trinh-so/OCR.js.map +1 -1
  6. package/lib/commonjs/screens/toan-trinh-so/RegisterCamera.js +1 -1
  7. package/lib/commonjs/screens/toan-trinh-so/RegisterCamera.js.flow +51 -5
  8. package/lib/commonjs/screens/toan-trinh-so/RegisterCamera.js.map +1 -1
  9. package/lib/commonjs/screens/toan-trinh-so/TTSSelfie.js +1 -1
  10. package/lib/commonjs/screens/toan-trinh-so/TTSSelfie.js.flow +26 -4
  11. package/lib/commonjs/screens/toan-trinh-so/TTSSelfie.js.map +1 -1
  12. package/lib/commonjs/screens/toan-trinh-so/VehicleCamera.js +1 -1
  13. package/lib/commonjs/screens/toan-trinh-so/VehicleCamera.js.flow +53 -5
  14. package/lib/commonjs/screens/toan-trinh-so/VehicleCamera.js.map +1 -1
  15. package/lib/module/screens/home/index.js +1 -1
  16. package/lib/module/screens/toan-trinh-so/OCR.js +1 -1
  17. package/lib/module/screens/toan-trinh-so/OCR.js.map +1 -1
  18. package/lib/module/screens/toan-trinh-so/RegisterCamera.js +1 -1
  19. package/lib/module/screens/toan-trinh-so/RegisterCamera.js.map +1 -1
  20. package/lib/module/screens/toan-trinh-so/TTSSelfie.js +1 -1
  21. package/lib/module/screens/toan-trinh-so/TTSSelfie.js.map +1 -1
  22. package/lib/module/screens/toan-trinh-so/VehicleCamera.js +1 -1
  23. package/lib/module/screens/toan-trinh-so/VehicleCamera.js.map +1 -1
  24. package/lib/typescript/screens/toan-trinh-so/OCR.d.ts.map +1 -1
  25. package/lib/typescript/screens/toan-trinh-so/RegisterCamera.d.ts.map +1 -1
  26. package/lib/typescript/screens/toan-trinh-so/TTSSelfie.d.ts.map +1 -1
  27. package/lib/typescript/screens/toan-trinh-so/VehicleCamera.d.ts.map +1 -1
  28. package/package.json +1 -1
  29. package/src/screens/home/index.tsx +1 -1
  30. package/src/screens/toan-trinh-so/OCR.tsx +69 -14
  31. package/src/screens/toan-trinh-so/RegisterCamera.tsx +51 -5
  32. package/src/screens/toan-trinh-so/TTSSelfie.tsx +26 -4
  33. package/src/screens/toan-trinh-so/VehicleCamera.tsx +53 -5
  34. /package/lib/commonjs/assets/tts/{Frame 1000011947.png → Frame1000011947.png} +0 -0
  35. /package/lib/module/assets/tts/{Frame 1000011947.png → Frame1000011947.png} +0 -0
  36. /package/src/assets/tts/{Frame 1000011947.png → Frame1000011947.png} +0 -0
@@ -5,6 +5,7 @@ import {
5
5
  Dimensions,
6
6
  Image,
7
7
  ImageStyle,
8
+ PermissionsAndroid,
8
9
  Platform,
9
10
  SafeAreaView,
10
11
  TextStyle,
@@ -12,7 +13,11 @@ import {
12
13
  View,
13
14
  ViewStyle,
14
15
  } from 'react-native';
15
- import { CommonActions, useNavigation } from '@react-navigation/native';
16
+ import {
17
+ CommonActions,
18
+ useNavigation,
19
+ useIsFocused,
20
+ } from '@react-navigation/native';
16
21
  import {
17
22
  request,
18
23
  PERMISSIONS,
@@ -38,6 +43,8 @@ import ImagePicker from 'react-native-image-crop-picker';
38
43
  import { IconUpload } from '../../assets/svgs';
39
44
 
40
45
  export default function RegisterCamera(props: any) {
46
+ const isFocused = useIsFocused();
47
+ const [shouldRenderCamera, setShouldRenderCamera] = useState(false);
41
48
  const navigation = useNavigation();
42
49
  const [showModal, setShowModal] = useState(false);
43
50
  const [taking, setTaking] = useState(false);
@@ -140,6 +147,21 @@ export default function RegisterCamera(props: any) {
140
147
  requestPermissions();
141
148
  }, []);
142
149
 
150
+ useEffect(() => {
151
+ let timeout: NodeJS.Timeout;
152
+
153
+ if (isFocused) {
154
+ // Delay mounting camera to give Android time to release the previous one
155
+ timeout = setTimeout(() => {
156
+ setShouldRenderCamera(true);
157
+ }, 500); // thử 300ms–500ms nếu cần
158
+ } else {
159
+ setShouldRenderCamera(false);
160
+ }
161
+
162
+ return () => clearTimeout(timeout);
163
+ }, [isFocused]);
164
+
143
165
  const takePhoto = async () => {
144
166
  setTaking(true);
145
167
  const options = {
@@ -168,18 +190,40 @@ export default function RegisterCamera(props: any) {
168
190
  };
169
191
 
170
192
  const pickImageFromGallery = async () => {
193
+ if (Platform.OS === 'android') {
194
+ const granted = await PermissionsAndroid.request(
195
+ PermissionsAndroid.PERMISSIONS.READ_MEDIA_IMAGES ||
196
+ PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE,
197
+ {
198
+ title: 'Permission to access photos',
199
+ message: 'App needs access to your photos to pick images.',
200
+ buttonNeutral: 'Ask Me Later',
201
+ buttonNegative: 'Cancel',
202
+ buttonPositive: 'OK',
203
+ }
204
+ );
205
+
206
+ if (granted !== PermissionsAndroid.RESULTS.GRANTED) {
207
+ console.log('Permission denied');
208
+ return;
209
+ }
210
+ }
171
211
  ImagePicker.openPicker({}).then((image) => {
172
212
  if (props?.route?.params?.front) {
173
213
  navigation.push(ScreenNames.VehicleRegistration, {
174
- uri: image?.sourceURL,
214
+ uri:
215
+ Platform.OS === 'android' ? image?.path : 'file://' + image?.path,
175
216
  loan: props?.route?.params?.loan,
176
217
  });
177
218
  } else if (props.route?.params?.callback) {
178
219
  navigation.goBack();
179
- props.route?.params?.callback(image?.sourceURL);
220
+ props.route?.params?.callback(
221
+ Platform.OS === 'android' ? image?.path : 'file://' + image?.path
222
+ );
180
223
  } else {
181
224
  navigation.push(ScreenNames.RegisterBack, {
182
- uri: image?.sourceURL,
225
+ uri:
226
+ Platform.OS === 'android' ? image?.path : 'file://' + image?.path,
183
227
  loan: props?.route?.params?.loan,
184
228
  });
185
229
  }
@@ -190,7 +234,7 @@ export default function RegisterCamera(props: any) {
190
234
  style={[commonStyles.fill, { backgroundColor: 'black' }]}
191
235
  pointerEvents={'box-none'}
192
236
  >
193
- {passPermission && (
237
+ {passPermission && shouldRenderCamera ? (
194
238
  <View
195
239
  style={[
196
240
  commonStyles.fill,
@@ -324,6 +368,8 @@ export default function RegisterCamera(props: any) {
324
368
  )}
325
369
  </View>
326
370
  </View>
371
+ ) : (
372
+ <></>
327
373
  )}
328
374
 
329
375
  <Modal
@@ -7,7 +7,11 @@ import {
7
7
  Platform,
8
8
  View,
9
9
  } from 'react-native';
10
- import { CommonActions, useNavigation } from '@react-navigation/native';
10
+ import {
11
+ CommonActions,
12
+ useNavigation,
13
+ useIsFocused,
14
+ } from '@react-navigation/native';
11
15
  import {
12
16
  request,
13
17
  PERMISSIONS,
@@ -25,6 +29,8 @@ import { ScreenNames } from '../../navigation';
25
29
  import DeviceInfo from 'react-native-device-info';
26
30
 
27
31
  export default function TTSSelfie(props: any) {
32
+ const isFocused = useIsFocused();
33
+ const [shouldRenderCamera, setShouldRenderCamera] = useState(false);
28
34
  const navigation = useNavigation();
29
35
  const [taking, setTaking] = useState(false);
30
36
  const [isLoading, setIsLoading] = useState(false);
@@ -120,6 +126,21 @@ export default function TTSSelfie(props: any) {
120
126
  requestPermissions();
121
127
  }, []);
122
128
 
129
+ useEffect(() => {
130
+ let timeout: NodeJS.Timeout;
131
+
132
+ if (isFocused) {
133
+ // Delay mounting camera to give Android time to release the previous one
134
+ timeout = setTimeout(() => {
135
+ setShouldRenderCamera(true);
136
+ }, 500); // thử 300ms–500ms nếu cần
137
+ } else {
138
+ setShouldRenderCamera(false);
139
+ }
140
+
141
+ return () => clearTimeout(timeout);
142
+ }, [isFocused]);
143
+
123
144
  const takePhoto = async () => {
124
145
  setTaking(true);
125
146
  const options = {
@@ -163,7 +184,7 @@ export default function TTSSelfie(props: any) {
163
184
  style={{ flex: 1, backgroundColor: 'black' }}
164
185
  pointerEvents={'box-none'}
165
186
  >
166
- {passPermission && (
187
+ {passPermission && shouldRenderCamera ? (
167
188
  <View
168
189
  style={[
169
190
  commonStyles.fill,
@@ -179,7 +200,7 @@ export default function TTSSelfie(props: any) {
179
200
  flexDirection: 'row',
180
201
  alignItems: 'center',
181
202
  justifyContent: 'center',
182
- marginTop: DeviceInfo.hasNotch() ? 70 : 0,
203
+ marginTop: DeviceInfo.hasNotch() ? 70 : 16,
183
204
  }}
184
205
  >
185
206
  <MButton
@@ -212,6 +233,7 @@ export default function TTSSelfie(props: any) {
212
233
  }}
213
234
  type={RNCamera.Constants.Type.front}
214
235
  maxZoom={1}
236
+ captureAudio={false}
215
237
  androidCameraPermissionOptions={{
216
238
  title: 'Permission to use camera',
217
239
  message: 'We need your permission to use your camera',
@@ -263,7 +285,7 @@ export default function TTSSelfie(props: any) {
263
285
  )}
264
286
  </View>
265
287
  </View>
266
- )}
288
+ ) : null}
267
289
 
268
290
  <Loading isLoading={isLoading} />
269
291
  </View>
@@ -5,6 +5,7 @@ import {
5
5
  Dimensions,
6
6
  Image,
7
7
  ImageStyle,
8
+ PermissionsAndroid,
8
9
  Platform,
9
10
  SafeAreaView,
10
11
  TextStyle,
@@ -12,7 +13,11 @@ import {
12
13
  View,
13
14
  ViewStyle,
14
15
  } from 'react-native';
15
- import { CommonActions, useNavigation } from '@react-navigation/native';
16
+ import {
17
+ CommonActions,
18
+ useNavigation,
19
+ useIsFocused,
20
+ } from '@react-navigation/native';
16
21
  import Modal from 'react-native-modal';
17
22
  import { MText } from '../../components/MText';
18
23
  import LinearGradient from 'react-native-linear-gradient';
@@ -37,6 +42,8 @@ import { IconUpload } from '../../assets/svgs';
37
42
  import ImagePicker from 'react-native-image-crop-picker';
38
43
 
39
44
  export default function VehicleCamera(props: any) {
45
+ const isFocused = useIsFocused();
46
+ const [shouldRenderCamera, setShouldRenderCamera] = useState(false);
40
47
  const navigation = useNavigation();
41
48
  const [showModal, setShowModal] = useState(false);
42
49
  const [title, setTitle] = useState(
@@ -175,19 +182,58 @@ export default function VehicleCamera(props: any) {
175
182
  loadIntro();
176
183
  }, []);
177
184
 
185
+ useEffect(() => {
186
+ let timeout: NodeJS.Timeout;
187
+
188
+ if (isFocused) {
189
+ // Delay mounting camera to give Android time to release the previous one
190
+ timeout = setTimeout(() => {
191
+ setShouldRenderCamera(true);
192
+ }, 500); // thử 300ms–500ms nếu cần
193
+ } else {
194
+ setShouldRenderCamera(false);
195
+ }
196
+
197
+ return () => clearTimeout(timeout);
198
+ }, [isFocused]);
199
+
178
200
  const pickImageFromGallery = async () => {
201
+ if (Platform.OS === 'android') {
202
+ const granted = await PermissionsAndroid.request(
203
+ PermissionsAndroid.PERMISSIONS.READ_MEDIA_IMAGES ||
204
+ PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE,
205
+ {
206
+ title: 'Permission to access photos',
207
+ message: 'App needs access to your photos to pick images.',
208
+ buttonNeutral: 'Ask Me Later',
209
+ buttonNegative: 'Cancel',
210
+ buttonPositive: 'OK',
211
+ }
212
+ );
213
+
214
+ if (granted !== PermissionsAndroid.RESULTS.GRANTED) {
215
+ console.log('Permission denied');
216
+ return;
217
+ }
218
+ }
179
219
  ImagePicker.openPicker({}).then((image) => {
220
+ console.log(image);
221
+
180
222
  if (props?.route?.params?.front) {
181
223
  navigation.push(ScreenNames.VehicleRegistrationFront, {
182
- uri: image?.sourceURL,
224
+ uri:
225
+ Platform.OS === 'android' ? image?.path : 'file://' + image?.path,
183
226
  loan: props?.route?.params?.loan,
184
227
  });
185
228
  } else if (props.route?.params?.callback) {
186
229
  navigation.goBack();
187
- props.route?.params?.callback(image?.sourceURL);
230
+ props.route?.params?.callback(
231
+ Platform.OS === 'android' ? image?.path : 'file://' + image?.path
232
+ );
188
233
  } else {
189
234
  navigation.push(ScreenNames.VehicleRegistrationBack, {
190
- uri: image?.sourceURL,
235
+ uri:
236
+ Platform.OS === 'android' ? image?.path : 'file://' + image?.path,
191
237
  loan: props?.route?.params?.loan,
192
238
  });
193
239
  }
@@ -199,7 +245,7 @@ export default function VehicleCamera(props: any) {
199
245
  style={[$flex, { backgroundColor: 'black' }]}
200
246
  pointerEvents={'box-none'}
201
247
  >
202
- {passPermission && (
248
+ {passPermission && shouldRenderCamera ? (
203
249
  <View
204
250
  style={[
205
251
  commonStyles.alignCenter,
@@ -339,6 +385,8 @@ export default function VehicleCamera(props: any) {
339
385
  </MText>
340
386
  </SafeAreaView>
341
387
  </View>
388
+ ) : (
389
+ <></>
342
390
  )}
343
391
  <Modal
344
392
  isVisible={showModal}