From 16a40838e11d62663a4aa207164cb9154f814458 Mon Sep 17 00:00:00 2001 From: Philipp Walter Date: Fri, 12 Jul 2024 13:58:47 +0200 Subject: [PATCH] chore: switch to react-native-vision-camera --- android/app/build.gradle | 1 - android/gradle.properties | 3 + ios/Podfile.lock | 16 ++-- ios/bitkit.xcodeproj/project.pbxproj | 122 ++++++++++++------------- package.json | 2 +- src/components/Camera.tsx | 130 +++++++++++++++------------ yarn.lock | 32 ++++--- 7 files changed, 167 insertions(+), 139 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index f27ee9630..f2895873a 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -86,7 +86,6 @@ android { versionCode 130 versionName "1.0.3" multiDexEnabled true - missingDimensionStrategy 'react-native-camera', 'general' testBuildType System.getProperty('testBuildType', 'debug') testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } diff --git a/android/gradle.properties b/android/gradle.properties index 3dbe50bf6..a3888b9e0 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -37,3 +37,6 @@ newArchEnabled=false # Use this property to enable or disable the Hermes JS engine. # If set to false, you will be using JSC instead. hermesEnabled=true + +# Include MLKit model for react-native-vision-camera +VisionCamera_enableCodeScanner=true diff --git a/ios/Podfile.lock b/ios/Podfile.lock index b5780de08..6731b7f0c 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1690,8 +1690,6 @@ PODS: - React-logger (= 0.75.2) - React-perflogger (= 0.75.2) - React-utils (= 0.75.2) - - ReactNativeCameraKit (14.0.0-beta15): - - React-Core - RNCClipboard (1.14.1): - React-Core - RNDeviceInfo (11.1.0): @@ -1858,6 +1856,12 @@ PODS: - ReactCommon/turbomodule/core - Yoga - SSZipArchive (2.4.3) + - VisionCamera (4.5.3): + - VisionCamera/Core (= 4.5.3) + - VisionCamera/React (= 4.5.3) + - VisionCamera/Core (4.5.3) + - VisionCamera/React (4.5.3): + - React-Core - Yoga (0.0.0) - ZXingObjC (3.6.9): - ZXingObjC/All (= 3.6.9) @@ -1942,7 +1946,6 @@ DEPENDENCIES: - React-utils (from `../node_modules/react-native/ReactCommon/react/utils`) - ReactCodegen (from `build/generated/ios`) - ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`) - - ReactNativeCameraKit (from `../node_modules/react-native-camera-kit`) - "RNCClipboard (from `../node_modules/@react-native-clipboard/clipboard`)" - RNDeviceInfo (from `../node_modules/react-native-device-info`) - RNFS (from `../node_modules/react-native-fs`) @@ -1960,6 +1963,7 @@ DEPENDENCIES: - RNSVG (from `../node_modules/react-native-svg`) - RNZipArchive (from `../node_modules/react-native-zip-archive`) - sodium-react-native-direct (from `../node_modules/sodium-react-native-direct`) + - VisionCamera (from `../node_modules/react-native-vision-camera`) - Yoga (from `../node_modules/react-native/ReactCommon/yoga`) SPEC REPOS: @@ -2125,8 +2129,6 @@ EXTERNAL SOURCES: :path: build/generated/ios ReactCommon: :path: "../node_modules/react-native/ReactCommon" - ReactNativeCameraKit: - :path: "../node_modules/react-native-camera-kit" RNCClipboard: :path: "../node_modules/@react-native-clipboard/clipboard" RNDeviceInfo: @@ -2161,6 +2163,8 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native-zip-archive" sodium-react-native-direct: :path: "../node_modules/sodium-react-native-direct" + VisionCamera: + :path: "../node_modules/react-native-vision-camera" Yoga: :path: "../node_modules/react-native/ReactCommon/yoga" @@ -2245,7 +2249,6 @@ SPEC CHECKSUMS: React-utils: 81a715d9c0a2a49047e77a86f3a2247408540deb ReactCodegen: 60973d382704c793c605b9be0fc7f31cb279442f ReactCommon: 6ef348087d250257c44c0204461c03f036650e9b - ReactNativeCameraKit: 71343efc1256720184ce980f164c7eedb78d5c16 RNCClipboard: 0a720adef5ec193aa0e3de24c3977222c7e52a37 RNDeviceInfo: b899ce37a403a4dea52b7cb85e16e49c04a5b88e RNFS: 4ac0f0ea233904cb798630b3c077808c06931688 @@ -2265,6 +2268,7 @@ SPEC CHECKSUMS: SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d sodium-react-native-direct: 8feb9a6d0d88ce65efa305d6cc774c11c62d9a15 SSZipArchive: fe6a26b2a54d5a0890f2567b5cc6de5caa600aef + VisionCamera: cb84d0d8485b3e67c91b62931d3aa88f49747c92 Yoga: a1d7895431387402a674fd0d1c04ec85e87909b8 ZXingObjC: 8898711ab495761b2dbbdec76d90164a6d7e14c5 diff --git a/ios/bitkit.xcodeproj/project.pbxproj b/ios/bitkit.xcodeproj/project.pbxproj index 5d0491f67..5fa0fc315 100644 --- a/ios/bitkit.xcodeproj/project.pbxproj +++ b/ios/bitkit.xcodeproj/project.pbxproj @@ -13,15 +13,15 @@ 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; 17074219BB5847259EAFC7A6 /* InterTight-Black.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 3815D562618543E7A9BC191E /* InterTight-Black.ttf */; }; 57072143CA0F49089AE64F61 /* InterTight-ExtraBold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = A223BA795CEB4CB2B344FBAF /* InterTight-ExtraBold.ttf */; }; + 5A83D165E47DEEE95B325079 /* libPods-bitkit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = AB482673B9B94AC9C72F162C /* libPods-bitkit.a */; }; 6980B602E6DC4429841BE5EE /* InterTight-Medium.ttf in Resources */ = {isa = PBXBuildFile; fileRef = D67AECF5F543462F90EC89AD /* InterTight-Medium.ttf */; }; - 736CBA139CF4E24B0259F5A1 /* libPods-bitkit-bitkitTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EC837B5F4E83A0457BF0754D /* libPods-bitkit-bitkitTests.a */; }; 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; }; 8BD8301E3A1B44DDA3C8A10D /* Damion-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = DEC74C5375A34FFCAEBA0781 /* Damion-Regular.ttf */; }; 925570EA7B1D43CC8AD07B91 /* InterTight-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = CA37793F82F144678099A00D /* InterTight-Bold.ttf */; }; - 9777B77C9A5650BC4E0B860D /* libPods-bitkit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A27D5E6C57728844FF26A95 /* libPods-bitkit.a */; }; 9952E811473D46FB9003A56D /* InterTight-SemiBold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 50A8DA09F2974D05A3C58E87 /* InterTight-SemiBold.ttf */; }; B3BE07A9843E4B7DA375B877 /* InterTight-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 79DFAC55B0D745DE815EC2E0 /* InterTight-Regular.ttf */; }; E2F35FC226645CE623C61C03 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 919FE2A2B4A7605C9F606896 /* PrivacyInfo.xcprivacy */; }; + EBDBF610AFE6D875FF454C17 /* libPods-bitkit-bitkitTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 94E3D8A93BDD5209C8034928 /* libPods-bitkit-bitkitTests.a */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -38,7 +38,6 @@ 00E356EE1AD99517003FC87E /* bitkitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = bitkitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 00E356F21AD99517003FC87E /* bitkitTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = bitkitTests.m; sourceTree = ""; }; - 0A27D5E6C57728844FF26A95 /* libPods-bitkit.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-bitkit.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 13B07F961A680F5B00A75B9A /* bitkit.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = bitkit.app; sourceTree = BUILT_PRODUCTS_DIR; }; 13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = bitkit/AppDelegate.h; sourceTree = ""; }; 13B07FB01A68108700A75B9A /* AppDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AppDelegate.mm; path = bitkit/AppDelegate.mm; sourceTree = ""; }; @@ -46,20 +45,21 @@ 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = bitkit/Info.plist; sourceTree = ""; }; 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = bitkit/main.m; sourceTree = ""; }; 13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = PrivacyInfo.xcprivacy; path = bitkit/PrivacyInfo.xcprivacy; sourceTree = ""; }; - 1B926D2C850C55DAF372BA66 /* Pods-bitkit.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-bitkit.release.xcconfig"; path = "Target Support Files/Pods-bitkit/Pods-bitkit.release.xcconfig"; sourceTree = ""; }; + 248989D6DCFDBA51FFE2CCEF /* Pods-bitkit-bitkitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-bitkit-bitkitTests.debug.xcconfig"; path = "Target Support Files/Pods-bitkit-bitkitTests/Pods-bitkit-bitkitTests.debug.xcconfig"; sourceTree = ""; }; + 28F0E894DA615D8F462857E2 /* Pods-bitkit.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-bitkit.release.xcconfig"; path = "Target Support Files/Pods-bitkit/Pods-bitkit.release.xcconfig"; sourceTree = ""; }; 3815D562618543E7A9BC191E /* InterTight-Black.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "InterTight-Black.ttf"; path = "../src/assets/fonts/InterTight-Black.ttf"; sourceTree = ""; }; - 476A1902A666759266644AE2 /* Pods-bitkit-bitkitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-bitkit-bitkitTests.debug.xcconfig"; path = "Target Support Files/Pods-bitkit-bitkitTests/Pods-bitkit-bitkitTests.debug.xcconfig"; sourceTree = ""; }; 50A8DA09F2974D05A3C58E87 /* InterTight-SemiBold.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "InterTight-SemiBold.ttf"; path = "../src/assets/fonts/InterTight-SemiBold.ttf"; sourceTree = ""; }; - 56EACD478C48AD8E405EEFB1 /* Pods-bitkit-bitkitTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-bitkit-bitkitTests.release.xcconfig"; path = "Target Support Files/Pods-bitkit-bitkitTests/Pods-bitkit-bitkitTests.release.xcconfig"; sourceTree = ""; }; - 7716EC7037121FAAAB92458C /* Pods-bitkit.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-bitkit.debug.xcconfig"; path = "Target Support Files/Pods-bitkit/Pods-bitkit.debug.xcconfig"; sourceTree = ""; }; + 6171590D8F7D7C8AA444D5C0 /* Pods-bitkit-bitkitTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-bitkit-bitkitTests.release.xcconfig"; path = "Target Support Files/Pods-bitkit-bitkitTests/Pods-bitkit-bitkitTests.release.xcconfig"; sourceTree = ""; }; 79DFAC55B0D745DE815EC2E0 /* InterTight-Regular.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "InterTight-Regular.ttf"; path = "../src/assets/fonts/InterTight-Regular.ttf"; sourceTree = ""; }; 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = bitkit/LaunchScreen.storyboard; sourceTree = ""; }; 919FE2A2B4A7605C9F606896 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xml; name = PrivacyInfo.xcprivacy; path = bitkit/PrivacyInfo.xcprivacy; sourceTree = ""; }; + 94E3D8A93BDD5209C8034928 /* libPods-bitkit-bitkitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-bitkit-bitkitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; A223BA795CEB4CB2B344FBAF /* InterTight-ExtraBold.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "InterTight-ExtraBold.ttf"; path = "../src/assets/fonts/InterTight-ExtraBold.ttf"; sourceTree = ""; }; + AB482673B9B94AC9C72F162C /* libPods-bitkit.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-bitkit.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + BFD185E35E18F8EE19BDB9A7 /* Pods-bitkit.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-bitkit.debug.xcconfig"; path = "Target Support Files/Pods-bitkit/Pods-bitkit.debug.xcconfig"; sourceTree = ""; }; CA37793F82F144678099A00D /* InterTight-Bold.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "InterTight-Bold.ttf"; path = "../src/assets/fonts/InterTight-Bold.ttf"; sourceTree = ""; }; D67AECF5F543462F90EC89AD /* InterTight-Medium.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "InterTight-Medium.ttf"; path = "../src/assets/fonts/InterTight-Medium.ttf"; sourceTree = ""; }; DEC74C5375A34FFCAEBA0781 /* Damion-Regular.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "Damion-Regular.ttf"; path = "../src/assets/fonts/Damion-Regular.ttf"; sourceTree = ""; }; - EC837B5F4E83A0457BF0754D /* libPods-bitkit-bitkitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-bitkit-bitkitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; /* End PBXFileReference section */ @@ -68,7 +68,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 736CBA139CF4E24B0259F5A1 /* libPods-bitkit-bitkitTests.a in Frameworks */, + EBDBF610AFE6D875FF454C17 /* libPods-bitkit-bitkitTests.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -76,7 +76,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 9777B77C9A5650BC4E0B860D /* libPods-bitkit.a in Frameworks */, + 5A83D165E47DEEE95B325079 /* libPods-bitkit.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -119,8 +119,8 @@ isa = PBXGroup; children = ( ED297162215061F000B7C4FE /* JavaScriptCore.framework */, - 0A27D5E6C57728844FF26A95 /* libPods-bitkit.a */, - EC837B5F4E83A0457BF0754D /* libPods-bitkit-bitkitTests.a */, + AB482673B9B94AC9C72F162C /* libPods-bitkit.a */, + 94E3D8A93BDD5209C8034928 /* libPods-bitkit-bitkitTests.a */, ); name = Frameworks; sourceTree = ""; @@ -183,10 +183,10 @@ BBD78D7AC51CEA395F1C20DB /* Pods */ = { isa = PBXGroup; children = ( - 7716EC7037121FAAAB92458C /* Pods-bitkit.debug.xcconfig */, - 1B926D2C850C55DAF372BA66 /* Pods-bitkit.release.xcconfig */, - 476A1902A666759266644AE2 /* Pods-bitkit-bitkitTests.debug.xcconfig */, - 56EACD478C48AD8E405EEFB1 /* Pods-bitkit-bitkitTests.release.xcconfig */, + BFD185E35E18F8EE19BDB9A7 /* Pods-bitkit.debug.xcconfig */, + 28F0E894DA615D8F462857E2 /* Pods-bitkit.release.xcconfig */, + 248989D6DCFDBA51FFE2CCEF /* Pods-bitkit-bitkitTests.debug.xcconfig */, + 6171590D8F7D7C8AA444D5C0 /* Pods-bitkit-bitkitTests.release.xcconfig */, ); path = Pods; sourceTree = ""; @@ -198,12 +198,12 @@ isa = PBXNativeTarget; buildConfigurationList = 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "bitkitTests" */; buildPhases = ( - 5BE42D8578E5EBF4ED61F80E /* [CP] Check Pods Manifest.lock */, + 558F3D8C36E06837D8AE1094 /* [CP] Check Pods Manifest.lock */, 00E356EA1AD99517003FC87E /* Sources */, 00E356EB1AD99517003FC87E /* Frameworks */, 00E356EC1AD99517003FC87E /* Resources */, - 29D79B280A4190C1130EEDF4 /* [CP] Embed Pods Frameworks */, - 890F48CFF6EAC774E58DAC4D /* [CP] Copy Pods Resources */, + 4350F88F05B17CD7D3A19F06 /* [CP] Embed Pods Frameworks */, + A9EDC1457B737C513C2A186F /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -219,13 +219,13 @@ isa = PBXNativeTarget; buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "bitkit" */; buildPhases = ( - 1E38345B3A03A65F0B188C80 /* [CP] Check Pods Manifest.lock */, + ADFC6AD5E0DBB405226C9563 /* [CP] Check Pods Manifest.lock */, 13B07F871A680F5B00A75B9A /* Sources */, 13B07F8C1A680F5B00A75B9A /* Frameworks */, 13B07F8E1A680F5B00A75B9A /* Resources */, 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */, - B2C127469367779971988635 /* [CP] Embed Pods Frameworks */, - 51956367EFA5CA6D6DEC93C9 /* [CP] Copy Pods Resources */, + 4D8F27D5DD7654B9301B3100 /* [CP] Embed Pods Frameworks */, + A8D68D69DD59EE8DBE692D6E /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -316,29 +316,7 @@ shellPath = /bin/sh; shellScript = "set -e\n\nWITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"$REACT_NATIVE_PATH/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n"; }; - 1E38345B3A03A65F0B188C80 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-bitkit-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - 29D79B280A4190C1130EEDF4 /* [CP] Embed Pods Frameworks */ = { + 4350F88F05B17CD7D3A19F06 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -355,24 +333,24 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-bitkit-bitkitTests/Pods-bitkit-bitkitTests-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - 51956367EFA5CA6D6DEC93C9 /* [CP] Copy Pods Resources */ = { + 4D8F27D5DD7654B9301B3100 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-bitkit/Pods-bitkit-resources-${CONFIGURATION}-input-files.xcfilelist", + "${PODS_ROOT}/Target Support Files/Pods-bitkit/Pods-bitkit-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); - name = "[CP] Copy Pods Resources"; + name = "[CP] Embed Pods Frameworks"; outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-bitkit/Pods-bitkit-resources-${CONFIGURATION}-output-files.xcfilelist", + "${PODS_ROOT}/Target Support Files/Pods-bitkit/Pods-bitkit-frameworks-${CONFIGURATION}-output-files.xcfilelist", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-bitkit/Pods-bitkit-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-bitkit/Pods-bitkit-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - 5BE42D8578E5EBF4ED61F80E /* [CP] Check Pods Manifest.lock */ = { + 558F3D8C36E06837D8AE1094 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -394,7 +372,24 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 890F48CFF6EAC774E58DAC4D /* [CP] Copy Pods Resources */ = { + A8D68D69DD59EE8DBE692D6E /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-bitkit/Pods-bitkit-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-bitkit/Pods-bitkit-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-bitkit/Pods-bitkit-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + A9EDC1457B737C513C2A186F /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -411,21 +406,26 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-bitkit-bitkitTests/Pods-bitkit-bitkitTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; - B2C127469367779971988635 /* [CP] Embed Pods Frameworks */ = { + ADFC6AD5E0DBB405226C9563 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-bitkit/Pods-bitkit-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); - name = "[CP] Embed Pods Frameworks"; + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-bitkit/Pods-bitkit-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-bitkit-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-bitkit/Pods-bitkit-frameworks.sh\"\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -461,7 +461,7 @@ /* Begin XCBuildConfiguration section */ 00E356F61AD99517003FC87E /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 476A1902A666759266644AE2 /* Pods-bitkit-bitkitTests.debug.xcconfig */; + baseConfigurationReference = 248989D6DCFDBA51FFE2CCEF /* Pods-bitkit-bitkitTests.debug.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; @@ -489,7 +489,7 @@ }; 00E356F71AD99517003FC87E /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 56EACD478C48AD8E405EEFB1 /* Pods-bitkit-bitkitTests.release.xcconfig */; + baseConfigurationReference = 6171590D8F7D7C8AA444D5C0 /* Pods-bitkit-bitkitTests.release.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; @@ -514,7 +514,7 @@ }; 13B07F941A680F5B00A75B9A /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7716EC7037121FAAAB92458C /* Pods-bitkit.debug.xcconfig */; + baseConfigurationReference = BFD185E35E18F8EE19BDB9A7 /* Pods-bitkit.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIconOrange; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES; @@ -546,7 +546,7 @@ }; 13B07F951A680F5B00A75B9A /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 1B926D2C850C55DAF372BA66 /* Pods-bitkit.release.xcconfig */; + baseConfigurationReference = 28F0E894DA615D8F462857E2 /* Pods-bitkit.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIconOrange; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES; diff --git a/package.json b/package.json index f54540073..d08534876 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,6 @@ "react-native": "0.75.2", "react-native-address-generator": "0.3.3", "react-native-biometrics": "3.0.1", - "react-native-camera-kit": "14.0.0-beta15", "react-native-device-info": "11.1.0", "react-native-dotenv": "3.4.11", "react-native-draggable-flatlist": "4.0.1", @@ -111,6 +110,7 @@ "react-native-svg": "15.2.0", "react-native-tcp-socket": "6.0.6", "react-native-toast-message": "2.2.0", + "react-native-vision-camera": "4.5.3", "react-native-zip-archive": "6.1.0", "react-redux": "9.1.2", "readable-stream": "4.5.2", diff --git a/src/components/Camera.tsx b/src/components/Camera.tsx index 90d1f26da..abfb563d1 100644 --- a/src/components/Camera.tsx +++ b/src/components/Camera.tsx @@ -1,14 +1,26 @@ -import React, { ReactElement, useState, useEffect } from 'react'; -import { StyleSheet, Platform, View } from 'react-native'; +import React, { + ReactElement, + useState, + useEffect, + useRef, + useCallback, +} from 'react'; +import { StyleSheet } from 'react-native'; import { useIsFocused } from '@react-navigation/native'; -import { check, request, PERMISSIONS, RESULTS } from 'react-native-permissions'; -import { Camera as CameraKit, CameraType } from 'react-native-camera-kit'; -import { useTranslation } from 'react-i18next'; +import { + Camera as VisionCamera, + Point, + useCameraDevice, + useCodeScanner, + useCameraPermission, +} from 'react-native-vision-camera'; import CameraNoAuth from './CameraNoAuth'; import GradientView from './GradientView'; +import { Gesture, GestureDetector } from 'react-native-gesture-handler'; +import { runOnJS } from 'react-native-reanimated'; -enum Status { +enum EAuthStatus { AUTHORIZED = 'AUTHORIZED', NOT_AUTHORIZED = 'NOT_AUTHORIZED', UNKNOWN = 'UNKNOWN', @@ -25,72 +37,72 @@ const Camera = ({ bottomSheet?: boolean; onBarCodeRead: (data: string) => void; }): ReactElement => { - const { t } = useTranslation('other'); + const camera = useRef(null); + const scannedCode = useRef(''); const isFocused = useIsFocused(); - const [_data, setData] = useState(''); - const [cameraStatus, setCameraStatus] = useState(Status.UNKNOWN); + const [authStatus, setAuthStatus] = useState(EAuthStatus.UNKNOWN); + + const device = useCameraDevice('back'); + const { hasPermission, requestPermission } = useCameraPermission(); useEffect(() => { - (async (): Promise => { - const cameraPermission = - Platform.OS === 'ios' - ? PERMISSIONS.IOS.CAMERA - : PERMISSIONS.ANDROID.CAMERA; - const checkResponse = await check(cameraPermission); - switch (checkResponse) { - case RESULTS.UNAVAILABLE: - case RESULTS.BLOCKED: - setCameraStatus(Status.NOT_AUTHORIZED); - break; - case RESULTS.DENIED: - const rationale = { - title: t('camera_ask_title'), - message: t('camera_ask_msg'), - buttonPositive: t('ok'), - buttonNegative: t('cancel'), - }; - const requestResponse = await request(cameraPermission, rationale); - setCameraStatus( - requestResponse === RESULTS.GRANTED - ? Status.AUTHORIZED - : Status.NOT_AUTHORIZED, - ); - break; - case RESULTS.LIMITED: - case RESULTS.GRANTED: - setCameraStatus(Status.AUTHORIZED); - break; + const checkPermission = async (): Promise => { + if (hasPermission) { + setAuthStatus(EAuthStatus.AUTHORIZED); + } else { + const granted = await requestPermission(); + if (granted) { + setAuthStatus(EAuthStatus.AUTHORIZED); + } else { + setAuthStatus(EAuthStatus.NOT_AUTHORIZED); + } + } + }; + + checkPermission(); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + const codeScanner = useCodeScanner({ + codeTypes: ['qr'], + onCodeScanned: (codes) => { + const code = codes.find((c) => c.value); + if (code?.value && scannedCode.current !== code.value) { + scannedCode.current = code.value; + onBarCodeRead(code.value); } - })(); - }, [t]); + }, + }); - const handleCodeRead = (event): void => { - const { codeStringValue } = event.nativeEvent; - if (_data !== codeStringValue) { - setData(codeStringValue); - onBarCodeRead(codeStringValue); - } - }; + const focus = useCallback((point: Point) => { + camera.current?.focus(point); + }, []); - if (!isFocused) { - return ; - } + const gesture = Gesture.Tap().onEnd(({ x, y }) => { + runOnJS(focus)({ x, y }); + }); return ( - {cameraStatus === Status.AUTHORIZED && ( + {authStatus === EAuthStatus.AUTHORIZED && ( <> - + {device && ( + + console.error(error)} + /> + + )} {children} )} - {cameraStatus === Status.NOT_AUTHORIZED && ( + {authStatus === EAuthStatus.NOT_AUTHORIZED && ( )} diff --git a/yarn.lock b/yarn.lock index 7c4a38376..c76ccd490 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6637,7 +6637,6 @@ __metadata: react-native-address-generator: 0.3.3 react-native-biometrics: 3.0.1 react-native-bundle-visualizer: ^3.1.3 - react-native-camera-kit: 14.0.0-beta15 react-native-device-info: 11.1.0 react-native-dotenv: 3.4.11 react-native-draggable-flatlist: 4.0.1 @@ -6667,6 +6666,7 @@ __metadata: react-native-svg-transformer: ^1.3.0 react-native-tcp-socket: 6.0.6 react-native-toast-message: 2.2.0 + react-native-vision-camera: 4.5.3 react-native-zip-archive: 6.1.0 react-redux: 9.1.2 reactotron-react-native: ^5.1.6 @@ -14083,16 +14083,6 @@ __metadata: languageName: node linkType: hard -"react-native-camera-kit@npm:14.0.0-beta15": - version: 14.0.0-beta15 - resolution: "react-native-camera-kit@npm:14.0.0-beta15" - peerDependencies: - react: "*" - react-native: "*" - checksum: 6867d00df53dec159c48898a657628819cd637e7083b20f1ed5b6b93aafff01899642d8a99752faf2cef7b713e0f330327d8c38ca22aabb73c80ce1b42fcead3 - languageName: node - linkType: hard - "react-native-device-info@npm:11.1.0": version: 11.1.0 resolution: "react-native-device-info@npm:11.1.0" @@ -14462,6 +14452,26 @@ __metadata: languageName: node linkType: hard +"react-native-vision-camera@npm:4.5.3": + version: 4.5.3 + resolution: "react-native-vision-camera@npm:4.5.3" + peerDependencies: + "@shopify/react-native-skia": "*" + react: "*" + react-native: "*" + react-native-reanimated: "*" + react-native-worklets-core: "*" + peerDependenciesMeta: + "@shopify/react-native-skia": + optional: true + react-native-reanimated: + optional: true + react-native-worklets-core: + optional: true + checksum: 99d57a70f93134903ae25ef798947f79804ea00e3b58cbb21131115552e6f2950d2a3be9a6a237232ca6bab7b5031aa12d9ca2df659be39dc607d75997317abc + languageName: node + linkType: hard + "react-native-zip-archive@npm:6.1.0": version: 6.1.0 resolution: "react-native-zip-archive@npm:6.1.0"