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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,7 @@ dist/
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
!*.xcworkspace/contents.xcworkspacedata

### RN Codegen bug
# There's no such thing as podspecs for Android, so ignore the generated file
android/generated/ReactCodegen.podspec
21 changes: 9 additions & 12 deletions ReactNativeCameraKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,22 @@ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
Pod::Spec.new do |s|
s.name = "ReactNativeCameraKit"
s.version = package["version"]
s.summary = "A high performance, easy to use camera API"
s.summary = package["description"]
s.license = "MIT"

s.authors = "CameraKit"
s.homepage = "https://github.com/teslamotors/react-native-camera-kit"
s.platform = :ios, "11.0"
s.platform = :ios, "15.0"

s.source = { :git => "https://github.com/teslamotors/react-native-camera-kit.git", :tag => "v#{s.version}" }
s.source_files = "ios/**/*.{h,m,mm,swift}"
s.private_header_files = 'ios/ReactNativeCameraKit/ReactNativeCameraKit-Swift.pre.h'
s.source_files = [
# Exclude .h files as they cause Swift compiler to treat them as C files, but they are C++
# See https://github.com/facebook/react-native/issues/45424#issuecomment-2354737063
"ios/ReactNativeCameraKit/*.{m,swift,mm}",
"ios/generated/rncamerakit_specs/*.{m,mm,cpp}",
]

if ENV['USE_FRAMEWORKS']
exisiting_flags = s.attributes_hash["compiler_flags"]
if exisiting_flags.present?
s.compiler_flags = exisiting_flags + "-DCK_USE_FRAMEWORKS=1"
else
s.compiler_flags = "-DCK_USE_FRAMEWORKS=1"
end
end
s.private_header_files = 'ios/ReactNativeCameraKit/ReactNativeCameraKit-Swift.pre.h'

if defined?(install_modules_dependencies()) != nil
install_modules_dependencies(s)
Expand Down
8 changes: 3 additions & 5 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ android {
warning 'InvalidPackage'
}

