@supportworks/multi-imagepicker 8.0.19 → 8.2.1

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 CHANGED
@@ -1,4 +1,11 @@
1
1
 
2
+ # v8.2.1 2026-04-10
3
+ * temporary attempt to fix multiple nested modals issue on older iPads
4
+
5
+ # v8.2.0 2026-04-09
6
+ * reverted back to v8.0.16
7
+ * then changed UploadWarningModal to just be a regular component instead of a modal, to fix multiple nested modals issue on older iPads
8
+
2
9
  # v8.0.19 2026-03-31
3
10
  * tweak to attaching
4
11
 
package/index.js CHANGED
@@ -6,11 +6,13 @@ import ImageIndicators from './src/components/ImageIndicators'
6
6
  import ActionBar from './src/components/ActionBar'
7
7
  import ImageDetailsModal from './src/components/ImageDetailsModal'
8
8
  import CameraModal from './src/components/CameraModal'
9
+ import AddImagesView from './src/components/AddImagesView'
9
10
 
10
11
  export {
11
12
  MultiImagePicker,
12
13
  SelectedImages,
13
14
  AddImages,
15
+ AddImagesView,
14
16
  MIPickerApi,
15
17
  ImageIndicators,
16
18
  ActionBar,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supportworks/multi-imagepicker",
3
- "version": "8.0.19",
3
+ "version": "8.2.1",
4
4
  "description": "Android and iOS customized multiple image picker. For react-native >= 0.60.",
5
5
  "main": "index.js",
6
6
  "author": {
@@ -1,88 +1,17 @@
1
1
  import React, { useCallback, useEffect, useState, useRef, forwardRef, useImperativeHandle } from 'react'
2
2
  import {
3
3
  View,
4
- Modal,
5
- StyleSheet, ScrollView, KeyboardAvoidingView, Platform, PermissionsAndroid, Alert
4
+ StyleSheet, Platform, PermissionsAndroid, Alert
6
5
  } from 'react-native'
7
6
  import Moment from 'moment'
8
- import { Icons } from '@supportworks/icon-library'
9
7
  import loaderHandler from './loaderHandler'
10
8
  import MultiImagePicker from './MultiImagePicker'
11
- import SelectedImages from './SelectedImages'
12
- import { colors } from '@supportworks/app-styler'
13
9
  import { LoadingOverlay } from '@supportworks/navbars'
14
- import { CheckBox, AppBarH8, CommonButton, ListItem, ScreenSafeAreaView } from '@supportworks/core-controls'
15
10
  import { CameraRoll } from '@react-native-camera-roll/camera-roll'
16
11
  import { Api } from '@supportworks/api-core'
17
12
  import { Analytics } from '@supportworks/analytics'
18
13
  import AsyncStorage from '@react-native-async-storage/async-storage'
19
- import UploadWarningModal from './UploadWarningModal'
20
-
21
- const ADD_IMAGES_LOG_PREFIX = '[AddImages]'
22
-
23
- function getFileExtension (value = '') {
24
- const normalizedValue = String(value || '').split('?')[0]
25
- const lastSlash = normalizedValue.lastIndexOf('/')
26
- const lastDot = normalizedValue.lastIndexOf('.')
27
-
28
- if (lastDot === -1 || lastDot < lastSlash) {
29
- return ''
30
- }
31
-
32
- return normalizedValue.substring(lastDot)
33
- }
34
-
35
- function summarizeImageForLog (img = {}, idx = null) {
36
- const path = img?.path || ''
37
- const filename = img?.filename || ''
38
-
39
- return {
40
- idx,
41
- path,
42
- mime: img?.mime || null,
43
- filename: filename || null,
44
- filenameHasExtension: !!getFileExtension(filename),
45
- defaultName: img?.defaultName || null,
46
- pathExtension: getFileExtension(path) || null,
47
- width: img?.width ?? null,
48
- height: img?.height ?? null,
49
- size: img?.size ?? null,
50
- sourceURL: img?.sourceURL || null,
51
- hasDepthMapUri: !!img?.depthMapUri,
52
- saveToDevice: img?.saveToDevice ?? null,
53
- showToCust: img?.showToCust ?? null,
54
- isValid: img?.isValid ?? null
55
- }
56
- }
57
-
58
- function summarizePayloadForLog (payload = {}) {
59
- const imageArray = Array.isArray(payload?.imageArray) ? payload.imageArray : []
60
- const imageDescArray = Array.isArray(payload?.imageDescArray) ? payload.imageDescArray : []
61
- const imageValidArray = Array.isArray(payload?.imageValidArray) ? payload.imageValidArray : []
62
-
63
- return {
64
- imageSource: payload?.imageSource || null,
65
- index: payload?.index ?? null,
66
- cancelIndex: payload?.cancelIndex ?? null,
67
- imageCount: imageArray.length,
68
- descCount: imageDescArray.length,
69
- validCount: imageValidArray.length,
70
- images: imageArray.map((img, idx) => summarizeImageForLog(img, idx))
71
- }
72
- }
73
-
74
- function logAddImages (message, details = null) {
75
- if (details === null || details === undefined) {
76
- console.log(`${ADD_IMAGES_LOG_PREFIX} ${message}`)
77
- return
78
- }
79
-
80
- try {
81
- console.log(`${ADD_IMAGES_LOG_PREFIX} ${message}: ${JSON.stringify(details)}`)
82
- } catch (err) {
83
- console.log(`${ADD_IMAGES_LOG_PREFIX} ${message}`, details)
84
- }
85
- }
14
+ import AddImagesView from './AddImagesView'
86
15
 
87
16
  const AddImages = forwardRef((
88
17
  {
@@ -94,12 +23,13 @@ const AddImages = forwardRef((
94
23
  allowEdit = true, // whether to allow user to edit file names and descriptions
95
24
  annotationAllowed = false, // whether to allow annotations on images
96
25
  showToCustomerAllowed = false, // whether to allow "show to customer" option
26
+ renderInlineEditor = true, // backward-compatible inline editor rendering; disable to mount AddImagesView elsewhere
27
+ onEditorStateChange = null, // optional callback for externally mounting AddImagesView in a caller-controlled full-screen container
97
28
  maxCount, // = null, //max number of images that can be selected. Passed to MultiImagePicker. If null default not commented out, causes crash, so leave it this way.
98
29
  children
99
30
  }, ref) => {
100
31
  const [showAttaching, setShowAttaching] = useState(false)
101
32
  const [showAdd, setShowAdd] = useState(false)
102
- const [pendingAttach, setPendingAttach] = useState(false)
103
33
  const [showInfoDialog, setShowInfoDialog] = useState(false)
104
34
  const [allImageDataValid, setAllImageDataValid] = useState(true)
105
35
  const [showToCust, setShowToCust] = useState(false)
@@ -113,6 +43,14 @@ const AddImages = forwardRef((
113
43
  const imgSourceRef = useRef(null) // temp value designating picker type used, if image was "taken" from device now, or image(s) chosen from "library"
114
44
  const pickerRef = useRef(null)
115
45
  const isMountedRef = useRef(true)
46
+ const onCloseRef = useRef(null)
47
+ const onAttachRef = useRef(null)
48
+ const onDeleteItemRef = useRef(null)
49
+ const onItemChangeRef = useRef(null)
50
+ const onCloseInfoDialogRef = useRef(null)
51
+ const onValidateRef = useRef(null)
52
+ const onPressCheckboxShowToCustRef = useRef(null)
53
+ const onPressCheckboxSaveToDeviceRef = useRef(null)
116
54
  const STORAGE_KEY_SKIP_DIALOG = '@MIP_UploadWarningsModal_Skip'
117
55
  const allowSaveToDevicePlatform = Platform.OS !== 'android' // TODO: set to true when Android support is added
118
56
 
@@ -127,7 +65,6 @@ const AddImages = forwardRef((
127
65
  }, [])
128
66
 
129
67
  const triggerAction = useCallback(() => {
130
- logAddImages('triggerAction called', { hasPickerRef: !!pickerRef.current })
131
68
  if (pickerRef.current && typeof pickerRef.current.showActionSheet === 'function') {
132
69
  pickerRef.current.showActionSheet()
133
70
  }
@@ -160,14 +97,6 @@ const AddImages = forwardRef((
160
97
  const addPicturesToProject = useCallback(async () => {
161
98
  // go through all images selected and add to project
162
99
  try {
163
- logAddImages('addPicturesToProject start', {
164
- itemCount: itemsRef.current.length,
165
- imageSource: imgSourceRef.current,
166
- allowSaveToDevice,
167
- saveToDevice,
168
- showToCust,
169
- items: (itemsRef.current || []).map((item, idx) => summarizeImageForLog(item, idx))
170
- })
171
100
  loaderHandler.showLoader('Saving Pictures...')
172
101
 
173
102
  // Save selected images to device camera roll (per-item), only for camera-taken images
@@ -181,157 +110,64 @@ const AddImages = forwardRef((
181
110
  {
182
111
  for (const it of toSave) {
183
112
  try {
184
- logAddImages('CameraRoll.save attempt', summarizeImageForLog(it))
185
113
  await CameraRoll.save(it.path)
186
- logAddImages('CameraRoll.save success', { path: it.path })
187
114
  } catch (err) {
188
- logAddImages('CameraRoll.save failed', {
189
- path: it.path,
190
- error: err?.message || err?.toString?.() || String(err),
191
- stack: err?.stack || null
192
- })
115
+ console.log('CameraRoll.save failed for ' + it.path + '; Error: ' + err)
193
116
  }
194
117
  }
195
118
  }
196
119
  }
197
120
  }
198
121
  } catch (e) {
199
- logAddImages('Error during save-to-device batch', {
200
- error: e?.message || e?.toString?.() || String(e),
201
- stack: e?.stack || null
202
- })
122
+ console.log('Error during save-to-device batch: ' + e)
203
123
  }
204
124
 
205
125
  // Upload/add images to project
206
126
  for (let i = 0; i < itemsRef.current.length; i++) {
207
- const currentItem = itemsRef.current[i]
208
- logAddImages('Uploading item', {
209
- idx: i,
210
- imageSource: imgSourceRef.current,
211
- item: summarizeImageForLog(currentItem, i)
212
- })
213
127
  if (addPicture) {
214
- const addPictureResult = await addPicture(currentItem, currentItem?.desc || '', prospectInst)
215
- logAddImages('addPicture result', { idx: i, result: addPictureResult })
128
+ await addPicture(itemsRef.current[i], itemsRef.current[i]?.desc || '', prospectInst)
216
129
  } else {
217
- const apiResult = await Api.getApi().addOnePictureToProject(currentItem, currentItem?.desc || '', prospectInst)
218
- logAddImages('Api.addOnePictureToProject result', { idx: i, result: apiResult })
130
+ await Api.getApi().addOnePictureToProject(itemsRef.current[i], itemsRef.current[i]?.desc || '', prospectInst)
219
131
  }
220
132
  }
221
133
 
222
134
  loaderHandler.hideLoader()
223
- logAddImages('addPicturesToProject complete', { itemCount: itemsRef.current.length })
224
135
  return true
225
136
  } catch (err) {
226
- logAddImages('addPicturesToProject failed', {
227
- error: err?.message || err?.toString?.() || String(err),
228
- stack: err?.stack || null,
229
- imageSource: imgSourceRef.current,
230
- items: (itemsRef.current || []).map((item, idx) => summarizeImageForLog(item, idx))
231
- })
137
+ console.log('----addPicturesToProject: returning false; ERROR: ' + err.toString())
232
138
  loaderHandler.hideLoader()
233
139
  return false
234
140
  }
235
141
  }, [addPicture, prospectInst, hasAndroidWritePermission, showToCust, saveToDevice, allowSaveToDevice])
236
142
 
237
- const performAttach = useCallback(async () => {
143
+ const onAttach = useCallback(async () => {
238
144
  if (!isMountedRef.current) {
239
145
  return
240
146
  }
241
147
 
242
- logAddImages('performAttach start', {
243
- itemCount: itemsRef.current.length,
244
- imageSource: imgSourceRef.current,
245
- allowEdit,
246
- allowSaveToDevice,
247
- showToCustomerAllowed
248
- })
249
- setShowAttaching(true)
148
+ setShowAttaching(false)
149
+ setShowAdd(false)
250
150
 
251
- try {
252
- const addPicturesResult = await addPicturesToProject()
253
- logAddImages('performAttach addPicturesToProject result', { result: addPicturesResult })
254
- if (allowEdit && allowSaveToDevice) {
255
- await Api.getApi().setDefaultSavePhotosToDevice(saveToDevice)
256
- }
257
- if (allowEdit && showToCustomerAllowed) {
258
- await Api.getApi().setDefaultShowToCustomer(showToCust)
259
- }
260
- Analytics.logEvent('mip_addImages_onAttach', { source_page: 'MultiImagePicker' })
261
- if (callback) {
262
- callback()
263
- }
264
- } finally {
265
- if (isMountedRef.current) {
266
- setShowAttaching(false)
267
- setPendingAttach(false)
268
- }
269
- logAddImages('performAttach end', {
270
- itemCount: itemsRef.current.length,
271
- pendingAttach: false
272
- })
151
+ await addPicturesToProject()
152
+ if (allowEdit && allowSaveToDevice) {
153
+ await Api.getApi().setDefaultSavePhotosToDevice(saveToDevice)
273
154
  }
274
- }, [addPicturesToProject, allowEdit, callback, saveToDevice, allowSaveToDevice, showToCust, showToCustomerAllowed])
275
-
276
- const onAttach = useCallback(() => {
277
- if (!isMountedRef.current) {
278
- return
155
+ if (allowEdit && showToCustomerAllowed) {
156
+ await Api.getApi().setDefaultShowToCustomer(showToCust)
279
157
  }
280
-
281
- logAddImages('onAttach pressed', {
282
- platform: Platform.OS,
283
- showAdd,
284
- itemCount: itemsRef.current.length,
285
- allImageDataValid,
286
- imageSource: imgSourceRef.current
287
- })
288
-
289
- if (Platform.OS === 'ios' && showAdd) {
290
- logAddImages('onAttach deferring until modal closes on iOS', {
291
- itemCount: itemsRef.current.length,
292
- imageSource: imgSourceRef.current
293
- })
294
- setPendingAttach(true)
295
- setShowAdd(false)
296
- return
158
+ Analytics.logEvent('mip_addImages_onAttach', { source_page: 'MultiImagePicker' })
159
+ if (callback) {
160
+ callback()
297
161
  }
298
-
299
- void performAttach()
300
- }, [allImageDataValid, performAttach, showAdd])
301
-
302
- const onAddModalDismiss = useCallback(() => {
303
- logAddImages('onAddModalDismiss fired', {
304
- pendingAttach,
305
- itemCount: itemsRef.current.length,
306
- imageSource: imgSourceRef.current
307
- })
308
- }, [pendingAttach])
309
-
310
- useEffect(() => {
311
- if (!pendingAttach || showAdd) {
312
- return
313
- }
314
-
315
- logAddImages('pendingAttach detected with modal closed, starting performAttach', {
316
- itemCount: itemsRef.current.length,
317
- imageSource: imgSourceRef.current
318
- })
319
- void performAttach()
320
- }, [pendingAttach, performAttach, showAdd])
162
+ }, [addPicturesToProject, allowEdit, callback, saveToDevice, allowSaveToDevice, showToCust, showToCustomerAllowed])
321
163
 
322
164
  const onClose = useCallback(() => {
323
165
  if (!isMountedRef.current) {
324
166
  return
325
167
  }
326
- logAddImages('onClose called', {
327
- itemCount: itemsRef.current.length,
328
- imageSource: imgSourceRef.current,
329
- pendingAttach
330
- })
331
- setPendingAttach(false)
332
168
  setShowAttaching(false)
333
169
  setShowAdd(false)
334
- }, [pendingAttach])
170
+ }, [])
335
171
 
336
172
  const onCloseInfoDialog = useCallback(async (storageVal) => {
337
173
  try {
@@ -452,8 +288,6 @@ const AddImages = forwardRef((
452
288
  // Build unified items list from payload
453
289
  // handle return of selected images from MultiImagePicker
454
290
 
455
- logAddImages('onImageSelect raw payload', summarizePayloadForLog(payload))
456
-
457
291
  const { imageArray = [], imageDescArray = [], imageValidArray = [] } = payload || {}
458
292
  const timestampSeed = Date.now()
459
293
  itemsRef.current = imageArray.map((img, i) => ({
@@ -466,31 +300,9 @@ const AddImages = forwardRef((
466
300
  }))
467
301
  imgSourceRef.current = payload.imageSource
468
302
 
469
- logAddImages('onImageSelect normalized items', {
470
- imageSource: payload?.imageSource || null,
471
- itemCount: itemsRef.current.length,
472
- items: itemsRef.current.map((item, idx) => summarizeImageForLog(item, idx))
473
- })
474
-
475
- if (payload?.imageSource === 'taken') {
476
- const suspiciousTakenItems = itemsRef.current
477
- .map((item, idx) => ({ idx, item }))
478
- .filter(({ item }) => !item?.filename || !getFileExtension(item.filename))
479
- .map(({ idx, item }) => summarizeImageForLog(item, idx))
480
-
481
- if (suspiciousTakenItems.length > 0) {
482
- logAddImages('taken image(s) missing filename extension after normalization', suspiciousTakenItems)
483
- }
484
- }
485
-
486
303
  // init for saving selected images to device camera roll, only for camera-taken images
487
304
  const canSaveToDevice = allowSaveToDevicePlatform && (payload.imageSource === 'taken')
488
305
  setAllowSaveToDevice(canSaveToDevice)
489
- logAddImages('onImageSelect save-to-device capability', {
490
- allowSaveToDevicePlatform,
491
- imageSource: payload?.imageSource || null,
492
- canSaveToDevice
493
- })
494
306
 
495
307
  if (allowEdit) {
496
308
  const [defaultSaveToDevice, defaultShowToCustomer] = await Promise.all([
@@ -498,11 +310,6 @@ const AddImages = forwardRef((
498
310
  showToCustomerAllowed ? Api.getApi().getDefaultShowToCustomer() : Promise.resolve(false)
499
311
  ])
500
312
 
501
- logAddImages('onImageSelect default flags loaded', {
502
- defaultSaveToDevice,
503
- defaultShowToCustomer
504
- })
505
-
506
313
  // initialize per-image flags
507
314
  const initialSaveFlag = canSaveToDevice ? defaultSaveToDevice : false
508
315
  const initialShowFlag = showToCustomerAllowed ? !!defaultShowToCustomer : false
@@ -525,17 +332,8 @@ const AddImages = forwardRef((
525
332
  if (skipped !== 'true') {
526
333
  setShowInfoDialog(true)
527
334
  }
528
- logAddImages('onImageSelect modal shown', {
529
- itemCount: itemsRef.current.length,
530
- skippedUploadWarningDialog: skipped === 'true',
531
- initialSaveFlag,
532
- initialShowFlag
533
- })
534
335
  } catch (e) {
535
- logAddImages('error reading skip dialog pref', {
536
- error: e?.message || e?.toString?.() || String(e),
537
- stack: e?.stack || null
538
- })
336
+ console.log('AddImages: error reading skip dialog pref: ' + e)
539
337
  setShowInfoDialog(true)
540
338
  }
541
339
  }
@@ -544,174 +342,121 @@ const AddImages = forwardRef((
544
342
  if (isMountedRef.current) {
545
343
  setItems([...itemsRef.current])
546
344
  }
547
- logAddImages('allowEdit disabled, attaching immediately', {
548
- itemCount: itemsRef.current.length,
549
- imageSource: payload?.imageSource || null
550
- })
551
345
  await onAttach()
552
346
  }
553
347
  }, [allowEdit, buildDefaultFilename, onAttach, showToCustomerAllowed])
554
348
 
555
- const SaveOptions = () => {
556
- if (!showToCustomerAllowed && !allowSaveToDevice) {
557
- return null
349
+ const addImagesEditor = (
350
+ <View style={styles.Overlay}>
351
+ <AddImagesView
352
+ items={items}
353
+ annotationAllowed={annotationAllowed}
354
+ showToCustomerAllowed={showToCustomerAllowed}
355
+ allowSaveToDevice={allowSaveToDevice}
356
+ allImageDataValid={allImageDataValid}
357
+ showInfoDialog={showInfoDialog}
358
+ onClose={onClose}
359
+ onAttach={onAttach}
360
+ onDeleteItem={handleDeleteItem}
361
+ onItemChange={onItemChange}
362
+ onCloseInfoDialog={onCloseInfoDialog}
363
+ onValidate={handleSetAllImageDataValid}
364
+ onPressCheckboxShowToCust={onPressCheckbox_ShowToCust}
365
+ onPressCheckboxSaveToDevice={onPressCheckbox_SaveToDevice}
366
+ />
367
+ </View>
368
+ )
369
+
370
+ useEffect(() => {
371
+ onCloseRef.current = onClose
372
+ onAttachRef.current = onAttach
373
+ onDeleteItemRef.current = handleDeleteItem
374
+ onItemChangeRef.current = onItemChange
375
+ onCloseInfoDialogRef.current = onCloseInfoDialog
376
+ onValidateRef.current = handleSetAllImageDataValid
377
+ onPressCheckboxShowToCustRef.current = onPressCheckbox_ShowToCust
378
+ onPressCheckboxSaveToDeviceRef.current = onPressCheckbox_SaveToDevice
379
+ }, [
380
+ handleDeleteItem,
381
+ handleSetAllImageDataValid,
382
+ onAttach,
383
+ onClose,
384
+ onCloseInfoDialog,
385
+ onItemChange,
386
+ onPressCheckbox_SaveToDevice,
387
+ onPressCheckbox_ShowToCust
388
+ ])
389
+
390
+ const externalOnClose = useCallback((...args) => onCloseRef.current?.(...args), [])
391
+ const externalOnAttach = useCallback((...args) => onAttachRef.current?.(...args), [])
392
+ const externalOnDeleteItem = useCallback((...args) => onDeleteItemRef.current?.(...args), [])
393
+ const externalOnItemChange = useCallback((...args) => onItemChangeRef.current?.(...args), [])
394
+ const externalOnCloseInfoDialog = useCallback((...args) => onCloseInfoDialogRef.current?.(...args), [])
395
+ const externalOnValidate = useCallback((...args) => onValidateRef.current?.(...args), [])
396
+ const externalOnPressCheckboxShowToCust = useCallback((...args) => onPressCheckboxShowToCustRef.current?.(...args), [])
397
+ const externalOnPressCheckboxSaveToDevice = useCallback((...args) => onPressCheckboxSaveToDeviceRef.current?.(...args), [])
398
+
399
+ useEffect(() => {
400
+ if (typeof onEditorStateChange !== 'function') {
401
+ return
558
402
  }
559
- const total = items.length
560
- const saveCount = items.filter(i => !!i.saveToDevice).length
561
- const showCount = items.filter(i => !!i.showToCust).length
562
- const allSave = total > 0 && saveCount === total
563
- const someSave = total > 0 && saveCount > 0 && saveCount < total
564
- const allShow = total > 0 && showCount === total
565
- const someShow = total > 0 && showCount > 0 && showCount < total
566
- // console.log(`SaveOptions: total=${total}, saveCount=${saveCount}, showCount=${showCount}, allSave=${allSave}, someSave=${someSave}, allShow=${allShow}, someShow=${someShow}`)
567
-
568
- return (
569
- <View style={styles.SaveOptionsContainer}>
570
- {showToCustomerAllowed
571
- ? <ListItem
572
- key='showToCust'
573
- leftContent={
574
- <View style={styles.IconCircle}>
575
- <Icons.IconEye_WithPad fill={colors.buttonPrimary} fillOpacity={1} />
576
- </View>
577
- }
578
- mainAction={onPressCheckbox_ShowToCust}
579
- rightAction={onPressCheckbox_ShowToCust}
580
- title='Show all to customer'
581
- subtitle='Select to share all w/ customer.'
582
- rightContent={<CheckBox
583
- checked={allShow}
584
- indeterminate={someShow}
585
- onChange={onPressCheckbox_ShowToCust}
586
- />}
587
- height={55}
588
- paddingLeft={20}
589
- rightContentWidth={40}
590
- paddingRight={16}
591
- topSeparator={false}
592
- />
593
- : null}
594
- {allowSaveToDevice
595
- ? <ListItem
596
- key='saveToDevice'
597
- leftContent={
598
- <View style={styles.IconCircle}>
599
- <Icons.IconSave_WithPad fill={colors.buttonPrimary} fillOpacity={1} />
600
- </View>
601
- }
602
- mainAction={onPressCheckbox_SaveToDevice}
603
- rightAction={onPressCheckbox_SaveToDevice}
604
- title='Download all to device'
605
- rightContent={<CheckBox
606
- checked={allSave}
607
- indeterminate={someSave}
608
- onChange={onPressCheckbox_SaveToDevice}
609
- />}
610
- height={56}
611
- paddingLeft={20}
612
- rightContentWidth={40}
613
- paddingRight={16}
614
- topSeparator={showToCustomerAllowed}
615
- />
616
- : null}
617
- </View>
618
- )
619
- }
620
403
 
621
- if (showAttaching) {
622
- return (
623
- <LoadingOverlay />
624
- )
625
- }
404
+ onEditorStateChange({
405
+ visible: showAdd,
406
+ attaching: showAttaching,
407
+ editorProps: {
408
+ items,
409
+ annotationAllowed,
410
+ showToCustomerAllowed,
411
+ allowSaveToDevice,
412
+ allImageDataValid,
413
+ showInfoDialog,
414
+ onClose: externalOnClose,
415
+ onAttach: externalOnAttach,
416
+ onDeleteItem: externalOnDeleteItem,
417
+ onItemChange: externalOnItemChange,
418
+ onCloseInfoDialog: externalOnCloseInfoDialog,
419
+ onValidate: externalOnValidate,
420
+ onPressCheckboxShowToCust: externalOnPressCheckboxShowToCust,
421
+ onPressCheckboxSaveToDevice: externalOnPressCheckboxSaveToDevice
422
+ }
423
+ })
424
+ }, [
425
+ allowSaveToDevice,
426
+ allImageDataValid,
427
+ annotationAllowed,
428
+ externalOnAttach,
429
+ externalOnClose,
430
+ externalOnCloseInfoDialog,
431
+ externalOnDeleteItem,
432
+ externalOnItemChange,
433
+ externalOnPressCheckboxSaveToDevice,
434
+ externalOnPressCheckboxShowToCust,
435
+ externalOnValidate,
436
+ items,
437
+ onEditorStateChange,
438
+ showAdd,
439
+ showAttaching,
440
+ showInfoDialog,
441
+ showToCustomerAllowed
442
+ ])
626
443
 
627
444
  return (
628
445
  <>
629
- {!showAdd && (
630
- <MultiImagePicker ref={setPickerRef} hitSlop={hitSlop} maxCount={maxCount} parentStyle={parentStyle} callback={onImageSelect}>
631
- {children}
632
- </MultiImagePicker>
633
- )}
634
-
635
- <Modal visible={showAdd} presentationStyle='fullScreen' animationType='slide' onDismiss={onAddModalDismiss}>
636
- <ScreenSafeAreaView style={styles.Page} edges={['top','bottom']} includeProvider>
637
- <AppBarH8
638
- variant='regular'
639
- title='Photos to Add'
640
- subtitle={items.length + ' Photo' + (items.length > 1 ? 's' : '')}
641
- leftContentType='closeButton'
642
- callback={onClose}
643
- bgColor={colors.backgroundMedium}
644
- bottomShadow
645
- />
646
- <SaveOptions />
647
- <KeyboardAvoidingView behavior='padding' enabled style={styles.Content}>
648
- <ScrollView contentContainerStyle={styles.ScrollViewContainer} keyboardShouldPersistTaps='handled'>
649
- <SelectedImages
650
- items={items}
651
- callback={handleSetAllImageDataValid}
652
- annotationAllowed={annotationAllowed}
653
- onDeleteItem={handleDeleteItem}
654
- onItemChange={onItemChange}
655
- allowSaveToDevice={allowSaveToDevice}
656
- allowShowToCustomer={showToCustomerAllowed}
657
- />
658
- </ScrollView>
659
- </KeyboardAvoidingView>
660
- <View style={styles.ButtonContainer}>
661
- <CommonButton
662
- variant='filled'
663
- size='medium'
664
- fullWidth
665
- label='Attach'
666
- endIcon={<Icons.IconUploadAll />}
667
- onPress={onAttach}
668
- disabled={!allImageDataValid}
669
- />
670
- </View>
671
- </ScreenSafeAreaView>
672
-
673
- {Api.getApi().sendPhotosToCRM() && false && (
674
- <UploadWarningModal
675
- visible={showInfoDialog}
676
- onClose={onCloseInfoDialog}
677
- />
678
- )}
679
- </Modal>
446
+ {!showAdd && !showAttaching && <MultiImagePicker ref={setPickerRef} hitSlop={hitSlop} maxCount={maxCount} parentStyle={parentStyle} callback={onImageSelect}>
447
+ {children}
448
+ </MultiImagePicker>}
449
+ {renderInlineEditor && showAdd && addImagesEditor}
450
+ {renderInlineEditor && showAttaching && <LoadingOverlay />}
680
451
  </>
681
452
  )
682
453
  })
683
454
 
684
455
  const styles = StyleSheet.create({
685
- Page: {
686
- backgroundColor: colors.backgroundMedium,
687
- flex: 1
688
- },
689
- Content: {
690
- flex: 1
691
- },
692
- ScrollViewContainer: {
693
- paddingBottom: 100,
694
- marginTop: 8
695
- },
696
- SaveOptionsContainer: {
697
- backgroundColor: colors.white,
698
- margin: 16,
699
- borderRadius: 16
700
- },
701
- IconCircle: {
702
- width: 32,
703
- height: 32,
704
- borderRadius: 16,
705
- backgroundColor: colors.buttonPrimaryLight,
706
- justifyContent: 'center',
707
- alignItems: 'center'
708
- },
709
- ButtonContainer: {
710
- height: 56,
711
- paddingHorizontal: 16,
712
- paddingVertical: 8,
713
- borderTopWidth: 1,
714
- borderTopColor: colors.black05
456
+ Overlay: {
457
+ ...StyleSheet.absoluteFillObject,
458
+ zIndex: 1000,
459
+ elevation: 1000
715
460
  }
716
461
  })
717
462
 
@@ -0,0 +1,173 @@
1
+ import React from 'react'
2
+ import { View, StyleSheet, ScrollView, KeyboardAvoidingView } from 'react-native'
3
+ import { Icons } from '@supportworks/icon-library'
4
+ import SelectedImages from './SelectedImages'
5
+ import { colors } from '@supportworks/app-styler'
6
+ import { CheckBox, AppBarH8, CommonButton, ListItem, ScreenSafeAreaView } from '@supportworks/core-controls'
7
+ import { Api } from '@supportworks/api-core'
8
+ import UploadWarningModal from './UploadWarningModal'
9
+
10
+ const AddImagesView = ({
11
+ items = [],
12
+ annotationAllowed = false,
13
+ showToCustomerAllowed = false,
14
+ allowSaveToDevice = false,
15
+ allImageDataValid = true,
16
+ showInfoDialog = false,
17
+ onClose = null,
18
+ onAttach = null,
19
+ onDeleteItem = null,
20
+ onItemChange = null,
21
+ onCloseInfoDialog = null,
22
+ onValidate = null,
23
+ onPressCheckboxShowToCust = null,
24
+ onPressCheckboxSaveToDevice = null
25
+ }) => {
26
+ const SaveOptions = () => {
27
+ if (!showToCustomerAllowed && !allowSaveToDevice) {
28
+ return null
29
+ }
30
+
31
+ const total = items.length
32
+ const saveCount = items.filter(i => !!i.saveToDevice).length
33
+ const showCount = items.filter(i => !!i.showToCust).length
34
+ const allSave = total > 0 && saveCount === total
35
+ const someSave = total > 0 && saveCount > 0 && saveCount < total
36
+ const allShow = total > 0 && showCount === total
37
+ const someShow = total > 0 && showCount > 0 && showCount < total
38
+
39
+ return (
40
+ <View style={styles.SaveOptionsContainer}>
41
+ {showToCustomerAllowed
42
+ ? <ListItem
43
+ key='showToCust'
44
+ leftContent={
45
+ <View style={styles.IconCircle}>
46
+ <Icons.IconEye_WithPad fill={colors.buttonPrimary} fillOpacity={1} />
47
+ </View>
48
+ }
49
+ mainAction={onPressCheckboxShowToCust}
50
+ rightAction={onPressCheckboxShowToCust}
51
+ title='Show all to customer'
52
+ subtitle='Select to share all w/ customer.'
53
+ rightContent={<CheckBox
54
+ checked={allShow}
55
+ indeterminate={someShow}
56
+ onChange={onPressCheckboxShowToCust}
57
+ />}
58
+ height={55}
59
+ paddingLeft={20}
60
+ rightContentWidth={40}
61
+ paddingRight={16}
62
+ topSeparator={false}
63
+ />
64
+ : null}
65
+ {allowSaveToDevice
66
+ ? <ListItem
67
+ key='saveToDevice'
68
+ leftContent={
69
+ <View style={styles.IconCircle}>
70
+ <Icons.IconSave_WithPad fill={colors.buttonPrimary} fillOpacity={1} />
71
+ </View>
72
+ }
73
+ mainAction={onPressCheckboxSaveToDevice}
74
+ rightAction={onPressCheckboxSaveToDevice}
75
+ title='Download all to device'
76
+ rightContent={<CheckBox
77
+ checked={allSave}
78
+ indeterminate={someSave}
79
+ onChange={onPressCheckboxSaveToDevice}
80
+ />}
81
+ height={56}
82
+ paddingLeft={20}
83
+ rightContentWidth={40}
84
+ paddingRight={16}
85
+ topSeparator={showToCustomerAllowed}
86
+ />
87
+ : null}
88
+ </View>
89
+ )
90
+ }
91
+
92
+ return (
93
+ <ScreenSafeAreaView style={styles.Page} edges={['top', 'bottom']} includeProvider>
94
+ <AppBarH8
95
+ variant='regular'
96
+ title='Photos to Add'
97
+ subtitle={items.length + ' Photo' + (items.length > 1 ? 's' : '')}
98
+ leftContentType='closeButton'
99
+ callback={onClose}
100
+ bgColor={colors.backgroundMedium}
101
+ bottomShadow
102
+ />
103
+ <SaveOptions />
104
+ <KeyboardAvoidingView behavior='padding' enabled style={styles.Content}>
105
+ <ScrollView contentContainerStyle={styles.ScrollViewContainer} keyboardShouldPersistTaps='handled'>
106
+ <SelectedImages
107
+ items={items}
108
+ callback={onValidate}
109
+ annotationAllowed={annotationAllowed}
110
+ onDeleteItem={onDeleteItem}
111
+ onItemChange={onItemChange}
112
+ allowSaveToDevice={allowSaveToDevice}
113
+ allowShowToCustomer={showToCustomerAllowed}
114
+ />
115
+ </ScrollView>
116
+ </KeyboardAvoidingView>
117
+ <View style={styles.ButtonContainer}>
118
+ <CommonButton
119
+ variant='filled'
120
+ size='medium'
121
+ fullWidth
122
+ label='Attach'
123
+ endIcon={<Icons.IconUploadAll />}
124
+ onPress={onAttach}
125
+ disabled={!allImageDataValid}
126
+ />
127
+ </View>
128
+
129
+ {Api.getApi().sendPhotosToCRM() && (
130
+ <UploadWarningModal
131
+ visible={showInfoDialog}
132
+ onClose={onCloseInfoDialog}
133
+ />
134
+ )}
135
+ </ScreenSafeAreaView>
136
+ )
137
+ }
138
+
139
+ const styles = StyleSheet.create({
140
+ Page: {
141
+ backgroundColor: colors.backgroundMedium,
142
+ flex: 1
143
+ },
144
+ Content: {
145
+ flex: 1
146
+ },
147
+ ScrollViewContainer: {
148
+ paddingBottom: 100,
149
+ marginTop: 8
150
+ },
151
+ SaveOptionsContainer: {
152
+ backgroundColor: colors.white,
153
+ margin: 16,
154
+ borderRadius: 16
155
+ },
156
+ IconCircle: {
157
+ width: 32,
158
+ height: 32,
159
+ borderRadius: 16,
160
+ backgroundColor: colors.buttonPrimaryLight,
161
+ justifyContent: 'center',
162
+ alignItems: 'center'
163
+ },
164
+ ButtonContainer: {
165
+ height: 56,
166
+ paddingHorizontal: 16,
167
+ paddingVertical: 8,
168
+ borderTopWidth: 1,
169
+ borderTopColor: colors.black05
170
+ }
171
+ })
172
+
173
+ export default AddImagesView
@@ -1,5 +1,5 @@
1
1
  import React, { useCallback, useState } from 'react'
2
- import { Modal, View, StyleSheet, Text, Platform } from 'react-native'
2
+ import { View, StyleSheet, Text, Platform } from 'react-native'
3
3
  import { colors, stdStyles } from '@supportworks/app-styler'
4
4
  import { CheckBox, CommonButton } from '@supportworks/core-controls'
5
5
  import { Icons } from '@supportworks/icon-library'
@@ -15,53 +15,56 @@ const UploadWarningModal = (
15
15
  if (onClose) onClose(skipInfoDialog)
16
16
  }, [onClose, skipInfoDialog])
17
17
 
18
+ if (!visible) {
19
+ return null
20
+ }
21
+
18
22
  return (
19
- <Modal
20
- animationType='fade'
21
- transparent
22
- visible={visible}
23
- onRequestClose={handleClose}
24
- >
25
- <View style={styles.ModalView}>
26
- <View style={styles.InfoDialogContent}>
27
- <View style={styles.InfoDialogIconRow}>
28
- <Icons.IconPencilLock fill={colors.brandPrimary} fillOpacity={1} />
29
- </View>
30
- <View style={styles.InfoDialogTitleRow}>
31
- <Text style={styles.TitleText}>
32
- Captions can't be updated in CRM after upload
33
- </Text>
34
- </View>
35
- <Text style={stdStyles.Body2}>
36
- Photo captions can be edited now, but not after submitting to the CRM. Please review before uploading.
23
+ <View style={styles.ModalView}>
24
+ <View style={styles.Backdrop} />
25
+ <View style={styles.InfoDialogContent}>
26
+ <View style={styles.InfoDialogIconRow}>
27
+ <Icons.IconPencilLock fill={colors.brandPrimary} fillOpacity={1} />
28
+ </View>
29
+ <View style={styles.InfoDialogTitleRow}>
30
+ <Text style={styles.TitleText}>
31
+ Captions can't be updated in CRM after upload
37
32
  </Text>
38
- <View style={styles.InfoDialogCheckboxRow}>
39
- <CheckBox
40
- label="Don't show this message again"
41
- checked={!!skipInfoDialog}
42
- onChange={(newVal) => setSkipInfoDialog(newVal)}
43
- />
44
- </View>
45
- <View style={styles.InfoDialogButtonRow}>
46
- <CommonButton
47
- variant='filled'
48
- size='medium'
49
- label='Got it'
50
- fullWidth
51
- onPress={handleClose}
52
- />
53
- </View>
33
+ </View>
34
+ <Text style={stdStyles.Body2}>
35
+ Photo captions can be edited now, but not after submitting to the CRM. Please review before uploading.
36
+ </Text>
37
+ <View style={styles.InfoDialogCheckboxRow}>
38
+ <CheckBox
39
+ label="Don't show this message again"
40
+ checked={!!skipInfoDialog}
41
+ onChange={(newVal) => setSkipInfoDialog(newVal)}
42
+ />
43
+ </View>
44
+ <View style={styles.InfoDialogButtonRow}>
45
+ <CommonButton
46
+ variant='filled'
47
+ size='medium'
48
+ label='Got it'
49
+ fullWidth
50
+ onPress={handleClose}
51
+ />
54
52
  </View>
55
53
  </View>
56
- </Modal>
54
+ </View>
57
55
  )
58
56
  }
59
57
 
60
58
  const styles = StyleSheet.create({
61
59
  ModalView: {
62
- flex: 1,
60
+ ...StyleSheet.absoluteFillObject,
63
61
  justifyContent: 'center',
64
62
  alignItems: 'center',
63
+ zIndex: 10
64
+ },
65
+ Backdrop: {
66
+ ...StyleSheet.absoluteFillObject,
67
+ backgroundColor: colors.black36
65
68
  },
66
69
  InfoDialogContent: {
67
70
  backgroundColor: 'white',