@supportworks/multi-imagepicker 8.0.16 → 8.0.18
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/changes.md +6 -0
- package/package.json +1 -1
- package/src/components/AddImages.js +52 -23
package/changes.md
CHANGED
package/package.json
CHANGED
|
@@ -33,6 +33,7 @@ const AddImages = forwardRef((
|
|
|
33
33
|
}, ref) => {
|
|
34
34
|
const [showAttaching, setShowAttaching] = useState(false)
|
|
35
35
|
const [showAdd, setShowAdd] = useState(false)
|
|
36
|
+
const [pendingAttach, setPendingAttach] = useState(false)
|
|
36
37
|
const [showInfoDialog, setShowInfoDialog] = useState(false)
|
|
37
38
|
const [allImageDataValid, setAllImageDataValid] = useState(true)
|
|
38
39
|
const [showToCust, setShowToCust] = useState(false)
|
|
@@ -135,31 +136,59 @@ const AddImages = forwardRef((
|
|
|
135
136
|
}
|
|
136
137
|
}, [addPicture, prospectInst, hasAndroidWritePermission, showToCust, saveToDevice, allowSaveToDevice])
|
|
137
138
|
|
|
138
|
-
const
|
|
139
|
+
const performAttach = useCallback(async () => {
|
|
139
140
|
if (!isMountedRef.current) {
|
|
140
141
|
return
|
|
141
142
|
}
|
|
142
143
|
|
|
143
|
-
setShowAttaching(
|
|
144
|
-
setShowAdd(false)
|
|
144
|
+
setShowAttaching(true)
|
|
145
145
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
146
|
+
try {
|
|
147
|
+
await addPicturesToProject()
|
|
148
|
+
if (allowEdit && allowSaveToDevice) {
|
|
149
|
+
await Api.getApi().setDefaultSavePhotosToDevice(saveToDevice)
|
|
150
|
+
}
|
|
151
|
+
if (allowEdit && showToCustomerAllowed) {
|
|
152
|
+
await Api.getApi().setDefaultShowToCustomer(showToCust)
|
|
153
|
+
}
|
|
154
|
+
Analytics.logEvent('mip_addImages_onAttach', { source_page: 'MultiImagePicker' })
|
|
155
|
+
if (callback) {
|
|
156
|
+
callback()
|
|
157
|
+
}
|
|
158
|
+
} finally {
|
|
159
|
+
if (isMountedRef.current) {
|
|
160
|
+
setShowAttaching(false)
|
|
161
|
+
setPendingAttach(false)
|
|
162
|
+
}
|
|
149
163
|
}
|
|
150
|
-
|
|
151
|
-
|
|
164
|
+
}, [addPicturesToProject, allowEdit, callback, saveToDevice, allowSaveToDevice, showToCust, showToCustomerAllowed])
|
|
165
|
+
|
|
166
|
+
const onAttach = useCallback(() => {
|
|
167
|
+
if (!isMountedRef.current) {
|
|
168
|
+
return
|
|
152
169
|
}
|
|
153
|
-
|
|
154
|
-
if (
|
|
155
|
-
|
|
170
|
+
|
|
171
|
+
if (Platform.OS === 'ios' && showAdd) {
|
|
172
|
+
setPendingAttach(true)
|
|
173
|
+
setShowAdd(false)
|
|
174
|
+
return
|
|
156
175
|
}
|
|
157
|
-
|
|
176
|
+
|
|
177
|
+
void performAttach()
|
|
178
|
+
}, [performAttach, showAdd])
|
|
179
|
+
|
|
180
|
+
const onAddModalDismiss = useCallback(() => {
|
|
181
|
+
if (!pendingAttach) {
|
|
182
|
+
return
|
|
183
|
+
}
|
|
184
|
+
void performAttach()
|
|
185
|
+
}, [pendingAttach, performAttach])
|
|
158
186
|
|
|
159
187
|
const onClose = useCallback(() => {
|
|
160
188
|
if (!isMountedRef.current) {
|
|
161
189
|
return
|
|
162
190
|
}
|
|
191
|
+
setPendingAttach(false)
|
|
163
192
|
setShowAttaching(false)
|
|
164
193
|
setShowAdd(false)
|
|
165
194
|
}, [])
|
|
@@ -413,9 +442,15 @@ const AddImages = forwardRef((
|
|
|
413
442
|
)
|
|
414
443
|
}
|
|
415
444
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
445
|
+
return (
|
|
446
|
+
<>
|
|
447
|
+
{!showAdd && (
|
|
448
|
+
<MultiImagePicker ref={setPickerRef} hitSlop={hitSlop} maxCount={maxCount} parentStyle={parentStyle} callback={onImageSelect}>
|
|
449
|
+
{children}
|
|
450
|
+
</MultiImagePicker>
|
|
451
|
+
)}
|
|
452
|
+
|
|
453
|
+
<Modal visible={showAdd} presentationStyle='fullScreen' animationType='slide' onDismiss={onAddModalDismiss}>
|
|
419
454
|
<ScreenSafeAreaView style={styles.Page} edges={['top','bottom']} includeProvider>
|
|
420
455
|
<AppBarH8
|
|
421
456
|
variant='regular'
|
|
@@ -453,20 +488,14 @@ const AddImages = forwardRef((
|
|
|
453
488
|
</View>
|
|
454
489
|
</ScreenSafeAreaView>
|
|
455
490
|
|
|
456
|
-
{Api.getApi().sendPhotosToCRM() && (
|
|
491
|
+
{Api.getApi().sendPhotosToCRM() && false && (
|
|
457
492
|
<UploadWarningModal
|
|
458
493
|
visible={showInfoDialog}
|
|
459
494
|
onClose={onCloseInfoDialog}
|
|
460
495
|
/>
|
|
461
496
|
)}
|
|
462
497
|
</Modal>
|
|
463
|
-
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
return (
|
|
467
|
-
<MultiImagePicker ref={setPickerRef} hitSlop={hitSlop} maxCount={maxCount} parentStyle={parentStyle} callback={onImageSelect}>
|
|
468
|
-
{children}
|
|
469
|
-
</MultiImagePicker>
|
|
498
|
+
</>
|
|
470
499
|
)
|
|
471
500
|
})
|
|
472
501
|
|