if (!isNewArchitectureEnabled()) {
sourceSets {
main {
java.srcDirs += 'src/paper/java'
}
sourceSets {
main {
java.srcDirs += 'generated'
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @nolint
*/

package com.rncamerakit;
package com.facebook.fbreact.specs;

import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.bridge.Promise;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public void setProperty(T view, String propName, @Nullable Object value) {
mViewManager.setZoomMode(view, value == null ? null : (String) value);
break;
case "zoom":
mViewManager.setZoom(view, value == null ? 0f : ((Double) value).doubleValue());
mViewManager.setZoom(view, value == null ? -1f : ((Double) value).doubleValue());
break;
case "maxZoom":
mViewManager.setMaxZoom(view, value == null ? 0f : ((Double) value).doubleValue());
mViewManager.setMaxZoom(view, value == null ? -1f : ((Double) value).doubleValue());
break;
case "torchMode":
mViewManager.setTorchMode(view, value == null ? null : (String) value);
Expand All @@ -67,7 +67,7 @@ public void setProperty(T view, String propName, @Nullable Object value) {
mViewManager.setRatioOverlayColor(view, ColorPropConverter.getColor(value, view.getContext()));
break;
case "resetFocusTimeout":
mViewManager.setResetFocusTimeout(view, value == null ? 0 : ((Double) value).intValue());
mViewManager.setResetFocusTimeout(view, value == null ? -1 : ((Double) value).intValue());
break;
case "resetFocusWhenMotionDetected":
mViewManager.setResetFocusWhenMotionDetected(view, value == null ? false : (boolean) value);
Expand All @@ -76,7 +76,7 @@ public void setProperty(T view, String propName, @Nullable Object value) {
mViewManager.setResizeMode(view, value == null ? null : (String) value);
break;
case "scanThrottleDelay":
mViewManager.setScanThrottleDelay(view, value == null ? 0 : ((Double) value).intValue());
mViewManager.setScanThrottleDelay(view, value == null ? -1 : ((Double) value).intValue());
break;
case "barcodeFrameSize":
mViewManager.setBarcodeFrameSize(view, (ReadableMap) value);
Expand All @@ -85,7 +85,7 @@ public void setProperty(T view, String propName, @Nullable Object value) {
mViewManager.setShutterPhotoSound(view, value == null ? false : (boolean) value);
break;
case "shutterAnimationDuration":
mViewManager.setShutterAnimationDuration(view, value == null ? 0 : ((Double) value).intValue());
mViewManager.setShutterAnimationDuration(view, value == null ? -1 : ((Double) value).intValue());
break;
case "outputPath":
mViewManager.setOutputPath(view, value == null ? null : (String) value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;

public interface CKCameraManagerInterface<T extends View> {
public interface CKCameraManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
void setFlashMode(T view, @Nullable String value);
void setFocusMode(T view, @Nullable String value);
void setMaxPhotoQualityPrioritization(T view, @Nullable String value);
Expand Down
45 changes: 45 additions & 0 deletions android/generated/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)

file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/rncamerakit_specs/*.cpp)

add_library(
react_codegen_rncamerakit_specs
OBJECT
${react_codegen_SRCS}
)

target_include_directories(react_codegen_rncamerakit_specs PUBLIC . react/renderer/components/rncamerakit_specs)

target_link_libraries(
react_codegen_rncamerakit_specs
fbjni
jsi
# We need to link different libraries based on whether we are building rncore or not, that's necessary
# because we want to break a circular dependency between react_codegen_rncore and reactnative
reactnative
)

# Fix crash on startup on RN 0.81 or newer due to broken codegen (it always uses target_compile_options)
# Do not commit the change where the if-statement is removed unless they fix Codegen
# See https://github.com/software-mansion/react-native-screens/pull/3114/commits/b4d283c8fc65e36ec60726fd7513735ccc7e1fe9
# See https://github.com/react-native-maps/react-native-maps/issues/5699
# (commit https://github.com/react-native-maps/react-native-maps/commit/c587f30b8499b79a2266687c641bfed10b3ecc2c)
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 80)
target_compile_reactnative_options(react_codegen_rncamerakit_specs PRIVATE)
else()
target_compile_options(
react_codegen_rncamerakit_specs
PRIVATE
-DLOG_TAG=\"ReactNative\"
-fexceptions
-frtti
-std=c++20
-Wall
)
endif()
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateComponentDescriptorCpp.js
*/

#include "ComponentDescriptors.h"
#include <react/renderer/core/ConcreteComponentDescriptor.h>
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>

namespace facebook::react {

void rncamerakit_specs_registerComponentDescriptorsFromCodegen(
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry) {
registry->add(concreteComponentDescriptorProvider<CKCameraComponentDescriptor>());
}

} // namespace facebook::react
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateComponentDescriptorH.js
*/

#pragma once

#include "ShadowNodes.h"
#include <react/renderer/core/ConcreteComponentDescriptor.h>
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>

namespace facebook::react {

using CKCameraComponentDescriptor = ConcreteComponentDescriptor<CKCameraShadowNode>;

void rncamerakit_specs_registerComponentDescriptorsFromCodegen(
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);

} // namespace facebook::react
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@

/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateEventEmitterCpp.js
*/

#include "EventEmitters.h"


namespace facebook::react {

void CKCameraEventEmitter::onOrientationChange(OnOrientationChange $event) const {
dispatchEvent("orientationChange", [$event=std::move($event)](jsi::Runtime &runtime) {
auto $payload = jsi::Object(runtime);
$payload.setProperty(runtime, "orientation", $event.orientation);
return $payload;
});
}


void CKCameraEventEmitter::onZoom(OnZoom $event) const {
dispatchEvent("zoom", [$event=std::move($event)](jsi::Runtime &runtime) {
auto $payload = jsi::Object(runtime);
$payload.setProperty(runtime, "zoom", $event.zoom);
return $payload;
});
}


void CKCameraEventEmitter::onError(OnError $event) const {
dispatchEvent("error", [$event=std::move($event)](jsi::Runtime &runtime) {
auto $payload = jsi::Object(runtime);
$payload.setProperty(runtime, "errorMessage", $event.errorMessage);
return $payload;
});
}


void CKCameraEventEmitter::onReadCode(OnReadCode $event) const {
dispatchEvent("readCode", [$event=std::move($event)](jsi::Runtime &runtime) {
auto $payload = jsi::Object(runtime);
$payload.setProperty(runtime, "codeStringValue", $event.codeStringValue);
$payload.setProperty(runtime, "codeFormat", $event.codeFormat);
return $payload;
});
}


void CKCameraEventEmitter::onCaptureButtonPressIn(OnCaptureButtonPressIn $event) const {
dispatchEvent("captureButtonPressIn", [](jsi::Runtime &runtime) {
auto $payload = jsi::Object(runtime);

return $payload;
});
}


void CKCameraEventEmitter::onCaptureButtonPressOut(OnCaptureButtonPressOut $event) const {
dispatchEvent("captureButtonPressOut", [](jsi::Runtime &runtime) {
auto $payload = jsi::Object(runtime);

return $payload;
});
}


void CKCameraEventEmitter::onPictureTaken(OnPictureTaken $event) const {
dispatchEvent("pictureTaken", [$event=std::move($event)](jsi::Runtime &runtime) {
auto $payload = jsi::Object(runtime);
$payload.setProperty(runtime, "uri", $event.uri);
return $payload;
});
}

} // namespace facebook::react
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateEventEmitterH.js
*/
#pragma once

#include <react/renderer/components/view/ViewEventEmitter.h>


namespace facebook::react {
class CKCameraEventEmitter : public ViewEventEmitter {
public:
using ViewEventEmitter::ViewEventEmitter;

struct OnOrientationChange {
int orientation;
};

struct OnZoom {
double zoom;
};

struct OnError {
std::string errorMessage;
};

struct OnReadCode {
std::string codeStringValue;
std::string codeFormat;
};

struct OnCaptureButtonPressIn {

};

struct OnCaptureButtonPressOut {

};

struct OnPictureTaken {
std::string uri;
};
void onOrientationChange(OnOrientationChange value) const;

void onZoom(OnZoom value) const;

void onError(OnError value) const;

void onReadCode(OnReadCode value) const;

void onCaptureButtonPressIn(OnCaptureButtonPressIn value) const;

void onCaptureButtonPressOut(OnCaptureButtonPressOut value) const;

void onPictureTaken(OnPictureTaken value) const;
};
} // namespace facebook::react
Loading
Loading