@supportworks/multi-imagepicker 8.4.9 → 8.4.11

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.
@@ -0,0 +1,188 @@
1
+ /* global beforeEach, afterEach, describe, expect, it, jest */
2
+ import React from 'react'
3
+ import renderer, { act } from 'react-test-renderer'
4
+ import { Alert, Platform } from 'react-native'
5
+ import ImagePicker from 'react-native-image-crop-picker'
6
+ import ImageResizer from '@bam.tech/react-native-image-resizer'
7
+ import { showLoadingOverlay, hideLoadingOverlay } from '@supportworks/navbars'
8
+ import { check } from 'react-native-permissions'
9
+ import MultiImagePicker from '@supportworks/multi-imagepicker/src/components/MultiImagePicker'
10
+ import { isPhotoOperationActive } from '@supportworks/multi-imagepicker/src/components/photoOperation'
11
+
12
+ jest.mock('react-native', () => ({
13
+ AppState: { currentState: 'active' },
14
+ View: 'View',
15
+ TouchableOpacity: 'TouchableOpacity',
16
+ Modal: 'Modal',
17
+ Alert: { alert: jest.fn() },
18
+ Platform: { OS: 'ios', Version: 26, select: values => values.ios },
19
+ Linking: { openURL: jest.fn() }
20
+ }))
21
+ jest.mock('@supportworks/core-controls-ui', () => ({ ActionSheet: 'ActionSheet' }))
22
+ jest.mock('react-native-image-crop-picker', () => ({ openPicker: jest.fn(), openCamera: jest.fn() }))
23
+ jest.mock('@bam.tech/react-native-image-resizer', () => ({ createResizedImage: jest.fn() }))
24
+ jest.mock('@supportworks/api-core', () => ({ Api: { getApi: () => ({ moveLocalFile: jest.fn().mockResolvedValue() }) } }))
25
+ jest.mock('@supportworks/navbars', () => ({ showLoadingOverlay: jest.fn(), hideLoadingOverlay: jest.fn() }))
26
+ jest.mock('react-native-permissions', () => ({
27
+ check: jest.fn(),
28
+ request: jest.fn(),
29
+ openSettings: jest.fn(),
30
+ PERMISSIONS: { IOS: { CAMERA: 'camera', PHOTO_LIBRARY: 'photos' }, ANDROID: { CAMERA: 'camera' } },
31
+ RESULTS: { GRANTED: 'granted', DENIED: 'denied', BLOCKED: 'blocked' }
32
+ }))
33
+ jest.mock('@supportworks/multi-imagepicker/src/components/CameraModal', () => 'CameraModal')
34
+
35
+ const deferred = () => {
36
+ let resolve
37
+ const promise = new Promise(_resolve => { resolve = _resolve })
38
+ return { promise, resolve }
39
+ }
40
+
41
+ const selectPhotoOption = (sheet, index) => {
42
+ sheet.props.onSelect(sheet.props.options[index])
43
+ return sheet.props.onClose()
44
+ }
45
+
46
+ describe('photo operation lifecycle', () => {
47
+ let component
48
+ let originalFrame
49
+ beforeEach(() => {
50
+ jest.clearAllMocks()
51
+ Platform.Version = 26
52
+ originalFrame = global.requestAnimationFrame
53
+ global.requestAnimationFrame = callback => callback()
54
+ check.mockResolvedValue('granted')
55
+ ImagePicker.openPicker.mockResolvedValue([{ path: '/photo.jpg' }])
56
+ ImageResizer.createResizedImage.mockResolvedValue({ path: '/resized.jpg', width: 1500, height: 2000 })
57
+ showLoadingOverlay.mockReturnValue('processing-token')
58
+ })
59
+ afterEach(async () => {
60
+ if (component) await act(async () => { component.unmount() })
61
+ component = null
62
+ global.requestAnimationFrame = originalFrame
63
+ expect(isPhotoOperationActive()).toBe(false)
64
+ })
65
+
66
+ it('opens from the imperative trigger and dismisses without starting a photo operation', async () => {
67
+ const pickerRef = React.createRef()
68
+ const callback = jest.fn()
69
+ await act(async () => { component = renderer.create(<MultiImagePicker ref={pickerRef} callback={callback} />) })
70
+ await act(async () => { pickerRef.current.showActionSheet() })
71
+ expect(component.root.findByType('ActionSheet').props.visible).toBe(true)
72
+ await act(async () => { await component.root.findByType('ActionSheet').props.onClose() })
73
+ expect(component.root.findByType('ActionSheet').props.visible).toBe(false)
74
+ expect(ImagePicker.openPicker).not.toHaveBeenCalled()
75
+ expect(check).not.toHaveBeenCalled()
76
+ expect(callback).not.toHaveBeenCalled()
77
+ })
78
+
79
+ it('waits for dismissal before opening the library and handles duplicate dismissal once', async () => {
80
+ await act(async () => { component = renderer.create(<MultiImagePicker />) })
81
+ await act(async () => { component.root.findByType('TouchableOpacity').props.onPress() })
82
+ const sheet = component.root.findByType('ActionSheet')
83
+ await act(async () => { sheet.props.onSelect(sheet.props.options[1]) })
84
+ expect(ImagePicker.openPicker).not.toHaveBeenCalled()
85
+ expect(check).not.toHaveBeenCalled()
86
+ await act(async () => { await sheet.props.onClose() })
87
+ expect(ImagePicker.openPicker).toHaveBeenCalledTimes(1)
88
+ await act(async () => { await sheet.props.onClose() })
89
+ expect(ImagePicker.openPicker).toHaveBeenCalledTimes(1)
90
+ })
91
+
92
+ it('preserves custom option indexes and exposes Cancel without invoking the callback', async () => {
93
+ const callback = jest.fn()
94
+ await act(async () => {
95
+ component = renderer.create(<MultiImagePicker customButtons={['Import Inspection Photos']} callback={callback} />)
96
+ })
97
+ expect(component.root.findByType('ActionSheet').props.options.map(option => option.title)).toEqual([
98
+ 'Import Inspection Photos', 'Take Photo...', 'Choose from Library...', 'Cancel'
99
+ ])
100
+ await act(async () => { await selectPhotoOption(component.root.findByType('ActionSheet'), 3) })
101
+ expect(callback).not.toHaveBeenCalled()
102
+ await act(async () => { await selectPhotoOption(component.root.findByType('ActionSheet'), 0) })
103
+ expect(callback).toHaveBeenCalledWith(expect.objectContaining({ index: 0, cancelIndex: 3, imageArray: [] }))
104
+ expect(ImagePicker.openPicker).not.toHaveBeenCalled()
105
+ expect(check).not.toHaveBeenCalled()
106
+ })
107
+
108
+ it('blocks both repeated taps and other pickers through native selection, processing, and saving', async () => {
109
+ const selected = deferred()
110
+ const resized = deferred()
111
+ const saved = deferred()
112
+ ImagePicker.openPicker.mockReturnValueOnce(selected.promise)
113
+ ImageResizer.createResizedImage.mockReturnValueOnce(resized.promise)
114
+ const callback = jest.fn(() => saved.promise)
115
+ await act(async () => { component = renderer.create(<><MultiImagePicker callback={callback} /><MultiImagePicker callback={jest.fn()} /></>) })
116
+ let operation
117
+ await act(async () => { operation = selectPhotoOption(component.root.findAllByType('ActionSheet')[0], 1) })
118
+ await act(async () => {
119
+ await selectPhotoOption(component.root.findAllByType('ActionSheet')[0], 1)
120
+ await selectPhotoOption(component.root.findAllByType('ActionSheet')[1], 1)
121
+ })
122
+ expect(ImagePicker.openPicker).toHaveBeenCalledTimes(1)
123
+ expect(component.root.findAllByType('TouchableOpacity')[0].props.disabled).toBe(true)
124
+ await act(async () => { selected.resolve([{ path: '/photo.jpg' }]) })
125
+ expect(showLoadingOverlay).toHaveBeenCalledWith({ message: 'Processing Photos...' })
126
+ expect(isPhotoOperationActive()).toBe(true)
127
+ await act(async () => { resized.resolve({ path: '/resized.jpg', width: 1500, height: 2000 }) })
128
+ expect(callback).toHaveBeenCalledTimes(1)
129
+ expect(hideLoadingOverlay).not.toHaveBeenCalled()
130
+ await act(async () => { await selectPhotoOption(component.root.findAllByType('ActionSheet')[1], 1) })
131
+ expect(ImagePicker.openPicker).toHaveBeenCalledTimes(1)
132
+ await act(async () => { saved.resolve(); await operation })
133
+ expect(hideLoadingOverlay).toHaveBeenCalledWith('processing-token')
134
+ expect(isPhotoOperationActive()).toBe(false)
135
+ })
136
+
137
+ it('waits for camera dismissal, then keeps processing visible until the editor is ready', async () => {
138
+ const ready = deferred()
139
+ const callback = jest.fn(() => ready.promise)
140
+ await act(async () => { component = renderer.create(<MultiImagePicker callback={callback} />) })
141
+ let operation
142
+ await act(async () => { operation = selectPhotoOption(component.root.findByType('ActionSheet'), 0) })
143
+ await act(async () => { component.root.findByType('CameraModal').props.onDone([{ imageURI: '/taken.jpg' }]) })
144
+ expect(ImageResizer.createResizedImage).not.toHaveBeenCalled()
145
+ await act(async () => { component.root.findByType('Modal').props.onDismiss() })
146
+ expect(showLoadingOverlay).toHaveBeenCalled()
147
+ expect(callback.mock.calls[0][0]).toMatchObject({ imageSource: 'taken', imageArray: [{ path: '/taken.jpg', width: 1500, height: 2000 }] })
148
+ expect(hideLoadingOverlay).not.toHaveBeenCalled()
149
+ await act(async () => { ready.resolve(); await operation })
150
+ expect(hideLoadingOverlay).toHaveBeenCalledWith('processing-token')
151
+ })
152
+
153
+ it.each(['cancel', 'permission', 'resize', 'save'])('releases the guard after %s without leaving a loading overlay', async failure => {
154
+ if (failure === 'cancel') ImagePicker.openPicker.mockRejectedValue({ code: 'E_PICKER_CANCELLED' })
155
+ if (failure === 'permission') check.mockResolvedValue('blocked')
156
+ if (failure === 'resize') ImageResizer.createResizedImage.mockRejectedValue(new Error('resize failed'))
157
+ const callback = jest.fn(failure === 'save' ? () => Promise.reject(new Error('save failed')) : () => Promise.resolve())
158
+ await act(async () => { component = renderer.create(<MultiImagePicker callback={callback} />) })
159
+ await act(async () => { await selectPhotoOption(component.root.findByType('ActionSheet'), 1) })
160
+ expect(isPhotoOperationActive()).toBe(false)
161
+ if (failure === 'cancel') expect(Alert.alert).not.toHaveBeenCalled()
162
+ if (failure === 'resize' || failure === 'save') expect(hideLoadingOverlay).toHaveBeenCalledWith('processing-token')
163
+ })
164
+
165
+ it('keeps captured photos when the legacy camera is canceled and waits for saving', async () => {
166
+ Platform.Version = 25
167
+ ImagePicker.openCamera.mockResolvedValueOnce({ path: '/legacy.jpg' }).mockRejectedValueOnce({ code: 'E_PICKER_CANCELLED' })
168
+ const saved = deferred()
169
+ const callback = jest.fn(() => saved.promise)
170
+ await act(async () => { component = renderer.create(<MultiImagePicker callback={callback} />) })
171
+ let operation
172
+ await act(async () => { operation = selectPhotoOption(component.root.findByType('ActionSheet'), 0) })
173
+ expect(callback.mock.calls[0][0]).toMatchObject({ imageSource: 'taken', imageArray: [{ path: '/legacy.jpg' }] })
174
+ expect(isPhotoOperationActive()).toBe(true)
175
+ await act(async () => { saved.resolve(); await operation })
176
+ expect(isPhotoOperationActive()).toBe(false)
177
+ })
178
+
179
+ it('releases a camera operation if its parent unmounts before Done', async () => {
180
+ await act(async () => { component = renderer.create(<MultiImagePicker callback={jest.fn()} />) })
181
+ let operation
182
+ await act(async () => { operation = selectPhotoOption(component.root.findByType('ActionSheet'), 0) })
183
+ await act(async () => { component.unmount() })
184
+ await operation
185
+ component = null
186
+ expect(isPhotoOperationActive()).toBe(false)
187
+ })
188
+ })
package/changes.md CHANGED
@@ -1,3 +1,6 @@
1
+ # v8.4.11 2026-11-14
2
+ * DEV-10323: Use the shared Add Photos action sheet with Close/Cancel; start camera, library, and custom actions after dismissal.
3
+
1
4
  # Unreleased
