@supportworks/multi-imagepicker 8.4.9 → 8.4.10
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/package.json +3 -2
- package/src/components/CameraModal.tsx +47 -46
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supportworks/multi-imagepicker",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.10",
|
|
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.
|
|
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
|
|
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
|
-
|
|
580
|
-
|
|
581
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
{
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
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:
|
|
1549
|
+
marginBottom: 19
|
|
1549
1550
|
},
|
|
1550
1551
|
galleryScrollContainer: {
|
|
1551
|
-
paddingHorizontal:
|
|
1552
|
-
alignItems: '
|
|
1552
|
+
paddingHorizontal: 16,
|
|
1553
|
+
alignItems: 'flex-start'
|
|
1553
1554
|
},
|
|
1554
1555
|
galleryImageItem: {
|
|
1555
1556
|
width: 54,
|