diff --git a/android/src/main/java/com/rncamerakit/CKCameraManager.kt b/android/src/main/java/com/rncamerakit/CKCameraManager.kt index 6c3b22acb..82e3a4794 100644 --- a/android/src/main/java/com/rncamerakit/CKCameraManager.kt +++ b/android/src/main/java/com/rncamerakit/CKCameraManager.kt @@ -141,4 +141,6 @@ class CKCameraManager : SimpleViewManager(), CKCameraManagerInterface< override fun setResizeMode(view: CKCamera?, value: String?) = Unit override fun setScanThrottleDelay(view: CKCamera?, value: Int) = Unit + + override fun setMaxPhotoQualityPrioritization(view: CKCamera?, value: String?) = Unit } diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/CKCameraManagerDelegate.java b/android/src/paper/java/com/facebook/react/viewmanagers/CKCameraManagerDelegate.java index 96c9b840e..b711bdb3d 100644 --- a/android/src/paper/java/com/facebook/react/viewmanagers/CKCameraManagerDelegate.java +++ b/android/src/paper/java/com/facebook/react/viewmanagers/CKCameraManagerDelegate.java @@ -28,6 +28,9 @@ public void setProperty(T view, String propName, @Nullable Object value) { case "focusMode": mViewManager.setFocusMode(view, value == null ? null : (String) value); break; + case "maxPhotoQualityPrioritization": + mViewManager.setMaxPhotoQualityPrioritization(view, value == null ? null : (String) value); + break; case "zoomMode": mViewManager.setZoomMode(view, value == null ? null : (String) value); break; diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/CKCameraManagerInterface.java b/android/src/paper/java/com/facebook/react/viewmanagers/CKCameraManagerInterface.java index 25cd980c3..8f3308f42 100644 --- a/android/src/paper/java/com/facebook/react/viewmanagers/CKCameraManagerInterface.java +++ b/android/src/paper/java/com/facebook/react/viewmanagers/CKCameraManagerInterface.java @@ -15,6 +15,7 @@ public interface CKCameraManagerInterface { void setFlashMode(T view, @Nullable String value); void setFocusMode(T view, @Nullable String value); + void setMaxPhotoQualityPrioritization(T view, @Nullable String value); void setZoomMode(T view, @Nullable String value); void setZoom(T view, double value); void setMaxZoom(T view, double value); diff --git a/ios/ReactNativeCameraKit/CKCameraViewComponentView.mm b/ios/ReactNativeCameraKit/CKCameraViewComponentView.mm index 5924c8243..c96311de6 100644 --- a/ios/ReactNativeCameraKit/CKCameraViewComponentView.mm +++ b/ios/ReactNativeCameraKit/CKCameraViewComponentView.mm @@ -165,6 +165,11 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared & _view.flashMode = [flashMode isEqualToString:@"auto"] ? CKFlashModeAuto : [flashMode isEqualToString:@"on"] ? CKFlashModeOn : CKFlashModeOff; [changedProps addObject:@"flashMode"]; } + id maxPhotoQualityPrioritization = CKConvertFollyDynamicToId(newProps.maxPhotoQualityPrioritization); + if (maxPhotoQualityPrioritization != nil && [maxPhotoQualityPrioritization isKindOfClass:NSString.class]) { + _view.maxPhotoQualityPrioritization = [flashMode isEqualToString:@"balanced"] ? CKMaxPhotoQualityPrioritizationBalanced : [flashMode isEqualToString:@"quality"] ? CKMaxPhotoQualityPrioritizationQuality : CKMaxPhotoQualityPrioritizationSpeed; + [changedProps addObject:@"flashMode"]; + } id torchMode = CKConvertFollyDynamicToId(newProps.torchMode); if (torchMode != nil && [torchMode isKindOfClass:NSString.class]) { _view.torchMode = [torchMode isEqualToString:@"on"] ? CKTorchModeOn : CKTorchModeOff; @@ -180,14 +185,12 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared & _view.ratioOverlayColor = ratioOverlayColor; [changedProps addObject:@"ratioOverlayColor"]; } - id scanBarcode = CKConvertFollyDynamicToId(newProps.scanBarcode); - if (scanBarcode != nil) { - _view.scanBarcode = scanBarcode; + if (_view.scanBarcode != newProps.scanBarcode) { + _view.scanBarcode = newProps.scanBarcode; [changedProps addObject:@"scanBarcode"]; } - id showFrame = CKConvertFollyDynamicToId(newProps.showFrame); - if (showFrame != nil) { - _view.showFrame = showFrame; + if (_view.showFrame != newProps.showFrame) { + _view.showFrame = newProps.showFrame; [changedProps addObject:@"showFrame"]; } id scanThrottleDelay = CKConvertFollyDynamicToId(newProps.scanThrottleDelay); @@ -210,9 +213,8 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared & _view.resetFocusTimeout = [resetFocusTimeout intValue]; [changedProps addObject:@"resetFocusTimeout"]; } - id resetFocusWhenMotionDetected = CKConvertFollyDynamicToId(newProps.resetFocusWhenMotionDetected); - if (resetFocusWhenMotionDetected != nil) { - _view.resetFocusWhenMotionDetected = resetFocusWhenMotionDetected; + if (_view.resetFocusWhenMotionDetected != newProps.resetFocusWhenMotionDetected) { + _view.resetFocusWhenMotionDetected = newProps.resetFocusWhenMotionDetected; [changedProps addObject:@"resetFocusWhenMotionDetected"]; } id focusMode = CKConvertFollyDynamicToId(newProps.focusMode); diff --git a/src/specs/CameraNativeComponent.ts b/src/specs/CameraNativeComponent.ts index 90d649313..9f63c0a00 100644 --- a/src/specs/CameraNativeComponent.ts +++ b/src/specs/CameraNativeComponent.ts @@ -22,6 +22,7 @@ type OnZoom = { export interface NativeProps extends ViewProps { flashMode?: string; focusMode?: string; + maxPhotoQualityPrioritization?: string; zoomMode?: string; zoom?: Double; maxZoom?: Double;