Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions android/src/main/java/com/rncamerakit/CKCameraManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,6 @@ class CKCameraManager : SimpleViewManager<CKCamera>(), 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
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
import androidx.annotation.Nullable;
import com.facebook.react.bridge.ColorPropConverter;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
import com.facebook.react.uimanager.BaseViewManagerInterface;

public class CKCameraManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & CKCameraManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public class CKCameraManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & CKCameraManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public CKCameraManagerDelegate(U viewManager) {
super(viewManager);
}
Expand All @@ -30,6 +29,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;
Expand Down Expand Up @@ -57,9 +59,6 @@ public void setProperty(T view, String propName, @Nullable Object value) {
case "frameColor":
mViewManager.setFrameColor(view, ColorPropConverter.getColor(value, view.getContext()));
break;
case "barcodeFrameSize":
mViewManager.setBarcodeFrameSize(view, value == null ? null : (ReadableMap) value);
break;
case "ratioOverlay":
mViewManager.setRatioOverlay(view, value == null ? null : (String) value);
break;
Expand All @@ -78,6 +77,9 @@ public void setProperty(T view, String propName, @Nullable Object value) {
case "scanThrottleDelay":
mViewManager.setScanThrottleDelay(view, value == null ? 0 : ((Double) value).intValue());
break;
case "barcodeFrameSize":
mViewManager.setBarcodeFrameSize(view, (ReadableMap) value);
break;
case "shutterPhotoSound":
mViewManager.setShutterPhotoSound(view, value == null ? false : (boolean) value);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
public interface CKCameraManagerInterface<T extends View> {
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);
Expand All @@ -25,13 +26,13 @@ public interface CKCameraManagerInterface<T extends View> {
void setShowFrame(T view, boolean value);
void setLaserColor(T view, @Nullable Integer value);
void setFrameColor(T view, @Nullable Integer value);
void setBarcodeFrameSize(T view, @Nullable ReadableMap value);
void setRatioOverlay(T view, @Nullable String value);
void setRatioOverlayColor(T view, @Nullable Integer value);
void setResetFocusTimeout(T view, int value);
void setResetFocusWhenMotionDetected(T view, boolean value);
void setResizeMode(T view, @Nullable String value);
void setScanThrottleDelay(T view, int value);
void setBarcodeFrameSize(T view, @Nullable ReadableMap value);
void setShutterPhotoSound(T view, boolean value);
void setShutterAnimationDuration(T view, int value);
void setOutputPath(T view, @Nullable String value);
Expand Down
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,7 @@ PODS:
- React-logger (= 0.76.3)
- React-perflogger (= 0.76.3)
- React-utils (= 0.76.3)
- ReactNativeCameraKit (14.1.0):
- ReactNativeCameraKit (14.2.0):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -1799,7 +1799,7 @@ SPEC CHECKSUMS:
React-utils: ee370a52b08a000963af1a60c31e6c87a70620a5
ReactCodegen: 5148a0102fc8f0a1f9b05d955da886b44447679d
ReactCommon: b8485556b596ef2f44f59bc586113bda138fb804
ReactNativeCameraKit: e72b838dac4ea2da19b7eb5d00b23125072790fd
ReactNativeCameraKit: 72cc60b69ae192fe55a3e3f294ed46833308bb22
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
Yoga: 3deb2471faa9916c8a82dda2a22d3fba2620ad37

Expand Down
27 changes: 18 additions & 9 deletions ios/ReactNativeCameraKit/CKCameraViewComponentView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [maxPhotoQualityPrioritization isEqualToString:@"balanced"] ? CKMaxPhotoQualityPrioritizationBalanced : [maxPhotoQualityPrioritization isEqualToString:@"quality"] ? CKMaxPhotoQualityPrioritizationQuality : CKMaxPhotoQualityPrioritizationSpeed;
[changedProps addObject:@"maxPhotoQualityPrioritization"];
}
id torchMode = CKConvertFollyDynamicToId(newProps.torchMode);
if (torchMode != nil && [torchMode isKindOfClass:NSString.class]) {
_view.torchMode = [torchMode isEqualToString:@"on"] ? CKTorchModeOn : CKTorchModeOff;
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -235,6 +237,13 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
_view.maxZoom = maxZoom;
[changedProps addObject:@"maxZoom"];
}
float barcodeWidth = newProps.barcodeFrameSize.width;
float barcodeHeight = newProps.barcodeFrameSize.height;
if (barcodeWidth != [_view.barcodeFrameSize[@"width"] floatValue] || barcodeHeight != [_view.barcodeFrameSize[@"height"] floatValue]) {
_view.barcodeFrameSize = @{@"width": @(barcodeWidth), @"height": @(barcodeHeight)};
[changedProps addObject:@"barcodeFrameSize"];
}


[super updateProps:props oldProps:oldProps];
[_view didSetProps:changedProps];
Expand Down
4 changes: 4 additions & 0 deletions src/specs/CameraNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import type {
DirectEventHandler,
Int32,
Double,
WithDefault,
Float,
} from 'react-native/Libraries/Types/CodegenTypes';

type OnReadCodeData = {
Expand All @@ -22,6 +24,7 @@ type OnZoom = {
export interface NativeProps extends ViewProps {
flashMode?: string;
focusMode?: string;
maxPhotoQualityPrioritization?: string;
zoomMode?: string;
zoom?: Double;
maxZoom?: Double;
Expand All @@ -41,6 +44,7 @@ export interface NativeProps extends ViewProps {
resetFocusWhenMotionDetected?: boolean;
resizeMode?: string;
scanThrottleDelay?: Int32;
barcodeFrameSize?: { width?: WithDefault<Float, 300>; height?: WithDefault<Float, 150> };
shutterPhotoSound?: boolean;
onCaptureButtonPressIn?: DirectEventHandler<{}>;
onCaptureButtonPressOut?: DirectEventHandler<{}>;
Expand Down
Loading