@@ -13,7 +13,9 @@ import Controls from '../Controls';
13
13
import Layout from '../Layout' ;
14
14
import Overlay from '../Overlay' ;
15
15
import Sights from '../Sights' ;
16
+ import UploadCenter from '../UploadCenter' ;
16
17
18
+ import Constants from '../../const' ;
17
19
import log from '../../utils/log' ;
18
20
19
21
import {
@@ -42,23 +44,32 @@ const styles = StyleSheet.create({
42
44
/**
43
45
* @param controls
44
46
* @param controlsContainerStyle
47
+ * @param enableComplianceCheck
45
48
* @param footer
46
49
* @param fullscreen
47
50
* @param initialState
48
51
* @param inspectionId
52
+ * @param isSubmitting
49
53
* @param loading
50
54
* @param navigationOptions
51
55
* @param offline
52
56
* @param onChange
53
57
* @param onReady
58
+ * @param onCaptureTourFinish
59
+ * @param onCaptureTourStart
60
+ * @param onComplianceCheckFinish
61
+ * @param onComplianceCheckStart
62
+ * @param onStartUploadPicture
63
+ * @param onFinishUploadPicture
64
+ * @param onRetakeAll
54
65
* @param onFinish
55
66
* @param primaryColor
56
67
* @param sightIds
57
68
* @param sightsContainerStyle
58
69
* @param style
70
+ * @param submitButtonLabel
59
71
* @param thumbnailStyle
60
72
* @param uploads
61
- * @param RenderOnFinish
62
73
* @param submitButtonProps
63
74
* @param task
64
75
* @return {JSX.Element }
@@ -67,23 +78,30 @@ const styles = StyleSheet.create({
67
78
export default function Capture ( {
68
79
controls,
69
80
controlsContainerStyle,
81
+ enableComplianceCheck,
70
82
footer,
71
83
fullscreen,
72
84
initialState,
73
85
inspectionId,
86
+ isSubmitting,
74
87
loading,
75
88
navigationOptions,
76
89
offline,
77
90
onChange,
91
+ onCaptureTourFinish,
92
+ onCaptureTourStart,
93
+ onComplianceCheckFinish,
94
+ onComplianceCheckStart,
78
95
onReady,
79
- onFinish,
96
+ onRetakeAll,
97
+ onStartUploadPicture,
98
+ onFinishUploadPicture,
80
99
orientationBlockerProps,
81
100
primaryColor,
82
- renderOnFinish : RenderOnFinish ,
83
101
sightIds,
84
102
sightsContainerStyle,
85
103
style,
86
- submitButtonProps ,
104
+ submitButtonLabel ,
87
105
task,
88
106
thumbnailStyle,
89
107
uploads,
@@ -156,7 +174,13 @@ export default function Capture({
156
174
const createDamageDetectionAsync = useCreateDamageDetectionAsync ( ) ;
157
175
const takePictureAsync = useTakePictureAsync ( { camera } ) ;
158
176
const setPictureAsync = useSetPictureAsync ( { current, sights, uploads } ) ;
159
- const startUploadAsync = useStartUploadAsync ( { inspectionId, sights, uploads, task, onFinish } ) ;
177
+ const startUploadAsync = useStartUploadAsync ( {
178
+ inspectionId,
179
+ sights,
180
+ uploads,
181
+ task,
182
+ onFinish : onCaptureTourFinish ,
183
+ } ) ;
160
184
const checkComplianceAsync = useCheckComplianceAsync ( {
161
185
compliance,
162
186
inspectionId,
@@ -222,10 +246,13 @@ export default function Capture({
222
246
} , [ tour , sightIds ] ) ;
223
247
224
248
useEffect ( ( ) => {
225
- if ( tourHasFinished ) {
226
- log ( [ `Capture tour has been finished` ] ) ;
227
- }
228
- } , [ camera , tourHasFinished , onFinish ] ) ;
249
+ if ( enableComplianceCheck ) { log ( [ `Compliance check is enabled` ] ) ; }
250
+ } , [ enableComplianceCheck ] ) ;
251
+
252
+ useEffect ( ( ) => {
253
+ log ( [ `Capture tour has been started` ] ) ;
254
+ onCaptureTourStart ( ) ;
255
+ } , [ onCaptureTourStart ] ) ;
229
256
230
257
// END EFFECTS //
231
258
// RENDERING //
@@ -252,8 +279,12 @@ export default function Capture({
252
279
containerStyle = { controlsContainerStyle }
253
280
elements = { controls }
254
281
state = { states }
282
+ enableComplianceCheck = { enableComplianceCheck }
283
+ onStartUploadPicture = { onStartUploadPicture }
284
+ onFinishUploadPicture = { onFinishUploadPicture }
255
285
/>
256
- ) , [ api , controls , controlsContainerStyle , states ] ) ;
286
+ ) , [ api , controlsContainerStyle , controls , states , enableComplianceCheck ,
287
+ onStartUploadPicture , onFinishUploadPicture ] ) ;
257
288
258
289
const children = useMemo ( ( ) => (
259
290
< >
@@ -274,14 +305,19 @@ export default function Capture({
274
305
</ >
275
306
) , [ isReady , loading , overlay , primaryColor ] ) ;
276
307
277
- if ( tourHasFinished && RenderOnFinish ) {
308
+ if ( enableComplianceCheck && tourHasFinished ) {
278
309
return (
279
- < RenderOnFinish
310
+ < UploadCenter
280
311
{ ...states }
281
- submitButtonProps = { submitButtonProps }
312
+ isSubmitting = { isSubmitting }
313
+ onComplianceCheckFinish = { onComplianceCheckFinish }
314
+ onComplianceCheckStart = { onComplianceCheckStart }
315
+ onRetakeAll = { onRetakeAll }
316
+ submitButtonLabel = { submitButtonLabel }
282
317
task = { task }
283
318
inspectionId = { inspectionId }
284
319
checkComplianceAsync = { checkComplianceAsync }
320
+ navigationOptions = { navigationOptions }
285
321
/>
286
322
) ;
287
323
}
@@ -313,26 +349,7 @@ export default function Capture({
313
349
// END RENDERING //
314
350
}
315
351
316
- Capture . defaultSightIds = [
317
- 'xsuH1g5T' , // Beauty Shot
318
- 'xfbBpq3Q' , // Front Bumper Side Left
319
- 'LE9h1xh0' , // Front Fender Left
320
- 'IVcF1dOP' , // Doors Left
321
- 'm1rhrZ88' , // Front Roof Left
322
- 'GvCtVnoD' , // Rear Lateral Left
323
- '3vKXafwc' , // Rear Fender Left
324
- 'XyeyZlaU' , // Rear
325
- 'Cce1KCd3' , // Rear Fender Right
326
- 'AoO-nOoM' , // Rear Lateral Right
327
- 'Pzgw0WGe' , // Doors Right
328
- 'jqJOb6Ov' , // Front Fender Right
329
- 'CELBsvYD' , // Front Bumper Side Right
330
- 'vLcBGkeh' , // Front
331
- 'IqwSM3' , // Front seats
332
- 'rSvk2C' , // Dashboard
333
- 'rj5mhm' , // Back seats
334
- 'qhKA2z' , // Trunk
335
- ] ;
352
+ Capture . defaultSightIds = Constants . defaultSightIds ;
336
353
337
354
Capture . propTypes = {
338
355
controls : PropTypes . arrayOf ( PropTypes . shape ( {
@@ -341,6 +358,7 @@ Capture.propTypes = {
341
358
onPress : PropTypes . func ,
342
359
} ) ) ,
343
360
controlsContainerStyle : PropTypes . objectOf ( PropTypes . any ) ,
361
+ enableComplianceCheck : PropTypes . bool ,
344
362
footer : PropTypes . element ,
345
363
fullscreen : PropTypes . objectOf ( PropTypes . any ) ,
346
364
initialState : PropTypes . shape ( {
@@ -350,6 +368,7 @@ Capture.propTypes = {
350
368
uploads : PropTypes . objectOf ( PropTypes . any ) ,
351
369
} ) ,
352
370
inspectionId : PropTypes . string ,
371
+ isSubmitting : PropTypes . bool ,
353
372
loading : PropTypes . bool ,
354
373
navigationOptions : PropTypes . shape ( {
355
374
allowNavigate : PropTypes . bool ,
@@ -359,15 +378,22 @@ Capture.propTypes = {
359
378
retakeMinTry : PropTypes . number ,
360
379
} ) ,
361
380
offline : PropTypes . objectOf ( PropTypes . any ) ,
381
+ onCaptureTourFinish : PropTypes . func ,
382
+ onCaptureTourStart : PropTypes . func ,
362
383
onChange : PropTypes . func ,
384
+ onComplianceCheckFinish : PropTypes . func ,
385
+ onComplianceCheckStart : PropTypes . func ,
363
386
onFinish : PropTypes . func ,
387
+ onFinishUploadPicture : PropTypes . func ,
364
388
onReady : PropTypes . func ,
389
+ onRetakeAll : PropTypes . func ,
390
+ onStartUploadPicture : PropTypes . func ,
365
391
orientationBlockerProps : PropTypes . shape ( { title : PropTypes . string } ) ,
366
392
primaryColor : PropTypes . string ,
367
393
renderOnFinish : PropTypes . func ,
368
394
sightIds : PropTypes . arrayOf ( PropTypes . string ) ,
369
395
sightsContainerStyle : PropTypes . objectOf ( PropTypes . any ) ,
370
- submitButtonProps : PropTypes . shape ( { onPress : PropTypes . func . isRequired } ) ,
396
+ submitButtonLabel : PropTypes . string ,
371
397
task : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . object ] ) ,
372
398
thumbnailStyle : PropTypes . objectOf ( PropTypes . any ) ,
373
399
uploads : PropTypes . shape ( {
@@ -404,15 +430,24 @@ Capture.defaultProps = {
404
430
retakeMinTry : 1 ,
405
431
} ,
406
432
offline : null ,
433
+ onCaptureTourFinish : ( ) => { } ,
434
+ onCaptureTourStart : ( ) => { } ,
407
435
onChange : ( ) => { } ,
436
+ onComplianceCheckFinish : ( ) => { } ,
437
+ onComplianceCheckStart : ( ) => { } ,
408
438
onFinish : ( ) => { } ,
439
+ onFinishUploadPicture : ( ) => { } ,
409
440
onReady : ( ) => { } ,
441
+ onStartUploadPicture : ( ) => { } ,
442
+ onRetakeAll : ( ) => { } ,
410
443
orientationBlockerProps : null ,
411
444
primaryColor : '#FFF' ,
412
445
renderOnFinish : null ,
413
446
sightIds : Capture . defaultSightIds ,
414
447
sightsContainerStyle : { } ,
415
- submitButtonProps : { } ,
448
+ enableComplianceCheck : false ,
449
+ isSubmitting : false ,
450
+ submitButtonLabel : 'Skip retaking' ,
416
451
task : 'damage_detection' ,
417
452
thumbnailStyle : { } ,
418
453
uploads : {
0 commit comments