@supportworks/multi-imagepicker 7.3.2 → 8.0.0
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/README.md +43 -219
- package/TestMIP.js +103 -0
- package/changes.md +3 -15
- package/index.js +3 -3
- package/package.json +1 -1
- package/src/components/ActionBar.js +3 -3
- package/src/components/AddImages.js +175 -119
- package/src/components/CameraModal.tsx +790 -0
- package/src/components/ImageDetailsModal.js +11 -20
- package/src/components/ImageIndicators.js +7 -5
- package/src/components/MultiImagePicker.js +76 -10
- package/src/components/MultiImagePicker_JOHNRIPPLE.js +348 -0
- package/src/components/MultiImagePicker_OLD.js +281 -0
- package/src/components/SelectedImages.js +5 -5
- package/src/components/SingleImage.js +6 -6
- package/src/components/UploadWarningModal.js +40 -50
- package/src/lib/MIPickerApi.js +14 -17
- package/src/components/AddImagesProvider.js +0 -269
|
@@ -0,0 +1,790 @@
|
|
|
1
|
+
// Supportworks dependencies
|
|
2
|
+
import { colors } from '@supportworks/app-styler'
|
|
3
|
+
import { CommonButton, SwipeModal } from '@supportworks/core-controls'
|
|
4
|
+
import { Icons } from '@supportworks/icon-library'
|
|
5
|
+
// Camera module
|
|
6
|
+
import {
|
|
7
|
+
CameraView,
|
|
8
|
+
CameraViewRef,
|
|
9
|
+
OnStatusChangeEventPayload,
|
|
10
|
+
OnPhotoCapturedEventPayload,
|
|
11
|
+
ZoomLevel
|
|
12
|
+
} from '@supportworks/camera'
|
|
13
|
+
import React, { useRef, useState } from 'react'
|
|
14
|
+
import {
|
|
15
|
+
View,
|
|
16
|
+
Text,
|
|
17
|
+
StyleSheet,
|
|
18
|
+
TouchableOpacity,
|
|
19
|
+
Alert,
|
|
20
|
+
Image,
|
|
21
|
+
ScrollView,
|
|
22
|
+
Animated,
|
|
23
|
+
PanResponder
|
|
24
|
+
} from 'react-native'
|
|
25
|
+
import Svg, { Circle, Path } from 'react-native-svg'
|
|
26
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
27
|
+
|
|
28
|
+
// Types
|
|
29
|
+
interface CapturedImage {
|
|
30
|
+
uri: string
|
|
31
|
+
depthMapUri?: string
|
|
32
|
+
width?: number
|
|
33
|
+
height?: number
|
|
34
|
+
timestamp: string
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface CameraTestModalProps {
|
|
38
|
+
onDone: (images: { imageURI: string; depthMapURI?: string }[]) => void
|
|
39
|
+
onCancel: () => void
|
|
40
|
+
cameraRef?: React.RefObject<CameraViewRef | null>
|
|
41
|
+
/** If set to 1, only allows a single photo. New photos will replace the existing one. */
|
|
42
|
+
limit?: number
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Event types are now imported from the camera module
|
|
46
|
+
|
|
47
|
+
const ZOOM_LEVELS: ZoomLevel[] = ['1x', '2x', '3x', '4x', '5x']
|
|
48
|
+
const ZOOM_SLIDER_TRACK_LENGTH = 180
|
|
49
|
+
const ZOOM_SLIDER_WIDTH = 40
|
|
50
|
+
const ZOOM_SLIDER_THUMB_SIZE = 32
|
|
51
|
+
const ZOOM_SLIDER_STEP = ZOOM_LEVELS.length > 1 ? ZOOM_SLIDER_TRACK_LENGTH / (ZOOM_LEVELS.length - 1) : 0
|
|
52
|
+
const DEFAULT_ZOOM: ZoomLevel = '1x'
|
|
53
|
+
|
|
54
|
+
const clamp = (value: number, min: number, max: number) => {
|
|
55
|
+
return Math.min(Math.max(value, min), max)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const getTopPositionForZoom = (zoom: ZoomLevel) => {
|
|
59
|
+
if (ZOOM_SLIDER_STEP === 0) {
|
|
60
|
+
return 0
|
|
61
|
+
}
|
|
62
|
+
const index = ZOOM_LEVELS.indexOf(zoom)
|
|
63
|
+
if (index === -1) {
|
|
64
|
+
return 0
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const invertedIndex = ZOOM_LEVELS.length - 1 - index
|
|
68
|
+
return invertedIndex * ZOOM_SLIDER_STEP
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const getZoomForTopPosition = (position: number): ZoomLevel => {
|
|
72
|
+
if (ZOOM_SLIDER_STEP === 0) {
|
|
73
|
+
return DEFAULT_ZOOM
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const clampedPosition = clamp(position, 0, ZOOM_SLIDER_TRACK_LENGTH)
|
|
77
|
+
const normalizedIndex = Math.round(clampedPosition / ZOOM_SLIDER_STEP)
|
|
78
|
+
const zoomIndex = ZOOM_LEVELS.length - 1 - normalizedIndex
|
|
79
|
+
return ZOOM_LEVELS[clamp(zoomIndex, 0, ZOOM_LEVELS.length - 1)]
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const FlipCameraIcon: React.FC<{ size?: number; color?: string }> = ({ size = 28, color = colors.white }) => (
|
|
83
|
+
<Svg width={size} height={size} viewBox="0 0 24 24" fill="none">
|
|
84
|
+
<Path
|
|
85
|
+
d="M4.5 7H7l1.2-2h7.6L17 7h2.5c1.1 0 2 .9 2 2v7.5c0 1.1-.9 2-2 2H4.5c-1.1 0-2-.9-2-2V9c0-1.1.9-2 2-2Z"
|
|
86
|
+
stroke={color}
|
|
87
|
+
strokeWidth={1.6}
|
|
88
|
+
strokeLinecap="round"
|
|
89
|
+
strokeLinejoin="round"
|
|
90
|
+
/>
|
|
91
|
+
<Circle cx={12} cy={12.5} r={3.5} stroke={color} strokeWidth={1.6} />
|
|
92
|
+
<Path
|
|
93
|
+
d="M11.8 9.2A3.3 3.3 0 0 1 15 12.1"
|
|
94
|
+
stroke={color}
|
|
95
|
+
strokeWidth={1.4}
|
|
96
|
+
strokeLinecap="round"
|
|
97
|
+
strokeLinejoin="round"
|
|
98
|
+
/>
|
|
99
|
+
<Path d="M15 12.1l-1-.8" stroke={color} strokeWidth={1.4} strokeLinecap="round" strokeLinejoin="round" />
|
|
100
|
+
<Path d="M15 12.1l-.2 1.3" stroke={color} strokeWidth={1.4} strokeLinecap="round" strokeLinejoin="round" />
|
|
101
|
+
<Path
|
|
102
|
+
d="M12.2 15.8A3.3 3.3 0 0 1 9 12.9"
|
|
103
|
+
stroke={color}
|
|
104
|
+
strokeWidth={1.4}
|
|
105
|
+
strokeLinecap="round"
|
|
106
|
+
strokeLinejoin="round"
|
|
107
|
+
/>
|
|
108
|
+
<Path d="M9 12.9l.9-.8" stroke={color} strokeWidth={1.4} strokeLinecap="round" strokeLinejoin="round" />
|
|
109
|
+
<Path d="M9 12.9l-.2-1.3" stroke={color} strokeWidth={1.4} strokeLinecap="round" strokeLinejoin="round" />
|
|
110
|
+
</Svg>
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraRef: externalCameraRef, limit }) => {
|
|
114
|
+
const internalCameraRef = useRef<CameraViewRef>(null)
|
|
115
|
+
const cameraRef = externalCameraRef || internalCameraRef
|
|
116
|
+
const insets = useSafeAreaInsets()
|
|
117
|
+
|
|
118
|
+
// Debug logging
|
|
119
|
+
React.useEffect(() => {
|
|
120
|
+
console.log('CameraModal: cameraRef is', externalCameraRef ? 'external' : 'internal')
|
|
121
|
+
console.log('CameraModal: cameraRef.current is', cameraRef.current ? 'not null' : 'null')
|
|
122
|
+
}, [externalCameraRef, cameraRef])
|
|
123
|
+
const swipeModalRef = useRef<any>(null)
|
|
124
|
+
const shutterFlashAnim = useRef(new Animated.Value(0)).current
|
|
125
|
+
const [currentZoom, setCurrentZoom] = useState<ZoomLevel>(DEFAULT_ZOOM)
|
|
126
|
+
const [isDepthEnabled, setIsDepthEnabled] = useState<boolean>(true)
|
|
127
|
+
const [isFlashEnabled, setIsFlashEnabled] = useState<boolean>(false)
|
|
128
|
+
const [capturedImages, setCapturedImages] = useState<CapturedImage[]>([])
|
|
129
|
+
const [isFrontCamera, setIsFrontCamera] = useState<boolean>(false)
|
|
130
|
+
const [isGalleryModalVisible, setIsGalleryModalVisible] = useState<boolean>(false)
|
|
131
|
+
const [isDoneButtonDisabled, setIsDoneButtonDisabled] = useState<boolean>(false)
|
|
132
|
+
const knobTop = useRef(new Animated.Value(getTopPositionForZoom(DEFAULT_ZOOM))).current
|
|
133
|
+
const dragStartOffset = useRef(0)
|
|
134
|
+
const sliderDisabled = isFrontCamera
|
|
135
|
+
|
|
136
|
+
const handleStatusChange = (event: { nativeEvent: OnStatusChangeEventPayload }) => {
|
|
137
|
+
const newStatus = event?.nativeEvent?.status || 'Unknown'
|
|
138
|
+
console.log('CAMERA: Status changed to:', newStatus)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const handlePhotoCaptured = (event: { nativeEvent: OnPhotoCapturedEventPayload }) => {
|
|
142
|
+
console.log('CAMERA: Photo captured event:', event)
|
|
143
|
+
const imageUri = event?.nativeEvent?.imageUri
|
|
144
|
+
const depthMapUri = event?.nativeEvent?.depthMapUri
|
|
145
|
+
const imageSize = event?.nativeEvent?.imageSize
|
|
146
|
+
|
|
147
|
+
if (imageUri) {
|
|
148
|
+
const newImage: CapturedImage = {
|
|
149
|
+
uri: imageUri,
|
|
150
|
+
depthMapUri,
|
|
151
|
+
width: imageSize?.width,
|
|
152
|
+
height: imageSize?.height,
|
|
153
|
+
timestamp: new Date().toISOString()
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
setCapturedImages((prevImages) => {
|
|
157
|
+
// If limit is 1, and we already have an image, replace it
|
|
158
|
+
if (limit === 1) {
|
|
159
|
+
return [newImage]
|
|
160
|
+
}
|
|
161
|
+
// Otherwise add to the array
|
|
162
|
+
return [...prevImages, newImage]
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
// If limit is 1, automatically trigger done after capture
|
|
166
|
+
if (limit === 1) {
|
|
167
|
+
// Stop camera first
|
|
168
|
+
if (cameraRef.current) {
|
|
169
|
+
cameraRef.current.stopCamera()
|
|
170
|
+
}
|
|
171
|
+
// Then call onDone with the new image
|
|
172
|
+
onDone([
|
|
173
|
+
{
|
|
174
|
+
imageURI: imageUri,
|
|
175
|
+
depthMapURI: depthMapUri
|
|
176
|
+
}
|
|
177
|
+
])
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const triggerShutterFlash = () => {
|
|
183
|
+
// Flash to black immediately
|
|
184
|
+
Animated.timing(shutterFlashAnim, {
|
|
185
|
+
toValue: 1,
|
|
186
|
+
duration: 0,
|
|
187
|
+
useNativeDriver: true
|
|
188
|
+
}).start(() => {
|
|
189
|
+
// Fade back to transparent over 0.25s
|
|
190
|
+
Animated.timing(shutterFlashAnim, {
|
|
191
|
+
toValue: 0,
|
|
192
|
+
duration: 250,
|
|
193
|
+
useNativeDriver: true
|
|
194
|
+
}).start()
|
|
195
|
+
})
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const capturePhoto = () => {
|
|
199
|
+
console.log('CAMERA: Attempting to capture photo')
|
|
200
|
+
triggerShutterFlash() // Trigger the flash effect
|
|
201
|
+
if (cameraRef.current) {
|
|
202
|
+
cameraRef.current.capturePhoto()
|
|
203
|
+
} else {
|
|
204
|
+
Alert.alert('Error', 'Camera reference not available')
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const toggleCamera = () => {
|
|
209
|
+
console.log('CAMERA: Attempting to switch camera')
|
|
210
|
+
if (cameraRef.current) {
|
|
211
|
+
cameraRef.current.switchCamera()
|
|
212
|
+
setIsFrontCamera((prev) => !prev)
|
|
213
|
+
setIsFlashEnabled(false)
|
|
214
|
+
} else {
|
|
215
|
+
Alert.alert('Error', 'Camera reference not available')
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
React.useEffect(() => {
|
|
220
|
+
if (isFrontCamera) {
|
|
221
|
+
if (isDepthEnabled) {
|
|
222
|
+
setIsDepthEnabled(false)
|
|
223
|
+
}
|
|
224
|
+
if (isFlashEnabled) {
|
|
225
|
+
setIsFlashEnabled(false)
|
|
226
|
+
}
|
|
227
|
+
} else if (!isDepthEnabled) {
|
|
228
|
+
setIsDepthEnabled(true)
|
|
229
|
+
}
|
|
230
|
+
}, [isFrontCamera, isDepthEnabled, isFlashEnabled])
|
|
231
|
+
|
|
232
|
+
const toggleFlash = () => {
|
|
233
|
+
if (isFrontCamera) {
|
|
234
|
+
return
|
|
235
|
+
}
|
|
236
|
+
console.log('CAMERA: Attempting to toggle flash')
|
|
237
|
+
if (cameraRef.current) {
|
|
238
|
+
cameraRef.current.toggleFlash()
|
|
239
|
+
setIsFlashEnabled(!isFlashEnabled)
|
|
240
|
+
} else {
|
|
241
|
+
Alert.alert('Error', 'Camera reference not available')
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const handleZoomChange = React.useCallback((newZoom: ZoomLevel) => {
|
|
246
|
+
setCurrentZoom(newZoom)
|
|
247
|
+
}, [])
|
|
248
|
+
|
|
249
|
+
React.useEffect(() => {
|
|
250
|
+
if (isFrontCamera && currentZoom !== DEFAULT_ZOOM) {
|
|
251
|
+
setCurrentZoom(DEFAULT_ZOOM)
|
|
252
|
+
}
|
|
253
|
+
}, [isFrontCamera, currentZoom])
|
|
254
|
+
|
|
255
|
+
React.useEffect(() => {
|
|
256
|
+
if (cameraRef.current) {
|
|
257
|
+
cameraRef.current.setZoomLevel(currentZoom)
|
|
258
|
+
}
|
|
259
|
+
}, [cameraRef, currentZoom])
|
|
260
|
+
|
|
261
|
+
React.useEffect(() => {
|
|
262
|
+
const targetTop = getTopPositionForZoom(currentZoom)
|
|
263
|
+
dragStartOffset.current = targetTop
|
|
264
|
+
Animated.spring(knobTop, {
|
|
265
|
+
toValue: targetTop,
|
|
266
|
+
useNativeDriver: false,
|
|
267
|
+
tension: 180,
|
|
268
|
+
friction: 20
|
|
269
|
+
}).start()
|
|
270
|
+
}, [currentZoom, knobTop])
|
|
271
|
+
|
|
272
|
+
const sliderPanResponder = React.useMemo(
|
|
273
|
+
() =>
|
|
274
|
+
PanResponder.create({
|
|
275
|
+
onStartShouldSetPanResponder: () => !sliderDisabled,
|
|
276
|
+
onMoveShouldSetPanResponder: () => !sliderDisabled,
|
|
277
|
+
onPanResponderGrant: (evt) => {
|
|
278
|
+
const tapOffset = clamp(evt.nativeEvent.locationY - ZOOM_SLIDER_THUMB_SIZE / 2, 0, ZOOM_SLIDER_TRACK_LENGTH)
|
|
279
|
+
dragStartOffset.current = tapOffset
|
|
280
|
+
knobTop.setValue(tapOffset)
|
|
281
|
+
},
|
|
282
|
+
onPanResponderMove: (_, gestureState) => {
|
|
283
|
+
const next = clamp(dragStartOffset.current + gestureState.dy, 0, ZOOM_SLIDER_TRACK_LENGTH)
|
|
284
|
+
knobTop.setValue(next)
|
|
285
|
+
},
|
|
286
|
+
onPanResponderRelease: (_, gestureState) => {
|
|
287
|
+
const next = clamp(dragStartOffset.current + gestureState.dy, 0, ZOOM_SLIDER_TRACK_LENGTH)
|
|
288
|
+
const nextZoom = getZoomForTopPosition(next)
|
|
289
|
+
handleZoomChange(nextZoom)
|
|
290
|
+
},
|
|
291
|
+
onPanResponderTerminate: (_, gestureState) => {
|
|
292
|
+
const next = clamp(dragStartOffset.current + gestureState.dy, 0, ZOOM_SLIDER_TRACK_LENGTH)
|
|
293
|
+
const nextZoom = getZoomForTopPosition(next)
|
|
294
|
+
handleZoomChange(nextZoom)
|
|
295
|
+
}
|
|
296
|
+
}),
|
|
297
|
+
[sliderDisabled, handleZoomChange, knobTop]
|
|
298
|
+
)
|
|
299
|
+
|
|
300
|
+
const openGalleryModal = () => {
|
|
301
|
+
console.log('OPENING GALLERY MODAL', capturedImages.length)
|
|
302
|
+
if (capturedImages.length > 0) {
|
|
303
|
+
setIsGalleryModalVisible(true)
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const removeImage = (indexToRemove: number) => {
|
|
308
|
+
setCapturedImages((prevImages) => {
|
|
309
|
+
const newImages = prevImages.filter((_, index) => index !== indexToRemove)
|
|
310
|
+
return newImages
|
|
311
|
+
})
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
return (
|
|
315
|
+
<View style={styles.container}>
|
|
316
|
+
{/* Top Controls */}
|
|
317
|
+
<View
|
|
318
|
+
style={[
|
|
319
|
+
styles.topControls,
|
|
320
|
+
{ paddingTop: insets.top + 10, paddingLeft: 20 + insets.left, paddingRight: 20 + insets.right }
|
|
321
|
+
]}
|
|
322
|
+
>
|
|
323
|
+
<View style={styles.topLeft} />
|
|
324
|
+
{/* <View style={styles.topCenter}>
|
|
325
|
+
<Text style={styles.statusText}>{status}</Text>
|
|
326
|
+
</View> */}
|
|
327
|
+
<View style={styles.topRight}>
|
|
328
|
+
<TouchableOpacity
|
|
329
|
+
style={styles.topTextButton}
|
|
330
|
+
hitSlop={{ top: 12, bottom: 12, left: 12, right: 12 }}
|
|
331
|
+
onPress={() => {
|
|
332
|
+
// Stop camera first
|
|
333
|
+
if (cameraRef.current) {
|
|
334
|
+
cameraRef.current.stopCamera()
|
|
335
|
+
}
|
|
336
|
+
// Then call onCancel
|
|
337
|
+
onCancel()
|
|
338
|
+
}}
|
|
339
|
+
>
|
|
340
|
+
<Icons.IconUndo width={18} height={18} fill={colors.white} />
|
|
341
|
+
<Text style={styles.topTextButtonLabel}>Cancel</Text>
|
|
342
|
+
</TouchableOpacity>
|
|
343
|
+
</View>
|
|
344
|
+
</View>
|
|
345
|
+
<View pointerEvents="box-none" style={[styles.sideControls, { right: 20 + insets.right }]}>
|
|
346
|
+
<TouchableOpacity
|
|
347
|
+
style={[
|
|
348
|
+
styles.sideButton,
|
|
349
|
+
styles.sideButtonSpacing,
|
|
350
|
+
isFlashEnabled && styles.sideButtonActive,
|
|
351
|
+
isFrontCamera && styles.sideButtonDisabled
|
|
352
|
+
]}
|
|
353
|
+
onPress={toggleFlash}
|
|
354
|
+
disabled={isFrontCamera}
|
|
355
|
+
>
|
|
356
|
+
<Text style={styles.sideButtonText}>⚡</Text>
|
|
357
|
+
</TouchableOpacity>
|
|
358
|
+
<TouchableOpacity style={[styles.sideButton, styles.sideButtonSpacing]} onPress={toggleCamera}>
|
|
359
|
+
<FlipCameraIcon color={colors.white} />
|
|
360
|
+
</TouchableOpacity>
|
|
361
|
+
<TouchableOpacity style={[styles.shutterButton, styles.recordButtonOffset]} onPress={capturePhoto}>
|
|
362
|
+
<View style={styles.shutterInner} />
|
|
363
|
+
</TouchableOpacity>
|
|
364
|
+
</View>
|
|
365
|
+
|
|
366
|
+
{/* Camera View */}
|
|
367
|
+
<View style={styles.cameraContainer}>
|
|
368
|
+
<CameraView
|
|
369
|
+
ref={cameraRef}
|
|
370
|
+
isDepthEnabled={isDepthEnabled}
|
|
371
|
+
zoomLevel={currentZoom}
|
|
372
|
+
onStatusChange={handleStatusChange}
|
|
373
|
+
onPhotoCaptured={handlePhotoCaptured}
|
|
374
|
+
style={styles.camera}
|
|
375
|
+
/>
|
|
376
|
+
</View>
|
|
377
|
+
|
|
378
|
+
<View pointerEvents="box-none" style={[styles.zoomSliderContainer, { left: 20 + insets.left }]}>
|
|
379
|
+
<View style={[styles.zoomSlider, sliderDisabled && styles.zoomSliderDisabled]}>
|
|
380
|
+
<View style={styles.zoomRailContainer} {...sliderPanResponder.panHandlers}>
|
|
381
|
+
<View style={styles.zoomRail} />
|
|
382
|
+
<Animated.View style={[styles.zoomThumb, { top: knobTop }]}>
|
|
383
|
+
<Text style={styles.zoomThumbText}>{currentZoom}</Text>
|
|
384
|
+
</Animated.View>
|
|
385
|
+
</View>
|
|
386
|
+
</View>
|
|
387
|
+
</View>
|
|
388
|
+
|
|
389
|
+
{/* Bottom Controls Container */}
|
|
390
|
+
<View style={styles.bottomControlsContainer}>
|
|
391
|
+
{/* Gallery Thumbnail - Left */}
|
|
392
|
+
|
|
393
|
+
<TouchableOpacity style={styles.galleryContainer} onPress={openGalleryModal}>
|
|
394
|
+
{capturedImages.length > 0 ? (
|
|
395
|
+
<>
|
|
396
|
+
<View style={styles.galleryThumbnail}>
|
|
397
|
+
<Image
|
|
398
|
+
source={{
|
|
399
|
+
uri: capturedImages[capturedImages.length - 1].uri
|
|
400
|
+
}}
|
|
401
|
+
style={styles.galleryImage}
|
|
402
|
+
resizeMode="cover"
|
|
403
|
+
/>
|
|
404
|
+
</View>
|
|
405
|
+
<View style={styles.galleryBadge} pointerEvents="none">
|
|
406
|
+
<Text style={styles.galleryBadgeText}>{capturedImages.length}</Text>
|
|
407
|
+
</View>
|
|
408
|
+
</>
|
|
409
|
+
) : (
|
|
410
|
+
<View style={styles.galleryPlaceholder} />
|
|
411
|
+
)}
|
|
412
|
+
</TouchableOpacity>
|
|
413
|
+
|
|
414
|
+
{/* Done Button - Right */}
|
|
415
|
+
<View style={styles.doneButtonContainer}>
|
|
416
|
+
<CommonButton
|
|
417
|
+
label="Done"
|
|
418
|
+
disabled={isDoneButtonDisabled}
|
|
419
|
+
onPress={() => {
|
|
420
|
+
if (isDoneButtonDisabled) {
|
|
421
|
+
return
|
|
422
|
+
}
|
|
423
|
+
setIsDoneButtonDisabled(true)
|
|
424
|
+
// Stop camera first
|
|
425
|
+
if (cameraRef.current) {
|
|
426
|
+
cameraRef.current.stopCamera()
|
|
427
|
+
}
|
|
428
|
+
// Then call onDone with images
|
|
429
|
+
onDone(
|
|
430
|
+
capturedImages.map((img) => ({
|
|
431
|
+
imageURI: img.uri,
|
|
432
|
+
depthMapURI: img.depthMapUri
|
|
433
|
+
}))
|
|
434
|
+
)
|
|
435
|
+
}}
|
|
436
|
+
size="medium"
|
|
437
|
+
color="primary"
|
|
438
|
+
variant="filled"
|
|
439
|
+
endIcon={<Icons.IconForward_WithPad />}
|
|
440
|
+
/>
|
|
441
|
+
</View>
|
|
442
|
+
</View>
|
|
443
|
+
|
|
444
|
+
{/* Shutter Flash Overlay */}
|
|
445
|
+
<Animated.View style={[styles.shutterFlashOverlay, { opacity: shutterFlashAnim }]} pointerEvents="none" />
|
|
446
|
+
|
|
447
|
+
{/* Gallery SwipeModal */}
|
|
448
|
+
<SwipeModal
|
|
449
|
+
key={`gallery-${isGalleryModalVisible}`}
|
|
450
|
+
ref={swipeModalRef}
|
|
451
|
+
visible={isGalleryModalVisible}
|
|
452
|
+
title="Captured Images"
|
|
453
|
+
subtitle={`${capturedImages.length} images`}
|
|
454
|
+
onClose={() => setIsGalleryModalVisible(false)}
|
|
455
|
+
scrollOffset={1}
|
|
456
|
+
height={240}
|
|
457
|
+
propagateSwipe
|
|
458
|
+
navBarType={3}
|
|
459
|
+
>
|
|
460
|
+
<ScrollView
|
|
461
|
+
horizontal
|
|
462
|
+
showsHorizontalScrollIndicator={false}
|
|
463
|
+
contentContainerStyle={styles.galleryScrollContainer}
|
|
464
|
+
decelerationRate="fast"
|
|
465
|
+
>
|
|
466
|
+
{capturedImages
|
|
467
|
+
.slice()
|
|
468
|
+
.reverse()
|
|
469
|
+
.map((image, index) => (
|
|
470
|
+
<View key={index} style={styles.galleryImageItem}>
|
|
471
|
+
<Image source={{ uri: image.uri }} style={styles.galleryModalImage} resizeMode="cover" />
|
|
472
|
+
<View style={styles.galleryImageOverlay}>
|
|
473
|
+
<TouchableOpacity
|
|
474
|
+
style={styles.removeButton}
|
|
475
|
+
onPress={() => removeImage(capturedImages.length - 1 - index)}
|
|
476
|
+
>
|
|
477
|
+
<Icons.IconClose_WithPad />
|
|
478
|
+
</TouchableOpacity>
|
|
479
|
+
</View>
|
|
480
|
+
</View>
|
|
481
|
+
))}
|
|
482
|
+
</ScrollView>
|
|
483
|
+
</SwipeModal>
|
|
484
|
+
</View>
|
|
485
|
+
)
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
const styles = StyleSheet.create({
|
|
489
|
+
container: {
|
|
490
|
+
flex: 1,
|
|
491
|
+
padding: 10
|
|
492
|
+
},
|
|
493
|
+
topControls: {
|
|
494
|
+
position: 'absolute',
|
|
495
|
+
top: 0,
|
|
496
|
+
left: 0,
|
|
497
|
+
right: 0,
|
|
498
|
+
height: 60,
|
|
499
|
+
flexDirection: 'row',
|
|
500
|
+
alignItems: 'center',
|
|
501
|
+
justifyContent: 'space-between',
|
|
502
|
+
zIndex: 10
|
|
503
|
+
},
|
|
504
|
+
topLeft: {
|
|
505
|
+
width: 60,
|
|
506
|
+
alignItems: 'flex-start',
|
|
507
|
+
justifyContent: 'center'
|
|
508
|
+
},
|
|
509
|
+
topCenter: {
|
|
510
|
+
flex: 1,
|
|
511
|
+
alignItems: 'center',
|
|
512
|
+
justifyContent: 'center'
|
|
513
|
+
},
|
|
514
|
+
topRight: {
|
|
515
|
+
flexDirection: 'row',
|
|
516
|
+
alignItems: 'center',
|
|
517
|
+
justifyContent: 'flex-end',
|
|
518
|
+
flex: 1
|
|
519
|
+
},
|
|
520
|
+
topTextButton: {
|
|
521
|
+
flexDirection: 'row',
|
|
522
|
+
alignItems: 'center',
|
|
523
|
+
backgroundColor: colors.black60,
|
|
524
|
+
borderRadius: 22,
|
|
525
|
+
paddingHorizontal: 18,
|
|
526
|
+
height: 44,
|
|
527
|
+
minWidth: 100,
|
|
528
|
+
justifyContent: 'center'
|
|
529
|
+
},
|
|
530
|
+
topTextButtonLabel: {
|
|
531
|
+
color: colors.white,
|
|
532
|
+
fontSize: 16,
|
|
533
|
+
fontWeight: 'bold',
|
|
534
|
+
marginLeft: 6
|
|
535
|
+
},
|
|
536
|
+
statusText: {
|
|
537
|
+
color: colors.white,
|
|
538
|
+
fontSize: 14,
|
|
539
|
+
fontWeight: '500'
|
|
540
|
+
},
|
|
541
|
+
sideControls: {
|
|
542
|
+
position: 'absolute',
|
|
543
|
+
top: 0,
|
|
544
|
+
bottom: 0,
|
|
545
|
+
right: 20,
|
|
546
|
+
justifyContent: 'center',
|
|
547
|
+
alignItems: 'center',
|
|
548
|
+
zIndex: 10
|
|
549
|
+
},
|
|
550
|
+
sideButton: {
|
|
551
|
+
width: 44,
|
|
552
|
+
height: 44,
|
|
553
|
+
borderRadius: 22,
|
|
554
|
+
backgroundColor: colors.black60,
|
|
555
|
+
alignItems: 'center',
|
|
556
|
+
justifyContent: 'center'
|
|
557
|
+
},
|
|
558
|
+
sideButtonSpacing: {
|
|
559
|
+
marginBottom: 18
|
|
560
|
+
},
|
|
561
|
+
sideButtonText: {
|
|
562
|
+
color: colors.white,
|
|
563
|
+
fontSize: 16,
|
|
564
|
+
fontWeight: 'bold'
|
|
565
|
+
},
|
|
566
|
+
sideButtonActive: {
|
|
567
|
+
backgroundColor: colors.blue
|
|
568
|
+
},
|
|
569
|
+
sideButtonDisabled: {
|
|
570
|
+
opacity: 0.4
|
|
571
|
+
},
|
|
572
|
+
cameraContainer: {
|
|
573
|
+
position: 'absolute',
|
|
574
|
+
top: 0,
|
|
575
|
+
left: 0,
|
|
576
|
+
right: 0,
|
|
577
|
+
bottom: 0
|
|
578
|
+
},
|
|
579
|
+
camera: {
|
|
580
|
+
flex: 1
|
|
581
|
+
},
|
|
582
|
+
bottomControlsContainer: {
|
|
583
|
+
position: 'absolute',
|
|
584
|
+
bottom: 30,
|
|
585
|
+
left: 0,
|
|
586
|
+
right: 0,
|
|
587
|
+
flexDirection: 'row',
|
|
588
|
+
alignItems: 'center',
|
|
589
|
+
justifyContent: 'space-between',
|
|
590
|
+
paddingHorizontal: 20,
|
|
591
|
+
zIndex: 10
|
|
592
|
+
},
|
|
593
|
+
galleryContainer: {
|
|
594
|
+
width: 100,
|
|
595
|
+
height: 60,
|
|
596
|
+
alignItems: 'flex-start',
|
|
597
|
+
justifyContent: 'center',
|
|
598
|
+
overflow: 'visible'
|
|
599
|
+
},
|
|
600
|
+
galleryThumbnail: {
|
|
601
|
+
width: 50,
|
|
602
|
+
height: 50,
|
|
603
|
+
borderRadius: 8,
|
|
604
|
+
overflow: 'hidden',
|
|
605
|
+
position: 'relative',
|
|
606
|
+
backgroundColor: colors.black60,
|
|
607
|
+
borderWidth: 2,
|
|
608
|
+
borderColor: colors.white
|
|
609
|
+
},
|
|
610
|
+
galleryImage: {
|
|
611
|
+
width: '100%',
|
|
612
|
+
height: '100%',
|
|
613
|
+
position: 'absolute',
|
|
614
|
+
top: 0,
|
|
615
|
+
left: 0
|
|
616
|
+
},
|
|
617
|
+
galleryBadge: {
|
|
618
|
+
position: 'absolute',
|
|
619
|
+
top: -5,
|
|
620
|
+
right: 42, // Position relative to the 100px container, accounting for 50px thumbnail
|
|
621
|
+
width: 22,
|
|
622
|
+
height: 22,
|
|
623
|
+
borderRadius: 11,
|
|
624
|
+
backgroundColor: colors.blue,
|
|
625
|
+
alignItems: 'center',
|
|
626
|
+
justifyContent: 'center',
|
|
627
|
+
opacity: 1
|
|
628
|
+
},
|
|
629
|
+
galleryBadgeText: {
|
|
630
|
+
color: colors.white,
|
|
631
|
+
fontSize: 12,
|
|
632
|
+
fontWeight: 'bold'
|
|
633
|
+
},
|
|
634
|
+
galleryPlaceholder: {
|
|
635
|
+
width: 50,
|
|
636
|
+
height: 50,
|
|
637
|
+
borderRadius: 8,
|
|
638
|
+
backgroundColor: colors.black60,
|
|
639
|
+
borderWidth: 2,
|
|
640
|
+
borderColor: colors.black40,
|
|
641
|
+
borderStyle: 'dashed'
|
|
642
|
+
},
|
|
643
|
+
zoomSliderContainer: {
|
|
644
|
+
position: 'absolute',
|
|
645
|
+
top: 0,
|
|
646
|
+
bottom: 0,
|
|
647
|
+
justifyContent: 'center',
|
|
648
|
+
alignItems: 'center',
|
|
649
|
+
zIndex: 12,
|
|
650
|
+
width: ZOOM_SLIDER_WIDTH
|
|
651
|
+
},
|
|
652
|
+
zoomSlider: {
|
|
653
|
+
width: ZOOM_SLIDER_WIDTH,
|
|
654
|
+
alignItems: 'center',
|
|
655
|
+
paddingVertical: 12
|
|
656
|
+
},
|
|
657
|
+
zoomSliderDisabled: {
|
|
658
|
+
opacity: 0.4
|
|
659
|
+
},
|
|
660
|
+
zoomRailContainer: {
|
|
661
|
+
width: ZOOM_SLIDER_WIDTH,
|
|
662
|
+
height: ZOOM_SLIDER_TRACK_LENGTH + ZOOM_SLIDER_THUMB_SIZE,
|
|
663
|
+
alignItems: 'center',
|
|
664
|
+
justifyContent: 'center'
|
|
665
|
+
},
|
|
666
|
+
zoomRail: {
|
|
667
|
+
position: 'absolute',
|
|
668
|
+
top: ZOOM_SLIDER_THUMB_SIZE / 2,
|
|
669
|
+
bottom: ZOOM_SLIDER_THUMB_SIZE / 2,
|
|
670
|
+
width: 4,
|
|
671
|
+
borderRadius: 2,
|
|
672
|
+
backgroundColor: colors.black60
|
|
673
|
+
},
|
|
674
|
+
zoomThumb: {
|
|
675
|
+
position: 'absolute',
|
|
676
|
+
width: ZOOM_SLIDER_THUMB_SIZE,
|
|
677
|
+
height: ZOOM_SLIDER_THUMB_SIZE,
|
|
678
|
+
borderRadius: ZOOM_SLIDER_THUMB_SIZE / 2,
|
|
679
|
+
backgroundColor: colors.white,
|
|
680
|
+
alignItems: 'center',
|
|
681
|
+
justifyContent: 'center',
|
|
682
|
+
left: (ZOOM_SLIDER_WIDTH - ZOOM_SLIDER_THUMB_SIZE) / 2,
|
|
683
|
+
borderWidth: 2,
|
|
684
|
+
borderColor: colors.blue
|
|
685
|
+
},
|
|
686
|
+
zoomThumbText: {
|
|
687
|
+
color: colors.blue,
|
|
688
|
+
fontSize: 12,
|
|
689
|
+
fontWeight: 'bold'
|
|
690
|
+
},
|
|
691
|
+
modeContainer: {
|
|
692
|
+
position: 'absolute',
|
|
693
|
+
bottom: 80,
|
|
694
|
+
left: 0,
|
|
695
|
+
right: 0,
|
|
696
|
+
alignItems: 'center',
|
|
697
|
+
justifyContent: 'center'
|
|
698
|
+
},
|
|
699
|
+
modeButton: {
|
|
700
|
+
paddingHorizontal: 16,
|
|
701
|
+
paddingVertical: 8,
|
|
702
|
+
borderRadius: 15,
|
|
703
|
+
backgroundColor: colors.black60,
|
|
704
|
+
alignItems: 'center',
|
|
705
|
+
justifyContent: 'center'
|
|
706
|
+
},
|
|
707
|
+
modeButtonText: {
|
|
708
|
+
color: colors.white,
|
|
709
|
+
fontSize: 12,
|
|
710
|
+
fontWeight: 'bold'
|
|
711
|
+
},
|
|
712
|
+
shutterButton: {
|
|
713
|
+
width: 80,
|
|
714
|
+
height: 80,
|
|
715
|
+
borderRadius: 40,
|
|
716
|
+
backgroundColor: 'transparent',
|
|
717
|
+
alignItems: 'center',
|
|
718
|
+
justifyContent: 'center',
|
|
719
|
+
borderWidth: 4,
|
|
720
|
+
borderColor: colors.white
|
|
721
|
+
},
|
|
722
|
+
recordButtonOffset: {
|
|
723
|
+
marginTop: 20
|
|
724
|
+
},
|
|
725
|
+
shutterInner: {
|
|
726
|
+
width: 65,
|
|
727
|
+
height: 65,
|
|
728
|
+
borderRadius: 30,
|
|
729
|
+
backgroundColor: colors.white
|
|
730
|
+
},
|
|
731
|
+
doneButtonContainer: {
|
|
732
|
+
width: 100,
|
|
733
|
+
alignItems: 'flex-end',
|
|
734
|
+
justifyContent: 'center'
|
|
735
|
+
},
|
|
736
|
+
doneButtonText: {
|
|
737
|
+
color: colors.white,
|
|
738
|
+
fontSize: 14,
|
|
739
|
+
fontWeight: 'bold'
|
|
740
|
+
},
|
|
741
|
+
galleryScrollContainer: {
|
|
742
|
+
paddingHorizontal: 16,
|
|
743
|
+
paddingVertical: 16,
|
|
744
|
+
alignItems: 'center'
|
|
745
|
+
},
|
|
746
|
+
galleryImageItem: {
|
|
747
|
+
width: 90,
|
|
748
|
+
height: 120, // 3:4 aspect ratio (90/120 = 0.75) - vertical
|
|
749
|
+
marginRight: 12,
|
|
750
|
+
borderRadius: 8,
|
|
751
|
+
overflow: 'hidden',
|
|
752
|
+
position: 'relative',
|
|
753
|
+
backgroundColor: colors.black60
|
|
754
|
+
},
|
|
755
|
+
galleryModalImage: {
|
|
756
|
+
width: '100%',
|
|
757
|
+
height: '100%'
|
|
758
|
+
},
|
|
759
|
+
galleryImageOverlay: {
|
|
760
|
+
position: 'absolute',
|
|
761
|
+
top: 0,
|
|
762
|
+
left: 0,
|
|
763
|
+
right: 0,
|
|
764
|
+
bottom: 0,
|
|
765
|
+
backgroundColor: colors.black18,
|
|
766
|
+
alignItems: 'flex-end',
|
|
767
|
+
justifyContent: 'flex-start',
|
|
768
|
+
padding: 8
|
|
769
|
+
},
|
|
770
|
+
removeButton: {
|
|
771
|
+
width: 24,
|
|
772
|
+
height: 24,
|
|
773
|
+
borderRadius: 12,
|
|
774
|
+
backgroundColor: colors.white,
|
|
775
|
+
alignItems: 'center',
|
|
776
|
+
justifyContent: 'center',
|
|
777
|
+
opacity: 0.45
|
|
778
|
+
},
|
|
779
|
+
shutterFlashOverlay: {
|
|
780
|
+
position: 'absolute',
|
|
781
|
+
top: 0,
|
|
782
|
+
left: 0,
|
|
783
|
+
right: 0,
|
|
784
|
+
bottom: 0,
|
|
785
|
+
backgroundColor: colors.black,
|
|
786
|
+
zIndex: 5
|
|
787
|
+
}
|
|
788
|
+
})
|
|
789
|
+
|
|
790
|
+
export default CameraModal
|