2
5
  * DEV-10192: Protect the full-screen selected-media preview from Android navigation buttons/taskbar. Keep the annotation wrapper top-only because Canvas owns Samsung bottom padding; the attachment editor and image-details modal already protect both edges.
3
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supportworks/multi-imagepicker",
3
- "version": "8.4.9",
3
+ "version": "8.4.11",
4
4
  "description": "Android and iOS customized multiple image picker. For react-native >= 0.60.",
5
5
  "main": "index.js",
6
6
  "author": {
@@ -17,8 +17,9 @@
17
17
  "@supportworks/analytics": ">=1.0.1",
18
18
  "@supportworks/api-core": ">=1.0.9",
19
19
  "@supportworks/app-styler": ">=1.0.6",
20
- "@supportworks/camera": ">=0.2.3",
20
+ "@supportworks/camera": ">=0.3.1",
21
21
  "@supportworks/core-controls": ">=5.0.0",
22
+ "@supportworks/core-controls-ui": ">=1.1.7",
22
23
  "@supportworks/icon-library": ">=1.11.59",
23
24
  "@supportworks/navbars": ">=3.0.0",
24
25
  "expo-sensors": "*",
@@ -8,6 +8,7 @@ import {
8
8
  CameraViewRef,
9
9
  CameraInfo,
10
10
  OnStatusChangeEventPayload,
11
+ OnZoomChangeEventPayload,
11
12
  OnCamerasAvailableEventPayload,
12
13
  OnPhotoCapturedEventPayload,
13
14
  OnCaptureStateChangeEventPayload,
@@ -115,7 +116,6 @@ const ZOOM_SLIDER_WIDTH = 60
115
116
  const ZOOM_SLIDER_THUMB_SIZE = 42
116
117
  const ZOOM_SLIDER_THUMB_WIDTH = 52
117
118
  const ZOOM_PRESETS = [0.5, 1, 3]
118
- const ZOOM_STEP = 0.5
119
119
  type CameraPermissionState = 'checking' | 'granted' | 'denied'
120
120
 
121
121
  const waitForAppToBeActive = async () => {
@@ -135,10 +135,6 @@ const waitForAppToBeActive = async () => {
135
135
 
136
136
  const roundZoomValue = (value: number) => Math.round(value * 10) / 10
137
137
  const clamp = (value: number, min: number, max: number) => Math.min(Math.max(value, min), max)
138
- const snapZoomValue = (value: number, min: number, max: number) => {
139
- const snapped = Math.round(value / ZOOM_STEP) * ZOOM_STEP
140
- return roundZoomValue(clamp(snapped, min, max))
141
- }
142
138
 
143
139
  const formatZoomLabel = (zoom: number): ZoomLevel => `${Math.round(zoom * 100) / 100}x`
144
140
 
@@ -172,7 +168,7 @@ const getZoomForTopPosition = (position: number, minZoom: number, maxZoom: numbe
172
168
  const clampedPosition = clamp(position, 0, ZOOM_SLIDER_TRACK_LENGTH)
173
169
  const normalized = clampedPosition / ZOOM_SLIDER_TRACK_LENGTH
174
170
  const zoom = maxZoom - normalized * zoomRange
175
- return snapZoomValue(zoom, minZoom, maxZoom)
171
+ return clamp(zoom, minZoom, maxZoom)
176
172
  }
177
173
 
178
174
  const buildZoomRangeForPosition = (cameras: CameraInfo[], position: 'front' | 'back') => {
@@ -252,6 +248,7 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
252
248
  const zoomRailRef = useRef<View>(null)
253
249
  const zoomRailTopRef = useRef<number | null>(null)
254
250
  const [isZoomSliderVisible, setIsZoomSliderVisible] = useState(false)
251
+ const usesNativePinch = Platform.OS === 'ios' && !testImageSource
255
252
  const pinchStart = useRef<{ distance: number; zoom: number } | null>(null)
256
253
  const suppressFocusAfterPinch = useRef(false)
257
254
  const [currentZoom, setCurrentZoom] = useState<number>(DEFAULT_ZOOM)
@@ -576,18 +573,17 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
576
573
  const handleToggleZoomSlider = () => setIsZoomSliderVisible(visible => !visible)
577
574
 
578
575
  const handleZoomChange = React.useCallback((newZoom: number) => {
579
- setCurrentZoom((prevZoom) => {
580
- const nextZoom = snapZoomValue(newZoom, currentZoomRange.min, currentZoomRange.max)
581
- return isSameZoomLevel(prevZoom, nextZoom) ? prevZoom : nextZoom
582
- })
583
- }, [currentZoomRange.max, currentZoomRange.min])
576
+ const nextZoom = clamp(newZoom, currentZoomRange.min, currentZoomRange.max)
577
+ setCurrentZoom(nextZoom)
578
+ if (!testImageSource) cameraRef.current?.setZoomLevel(formatZoomLabel(nextZoom))
579
+ }, [cameraRef, currentZoomRange.max, currentZoomRange.min, testImageSource])
584
580
 
585
581
  React.useEffect(() => {
586
582
  const clampedZoom = clamp(currentZoom, currentZoomRange.min, currentZoomRange.max)
587
583
  if (!isSameZoomLevel(clampedZoom, currentZoom)) {
588
- setCurrentZoom(clampedZoom)
584
+ handleZoomChange(clampedZoom)
589
585
  }
590
- }, [currentZoom, currentZoomRange.max, currentZoomRange.min])
586
+ }, [currentZoom, currentZoomRange.max, currentZoomRange.min, handleZoomChange])
591
587
 
592
588
  React.useEffect(() => {
593
589
  pinchStart.current = null
@@ -617,12 +613,18 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
617
613
  return
618
614
  }
619
615
  const zoom = pinchStart.current.zoom * distance / pinchStart.current.distance
620
- setCurrentZoom(Math.round(clamp(zoom, currentZoomRange.min, currentZoomRange.max) * 100) / 100)
616
+ handleZoomChange(zoom)
621
617
  }
622
618
 
623
619
  const handlePinchEnd = () => { pinchStart.current = null }
624
620
 
621
+ const handleNativeZoomChange = React.useCallback((event: { nativeEvent: OnZoomChangeEventPayload }) => {
622
+ const zoom = parseFloat(event.nativeEvent.zoomLevel)
623
+ if (Number.isFinite(zoom) && zoom > 0) setCurrentZoom(zoom)
624
+ }, [])
625
+
625
626
  React.useEffect(() => {
627
+ if (!enableZoomSlider || !isZoomSliderVisible) return
626
628
  const targetTop = getTopPositionForZoom(currentZoom, currentZoomRange.min, currentZoomRange.max)
627
629
  if (isSliderDragging.current) {
628
630
  knobTop.setValue(targetTop)
@@ -637,7 +639,7 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
637
639
  })
638
640
  animation.start()
639
641
  return () => animation.stop()
640
- }, [currentZoom, currentZoomRange.max, currentZoomRange.min, knobTop])
642
+ }, [currentZoom, currentZoomRange.max, currentZoomRange.min, knobTop, enableZoomSlider, isZoomSliderVisible])
641
643
 
