Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

feat: support react-native-vision-camera v3 #139

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a2fdfbf
feat: support react-native-vision-camera v3
rkmackinnon Mar 28, 2023
6697b63
fix: add missing dependency on VisionCamera
rkmackinnon Apr 25, 2023
4dcfeab
Fix build with use_frameworks! :linkage => :static
rkmackinnon Apr 26, 2023
57cc338
Update Pods to recommended settings for XCode 14.3
rkmackinnon Apr 26, 2023
5d37292
Register plugins outside of AppDelegate, easier to use with Expo
AnomalousLLC May 9, 2023
918c201
Make sure Swift interface header is included when built statically
AnomalousLLC May 19, 2023
bc64524
Conditional import of Swift interface header
AnomalousLLC May 19, 2023
4ad35aa
Merge pull request #1 from AnomalousLLC/react-native-vision-camera-v3
rkmackinnon May 19, 2023
5738c15
Update VisionCameraCodeScanner.podspec
rkmackinnon May 19, 2023
dde6fec
Update AppDelegate.m
rkmackinnon May 19, 2023
01e5121
Fix hook & corresponding documentation
AnomalousLLC May 19, 2023
8196712
Recreate the types array
AnomalousLLC May 20, 2023
a4a96a5
Cleaner, ensures types is an array
AnomalousLLC May 20, 2023
187bc37
Merge pull request #2 from AnomalousLLC/react-native-vision-camera-v3…
rkmackinnon May 24, 2023
1202057
Update example app to use hook
rkmackinnon May 24, 2023
299180b
fix/remove-skia-workaround
rkmackinnon May 24, 2023
4fa6e09
fix/adjust-pathing
rkmackinnon May 30, 2023
5d522eb
fix/android-jni-error
rkmackinnon May 30, 2023
93ac09a
Update Android example app for newer react version
rkmackinnon May 30, 2023
7b980af
fix/update-react-native-worklets src/types pathing
rkmackinnon May 30, 2023
dedefa6
Add comment to hook.tsx
rkmackinnon May 30, 2023
f2933a7
add support for v3.0.0 for iOS
rkmackinnon Sep 2, 2023
17f2264
android fixes
rkmackinnon Sep 16, 2023
97ddfc8
add support for v3.1.0 for iOS
rkmackinnon Sep 28, 2023
06e77d2
more incomplete android fixes
rkmackinnon Sep 29, 2023
9873cb3
iOS AND Android working with v3.2.2
rkmackinnon Sep 30, 2023
415cd8e
fix bug with react-native-static-safe-area-insets
rkmackinnon Oct 3, 2023
e4d15c7
bump react-native-worklets-core version
rkmackinnon Oct 3, 2023
6448f95
update example app tsconfig to not extend root
rkmackinnon Oct 3, 2023
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
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ node_modules/
npm-debug.log
yarn-debug.log
yarn-error.log
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
example/.pnp/*
example/.yarn/*
!example/.yarn/patches
!example/.yarn/plugins
!example/.yarn/releases
!example/.yarn/sdks
!example/.yarn/versions

# BUCK
buck-out/
Expand Down
873 changes: 873 additions & 0 deletions .yarn/releases/yarn-3.5.0.cjs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-3.5.0.cjs
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,16 @@ VisionCamera Frame Processor Plugin to read barcodes using MLKit Vision Barcode
yarn add vision-camera-code-scanner
```

make sure you correctly [setup](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation/) react-native-reanimated and insert as a first line of your [`index.tsx`](https://github.com/rodgomesc/vision-camera-code-scanner/blob/1409a8afd02328a26e336036493b2d6ef8441359/example/index.tsx#L1)
make sure you correctly [setup](https://github.com/chrfalch/react-native-worklets) react-native-worklets and insert as a first line of your [`index.tsx`](https://github.com/rodgomesc/vision-camera-code-scanner/blob/1409a8afd02328a26e336036493b2d6ef8441359/example/index.tsx#L1)

```sh
import 'react-native-reanimated'
import "react-native-worklets/src";
```

Add this to your `babel.config.js`

```
[
'react-native-reanimated/plugin',
{
globals: ['__scanCodes'],
},
]
["react-native-worklets/plugin"],
```

## Usage
Expand Down Expand Up @@ -50,10 +45,15 @@ export default function App() {

// Alternatively you can use the underlying function:
//
// const [barcodes, setBarcodes] = React.useState<Barcode[]>([]);
// const setBarcodesJS = Worklets.createRunInJsFn(setBarcodes);
//
// const frameProcessor = useFrameProcessor((frame) => {
// 'worklet';
// const detectedBarcodes = scanBarcodes(frame, [BarcodeFormat.QR_CODE], { checkInverted: true });
// runOnJS(setBarcodes)(detectedBarcodes);
// const detectedBarcodes = scanBarcodes(frame, [BarcodeFormat.ALL_FORMATS], {
// checkInverted: true,
// });
// setBarcodesJS(detectedBarcodes);
// }, []);

React.useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ require "json"
package = JSON.parse(File.read(File.join(__dir__, "package.json")))

Pod::Spec.new do |s|
s.name = "vision-camera-code-scanner"
s.name = "VisionCameraCodeScanner"
s.version = package["version"]
s.summary = package["description"]
s.homepage = package["homepage"]
s.license = package["license"]
s.authors = package["author"]

s.platforms = { :ios => "11.0" }
s.platforms = { :ios => "12.4" }
s.source = { :git => "https://github.com/rodgomesc/vision-camera-code-scanner.git", :tag => "#{s.version}" }

s.source_files = "ios/**/*.{h,m,mm,swift}"

s.dependency "React-Core"
s.dependency "GoogleMLKit/BarcodeScanning"
s.dependency "VisionCamera"
end
10 changes: 5 additions & 5 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.android.tools.build:gradle:7.3.1'
}
}
}
Expand All @@ -18,11 +18,11 @@ def safeExtGet(prop, fallback) {
}

android {
compileSdkVersion safeExtGet('VisionCameraCodeScanner_compileSdkVersion', 30)
compileSdkVersion safeExtGet('VisionCameraCodeScanner_compileSdkVersion', 33)
ndkVersion "21.4.7075529"
defaultConfig {
minSdkVersion safeExtGet('VisionCameraCodeScanner_minSdkVersion', 21)
targetSdkVersion safeExtGet('VisionCameraCodeScanner_targetSdkVersion', 31)
minSdkVersion safeExtGet('VisionCameraCodeScanner_minSdkVersion', 26)
targetSdkVersion safeExtGet('VisionCameraCodeScanner_targetSdkVersion', 33)
versionCode 1
versionName "1.0"

Expand Down Expand Up @@ -57,5 +57,5 @@ dependencies {
implementation "com.facebook.react:react-native:+" // From node_modules
api project(":react-native-vision-camera")
implementation "androidx.camera:camera-core:1.1.0-alpha06"
implementation 'com.google.mlkit:barcode-scanning:17.0.0'
implementation 'com.google.mlkit:barcode-scanning:17.2.0'
}
Loading