@supportworks/multi-imagepicker 8.4.5 → 8.4.7
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 +12 -0
- package/package.json +1 -1
- package/src/components/AddImages.js +2 -1
- package/src/components/CameraModal.tsx +372 -202
- package/src/components/MultiImagePicker.js +2 -0
package/README.md
CHANGED
|
@@ -49,6 +49,14 @@ The API instance may provide `makeThumbnail(path)` and `deleteThumbnail(path)` f
|
|
|
49
49
|
|
|
50
50
|
Version 8.4.2 requires `@supportworks/navbars >=3.0.0` for `LoadingOverlayHost` and the shared loading service. Keep `AddImagesProvider` mounted around the editor flow.
|
|
51
51
|
|
|
52
|
+
## Camera layout testing and optional zoom slider
|
|
53
|
+
|
|
54
|
+
`MultiImagePicker` and `AddImages` accept `enableZoomSlider` (default `false`). When enabled, the camera offers an adjustment button to switch between zoom presets and the original vertical slider, with a button to return to the presets. The slider uses the camera's supported range, capped at 5×, in 0.5× steps.
|
|
55
|
+
|
|
56
|
+
A dedicated test harness can pass `testImageSource` (a React Native image source) directly to `src/components/CameraModal`. This replaces the native camera with a sample background, bypasses camera permission requests, and supplies simulated zoom and front/back states. Shutter presses create disposable sample files for Session Roll testing. They are deleted when the tester unmounts, including after Done; do not save its results to customer records. Captures use the source image, not an optically zoomed or focused camera image.
|
|
57
|
+
|
|
58
|
+
Keep that input out of normal camera launches. Ripple only supplies it from its core.test menu tester, presented in the same full-screen modal as normal camera use. Flash, focus, lens switching, and zoom in this mode exercise UI state only; they do not verify camera hardware.
|
|
59
|
+
|
|
52
60
|
## Usage - imports
|
|
53
61
|
|
|
54
62
|
```javascript
|
|
@@ -279,3 +287,7 @@ render() {
|
|
|
279
287
|
...
|
|
280
288
|
}
|
|
281
289
|
```
|
|
290
|
+
|
|
291
|
+
Camera pinch zoom uses two fingers on the preview and continuously adjusts within the reported camera range (up to 5×). It works independently of `enableZoomSlider`, which remains false by default. Presets and the optional original slider retain their fixed/half-step values. Single-finger taps still focus; finishing a pinch does not trigger focus. Physical-device testing is required to assess lens-transition smoothness.
|
|
292
|
+
|
|
293
|
+
Zoom presets are `.5`, `1`, and `3` when supported by the camera. The nearest preset stays selected and shows the current zoom while pinching or using the slider (for example, `1.5×` on the middle button). Exact midpoint ties select the lower preset. Tapping a button always returns to its fixed preset value.
|
package/package.json
CHANGED
|
@@ -23,6 +23,7 @@ const AddImages = forwardRef((
|
|
|
23
23
|
annotationAllowed = false, // whether to allow annotations on images
|
|
24
24
|
showToCustomerAllowed = false, // whether to allow "show to customer" option
|
|
25
25
|
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.
|
|
26
|
+
enableZoomSlider = false,
|
|
26
27
|
existingCount = 0, // number of images already attached outside of this picker session
|
|
27
28
|
children
|
|
28
29
|
}, ref) => {
|
|
@@ -450,7 +451,7 @@ const AddImages = forwardRef((
|
|
|
450
451
|
])
|
|
451
452
|
|
|
452
453
|
return (
|
|
453
|
-
!showAdd && !showAttaching && <MultiImagePicker ref={setPickerRef} hitSlop={hitSlop} maxCount={maxCount} existingCount={existingCount} parentStyle={parentStyle} callback={onImageSelect}>
|
|
454
|
+
!showAdd && !showAttaching && <MultiImagePicker enableZoomSlider={enableZoomSlider} ref={setPickerRef} hitSlop={hitSlop} maxCount={maxCount} existingCount={existingCount} parentStyle={parentStyle} callback={onImageSelect}>
|
|
454
455
|
{children}
|
|
455
456
|
</MultiImagePicker>
|
|
456
457
|
)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Supportworks dependencies
|
|
2
|
-
import { colors } from '@supportworks/app-styler'
|
|
2
|
+
import { colors, stdStyles } from '@supportworks/app-styler'
|
|
3
3
|
import { SwipeModal } from '@supportworks/core-controls'
|
|
4
4
|
import { Icons } from '@supportworks/icon-library'
|
|
5
5
|
// Camera module
|
|
@@ -20,6 +20,7 @@ import { Api } from '@supportworks/api-core'
|
|
|
20
20
|
import FramingGuideOverlay from './FramingGuideOverlay'
|
|
21
21
|
import {
|
|
22
22
|
AppState,
|
|
23
|
+
GestureResponderEvent,
|
|
23
24
|
ActivityIndicator,
|
|
24
25
|
View,
|
|
25
26
|
Text,
|
|
@@ -28,13 +29,14 @@ import {
|
|
|
28
29
|
Pressable,
|
|
29
30
|
Alert,
|
|
30
31
|
Image,
|
|
32
|
+
ImageSourcePropType,
|
|
31
33
|
FlatList,
|
|
32
34
|
Animated,
|
|
33
35
|
PanResponder,
|
|
34
36
|
Platform,
|
|
35
37
|
useWindowDimensions
|
|
36
38
|
} from 'react-native'
|
|
37
|
-
import Svg, {
|
|
39
|
+
import Svg, { Path } from 'react-native-svg'
|
|
38
40
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
39
41
|
import { check, openSettings, PERMISSIONS, request, RESULTS } from 'react-native-permissions'
|
|
40
42
|
|
|
@@ -85,33 +87,35 @@ interface CameraTestModalProps {
|
|
|
85
87
|
limit?: number
|
|
86
88
|
/** Shows a live tilt indicator nudging the user away from steep, floor-only close-ups. */
|
|
87
89
|
angleGuideEnabled?: boolean
|
|
90
|
+
/** Test harness only: replaces native camera access with disposable sample captures. */
|
|
91
|
+
testImageSource?: ImageSourcePropType
|
|
92
|
+
/** Offers a slider alongside the Sketch zoom presets. Off by default. */
|
|
93
|
+
enableZoomSlider?: boolean
|
|
88
94
|
}
|
|
89
95
|
|
|
90
96
|
// Event types are now imported from the camera module
|
|
91
97
|
|
|
92
98
|
const DEFAULT_ZOOM = 1
|
|
93
99
|
const FOCUS_RING_SIZE = 72
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
const
|
|
97
|
-
const
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
const
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
const
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
const DONE_BUTTON_TEXT_SIZE = 20
|
|
109
|
-
const DONE_BUTTON_ICON_SIZE = 28
|
|
110
|
-
const RIGHT_OVERLAY_WIDTH = 132
|
|
100
|
+
const SIDE_BUTTON_SIZE = 40
|
|
101
|
+
const SIDE_BUTTON_ICON_SIZE = 24
|
|
102
|
+
const SIDE_BUTTON_GAP = 8
|
|
103
|
+
const GALLERY_PREVIEW_SIZE = 48
|
|
104
|
+
const GALLERY_PREVIEW_MARGIN_BOTTOM = 40
|
|
105
|
+
const GALLERY_PREVIEW_BORDER_RADIUS = 8
|
|
106
|
+
const GALLERY_PREVIEW_BADGE_SIZE = 20
|
|
107
|
+
const SHUTTER_BUTTON_SIZE = 72
|
|
108
|
+
const SHUTTER_BUTTON_MARGIN_BOTTOM = 40
|
|
109
|
+
const DONE_BUTTON_HEIGHT = 40
|
|
110
|
+
const DONE_BUTTON_HORIZONTAL_PADDING = 12
|
|
111
|
+
const DONE_BUTTON_TEXT_SIZE = 14
|
|
112
|
+
const DONE_BUTTON_ICON_SIZE = 18
|
|
113
|
+
const RIGHT_OVERLAY_WIDTH = 95
|
|
111
114
|
const ZOOM_SLIDER_TRACK_LENGTH = 180
|
|
112
115
|
const ZOOM_SLIDER_WIDTH = 60
|
|
113
116
|
const ZOOM_SLIDER_THUMB_SIZE = 42
|
|
114
117
|
const ZOOM_SLIDER_THUMB_WIDTH = 52
|
|
118
|
+
const ZOOM_PRESETS = [0.5, 1, 3]
|
|
115
119
|
const ZOOM_STEP = 0.5
|
|
116
120
|
type CameraPermissionState = 'checking' | 'granted' | 'denied'
|
|
117
121
|
|
|
@@ -137,10 +141,12 @@ const snapZoomValue = (value: number, min: number, max: number) => {
|
|
|
137
141
|
return roundZoomValue(clamp(snapped, min, max))
|
|
138
142
|
}
|
|
139
143
|
|
|
140
|
-
const formatZoomLabel = (zoom: number): ZoomLevel => {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
+
const formatZoomLabel = (zoom: number): ZoomLevel => `${Math.round(zoom * 100) / 100}x`
|
|
145
|
+
|
|
146
|
+
const pinchDistance = (event: GestureResponderEvent) => {
|
|
147
|
+
const touches = event.nativeEvent.touches
|
|
148
|
+
if (touches.length !== 2) return 0
|
|
149
|
+
return Math.hypot(touches[0].pageX - touches[1].pageX, touches[0].pageY - touches[1].pageY)
|
|
144
150
|
}
|
|
145
151
|
|
|
146
152
|
const isSameZoomLevel = (left: number, right: number) => {
|
|
@@ -199,38 +205,20 @@ const buildZoomRangeForPosition = (cameras: CameraInfo[], position: 'front' | 'b
|
|
|
199
205
|
return { min: minZoom, max: maxZoom }
|
|
200
206
|
}
|
|
201
207
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
<
|
|
212
|
-
<Path
|
|
213
|
-
d="M11.8 9.2A3.3 3.3 0 0 1 15 12.1"
|
|
214
|
-
stroke={color}
|
|
215
|
-
strokeWidth={1.4}
|
|
216
|
-
strokeLinecap="round"
|
|
217
|
-
strokeLinejoin="round"
|
|
218
|
-
/>
|
|
219
|
-
<Path d="M15 12.1l-1-.8" stroke={color} strokeWidth={1.4} strokeLinecap="round" strokeLinejoin="round" />
|
|
220
|
-
<Path d="M15 12.1l-.2 1.3" stroke={color} strokeWidth={1.4} strokeLinecap="round" strokeLinejoin="round" />
|
|
221
|
-
<Path
|
|
222
|
-
d="M12.2 15.8A3.3 3.3 0 0 1 9 12.9"
|
|
223
|
-
stroke={color}
|
|
224
|
-
strokeWidth={1.4}
|
|
225
|
-
strokeLinecap="round"
|
|
226
|
-
strokeLinejoin="round"
|
|
227
|
-
/>
|
|
228
|
-
<Path d="M9 12.9l.9-.8" stroke={color} strokeWidth={1.4} strokeLinecap="round" strokeLinejoin="round" />
|
|
229
|
-
<Path d="M9 12.9l-.2-1.3" stroke={color} strokeWidth={1.4} strokeLinecap="round" strokeLinejoin="round" />
|
|
208
|
+
// Outlines from the camera icons in photos-upload_v2.1.sketch.
|
|
209
|
+
const FlipCameraIcon = ({ size = 24, color = colors.white }) => (
|
|
210
|
+
<Svg width={size} height={size} viewBox="0 0 24 24">
|
|
211
|
+
<Path fill={color} fillRule="evenodd" d="M20.0000 5.0000 L16.8300 5.0000 L15.0000 3.0000 L9.0000 3.0000 L7.1700 5.0000 L4.0000 5.0000 C2.9000 5.0000 2.0000 5.9000 2.0000 7.0000 L2.0000 19.0000 C2.0000 20.1000 2.9000 21.0000 4.0000 21.0000 L20.0000 21.0000 C21.1000 21.0000 22.0000 20.1000 22.0000 19.0000 L22.0000 7.0000 C22.0000 5.9000 21.1000 5.0000 20.0000 5.0000 Z M12.0000 18.0000 C9.2400 18.0000 7.0000 15.7600 7.0000 13.0000 L5.0000 13.0000 L7.5000 10.5000 L10.0000 13.0000 L8.0000 13.0000 C8.0000 15.2100 9.7900 17.0000 12.0000 17.0000 C12.5800 17.0000 13.1300 16.8700 13.6200 16.6500 L14.3600 17.3900 C13.6500 17.7600 12.8600 18.0000 12.0000 18.0000 Z M16.5000 15.5000 L14.0000 13.0000 L16.0000 13.0000 C16.0000 10.7900 14.2100 9.0000 12.0000 9.0000 C11.4200 9.0000 10.8700 9.1300 10.3800 9.3500 L9.6400 8.6200 C10.3500 8.2400 11.1400 8.0000 12.0000 8.0000 C14.7600 8.0000 17.0000 10.2400 17.0000 13.0000 L19.0000 13.0000 L16.5000 15.5000 Z" />
|
|
212
|
+
</Svg>
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
const FlashIcon = ({ enabled }: { enabled: boolean }) => (
|
|
216
|
+
<Svg width={24} height={24} viewBox="0 0 24 24">
|
|
217
|
+
<Path fill={colors.white} d={enabled ? 'M7 2v11h3v9l7-12h-4l4-8Z' : 'M17.0000 10.0000 L13.3900 10.0000 L15.6700 12.2800 L17.0000 10.0000 Z M17.0000 2.0000 L7.0000 2.0000 L7.0000 3.6100 L13.1300 9.7400 L17.0000 2.0000 Z M3.4100 2.8600 L2.0000 4.2700 L7.0000 9.2700 L7.0000 13.0000 L10.0000 13.0000 L10.0000 22.0000 L13.5800 15.8500 L17.7300 20.0000 L19.1400 18.5900 L3.4100 2.8600 Z'} />
|
|
230
218
|
</Svg>
|
|
231
219
|
)
|
|
232
220
|
|
|
233
|
-
const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraRef: externalCameraRef, limit, angleGuideEnabled }) => {
|
|
221
|
+
const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraRef: externalCameraRef, limit, angleGuideEnabled, testImageSource, enableZoomSlider = false }) => {
|
|
234
222
|
const internalCameraRef = useRef<CameraViewRef>(null)
|
|
235
223
|
const cameraRef = externalCameraRef || internalCameraRef
|
|
236
224
|
const insets = useSafeAreaInsets()
|
|
@@ -246,38 +234,40 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
|
|
|
246
234
|
: 1
|
|
247
235
|
const scaleMetric = (value: number, min = 0) => Math.max(min, Math.round(value * controlScale))
|
|
248
236
|
const focusRingSize = scaleMetric(FOCUS_RING_SIZE, 52)
|
|
249
|
-
const cancelButtonMinWidth =
|
|
250
|
-
const cancelButtonHeight =
|
|
237
|
+
const cancelButtonMinWidth = 84
|
|
238
|
+
const cancelButtonHeight = 40
|
|
251
239
|
const cancelButtonPaddingHorizontal = scaleMetric(14, 12)
|
|
252
|
-
const cancelButtonFontSize =
|
|
253
|
-
const
|
|
254
|
-
const
|
|
255
|
-
const
|
|
256
|
-
const
|
|
257
|
-
const
|
|
258
|
-
const
|
|
259
|
-
const
|
|
260
|
-
const
|
|
261
|
-
const
|
|
262
|
-
const
|
|
263
|
-
const
|
|
264
|
-
const
|
|
265
|
-
const
|
|
266
|
-
const
|
|
267
|
-
const
|
|
268
|
-
const
|
|
269
|
-
const
|
|
270
|
-
const doneButtonIconSize = scaleMetric(DONE_BUTTON_ICON_SIZE, 20)
|
|
271
|
-
const doneButtonMarginBottom = scaleMetric(30, 18)
|
|
272
|
-
const rightOverlayWidth = scaleMetric(RIGHT_OVERLAY_WIDTH, 96)
|
|
273
|
-
const topOverlayHorizontalInset = isTightLayout ? 10 : isPhoneSized ? 14 : 18
|
|
274
|
-
const overlaySideInset = isTightLayout ? 8 : isPhoneSized ? 10 : 16
|
|
240
|
+
const cancelButtonFontSize = 14
|
|
241
|
+
const sideButtonSize = SIDE_BUTTON_SIZE
|
|
242
|
+
const sideButtonGap = SIDE_BUTTON_GAP
|
|
243
|
+
const sideButtonIconSize = SIDE_BUTTON_ICON_SIZE
|
|
244
|
+
const galleryPreviewSize = GALLERY_PREVIEW_SIZE
|
|
245
|
+
const galleryPreviewMarginBottom = isPhoneSized ? 0 : GALLERY_PREVIEW_MARGIN_BOTTOM
|
|
246
|
+
const galleryPreviewBorderRadius = GALLERY_PREVIEW_BORDER_RADIUS
|
|
247
|
+
const galleryPreviewBadgeSize = GALLERY_PREVIEW_BADGE_SIZE
|
|
248
|
+
const shutterButtonSize = SHUTTER_BUTTON_SIZE
|
|
249
|
+
const shutterButtonMarginBottom = isPhoneSized ? 0 : SHUTTER_BUTTON_MARGIN_BOTTOM
|
|
250
|
+
const shutterInnerSize = 60
|
|
251
|
+
const doneButtonHeight = DONE_BUTTON_HEIGHT
|
|
252
|
+
const doneButtonHorizontalPadding = DONE_BUTTON_HORIZONTAL_PADDING
|
|
253
|
+
const doneButtonTextSize = DONE_BUTTON_TEXT_SIZE
|
|
254
|
+
const doneButtonIconSize = DONE_BUTTON_ICON_SIZE
|
|
255
|
+
const doneButtonMarginBottom = 0
|
|
256
|
+
const rightOverlayWidth = RIGHT_OVERLAY_WIDTH
|
|
257
|
+
const topOverlayHorizontalInset = 16
|
|
275
258
|
const showFlashControl = !isTightLayout
|
|
276
259
|
const showCameraSwitchControl = !isTightLayout
|
|
277
260
|
const showSecondaryControls = showFlashControl || showCameraSwitchControl
|
|
278
261
|
|
|
279
|
-
const
|
|
262
|
+
const closeGalleryRef = useRef<((type?: string) => void) | null>(null)
|
|
280
263
|
const shutterFlashAnim = useRef(new Animated.Value(0)).current
|
|
264
|
+
const knobTop = useRef(new Animated.Value(0)).current
|
|
265
|
+
const isSliderDragging = useRef(false)
|
|
266
|
+
const zoomRailRef = useRef<View>(null)
|
|
267
|
+
const zoomRailTopRef = useRef<number | null>(null)
|
|
268
|
+
const [isZoomSliderVisible, setIsZoomSliderVisible] = useState(false)
|
|
269
|
+
const pinchStart = useRef<{ distance: number; zoom: number } | null>(null)
|
|
270
|
+
const suppressFocusAfterPinch = useRef(false)
|
|
281
271
|
const [currentZoom, setCurrentZoom] = useState<number>(DEFAULT_ZOOM)
|
|
282
272
|
const [isDepthEnabled, setIsDepthEnabled] = useState<boolean>(true)
|
|
283
273
|
const [isFlashEnabled, setIsFlashEnabled] = useState<boolean>(false)
|
|
@@ -293,16 +283,30 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
|
|
|
293
283
|
const [isGalleryModalVisible, setIsGalleryModalVisible] = useState<boolean>(false)
|
|
294
284
|
const [isDoneButtonDisabled, setIsDoneButtonDisabled] = useState<boolean>(false)
|
|
295
285
|
const [focusPoint, setFocusPoint] = useState<{ x: number; y: number } | null>(null)
|
|
296
|
-
const [cameraPermissionState, setCameraPermissionState] = useState<CameraPermissionState>('checking')
|
|
286
|
+
const [cameraPermissionState, setCameraPermissionState] = useState<CameraPermissionState>(testImageSource ? 'granted' : 'checking')
|
|
297
287
|
const [isCapturePending, setIsCapturePending] = useState<boolean>(false)
|
|
298
288
|
const focusAnim = useRef(new Animated.Value(0)).current
|
|
299
|
-
const knobTop = useRef(new Animated.Value(0)).current
|
|
300
|
-
const isSliderDragging = useRef(false)
|
|
301
|
-
const zoomRailRef = useRef<View>(null)
|
|
302
|
-
const zoomRailTopRef = useRef<number | null>(null)
|
|
303
289
|
const capturePendingRef = useRef(false)
|
|
304
|
-
const
|
|
305
|
-
const
|
|
290
|
+
const testCapturePaths = useRef<string[]>([])
|
|
291
|
+
const isMounted = useRef(true)
|
|
292
|
+
const currentZoomRange = testImageSource
|
|
293
|
+
? { min: isFrontCamera ? 1 : 0.5, max: isFrontCamera ? 1 : 5 }
|
|
294
|
+
: isFrontCamera ? zoomRangeByPosition.front : zoomRangeByPosition.back
|
|
295
|
+
|
|
296
|
+
React.useEffect(() => {
|
|
297
|
+
isMounted.current = true
|
|
298
|
+
return () => {
|
|
299
|
+
isMounted.current = false
|
|
300
|
+
testCapturePaths.current.forEach(path => Api.getApi().RNFS.unlink(path).catch(() => {}))
|
|
301
|
+
testCapturePaths.current = []
|
|
302
|
+
}
|
|
303
|
+
}, [])
|
|
304
|
+
const availableZoomPresets = ZOOM_PRESETS.filter(zoom => zoom >= currentZoomRange.min && zoom <= currentZoomRange.max)
|
|
305
|
+
const displayZoom = roundZoomValue(currentZoom)
|
|
306
|
+
// Keep the lower preset selected at an exact midpoint between two presets.
|
|
307
|
+
const selectedZoomPreset = availableZoomPresets.reduce((nearest, zoom) =>
|
|
308
|
+
Math.abs(zoom - currentZoom) < Math.abs(nearest - currentZoom) ? zoom : nearest,
|
|
309
|
+
availableZoomPresets[0])
|
|
306
310
|
const captureLimit = typeof limit === 'number' && limit > 0 ? limit : null
|
|
307
311
|
const hasReachedCaptureLimit = captureLimit !== null && capturedImages.length >= captureLimit
|
|
308
312
|
const isShutterDisabled = isCapturePending || hasReachedCaptureLimit
|
|
@@ -326,6 +330,7 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
|
|
|
326
330
|
}, [])
|
|
327
331
|
|
|
328
332
|
React.useEffect(() => {
|
|
333
|
+
if (testImageSource) return
|
|
329
334
|
let isCancelled = false
|
|
330
335
|
|
|
331
336
|
const ensureCameraPermission = async () => {
|
|
@@ -463,6 +468,7 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
|
|
|
463
468
|
|
|
464
469
|
const handleCameraPress = React.useCallback(
|
|
465
470
|
(event: { nativeEvent: { locationX: number; locationY: number } }) => {
|
|
471
|
+
if (suppressFocusAfterPinch.current) return
|
|
466
472
|
const { locationX, locationY } = event.nativeEvent
|
|
467
473
|
triggerFocusRing(locationX, locationY)
|
|
468
474
|
if (cameraRef.current) {
|
|
@@ -488,7 +494,7 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
|
|
|
488
494
|
})
|
|
489
495
|
}
|
|
490
496
|
|
|
491
|
-
const
|
|
497
|
+
const handleCapturePhoto = async () => {
|
|
492
498
|
if (capturePendingRef.current) {
|
|
493
499
|
return
|
|
494
500
|
}
|
|
@@ -501,6 +507,27 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
|
|
|
501
507
|
console.log('CAMERA: Attempting to capture photo')
|
|
502
508
|
updateCapturePending(true)
|
|
503
509
|
triggerShutterFlash() // Trigger the flash effect
|
|
510
|
+
if (testImageSource) {
|
|
511
|
+
try {
|
|
512
|
+
const source = Image.resolveAssetSource(testImageSource)
|
|
513
|
+
const image = await ImageResizer.createResizedImage(source.uri, source.width, source.height, 'JPEG', 90)
|
|
514
|
+
if (!isMounted.current) {
|
|
515
|
+
await Api.getApi().RNFS.unlink(image.path).catch(() => {})
|
|
516
|
+
return
|
|
517
|
+
}
|
|
518
|
+
testCapturePaths.current.push(image.path)
|
|
519
|
+
handlePhotoCaptured({ nativeEvent: {
|
|
520
|
+
imageUri: image.uri,
|
|
521
|
+
depthMapUri: '',
|
|
522
|
+
imageSize: { width: image.width, height: image.height }
|
|
523
|
+
} })
|
|
524
|
+
} catch (error) {
|
|
525
|
+
if (isMounted.current) Alert.alert('Sample photo unavailable', 'Unable to create a test photo. Close and reopen the camera tester.')
|
|
526
|
+
} finally {
|
|
527
|
+
if (isMounted.current) updateCapturePending(false)
|
|
528
|
+
}
|
|
529
|
+
return
|
|
530
|
+
}
|
|
504
531
|
if (cameraRef.current) {
|
|
505
532
|
try {
|
|
506
533
|
cameraRef.current.capturePhoto()
|
|
@@ -514,7 +541,12 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
|
|
|
514
541
|
}
|
|
515
542
|
}
|
|
516
543
|
|
|
517
|
-
const
|
|
544
|
+
const handleToggleCamera = () => {
|
|
545
|
+
if (testImageSource) {
|
|
546
|
+
setIsFrontCamera(prev => !prev)
|
|
547
|
+
setIsFlashEnabled(false)
|
|
548
|
+
return
|
|
549
|
+
}
|
|
518
550
|
console.log('CAMERA: Attempting to switch camera')
|
|
519
551
|
if (cameraRef.current) {
|
|
520
552
|
cameraRef.current.switchCamera()
|
|
@@ -538,10 +570,14 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
|
|
|
538
570
|
}
|
|
539
571
|
}, [isFrontCamera, isDepthEnabled, isFlashEnabled])
|
|
540
572
|
|
|
541
|
-
const
|
|
573
|
+
const handleToggleFlash = () => {
|
|
542
574
|
if (isFrontCamera) {
|
|
543
575
|
return
|
|
544
576
|
}
|
|
577
|
+
if (testImageSource) {
|
|
578
|
+
setIsFlashEnabled(prev => !prev)
|
|
579
|
+
return
|
|
580
|
+
}
|
|
545
581
|
console.log('CAMERA: Attempting to toggle flash')
|
|
546
582
|
if (cameraRef.current) {
|
|
547
583
|
cameraRef.current.toggleFlash()
|
|
@@ -551,6 +587,8 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
|
|
|
551
587
|
}
|
|
552
588
|
}
|
|
553
589
|
|
|
590
|
+
const handleToggleZoomSlider = () => setIsZoomSliderVisible(visible => !visible)
|
|
591
|
+
|
|
554
592
|
const handleZoomChange = React.useCallback((newZoom: number) => {
|
|
555
593
|
setCurrentZoom((prevZoom) => {
|
|
556
594
|
const nextZoom = snapZoomValue(newZoom, currentZoomRange.min, currentZoomRange.max)
|
|
@@ -559,17 +597,44 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
|
|
|
559
597
|
}, [currentZoomRange.max, currentZoomRange.min])
|
|
560
598
|
|
|
561
599
|
React.useEffect(() => {
|
|
562
|
-
const clampedZoom =
|
|
600
|
+
const clampedZoom = clamp(currentZoom, currentZoomRange.min, currentZoomRange.max)
|
|
563
601
|
if (!isSameZoomLevel(clampedZoom, currentZoom)) {
|
|
564
602
|
setCurrentZoom(clampedZoom)
|
|
565
603
|
}
|
|
566
604
|
}, [currentZoom, currentZoomRange.max, currentZoomRange.min])
|
|
567
605
|
|
|
568
606
|
React.useEffect(() => {
|
|
569
|
-
|
|
570
|
-
|
|
607
|
+
pinchStart.current = null
|
|
608
|
+
}, [isFrontCamera, currentZoomRange.min, currentZoomRange.max])
|
|
609
|
+
|
|
610
|
+
const handleShouldCapturePinch = (event: GestureResponderEvent) => {
|
|
611
|
+
if (event.nativeEvent.touches.length === 1 && !pinchStart.current) {
|
|
612
|
+
suppressFocusAfterPinch.current = false
|
|
571
613
|
}
|
|
572
|
-
|
|
614
|
+
return !capturePendingRef.current && currentZoomRange.max > currentZoomRange.min && pinchDistance(event) > 0
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
const handlePinchStart = (event: GestureResponderEvent) => {
|
|
618
|
+
const distance = pinchDistance(event)
|
|
619
|
+
pinchStart.current = distance > 0 ? { distance, zoom: currentZoom } : null
|
|
620
|
+
suppressFocusAfterPinch.current = true
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
const handlePinchMove = (event: GestureResponderEvent) => {
|
|
624
|
+
const distance = pinchDistance(event)
|
|
625
|
+
if (!distance || capturePendingRef.current) {
|
|
626
|
+
pinchStart.current = null
|
|
627
|
+
return
|
|
628
|
+
}
|
|
629
|
+
if (!pinchStart.current) {
|
|
630
|
+
handlePinchStart(event)
|
|
631
|
+
return
|
|
632
|
+
}
|
|
633
|
+
const zoom = pinchStart.current.zoom * distance / pinchStart.current.distance
|
|
634
|
+
setCurrentZoom(Math.round(clamp(zoom, currentZoomRange.min, currentZoomRange.max) * 100) / 100)
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
const handlePinchEnd = () => { pinchStart.current = null }
|
|
573
638
|
|
|
574
639
|
React.useEffect(() => {
|
|
575
640
|
const targetTop = getTopPositionForZoom(currentZoom, currentZoomRange.min, currentZoomRange.max)
|
|
@@ -578,12 +643,14 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
|
|
|
578
643
|
return
|
|
579
644
|
}
|
|
580
645
|
|
|
581
|
-
Animated.spring(knobTop, {
|
|
646
|
+
const animation = Animated.spring(knobTop, {
|
|
582
647
|
toValue: targetTop,
|
|
583
648
|
useNativeDriver: false,
|
|
584
649
|
tension: 180,
|
|
585
650
|
friction: 20
|
|
586
|
-
})
|
|
651
|
+
})
|
|
652
|
+
animation.start()
|
|
653
|
+
return () => animation.stop()
|
|
587
654
|
}, [currentZoom, currentZoomRange.max, currentZoomRange.min, knobTop])
|
|
588
655
|
|
|
589
656
|
const measureZoomRail = React.useCallback(() => {
|
|
@@ -614,8 +681,8 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
|
|
|
614
681
|
const sliderPanResponder = React.useMemo(
|
|
615
682
|
() =>
|
|
616
683
|
PanResponder.create({
|
|
617
|
-
onStartShouldSetPanResponder: () =>
|
|
618
|
-
onMoveShouldSetPanResponder: () =>
|
|
684
|
+
onStartShouldSetPanResponder: () => (currentZoomRange.max > currentZoomRange.min),
|
|
685
|
+
onMoveShouldSetPanResponder: () => (currentZoomRange.max > currentZoomRange.min),
|
|
619
686
|
onPanResponderGrant: (event, gestureState) => {
|
|
620
687
|
isSliderDragging.current = true
|
|
621
688
|
measureZoomRail()
|
|
@@ -641,9 +708,14 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
|
|
|
641
708
|
isSliderDragging.current = false
|
|
642
709
|
}
|
|
643
710
|
}),
|
|
644
|
-
[getSliderTopFromGesture,
|
|
711
|
+
[getSliderTopFromGesture, (currentZoomRange.max > currentZoomRange.min), measureZoomRail, updateZoomFromSliderPosition]
|
|
645
712
|
)
|
|
646
713
|
|
|
714
|
+
const handleGalleryCloseReady = React.useCallback((closeModal: ((type?: string) => void) | null) => {
|
|
715
|
+
closeGalleryRef.current = closeModal
|
|
716
|
+
}, [])
|
|
717
|
+
const handleCloseGallery = () => closeGalleryRef.current?.('cancel')
|
|
718
|
+
|
|
647
719
|
const openGalleryModal = () => {
|
|
648
720
|
console.log('OPENING GALLERY MODAL', capturedImages.length)
|
|
649
721
|
if (limit !== 1 && capturedImages.length > 0) {
|
|
@@ -660,23 +732,25 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
|
|
|
660
732
|
|
|
661
733
|
const latestCapturedImage = capturedImages[capturedImages.length - 1]
|
|
662
734
|
const hasCapturedImages = capturedImages.length > 0
|
|
663
|
-
const shouldShowGalleryPreview = limit !== 1
|
|
735
|
+
const shouldShowGalleryPreview = limit !== 1
|
|
664
736
|
const shouldShowDoneButton = limit !== 1
|
|
665
|
-
const
|
|
666
|
-
const
|
|
737
|
+
const shouldShowZoomControls = currentZoomRange.max > currentZoomRange.min && !isTightLayout
|
|
738
|
+
const showZoomSlider = enableZoomSlider && isZoomSliderVisible && shouldShowZoomControls
|
|
739
|
+
const zoomControlsLength = availableZoomPresets.length * 40 + 16
|
|
667
740
|
const gallerySubtitle = `${capturedImages.length} ${capturedImages.length === 1 ? 'image' : 'images'}`
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
741
|
+
// Sketch 16:9: shutter ends 16pt above the photo edge (20pt on SE).
|
|
742
|
+
const phoneControlsBottom = isLandscape ? insets.bottom + 8 : insets.bottom > 0 ? 16 : 20
|
|
743
|
+
const primaryControlsTop = Math.max(insets.top + 96, windowHeight / 2 - shutterButtonSize / 2)
|
|
744
|
+
// SVT artboard: shutter center y=540, flash y=256, switch y=304.
|
|
745
|
+
const secondaryControlsTop = isPhoneSized ? insets.top + 8 : primaryControlsTop - 248
|
|
746
|
+
const zoomControlsTop = isPhoneSized
|
|
747
|
+
? windowHeight - phoneControlsBottom - shutterButtonSize - 63
|
|
748
|
+
: windowHeight / 2 - zoomControlsLength / 2
|
|
749
|
+
|
|
677
750
|
const zoomSliderHeight = ZOOM_SLIDER_TRACK_LENGTH + ZOOM_SLIDER_THUMB_SIZE
|
|
678
751
|
const zoomSliderTop = Math.max(insets.top + (isPhoneSized ? 88 : 104), Math.round(windowHeight * 0.5 - zoomSliderHeight / 2))
|
|
679
752
|
|
|
753
|
+
|
|
680
754
|
const handleCancelPress = () => {
|
|
681
755
|
if (capturePendingRef.current) {
|
|
682
756
|
return
|
|
@@ -769,25 +843,37 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
|
|
|
769
843
|
isCancelDisabled && styles.cancelButtonDisabled
|
|
770
844
|
]}
|
|
771
845
|
hitSlop={{ top: 12, bottom: 12, left: 12, right: 12 }}
|
|
846
|
+
accessibilityLabel="Cancel"
|
|
772
847
|
onPress={handleCancelPress}
|
|
773
848
|
disabled={isCancelDisabled}
|
|
774
849
|
>
|
|
775
850
|
<Text style={[styles.cancelButtonText, { fontSize: cancelButtonFontSize }]}>Cancel</Text>
|
|
776
851
|
</TouchableOpacity>
|
|
777
852
|
|
|
778
|
-
|
|
779
|
-
<View style={[styles.captureCountBadge, { width: captureBadgeSize, height: captureBadgeSize, borderRadius: captureBadgeSize / 2 }]}>
|
|
780
|
-
<Text style={[styles.captureCountBadgeText, { fontSize: captureBadgeFontSize }]}>{capturedImages.length}</Text>
|
|
781
|
-
</View>
|
|
782
|
-
) : (
|
|
783
|
-
<View style={[styles.topOverlaySpacer, { width: captureBadgeSize, height: captureBadgeSize }]} />
|
|
784
|
-
)}
|
|
853
|
+
|
|
785
854
|
</View>
|
|
786
855
|
|
|
787
856
|
{/* Camera View */}
|
|
788
|
-
<View
|
|
857
|
+
<View
|
|
858
|
+
style={styles.cameraContainer}
|
|
859
|
+
testID="camera-pinch-surface"
|
|
860
|
+
onStartShouldSetResponderCapture={handleShouldCapturePinch}
|
|
861
|
+
onMoveShouldSetResponderCapture={handleShouldCapturePinch}
|
|
862
|
+
onResponderGrant={handlePinchStart}
|
|
863
|
+
onResponderMove={handlePinchMove}
|
|
864
|
+
onResponderRelease={handlePinchEnd}
|
|
865
|
+
onResponderTerminate={handlePinchEnd}
|
|
866
|
+
>
|
|
789
867
|
<Pressable style={styles.cameraTouchLayer} onPress={handleCameraPress}>
|
|
790
|
-
|
|
868
|
+
{testImageSource ? (
|
|
869
|
+
<View style={[styles.camera, { overflow: 'hidden' }]}>
|
|
870
|
+
<Image
|
|
871
|
+
source={testImageSource}
|
|
872
|
+
resizeMode="cover"
|
|
873
|
+
style={[StyleSheet.absoluteFillObject, { width: '100%', height: '100%', transform: [{ scale: currentZoom / 0.5 }, { scaleX: isFrontCamera ? -1 : 1 }] }]}
|
|
874
|
+
/>
|
|
875
|
+
</View>
|
|
876
|
+
) : <CameraView
|
|
791
877
|
ref={cameraRef}
|
|
792
878
|
isDepthEnabled={isDepthEnabled}
|
|
793
879
|
zoomLevel={formatZoomLabel(currentZoom)}
|
|
@@ -797,7 +883,7 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
|
|
|
797
883
|
onCaptureStateChange={handleCaptureStateChange}
|
|
798
884
|
onError={handleCameraError}
|
|
799
885
|
style={styles.camera}
|
|
800
|
-
/>
|
|
886
|
+
/>}
|
|
801
887
|
{focusPoint ? (
|
|
802
888
|
<Animated.View
|
|
803
889
|
style={[
|
|
@@ -830,36 +916,50 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
|
|
|
830
916
|
|
|
831
917
|
<View
|
|
832
918
|
pointerEvents="box-none"
|
|
833
|
-
style={[styles.rightOverlay, { width:
|
|
919
|
+
style={[styles.rightOverlay, { width: isPhoneSized ? 88 : 40, right: (isPhoneSized ? 16 : 32) + insets.right, top: secondaryControlsTop }]}
|
|
834
920
|
>
|
|
835
921
|
{showSecondaryControls && (
|
|
836
|
-
<View style={[styles.sideActionGroup, {
|
|
922
|
+
<View style={[styles.sideActionGroup, { flexDirection: isPhoneSized ? 'row' : 'column' }]}>
|
|
837
923
|
{showFlashControl && (
|
|
838
924
|
<TouchableOpacity
|
|
839
925
|
style={[
|
|
840
926
|
styles.sideButton,
|
|
841
927
|
{ width: sideButtonSize, height: sideButtonSize, borderRadius: sideButtonSize / 2 },
|
|
842
|
-
showCameraSwitchControl && { marginBottom: sideButtonGap },
|
|
928
|
+
showCameraSwitchControl && (isPhoneSized ? { marginRight: sideButtonGap } : { marginBottom: sideButtonGap }),
|
|
843
929
|
isFlashEnabled && styles.sideButtonActive,
|
|
844
930
|
isFrontCamera && styles.sideButtonDisabled
|
|
845
931
|
]}
|
|
846
|
-
|
|
932
|
+
accessibilityRole="button"
|
|
933
|
+
accessibilityLabel="Toggle flash"
|
|
934
|
+
onPress={handleToggleFlash}
|
|
847
935
|
disabled={isFrontCamera}
|
|
848
936
|
>
|
|
849
|
-
<
|
|
937
|
+
<FlashIcon enabled={isFlashEnabled} />
|
|
850
938
|
</TouchableOpacity>
|
|
851
939
|
)}
|
|
852
940
|
{showCameraSwitchControl && (
|
|
853
941
|
<TouchableOpacity
|
|
854
942
|
style={[styles.sideButton, { width: sideButtonSize, height: sideButtonSize, borderRadius: sideButtonSize / 2 }]}
|
|
855
|
-
|
|
943
|
+
accessibilityRole="button"
|
|
944
|
+
accessibilityLabel="Switch camera"
|
|
945
|
+
onPress={handleToggleCamera}
|
|
856
946
|
>
|
|
857
947
|
<FlipCameraIcon size={sideButtonIconSize} color={colors.white} />
|
|
858
948
|
</TouchableOpacity>
|
|
859
949
|
)}
|
|
860
950
|
</View>
|
|
861
951
|
)}
|
|
952
|
+
</View>
|
|
862
953
|
|
|
954
|
+
<View
|
|
955
|
+
pointerEvents="box-none"
|
|
956
|
+
style={[
|
|
957
|
+
styles.rightOverlay,
|
|
958
|
+
isPhoneSized
|
|
959
|
+
? { left: 24 + insets.left, right: 24 + insets.right, bottom: phoneControlsBottom, height: shutterButtonSize, width: undefined, flexDirection: 'row', alignItems: 'center' }
|
|
960
|
+
: { width: rightOverlayWidth, right: 16 + insets.right, top: primaryControlsTop - (shouldShowGalleryPreview ? galleryPreviewSize + galleryPreviewMarginBottom : 0), alignItems: 'flex-end' }
|
|
961
|
+
]}
|
|
962
|
+
>
|
|
863
963
|
{shouldShowGalleryPreview ? (
|
|
864
964
|
<TouchableOpacity
|
|
865
965
|
style={[
|
|
@@ -868,10 +968,12 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
|
|
|
868
968
|
width: galleryPreviewSize,
|
|
869
969
|
height: galleryPreviewSize,
|
|
870
970
|
borderRadius: galleryPreviewBorderRadius,
|
|
871
|
-
marginBottom: galleryPreviewMarginBottom
|
|
971
|
+
marginBottom: galleryPreviewMarginBottom,
|
|
972
|
+
marginRight: isPhoneSized ? 0 : 12
|
|
872
973
|
},
|
|
873
974
|
!hasCapturedImages && styles.galleryPreviewButtonEmpty
|
|
874
975
|
]}
|
|
976
|
+
accessibilityLabel="Open Session Roll"
|
|
875
977
|
onPress={openGalleryModal}
|
|
876
978
|
activeOpacity={0.9}
|
|
877
979
|
>
|
|
@@ -885,7 +987,8 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
|
|
|
885
987
|
style={[
|
|
886
988
|
styles.galleryPreviewBadge,
|
|
887
989
|
{
|
|
888
|
-
right:
|
|
990
|
+
right: -9,
|
|
991
|
+
top: -9,
|
|
889
992
|
minWidth: galleryPreviewBadgeSize,
|
|
890
993
|
height: galleryPreviewBadgeSize,
|
|
891
994
|
borderRadius: galleryPreviewBadgeSize / 2
|
|
@@ -903,15 +1006,17 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
|
|
|
903
1006
|
style={[
|
|
904
1007
|
styles.shutterButton,
|
|
905
1008
|
{ width: shutterButtonSize, height: shutterButtonSize, borderRadius: shutterButtonSize / 2, marginBottom: shutterButtonMarginBottom },
|
|
1009
|
+
isPhoneSized && { position: 'absolute', left: '50%', marginLeft: -shutterButtonSize / 2 },
|
|
906
1010
|
isShutterDisabled && styles.shutterButtonDisabled
|
|
907
1011
|
]}
|
|
908
|
-
|
|
1012
|
+
accessibilityLabel="Take photo"
|
|
1013
|
+
onPress={handleCapturePhoto}
|
|
909
1014
|
disabled={isShutterDisabled}
|
|
910
1015
|
>
|
|
911
1016
|
<View
|
|
912
1017
|
style={[
|
|
913
1018
|
styles.shutterButtonOuter,
|
|
914
|
-
{ width: shutterButtonSize, height: shutterButtonSize, borderRadius: shutterButtonSize / 2, borderWidth:
|
|
1019
|
+
{ width: shutterButtonSize, height: shutterButtonSize, borderRadius: shutterButtonSize / 2, borderWidth: 4 },
|
|
915
1020
|
isShutterDisabled && styles.shutterButtonOuterDisabled
|
|
916
1021
|
]}
|
|
917
1022
|
/>
|
|
@@ -928,9 +1033,11 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
|
|
|
928
1033
|
<TouchableOpacity
|
|
929
1034
|
style={[
|
|
930
1035
|
styles.doneButton,
|
|
931
|
-
{ height: doneButtonHeight, paddingHorizontal: doneButtonHorizontalPadding, borderRadius: doneButtonHeight / 2, marginBottom: doneButtonMarginBottom },
|
|
1036
|
+
{ width: 95, height: doneButtonHeight, paddingHorizontal: doneButtonHorizontalPadding, borderRadius: doneButtonHeight / 2, marginBottom: doneButtonMarginBottom },
|
|
1037
|
+
isPhoneSized && { position: 'absolute', right: 0, top: !isLandscape && insets.bottom > 0 ? 17 : 16 },
|
|
932
1038
|
isDoneDisabled && styles.doneButtonDisabled
|
|
933
1039
|
]}
|
|
1040
|
+
accessibilityLabel="Done"
|
|
934
1041
|
onPress={handleDonePress}
|
|
935
1042
|
disabled={isDoneDisabled}
|
|
936
1043
|
>
|
|
@@ -950,22 +1057,75 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
|
|
|
950
1057
|
</View>
|
|
951
1058
|
) : null}
|
|
952
1059
|
|
|
953
|
-
{
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
<View
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
1060
|
+
{shouldShowZoomControls ? (
|
|
1061
|
+
<>
|
|
1062
|
+
{showZoomSlider ? (
|
|
1063
|
+
<View style={[styles.zoomSliderContainer, { left: 12 + insets.left, top: zoomSliderTop }]}>
|
|
1064
|
+
<View style={styles.zoomSlider}>
|
|
1065
|
+
<View
|
|
1066
|
+
ref={zoomRailRef}
|
|
1067
|
+
testID="camera-zoom-slider"
|
|
1068
|
+
style={styles.zoomRailContainer}
|
|
1069
|
+
onLayout={measureZoomRail}
|
|
1070
|
+
{...sliderPanResponder.panHandlers}
|
|
1071
|
+
>
|
|
1072
|
+
<View style={styles.zoomRail} />
|
|
1073
|
+
<Animated.View style={[styles.zoomThumb, { top: knobTop }]}>
|
|
1074
|
+
<Text style={styles.zoomThumbText}>{formatZoomLabel(currentZoom)}</Text>
|
|
1075
|
+
</Animated.View>
|
|
1076
|
+
</View>
|
|
1077
|
+
</View>
|
|
966
1078
|
</View>
|
|
1079
|
+
) : (
|
|
1080
|
+
<View
|
|
1081
|
+
style={[
|
|
1082
|
+
styles.zoomContainer,
|
|
1083
|
+
isPhoneSized
|
|
1084
|
+
? { width: zoomControlsLength, height: 48, left: (windowWidth - zoomControlsLength) / 2, top: zoomControlsTop, flexDirection: 'row' }
|
|
1085
|
+
: { width: 48, height: zoomControlsLength, left: 16 + insets.left, top: zoomControlsTop }
|
|
1086
|
+
]}
|
|
1087
|
+
>
|
|
1088
|
+
{availableZoomPresets.map(zoom => {
|
|
1089
|
+
const selected = zoom === selectedZoomPreset
|
|
1090
|
+
const handlePress = () => handleZoomChange(zoom)
|
|
1091
|
+
return (
|
|
1092
|
+
<TouchableOpacity
|
|
1093
|
+
key={zoom}
|
|
1094
|
+
accessibilityRole="button"
|
|
1095
|
+
accessibilityLabel={`${zoom} times zoom`}
|
|
1096
|
+
accessibilityState={{ selected }}
|
|
1097
|
+
accessibilityValue={selected ? { text: `${displayZoom} times zoom` } : undefined}
|
|
1098
|
+
onPress={handlePress}
|
|
1099
|
+
style={[styles.zoomButton, selected && styles.zoomButtonSelected]}
|
|
1100
|
+
>
|
|
1101
|
+
<Text numberOfLines={1} adjustsFontSizeToFit style={[styles.zoomText, selected && styles.zoomTextSelected]}>
|
|
1102
|
+
{selected ? `${displayZoom === 0.5 ? '.5' : displayZoom}×` : zoom === 0.5 ? '.5' : zoom}
|
|
1103
|
+
</Text>
|
|
1104
|
+
</TouchableOpacity>
|
|
1105
|
+
)
|
|
1106
|
+
})}
|
|
967
1107
|
</View>
|
|
968
|
-
|
|
1108
|
+
)}
|
|
1109
|
+
{enableZoomSlider && (
|
|
1110
|
+
<TouchableOpacity
|
|
1111
|
+
accessibilityRole="button"
|
|
1112
|
+
accessibilityLabel={showZoomSlider ? 'Show zoom presets' : 'Show zoom slider'}
|
|
1113
|
+
accessibilityState={{ expanded: showZoomSlider }}
|
|
1114
|
+
onPress={handleToggleZoomSlider}
|
|
1115
|
+
style={[
|
|
1116
|
+
styles.sideButton,
|
|
1117
|
+
{ position: 'absolute', zIndex: 12 },
|
|
1118
|
+
showZoomSlider
|
|
1119
|
+
? { left: 22 + insets.left, top: zoomSliderTop + zoomSliderHeight + 8 }
|
|
1120
|
+
: isPhoneSized
|
|
1121
|
+
? { left: (windowWidth + zoomControlsLength) / 2 + 8, top: zoomControlsTop + 4 }
|
|
1122
|
+
: { left: 20 + insets.left, top: zoomControlsTop + zoomControlsLength + 8 }
|
|
1123
|
+
]}
|
|
1124
|
+
>
|
|
1125
|
+
<Icons.IconAdjust size={24} fill={colors.white} fillOpacity={1} />
|
|
1126
|
+
</TouchableOpacity>
|
|
1127
|
+
)}
|
|
1128
|
+
</>
|
|
969
1129
|
) : null}
|
|
970
1130
|
|
|
971
1131
|
{/* Shutter Flash Overlay */}
|
|
@@ -974,20 +1134,22 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
|
|
|
974
1134
|
{/* Gallery SwipeModal */}
|
|
975
1135
|
<SwipeModal
|
|
976
1136
|
key={`gallery-${isGalleryModalVisible}`}
|
|
977
|
-
|
|
1137
|
+
implicit={handleGalleryCloseReady}
|
|
978
1138
|
visible={isGalleryModalVisible}
|
|
979
1139
|
onClose={() => setIsGalleryModalVisible(false)}
|
|
980
1140
|
scrollOffset={1}
|
|
981
1141
|
height={228}
|
|
982
1142
|
propagateSwipe
|
|
983
1143
|
showTopNav={false}
|
|
984
|
-
backgroundColor="#
|
|
1144
|
+
backgroundColor="#121212"
|
|
985
1145
|
>
|
|
986
1146
|
<View style={styles.gallerySheet}>
|
|
987
1147
|
<View style={styles.gallerySheetHeader}>
|
|
988
1148
|
<TouchableOpacity
|
|
989
1149
|
style={styles.gallerySheetClose}
|
|
990
|
-
onPress={
|
|
1150
|
+
onPress={handleCloseGallery}
|
|
1151
|
+
accessibilityRole="button"
|
|
1152
|
+
accessibilityLabel="Close Session Roll"
|
|
991
1153
|
hitSlop={{ top: 12, bottom: 12, left: 12, right: 12 }}
|
|
992
1154
|
>
|
|
993
1155
|
<Icons.IconClose_WithPad size={18} fill={colors.white} fillOpacity={1} />
|
|
@@ -1021,7 +1183,8 @@ const CameraModal: React.FC<CameraTestModalProps> = ({ onDone, onCancel, cameraR
|
|
|
1021
1183
|
onPress={() => removeImage(capturedImages.findIndex(item => item.uri === image.uri))}
|
|
1022
1184
|
hitSlop={{ top: 8, bottom: 8, left: 8, right: 8 }}
|
|
1023
1185
|
>
|
|
1024
|
-
<
|
|
1186
|
+
<View pointerEvents="none" style={[styles.removeButtonBackground, stdStyles.Shadow03dp]} />
|
|
1187
|
+
<Icons.IconCancel_WithPad size={18} fill={colors.white} fillOpacity={1} />
|
|
1025
1188
|
</TouchableOpacity>
|
|
1026
1189
|
</View>
|
|
1027
1190
|
)}
|
|
@@ -1091,16 +1254,12 @@ const styles = StyleSheet.create({
|
|
|
1091
1254
|
justifyContent: 'space-between',
|
|
1092
1255
|
zIndex: 10
|
|
1093
1256
|
},
|
|
1094
|
-
topOverlaySpacer: {
|
|
1095
|
-
width: 30,
|
|
1096
|
-
height: 30
|
|
1097
|
-
},
|
|
1098
1257
|
cancelButton: {
|
|
1099
1258
|
minWidth: 56,
|
|
1100
1259
|
height: 34,
|
|
1101
1260
|
paddingHorizontal: 14,
|
|
1102
1261
|
borderRadius: 17,
|
|
1103
|
-
backgroundColor:
|
|
1262
|
+
backgroundColor: colors.black18,
|
|
1104
1263
|
alignItems: 'center',
|
|
1105
1264
|
justifyContent: 'center'
|
|
1106
1265
|
},
|
|
@@ -1108,30 +1267,8 @@ const styles = StyleSheet.create({
|
|
|
1108
1267
|
opacity: 0.45
|
|
1109
1268
|
},
|
|
1110
1269
|
cancelButtonText: {
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
fontWeight: 'bold',
|
|
1114
|
-
opacity: 0.92
|
|
1115
|
-
},
|
|
1116
|
-
captureCountBadge: {
|
|
1117
|
-
width: 26,
|
|
1118
|
-
height: 26,
|
|
1119
|
-
borderRadius: 13,
|
|
1120
|
-
backgroundColor: colors.yellow,
|
|
1121
|
-
borderWidth: 2,
|
|
1122
|
-
borderColor: colors.white,
|
|
1123
|
-
alignItems: 'center',
|
|
1124
|
-
justifyContent: 'center'
|
|
1125
|
-
},
|
|
1126
|
-
captureCountBadgeText: {
|
|
1127
|
-
color: colors.white,
|
|
1128
|
-
fontSize: 13,
|
|
1129
|
-
fontWeight: 'bold'
|
|
1130
|
-
},
|
|
1131
|
-
sideButtonText: {
|
|
1132
|
-
color: colors.white,
|
|
1133
|
-
fontSize: SIDE_BUTTON_TEXT_SIZE,
|
|
1134
|
-
fontWeight: 'bold'
|
|
1270
|
+
...stdStyles.S3,
|
|
1271
|
+
color: colors.white
|
|
1135
1272
|
},
|
|
1136
1273
|
cameraContainer: {
|
|
1137
1274
|
position: 'absolute',
|
|
@@ -1192,22 +1329,18 @@ const styles = StyleSheet.create({
|
|
|
1192
1329
|
},
|
|
1193
1330
|
sideActionGroup: {
|
|
1194
1331
|
width: '100%',
|
|
1195
|
-
alignItems: 'center'
|
|
1196
|
-
marginBottom: SIDE_ACTION_GROUP_MARGIN_BOTTOM
|
|
1197
|
-
},
|
|
1198
|
-
sideButtonSpacing: {
|
|
1199
|
-
marginBottom: SIDE_BUTTON_GAP
|
|
1332
|
+
alignItems: 'center'
|
|
1200
1333
|
},
|
|
1201
1334
|
sideButton: {
|
|
1202
1335
|
width: SIDE_BUTTON_SIZE,
|
|
1203
1336
|
height: SIDE_BUTTON_SIZE,
|
|
1204
1337
|
borderRadius: SIDE_BUTTON_SIZE / 2,
|
|
1205
|
-
backgroundColor:
|
|
1338
|
+
backgroundColor: colors.black18,
|
|
1206
1339
|
alignItems: 'center',
|
|
1207
1340
|
justifyContent: 'center'
|
|
1208
1341
|
},
|
|
1209
1342
|
sideButtonActive: {
|
|
1210
|
-
backgroundColor:
|
|
1343
|
+
backgroundColor: colors.blue
|
|
1211
1344
|
},
|
|
1212
1345
|
sideButtonDisabled: {
|
|
1213
1346
|
opacity: 0.42
|
|
@@ -1217,7 +1350,7 @@ const styles = StyleSheet.create({
|
|
|
1217
1350
|
height: GALLERY_PREVIEW_SIZE,
|
|
1218
1351
|
borderRadius: GALLERY_PREVIEW_BORDER_RADIUS,
|
|
1219
1352
|
backgroundColor: 'rgba(255,255,255,0.12)',
|
|
1220
|
-
borderWidth:
|
|
1353
|
+
borderWidth: 2,
|
|
1221
1354
|
borderColor: colors.white,
|
|
1222
1355
|
overflow: 'visible',
|
|
1223
1356
|
alignItems: 'center',
|
|
@@ -1245,16 +1378,16 @@ const styles = StyleSheet.create({
|
|
|
1245
1378
|
right: -8,
|
|
1246
1379
|
minWidth: GALLERY_PREVIEW_BADGE_SIZE,
|
|
1247
1380
|
height: GALLERY_PREVIEW_BADGE_SIZE,
|
|
1248
|
-
paddingHorizontal:
|
|
1381
|
+
paddingHorizontal: 3,
|
|
1249
1382
|
borderRadius: GALLERY_PREVIEW_BADGE_SIZE / 2,
|
|
1250
1383
|
backgroundColor: colors.blue,
|
|
1251
1384
|
alignItems: 'center',
|
|
1252
1385
|
justifyContent: 'center'
|
|
1253
1386
|
},
|
|
1254
1387
|
galleryPreviewBadgeText: {
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1388
|
+
...stdStyles.Caption2,
|
|
1389
|
+
letterSpacing: 0.39,
|
|
1390
|
+
color: colors.white
|
|
1258
1391
|
},
|
|
1259
1392
|
zoomSliderContainer: {
|
|
1260
1393
|
position: 'absolute',
|
|
@@ -1295,6 +1428,40 @@ const styles = StyleSheet.create({
|
|
|
1295
1428
|
fontSize: 12,
|
|
1296
1429
|
fontWeight: 'bold'
|
|
1297
1430
|
},
|
|
1431
|
+
zoomContainer: {
|
|
1432
|
+
position: 'absolute',
|
|
1433
|
+
borderRadius: 24,
|
|
1434
|
+
backgroundColor: colors.black18,
|
|
1435
|
+
alignItems: 'center',
|
|
1436
|
+
justifyContent: 'center',
|
|
1437
|
+
gap: 8,
|
|
1438
|
+
padding: 4,
|
|
1439
|
+
zIndex: 12
|
|
1440
|
+
},
|
|
1441
|
+
zoomButton: {
|
|
1442
|
+
width: 32,
|
|
1443
|
+
height: 32,
|
|
1444
|
+
borderRadius: 16,
|
|
1445
|
+
backgroundColor: colors.black62,
|
|
1446
|
+
alignItems: 'center',
|
|
1447
|
+
justifyContent: 'center'
|
|
1448
|
+
},
|
|
1449
|
+
zoomButtonSelected: {
|
|
1450
|
+
paddingHorizontal: 4,
|
|
1451
|
+
width: 40,
|
|
1452
|
+
height: 40,
|
|
1453
|
+
borderRadius: 20,
|
|
1454
|
+
backgroundColor: colors.blue
|
|
1455
|
+
},
|
|
1456
|
+
zoomText: {
|
|
1457
|
+
...stdStyles.Caption2,
|
|
1458
|
+
letterSpacing: 0.39,
|
|
1459
|
+
color: colors.white
|
|
1460
|
+
},
|
|
1461
|
+
zoomTextSelected: {
|
|
1462
|
+
...stdStyles.S1,
|
|
1463
|
+
color: colors.white
|
|
1464
|
+
},
|
|
1298
1465
|
shutterButton: {
|
|
1299
1466
|
width: SHUTTER_BUTTON_SIZE,
|
|
1300
1467
|
height: SHUTTER_BUTTON_SIZE,
|
|
@@ -1311,9 +1478,9 @@ const styles = StyleSheet.create({
|
|
|
1311
1478
|
width: SHUTTER_BUTTON_SIZE,
|
|
1312
1479
|
height: SHUTTER_BUTTON_SIZE,
|
|
1313
1480
|
borderRadius: SHUTTER_BUTTON_SIZE / 2,
|
|
1314
|
-
borderWidth:
|
|
1481
|
+
borderWidth: 4,
|
|
1315
1482
|
borderColor: colors.white,
|
|
1316
|
-
backgroundColor: '
|
|
1483
|
+
backgroundColor: 'transparent'
|
|
1317
1484
|
},
|
|
1318
1485
|
shutterButtonOuterDisabled: {
|
|
1319
1486
|
borderColor: 'rgba(255,255,255,0.6)',
|
|
@@ -1339,9 +1506,8 @@ const styles = StyleSheet.create({
|
|
|
1339
1506
|
marginBottom: 30
|
|
1340
1507
|
},
|
|
1341
1508
|
doneButtonText: {
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
fontWeight: 'bold'
|
|
1509
|
+
...stdStyles.S3,
|
|
1510
|
+
color: colors.white
|
|
1345
1511
|
},
|
|
1346
1512
|
doneButtonIcon: {
|
|
1347
1513
|
marginLeft: 8
|
|
@@ -1396,17 +1562,17 @@ const styles = StyleSheet.create({
|
|
|
1396
1562
|
alignItems: 'center'
|
|
1397
1563
|
},
|
|
1398
1564
|
galleryImageItem: {
|
|
1399
|
-
width:
|
|
1400
|
-
height:
|
|
1565
|
+
width: 54,
|
|
1566
|
+
height: 72,
|
|
1401
1567
|
marginRight: 8,
|
|
1402
1568
|
borderRadius: 8,
|
|
1403
|
-
overflow: 'hidden',
|
|
1404
1569
|
position: 'relative',
|
|
1405
1570
|
backgroundColor: 'rgba(255,255,255,0.08)'
|
|
1406
1571
|
},
|
|
1407
1572
|
galleryModalImage: {
|
|
1408
1573
|
width: '100%',
|
|
1409
|
-
height: '100%'
|
|
1574
|
+
height: '100%',
|
|
1575
|
+
borderRadius: 8
|
|
1410
1576
|
},
|
|
1411
1577
|
removeButton: {
|
|
1412
1578
|
position: 'absolute',
|
|
@@ -1414,11 +1580,15 @@ const styles = StyleSheet.create({
|
|
|
1414
1580
|
left: 3,
|
|
1415
1581
|
width: 18,
|
|
1416
1582
|
height: 18,
|
|
1417
|
-
borderRadius: 9,
|
|
1418
|
-
backgroundColor: colors.white,
|
|
1419
1583
|
alignItems: 'center',
|
|
1420
|
-
justifyContent: 'center'
|
|
1421
|
-
|
|
1584
|
+
justifyContent: 'center'
|
|
1585
|
+
},
|
|
1586
|
+
removeButtonBackground: {
|
|
1587
|
+
position: 'absolute',
|
|
1588
|
+
width: 15,
|
|
1589
|
+
height: 15,
|
|
1590
|
+
borderRadius: 7.5,
|
|
1591
|
+
backgroundColor: colors.black62
|
|
1422
1592
|
},
|
|
1423
1593
|
shutterFlashOverlay: {
|
|
1424
1594
|
position: 'absolute',
|
|
@@ -44,6 +44,7 @@ const MultiImagePicker = forwardRef((props, ref) => {
|
|
|
44
44
|
existingCount = 0, // number of images already attached outside of this picker session
|
|
45
45
|
callbackData = null, // data appended to payload and passed with callback function (optional)
|
|
46
46
|
callback = null, // callback function (optional)
|
|
47
|
+
enableZoomSlider = false,
|
|
47
48
|
angleGuideEnabled = false, // shows a live tilt indicator in CameraModal nudging away from steep floor-only close-ups (optional)
|
|
48
49
|
children,
|
|
49
50
|
...touchableProps // any other props passed into MultiImagePicker will be spread onto the TouchableOpacity below
|
|
@@ -414,6 +415,7 @@ const MultiImagePicker = forwardRef((props, ref) => {
|
|
|
414
415
|
limit={remainingCount}
|
|
415
416
|
onCancel={() => handleCameraModalDone([])}
|
|
416
417
|
angleGuideEnabled={angleGuideEnabled}
|
|
418
|
+
enableZoomSlider={enableZoomSlider}
|
|
417
419
|
/>
|
|
418
420
|
</Modal>
|
|
419
421
|
)}
|