642
644
  const measureZoomRail = React.useCallback(() => {
643
645
  zoomRailRef.current?.measureInWindow((_, y) => {
@@ -844,36 +846,33 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
844
846
  <View
845
847
  style={styles.cameraContainer}
846
848
  testID="camera-pinch-surface"
847
- onStartShouldSetResponderCapture={handleShouldCapturePinch}
848
- onMoveShouldSetResponderCapture={handleShouldCapturePinch}
849
- onResponderGrant={handlePinchStart}
850
- onResponderMove={handlePinchMove}
851
- onResponderRelease={handlePinchEnd}
852
- onResponderTerminate={handlePinchEnd}
849
+ onStartShouldSetResponderCapture={usesNativePinch ? undefined : handleShouldCapturePinch}
850
+ onMoveShouldSetResponderCapture={usesNativePinch ? undefined : handleShouldCapturePinch}
851
+ onResponderGrant={usesNativePinch ? undefined : handlePinchStart}
852
+ onResponderMove={usesNativePinch ? undefined : handlePinchMove}
853
+ onResponderRelease={usesNativePinch ? undefined : handlePinchEnd}
854
+ onResponderTerminate={usesNativePinch ? undefined : handlePinchEnd}
853
855
  >
854
856
  <Pressable style={styles.cameraTouchLayer} onPress={handleCameraPress}>
855
- {/* Keep native preview views out of hit testing so this RN surface receives every finger. */}
856
- <View pointerEvents="none" style={styles.camera} testID="camera-preview-display">
857
- {testImageSource ? (
858
- <View style={[styles.camera, { overflow: 'hidden' }]}>
859
- <Image
860
- source={testImageSource}
861
- resizeMode="cover"
862
- style={[StyleSheet.absoluteFillObject, { width: '100%', height: '100%', transform: [{ scale: currentZoom / 0.5 }, { scaleX: isFrontCamera ? -1 : 1 }] }]}
863
- />
864
- </View>
865
- ) : <CameraView
866
- ref={cameraRef}
867
- isDepthEnabled={isDepthEnabled}
868
- zoomLevel={formatZoomLabel(currentZoom)}
869
- onStatusChange={handleStatusChange}
870
- onCamerasAvailable={handleCamerasAvailable}
871
- onPhotoCaptured={handlePhotoCaptured}
872
- onCaptureStateChange={handleCaptureStateChange}
873
- onError={handleCameraError}
874
- style={styles.camera}
875
- />}
876
- </View>
857
+ {testImageSource ? (
858
+ <View style={[styles.camera, { overflow: 'hidden' }]}>
859
+ <Image
860
+ source={testImageSource}
861
+ resizeMode="cover"
862
+ style={[StyleSheet.absoluteFillObject, { width: '100%', height: '100%', transform: [{ scale: currentZoom / 0.5 }, { scaleX: isFrontCamera ? -1 : 1 }] }]}
863
+ />
864
+ </View>
865
+ ) : <CameraView
866
+ ref={cameraRef}
867
+ isDepthEnabled={isDepthEnabled}
868
+ onZoomChange={handleNativeZoomChange}
869
+ onStatusChange={handleStatusChange}
870
+ onCamerasAvailable={handleCamerasAvailable}
871
+ onPhotoCaptured={handlePhotoCaptured}
872
+ onCaptureStateChange={handleCaptureStateChange}
873
+ onError={handleCameraError}
874
+ style={styles.camera}
875
+ />}
877
876
  {focusPoint ? (
878
877
  <Animated.View
879
878
  style={[
@@ -1132,6 +1131,7 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
1132
1131
  propagateSwipe
1133
1132
  showTopNav={false}
1134
1133
  backgroundColor="#121212"
1134
+ extendBackgroundToBottom
1135
1135
  >
1136
1136
  <View style={styles.gallerySheet}>
1137
1137
  <View style={styles.gallerySheetHeader}>
@@ -1510,6 +1510,7 @@ const styles = StyleSheet.create({
1510
1510
  paddingBottom: 16
1511
1511
  },
1512
1512
  gallerySheetHeader: {
1513
+ height: 56,
1513
1514
  flexDirection: 'row',
1514
1515
  alignItems: 'center',
1515
1516
  justifyContent: 'space-between',
@@ -1545,11 +1546,11 @@ const styles = StyleSheet.create({
1545
1546
  galleryDivider: {
1546
1547
  height: 1,
1547
1548
  backgroundColor: 'rgba(255,255,255,0.09)',
1548
- marginBottom: 14
1549
+ marginBottom: 19
1549
1550
  },
1550
1551
  galleryScrollContainer: {
1551
- paddingHorizontal: 14,
1552
- alignItems: 'center'
1552
+ paddingHorizontal: 16,
1553
+ alignItems: 'flex-start'
1553
1554
  },
1554
1555
  galleryImageItem: {
1555
1556
  width: 54,
@@ -8,7 +8,7 @@ import {
8
8
  Linking,
9
9
  Modal
10
10
  } from 'react-native'
11
- import ActionSheet from '@alessiocancian/react-native-actionsheet'
11
+ import { ActionSheet } from '@supportworks/core-controls-ui'
12
12
  import ImagePicker from 'react-native-image-crop-picker'
13
13
  import ImageResizer from '@bam.tech/react-native-image-resizer'
14
14
  import { Api } from '@supportworks/api-core'
@@ -53,12 +53,12 @@ const MultiImagePicker = forwardRef((props, ref) => {
53
53
  const [showCameraModal, setShowCameraModal] = useState(false)
54
54
  const [isCameraModalMounted, setIsCameraModalMounted] = useState(false)
55
55
  const [isBusy, setIsBusy] = useState(false)
56
- const [actionSheetInstanceKey, setActionSheetInstanceKey] = useState(0)
56
+ const [showPhotoOptions, setShowPhotoOptions] = useState(false)
57
57
 
58
58
  const imgArrRef = useRef([]) // temp array for holding selected images to attach, before title & desc updated
59
59
  const imgDescArrRef = useRef([]) // temp array for holding descriptions of selected images, before saved to project
60
60
  const imgValidArrRef = useRef([]) // temp array for holding boolean value specifying whether each image title is valid or not
61
- const actionSheetRef = useRef(null)
61
+ const pendingPhotoOptionRef = useRef(null)
62
62
  const pendingCameraResultRef = useRef([])
63
63
  const cameraResultResolverRef = useRef(null)
64
64
  const isMountedRef = useRef(true)
@@ -94,8 +94,8 @@ const MultiImagePicker = forwardRef((props, ref) => {
94
94
  )
95
95
 
96
96
  const resetActionSheet = useCallback(() => {
97
- actionSheetRef.current = null
98
- setActionSheetInstanceKey((prevKey) => prevKey + 1)
97
+ pendingPhotoOptionRef.current = null
98
+ setShowPhotoOptions(false)
99
99
  }, [])
100
100
 
101
101
  const showSelectionLimitAlert = useCallback(() => {
@@ -369,16 +369,15 @@ const MultiImagePicker = forwardRef((props, ref) => {
369
369
  }
370
370
  }, [checkAndOpenPicker, pickerDone, remainingCount, requestCameraPermission, resetActionSheet, showPermissionAlert, showSelectionLimitAlert, takePictures])
371
371
 
372
- const showActionSheet = useCallback(() => {
372
+ const handleOpenPhotoOptions = useCallback(() => {
373
373
  if (isPhotoOperationActive() || touchableProps.disabled) return
374
- if (actionSheetRef.current && typeof actionSheetRef.current.show === 'function') {
375
- actionSheetRef.current.show()
376
- }
374
+ pendingPhotoOptionRef.current = null
375
+ setShowPhotoOptions(true)
377
376
  }, [touchableProps.disabled])
378
377
 
379
378
  useImperativeHandle(ref, () => ({
380
- showActionSheet
381
- }), [showActionSheet])
379
+ showActionSheet: handleOpenPhotoOptions
380
+ }), [handleOpenPhotoOptions])
382
381
 
383
382
  const buttonArr = useMemo(
384
383
  () => [...customButtons, useCamera, useLibrary, 'Cancel'],
@@ -386,19 +385,29 @@ const MultiImagePicker = forwardRef((props, ref) => {
386
385
  )
387
386
  const cancelIndex = buttonArr.length - 1
388
387
 
388
+ const handleSelectPhotoOption = useCallback((option) => {
389
+ if (isPhotoOperationActive() || pendingPhotoOptionRef.current !== null) return
390
+ pendingPhotoOptionRef.current = option.index
391
+ }, [])
392
+
393
+ const handleClosePhotoOptions = useCallback(() => {
394
+ const index = pendingPhotoOptionRef.current
395
+ pendingPhotoOptionRef.current = null
396
+ setShowPhotoOptions(false)
397
+ if (index !== null) return handleUsePicker(index, cancelIndex)
398
+ }, [handleUsePicker, cancelIndex])
399
+
389
400
  return (
390
401
  <View style={parentStyle}>
391
402
  <ActionSheet
392
- key={`multi-image-picker-action-sheet-${actionSheetInstanceKey}`}
393
- ref={(node) => {
394
- actionSheetRef.current = node
395
- }}
403
+ visible={showPhotoOptions}
396
404
  title={title}
397
- options={buttonArr}
398
- cancelButtonIndex={cancelIndex}
399
- onPress={(buttonIndex) => handleUsePicker(buttonIndex, cancelIndex)}
405
+ options={buttonArr.map((title, index) => ({ title, index }))}
406
+ showCheckmark={false}
407
+ onSelect={handleSelectPhotoOption}
408
+ onClose={handleClosePhotoOptions}
400
409
  />
401
- <TouchableOpacity {...touchableProps} disabled={touchableProps.disabled || isBusy} onPress={showActionSheet}>
410
+ <TouchableOpacity {...touchableProps} disabled={touchableProps.disabled || isBusy} onPress={handleOpenPhotoOptions}>
402
411
  {children}
403
412
  </TouchableOpacity>
404
413
  {Platform.OS === 'ios' && isCameraModalMounted && (