Skip to content

Commit

Permalink
fix: booleans on ios and missing prop
Browse files Browse the repository at this point in the history
  • Loading branch information
WoLewicki committed Jan 7, 2025
1 parent 55bdd97 commit 971b78e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
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 @@ -141,4 +141,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 @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,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 Down
20 changes: 11 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 = [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;
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 Down
1 change: 1 addition & 0 deletions src/specs/CameraNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type OnZoom = {
export interface NativeProps extends ViewProps {
flashMode?: string;
focusMode?: string;
maxPhotoQualityPrioritization?: string;
zoomMode?: string;
zoom?: Double;
maxZoom?: Double;
Expand Down

0 comments on commit 971b78e

Please sign in to comment.