Skip to content

Commit 438d4c2

Browse files
committed
fix: maxPhotoQualityPrioritization and add barcode prop on new arch
1 parent 589c251 commit 438d4c2

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

android/src/paper/java/com/facebook/react/viewmanagers/CKCameraManagerDelegate.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@
1313
import androidx.annotation.Nullable;
1414
import com.facebook.react.bridge.ColorPropConverter;
1515
import com.facebook.react.bridge.ReadableMap;
16-
import com.facebook.react.uimanager.BaseViewManager;
1716
import com.facebook.react.uimanager.BaseViewManagerDelegate;
18-
import com.facebook.react.uimanager.LayoutShadowNode;
17+
import com.facebook.react.uimanager.BaseViewManagerInterface;
1918

20-
public class CKCameraManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & CKCameraManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
19+
public class CKCameraManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & CKCameraManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
2120
public CKCameraManagerDelegate(U viewManager) {
2221
super(viewManager);
2322
}
@@ -60,9 +59,6 @@ public void setProperty(T view, String propName, @Nullable Object value) {
6059
case "frameColor":
6160
mViewManager.setFrameColor(view, ColorPropConverter.getColor(value, view.getContext()));
6261
break;
63-
case "barcodeFrameSize":
64-
mViewManager.setBarcodeFrameSize(view, value == null ? null : (ReadableMap) value);
65-
break;
6662
case "ratioOverlay":
6763
mViewManager.setRatioOverlay(view, value == null ? null : (String) value);
6864
break;
@@ -81,6 +77,9 @@ public void setProperty(T view, String propName, @Nullable Object value) {
8177
case "scanThrottleDelay":
8278
mViewManager.setScanThrottleDelay(view, value == null ? 0 : ((Double) value).intValue());
8379
break;
80+
case "barcodeFrameSize":
81+
mViewManager.setBarcodeFrameSize(view, (ReadableMap) value);
82+
break;
8483
case "shutterPhotoSound":
8584
mViewManager.setShutterPhotoSound(view, value == null ? false : (boolean) value);
8685
break;

android/src/paper/java/com/facebook/react/viewmanagers/CKCameraManagerInterface.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ public interface CKCameraManagerInterface<T extends View> {
2626
void setShowFrame(T view, boolean value);
2727
void setLaserColor(T view, @Nullable Integer value);
2828
void setFrameColor(T view, @Nullable Integer value);
29-
void setBarcodeFrameSize(T view, @Nullable ReadableMap value);
3029
void setRatioOverlay(T view, @Nullable String value);
3130
void setRatioOverlayColor(T view, @Nullable Integer value);
3231
void setResetFocusTimeout(T view, int value);
3332
void setResetFocusWhenMotionDetected(T view, boolean value);
3433
void setResizeMode(T view, @Nullable String value);
3534
void setScanThrottleDelay(T view, int value);
35+
void setBarcodeFrameSize(T view, @Nullable ReadableMap value);
3636
void setShutterPhotoSound(T view, boolean value);
3737
void setShutterAnimationDuration(T view, int value);
3838
void setOutputPath(T view, @Nullable String value);

example/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,7 +1509,7 @@ PODS:
15091509
- React-logger (= 0.76.3)
15101510
- React-perflogger (= 0.76.3)
15111511
- React-utils (= 0.76.3)
1512-
- ReactNativeCameraKit (14.1.0):
1512+
- ReactNativeCameraKit (14.2.0):
15131513
- DoubleConversion
15141514
- glog
15151515
- hermes-engine
@@ -1799,7 +1799,7 @@ SPEC CHECKSUMS:
17991799
React-utils: ee370a52b08a000963af1a60c31e6c87a70620a5
18001800
ReactCodegen: 5148a0102fc8f0a1f9b05d955da886b44447679d
18011801
ReactCommon: b8485556b596ef2f44f59bc586113bda138fb804
1802-
ReactNativeCameraKit: e72b838dac4ea2da19b7eb5d00b23125072790fd
1802+
ReactNativeCameraKit: 72cc60b69ae192fe55a3e3f294ed46833308bb22
18031803
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
18041804
Yoga: 3deb2471faa9916c8a82dda2a22d3fba2620ad37
18051805

ios/ReactNativeCameraKit/CKCameraViewComponentView.mm

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
167167
}
168168
id maxPhotoQualityPrioritization = CKConvertFollyDynamicToId(newProps.maxPhotoQualityPrioritization);
169169
if (maxPhotoQualityPrioritization != nil && [maxPhotoQualityPrioritization isKindOfClass:NSString.class]) {
170-
_view.maxPhotoQualityPrioritization = [flashMode isEqualToString:@"balanced"] ? CKMaxPhotoQualityPrioritizationBalanced : [flashMode isEqualToString:@"quality"] ? CKMaxPhotoQualityPrioritizationQuality : CKMaxPhotoQualityPrioritizationSpeed;
170+
_view.maxPhotoQualityPrioritization = [maxPhotoQualityPrioritization isEqualToString:@"balanced"] ? CKMaxPhotoQualityPrioritizationBalanced : [maxPhotoQualityPrioritization isEqualToString:@"quality"] ? CKMaxPhotoQualityPrioritizationQuality : CKMaxPhotoQualityPrioritizationSpeed;
171171
[changedProps addObject:@"maxPhotoQualityPrioritization"];
172172
}
173173
id torchMode = CKConvertFollyDynamicToId(newProps.torchMode);
@@ -237,6 +237,13 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
237237
_view.maxZoom = maxZoom;
238238
[changedProps addObject:@"maxZoom"];
239239
}
240+
float barcodeWidth = newProps.barcodeFrameSize.width;
241+
float barcodeHeight = newProps.barcodeFrameSize.height;
242+
if (barcodeWidth != [_view.barcodeFrameSize[@"width"] floatValue] || barcodeHeight != [_view.barcodeFrameSize[@"height"] floatValue]) {
243+
_view.barcodeFrameSize = @{@"width": @(barcodeWidth), @"height": @(barcodeHeight)};
244+
[changedProps addObject:@"barcodeFrameSize"];
245+
}
246+
240247

241248
[super updateProps:props oldProps:oldProps];
242249
[_view didSetProps:changedProps];

src/specs/CameraNativeComponent.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import type {
44
DirectEventHandler,
55
Int32,
66
Double,
7+
WithDefault,
8+
Float,
79
} from 'react-native/Libraries/Types/CodegenTypes';
810

911
type OnReadCodeData = {
@@ -42,6 +44,7 @@ export interface NativeProps extends ViewProps {
4244
resetFocusWhenMotionDetected?: boolean;
4345
resizeMode?: string;
4446
scanThrottleDelay?: Int32;
47+
barcodeFrameSize?: { width?: WithDefault<Float, 300>; height?: WithDefault<Float, 150> };
4548
shutterPhotoSound?: boolean;
4649
onCaptureButtonPressIn?: DirectEventHandler<{}>;
4750
onCaptureButtonPressOut?: DirectEventHandler<{}>;

0 commit comments

Comments
 (0)