From 5516b20890d49f11b93d5faf31a11f34ae6f13ab Mon Sep 17 00:00:00 2001 From: Karim Stekelenburg Date: Thu, 14 Jan 2021 16:44:51 +0100 Subject: [PATCH] Add camera qr view to replace manual invitation input Signed-off-by: Karim Stekelenburg --- android/app/src/main/AndroidManifest.xml | 1 + .../project.pbxproj | 346 +----------------- ios/AriesMobileAgentJavaScript/Info.plist | 2 + ios/Podfile | 17 +- ios/Podfile.lock | 16 +- package.json | 5 +- src/App.tsx | 11 +- src/views/BaseView.tsx | 1 + src/views/RootView.tsx | 12 +- src/views/ScanInvitationView.tsx | 87 +++-- src/views/ScannerView.tsx | 104 ------ src/views/index.ts | 2 +- yarn.lock | 18 +- 13 files changed, 137 insertions(+), 485 deletions(-) delete mode 100644 src/views/ScannerView.tsx diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 1a69697..98f7c0d 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -6,6 +6,7 @@ + /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; }; - 979E033FF6851FF6B1071875 /* [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-AriesMobileAgentJavaScript-tvOSTests-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; - }; - BABFBF0B67EE153F378BE693 /* [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-AriesMobileAgentJavaScript-tvOS-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; - }; CCB69A3CC905AD8F0ED8288A /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -525,25 +368,6 @@ shellScript = "export RCT_METRO_PORT=\"${RCT_METRO_PORT:=8081}\"\necho \"export RCT_METRO_PORT=${RCT_METRO_PORT}\" > \"${SRCROOT}/../node_modules/react-native/scripts/.packager.env\"\nif [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\n if nc -w 5 -z localhost ${RCT_METRO_PORT} ; then\n if ! curl -s \"http://localhost:${RCT_METRO_PORT}/status\" | grep -q \"packager-status:running\" ; then\n echo \"Port ${RCT_METRO_PORT} already in use, packager is either not running or not running correctly\"\n exit 2\n fi\n else\n open \"$SRCROOT/../node_modules/react-native/scripts/launchPackager.command\" || echo \"Can't start packager automatically\"\n fi\nfi\n"; showEnvVarsInLog = 0; }; - FD10A7F122414F3F0027D42C /* Start Packager */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - name = "Start Packager"; - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "export RCT_METRO_PORT=\"${RCT_METRO_PORT:=8081}\"\necho \"export RCT_METRO_PORT=${RCT_METRO_PORT}\" > \"${SRCROOT}/../node_modules/react-native/scripts/.packager.env\"\nif [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\n if nc -w 5 -z localhost ${RCT_METRO_PORT} ; then\n if ! curl -s \"http://localhost:${RCT_METRO_PORT}/status\" | grep -q \"packager-status:running\" ; then\n echo \"Port ${RCT_METRO_PORT} already in use, packager is either not running or not running correctly\"\n exit 2\n fi\n else\n open \"$SRCROOT/../node_modules/react-native/scripts/launchPackager.command\" || echo \"Can't start packager automatically\"\n fi\nfi\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -565,23 +389,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 2D02E4771E0B4A5D006451C7 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 2D02E4BF1E0B4AB3006451C7 /* main.m in Sources */, - 2D02E4BC1E0B4A80006451C7 /* AppDelegate.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 2D02E48C1E0B4A5D006451C7 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 2DCD954D1E0B4F2C00145EB5 /* AriesMobileAgentJavaScriptTests.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ @@ -590,11 +397,6 @@ target = 13B07F861A680F5B00A75B9A /* AriesMobileAgentJavaScript */; targetProxy = 00E356F41AD99517003FC87E /* PBXContainerItemProxy */; }; - 2D02E4921E0B4A5D006451C7 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 2D02E47A1E0B4A5D006451C7 /* AriesMobileAgentJavaScript-tvOS */; - targetProxy = 2D02E4911E0B4A5D006451C7 /* PBXContainerItemProxy */; - }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ @@ -616,7 +418,7 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; - DEVELOPMENT_TEAM = UG66RMK356; + DEVELOPMENT_TEAM = 64Y6GSL5KV; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", @@ -642,7 +444,7 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; COPY_PHASE_STRIP = NO; - DEVELOPMENT_TEAM = UG66RMK356; + DEVELOPMENT_TEAM = 64Y6GSL5KV; INFOPLIST_FILE = AriesMobileAgentJavaScriptTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -665,7 +467,7 @@ CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = 1; DEAD_CODE_STRIPPING = NO; - DEVELOPMENT_TEAM = UG66RMK356; + DEVELOPMENT_TEAM = 64Y6GSL5KV; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -679,7 +481,7 @@ "-ObjC", "-lc++", ); - PRODUCT_BUNDLE_IDENTIFIER = "org.hyperledger.ama-rn"; + PRODUCT_BUNDLE_IDENTIFIER = "org.karimstekelenburg.moibile-agent"; PRODUCT_NAME = AriesMobileAgentJavaScript; SWIFT_OBJC_BRIDGING_HEADER = "AriesMobileAgentJavaScript-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -695,7 +497,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = UG66RMK356; + DEVELOPMENT_TEAM = 64Y6GSL5KV; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -709,7 +511,7 @@ "-ObjC", "-lc++", ); - PRODUCT_BUNDLE_IDENTIFIER = "org.hyperledger.ama-rn"; + PRODUCT_BUNDLE_IDENTIFIER = "org.karimstekelenburg.moibile-agent"; PRODUCT_NAME = AriesMobileAgentJavaScript; SWIFT_OBJC_BRIDGING_HEADER = "AriesMobileAgentJavaScript-Bridging-Header.h"; SWIFT_VERSION = 5.0; @@ -717,118 +519,6 @@ }; name = Release; }; - 2D02E4971E0B4A5E006451C7 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 1410BCFD738CB526A192D06A /* Pods-AriesMobileAgentJavaScript-tvOS.debug.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image"; - ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; - CLANG_ANALYZER_NONNULL = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - DEBUG_INFORMATION_FORMAT = dwarf; - DEVELOPMENT_TEAM = UG66RMK356; - ENABLE_TESTABILITY = YES; - GCC_NO_COMMON_BLOCKS = YES; - INFOPLIST_FILE = "AriesMobileAgentJavaScript-tvOS/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - OTHER_LDFLAGS = ( - "$(inherited)", - "-ObjC", - "-lc++", - ); - PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.REACT.AriesMobileAgentJavaScript-tvOS"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = appletvos; - TARGETED_DEVICE_FAMILY = 3; - TVOS_DEPLOYMENT_TARGET = 9.2; - }; - name = Debug; - }; - 2D02E4981E0B4A5E006451C7 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 8A0B5315DA71F0B49CE26746 /* Pods-AriesMobileAgentJavaScript-tvOS.release.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image"; - ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; - CLANG_ANALYZER_NONNULL = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DEVELOPMENT_TEAM = UG66RMK356; - GCC_NO_COMMON_BLOCKS = YES; - INFOPLIST_FILE = "AriesMobileAgentJavaScript-tvOS/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - OTHER_LDFLAGS = ( - "$(inherited)", - "-ObjC", - "-lc++", - ); - PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.REACT.AriesMobileAgentJavaScript-tvOS"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = appletvos; - TARGETED_DEVICE_FAMILY = 3; - TVOS_DEPLOYMENT_TARGET = 9.2; - }; - name = Release; - }; - 2D02E4991E0B4A5E006451C7 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 5E7EA8309BE115615C925F3A /* Pods-AriesMobileAgentJavaScript-tvOSTests.debug.xcconfig */; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - CLANG_ANALYZER_NONNULL = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_TESTABILITY = YES; - GCC_NO_COMMON_BLOCKS = YES; - INFOPLIST_FILE = "AriesMobileAgentJavaScript-tvOSTests/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - OTHER_LDFLAGS = ( - "$(inherited)", - "-ObjC", - "-lc++", - ); - PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.REACT.AriesMobileAgentJavaScript-tvOSTests"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = appletvos; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AriesMobileAgentJavaScript-tvOS.app/AriesMobileAgentJavaScript-tvOS"; - TVOS_DEPLOYMENT_TARGET = 10.1; - }; - name = Debug; - }; - 2D02E49A1E0B4A5E006451C7 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 2078CD217587F2D28143ABC2 /* Pods-AriesMobileAgentJavaScript-tvOSTests.release.xcconfig */; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - CLANG_ANALYZER_NONNULL = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_NO_COMMON_BLOCKS = YES; - INFOPLIST_FILE = "AriesMobileAgentJavaScript-tvOSTests/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - OTHER_LDFLAGS = ( - "$(inherited)", - "-ObjC", - "-lc++", - ); - PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.REACT.AriesMobileAgentJavaScript-tvOSTests"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = appletvos; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AriesMobileAgentJavaScript-tvOS.app/AriesMobileAgentJavaScript-tvOS"; - TVOS_DEPLOYMENT_TARGET = 10.1; - }; - name = Release; - }; 83CBBA201A601CBA00E9B192 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -949,24 +639,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 2D02E4BA1E0B4A5E006451C7 /* Build configuration list for PBXNativeTarget "AriesMobileAgentJavaScript-tvOS" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 2D02E4971E0B4A5E006451C7 /* Debug */, - 2D02E4981E0B4A5E006451C7 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 2D02E4BB1E0B4A5E006451C7 /* Build configuration list for PBXNativeTarget "AriesMobileAgentJavaScript-tvOSTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 2D02E4991E0B4A5E006451C7 /* Debug */, - 2D02E49A1E0B4A5E006451C7 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "AriesMobileAgentJavaScript" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/ios/AriesMobileAgentJavaScript/Info.plist b/ios/AriesMobileAgentJavaScript/Info.plist index a77fe7a..5deadaa 100644 --- a/ios/AriesMobileAgentJavaScript/Info.plist +++ b/ios/AriesMobileAgentJavaScript/Info.plist @@ -53,5 +53,7 @@ UIViewControllerBasedStatusBarAppearance + NSCameraUsageDescription + Your message to user when the camera is accessed for the first time diff --git a/ios/Podfile b/ios/Podfile index 23cf404..fb3e720 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -34,6 +34,9 @@ target 'AriesMobileAgentJavaScript' do pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec' pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec' + permissions_path = '../node_modules/react-native-permissions/ios' + pod 'Permission-Camera', :path => "#{permissions_path}/Camera/Permission-Camera.podspec" + pod 'react-native-camera', :path => '../node_modules/react-native-camera' target 'AriesMobileAgentJavaScriptTests' do @@ -45,12 +48,12 @@ target 'AriesMobileAgentJavaScript' do use_native_modules! end -target 'AriesMobileAgentJavaScript-tvOS' do - # Pods for AriesMobileAgentJavaScript-tvOS +# target 'AriesMobileAgentJavaScript-tvOS' do +# # Pods for AriesMobileAgentJavaScript-tvOS - target 'AriesMobileAgentJavaScript-tvOSTests' do - inherit! :search_paths - # Pods for testing - end +# target 'AriesMobileAgentJavaScript-tvOSTests' do +# inherit! :search_paths +# # Pods for testing +# end -end +# end diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 4d08e19..a346413 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -23,6 +23,8 @@ PODS: - lottie-react-native (3.5.0): - lottie-ios (~> 3.1.8) - React + - Permission-Camera (3.0.0): + - RNPermissions - RCTRequired (0.61.5) - RCTTypeSafety (0.61.5): - FBLazyVector (= 0.61.5) @@ -237,6 +239,8 @@ PODS: - React - RNFS (2.16.6): - React + - RNPermissions (3.0.0): + - React-Core - RNScreens (2.16.1): - React-Core - RNSVG (12.1.0): @@ -251,6 +255,7 @@ DEPENDENCIES: - glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`) - lottie-ios (from `../node_modules/lottie-ios`) - lottie-react-native (from `../node_modules/lottie-react-native`) + - Permission-Camera (from `../node_modules/react-native-permissions/ios/Camera/Permission-Camera.podspec`) - RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`) - RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`) - React (from `../node_modules/react-native/`) @@ -278,6 +283,7 @@ DEPENDENCIES: - ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`) - rn-indy-sdk (from `../node_modules/rn-indy-sdk`) - RNFS (from `../node_modules/react-native-fs`) + - RNPermissions (from `../node_modules/react-native-permissions`) - RNScreens (from `../node_modules/react-native-screens`) - RNSVG (from `../node_modules/react-native-svg`) - Yoga (from `../node_modules/react-native/ReactCommon/yoga`) @@ -301,6 +307,8 @@ EXTERNAL SOURCES: :path: "../node_modules/lottie-ios" lottie-react-native: :path: "../node_modules/lottie-react-native" + Permission-Camera: + :path: "../node_modules/react-native-permissions/ios/Camera/Permission-Camera.podspec" RCTRequired: :path: "../node_modules/react-native/Libraries/RCTRequired" RCTTypeSafety: @@ -349,6 +357,8 @@ EXTERNAL SOURCES: :path: "../node_modules/rn-indy-sdk" RNFS: :path: "../node_modules/react-native-fs" + RNPermissions: + :path: "../node_modules/react-native-permissions" RNScreens: :path: "../node_modules/react-native-screens" RNSVG: @@ -365,6 +375,7 @@ SPEC CHECKSUMS: glog: 1f3da668190260b06b429bb211bfbee5cd790c28 lottie-ios: 48fac6be217c76937e36e340e2d09cf7b10b7f5f lottie-react-native: 1fb4ce21d6ad37dab8343eaff8719df76035bd93 + Permission-Camera: 119b01de97a5b3edb637999e38476b68143b9d17 RCTRequired: b153add4da6e7dbc44aebf93f3cf4fcae392ddf1 RCTTypeSafety: 9aa1b91d7f9310fc6eadc3cf95126ffe818af320 React: b6a59ef847b2b40bb6e0180a97d0ca716969ac78 @@ -387,12 +398,13 @@ SPEC CHECKSUMS: React-RCTText: 9ccc88273e9a3aacff5094d2175a605efa854dbe React-RCTVibration: a49a1f42bf8f5acf1c3e297097517c6b3af377ad ReactCommon: 198c7c8d3591f975e5431bec1b0b3b581aa1c5dd - rn-indy-sdk: def342a0b0de8e2c78818367320beb48afe96e45 + rn-indy-sdk: 66036f7e0e0dff2b6bf82de8fc8838e1dd656447 RNFS: 2bd9eb49dc82fa9676382f0585b992c424cd59df + RNPermissions: 99dd8d4a30ff13509b949ca63cd1f69edc461775 RNScreens: 45c457af3d2ee9e08fc01e70da87e653d46b1198 RNSVG: ce9d996113475209013317e48b05c21ee988d42e Yoga: f2a7cd4280bfe2cca5a7aed98ba0eb3d1310f18b -PODFILE CHECKSUM: cbec772e9cab0670df74815acfd914bf296f6f17 +PODFILE CHECKSUM: b13146217985624f08ecd71034f63e6f8e227b06 COCOAPODS: 1.10.0 diff --git a/package.json b/package.json index ece5863..4e03a4d 100644 --- a/package.json +++ b/package.json @@ -29,12 +29,14 @@ "react-native-camera": "^3.40.0", "react-native-fs": "^2.16.6", "react-native-get-random-values": "^1.5.0", + "react-native-permissions": "^3.0.0", "react-native-safe-area-context": "^3.1.9", "react-native-screens": "^2.16.1", "react-native-svg": "^12.1.0", "react-redux": "^7.2.2", "redux": "^4.0.5", - "rn-indy-sdk": "^0.1.7" + "rn-indy-sdk": "file:rn-indy-sdk-v0.1.7.tgz", + "uuid": "^8.3.2" }, "devDependencies": { "@babel/core": "^7.6.2", @@ -42,6 +44,7 @@ "@react-native-community/eslint-config": "^0.0.5", "@types/react": "^16.9.55", "@types/react-native": "^0.61.23", + "@types/uuid": "^8.3.0", "@typescript-eslint/eslint-plugin": "^4.10.0", "@typescript-eslint/parser": "^4.10.0", "babel-jest": "^24.9.0", diff --git a/src/App.tsx b/src/App.tsx index 0b0b9fc..d41904b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,11 +1,10 @@ import * as eva from '@eva-design/eva' -import { ApplicationProvider, IconRegistry } from '@ui-kitten/components' +import { ApplicationProvider, IconRegistry, StyleService, useStyleSheet } from '@ui-kitten/components' import { EvaIconsPack } from '@ui-kitten/eva-icons' import React from 'react' import 'react-native-get-random-values' -import { Provider } from 'react-redux' +import { SafeAreaView } from 'react-native-safe-area-context' import { AgentProvider } from './agent/AgentProvider' -import { store } from './redux/store' import { RootView } from './views/RootView' const App = (): Element => { @@ -13,10 +12,8 @@ const App = (): Element => { <> - - - - + + diff --git a/src/views/BaseView.tsx b/src/views/BaseView.tsx index 5111670..a6c14f2 100644 --- a/src/views/BaseView.tsx +++ b/src/views/BaseView.tsx @@ -34,6 +34,7 @@ const themedStyles = StyleService.create({ }, header: { paddingVertical: 5, + marginBottom: 10, }, viewTitle: { marginVertical: 5, diff --git a/src/views/RootView.tsx b/src/views/RootView.tsx index 8718c42..38afccc 100644 --- a/src/views/RootView.tsx +++ b/src/views/RootView.tsx @@ -1,13 +1,23 @@ +import { StyleService, useStyleSheet } from '@ui-kitten/components' import React from 'react' +import { SafeAreaView } from 'react-native-safe-area-context' import { useAgent } from '../agent/AgentProvider' import { AppNavigator } from '../components' import { LoaderView } from './LoaderView' const RootView: React.FC = (): React.ReactElement => { + const styles = useStyleSheet(themedStyles) + const { loading } = useAgent() console.log(loading) - return <>{loading ? : } + return {loading ? : } } +const themedStyles = StyleService.create({ + safeAreaView: { + flex: 1, + backgroundColor: 'background-basic-color-1', + }, +}) export { RootView } diff --git a/src/views/ScanInvitationView.tsx b/src/views/ScanInvitationView.tsx index ddde396..b4170b3 100644 --- a/src/views/ScanInvitationView.tsx +++ b/src/views/ScanInvitationView.tsx @@ -1,9 +1,10 @@ -import { Button, Icon, Input } from '@ui-kitten/components' import { decodeInvitationFromUrl } from 'aries-framework-javascript' import { ConnectionInvitationMessage } from 'aries-framework-javascript/build/lib/protocols/connections/ConnectionInvitationMessage' -import React, { useState } from 'react' -import { Keyboard, StyleSheet, TouchableWithoutFeedback, View } from 'react-native' -import { RNCamera } from 'react-native-camera' +import React, { useEffect, useRef, useState } from 'react' +import { Alert, StyleSheet, View } from 'react-native' +import { BarCodeReadEvent, BarCodeType, RNCamera } from 'react-native-camera' +import Permissions from 'react-native-permissions' + import { useAgent } from '../agent/AgentProvider' import { InvitationModal } from '../components' import { BaseView } from './BaseView' @@ -12,11 +13,49 @@ const ScannerView = ({ navigation }): React.ReactElement => { const [invitationUrl, setInvitationUrl] = useState('') const [modalVisible, setModalVisible] = useState(false) const [invitationObject, setInvitationObject] = useState(undefined) + let qrScanned = false + + let cameraRef = useRef(null) const { agent } = useAgent() - async function onScan(scanResult: any): Promise { - console.warn(scanResult.type) - console.warn(scanResult.data) + useEffect(() => { + Permissions.check('ios.permission.CAMERA') + }, []) + + async function showInvitationAlert(invite: ConnectionInvitationMessage, newInvite = false): Promise { + Alert.alert( + 'Connection Invitation', + `ID:\t\t${invite.id}\n\nEndpoint:\t\t${invite.serviceEndpoint}`, + [ + { + text: 'Decline', + style: 'cancel', + onPress: async (): Promise => await onDecline(), + }, + { text: 'Accept', onPress: async (): Promise => await onAccept(invite) }, + ], + { + cancelable: true, + } + ) + } + + async function onScan(scanResult: BarCodeReadEvent): Promise { + console.log(scanResult) + + if (qrScanned === true) return + + console.log('hihi') + qrScanned = true + + if (scanResult.data === null) { + qrScanned = false + return + } + + const invitation = await decodeInvitationFromUrl(scanResult.data) + + await showInvitationAlert(invitation) } // try { @@ -30,36 +69,35 @@ const ScannerView = ({ navigation }): React.ReactElement => { // } // } - async function onAccept(): Promise { - await agent.connections.receiveInvitation(invitationObject.toJSON(), { autoAcceptConnection: true }) - setModalVisible(false) + async function onAccept(invite: ConnectionInvitationMessage): Promise { + await agent.connections.receiveInvitation(invite.toJSON(), { autoAcceptConnection: true }) navigation.navigate('Connections') + qrScanned = false } async function onDecline(): Promise { setModalVisible(false) setInvitationObject(undefined) + qrScanned = false } - let camera = null - return ( - + { - camera = ref + cameraRef = ref + }} + onBarCodeRead={(scanResult: BarCodeReadEvent): Promise => onScan(scanResult)} + captureAudio={false} + androidCameraPermissionOptions={{ + title: 'Permission to use camera', + message: 'We need your permission to use your camera', + buttonPositive: 'Ok', + buttonNegative: 'Cancel', }} - // defaultTouchToFocus - // flashMode={this.state.camera.flashMode} - // mirrorImage={false} - onBarCodeRead={scanResult => onScan(scanResult)} - // onFocusChanged={() => {}} - // onZoomChanged={() => {}} - permissionDialogTitle={'Permission to use camera'} - permissionDialogMessage={'We need your permission to use your camera phone'} style={styles.preview} - type={camera.type} + type="back" /> {modalVisible && ( @@ -77,7 +115,8 @@ const ScannerView = ({ navigation }): React.ReactElement => { const styles = StyleSheet.create({ container: { flex: 1, - alignItems: 'center', + margin: 30, + // alignItems: 'center', }, row: { flexDirection: 'row', diff --git a/src/views/ScannerView.tsx b/src/views/ScannerView.tsx deleted file mode 100644 index afbb3a2..0000000 --- a/src/views/ScannerView.tsx +++ /dev/null @@ -1,104 +0,0 @@ -import { Button, Icon, Input, Text } from '@ui-kitten/components' -import { decodeInvitationFromUrl } from 'aries-framework-javascript' -import { ConnectionInvitationMessage } from 'aries-framework-javascript/build/lib/protocols/connections/ConnectionInvitationMessage' -import React, { useState } from 'react' -import { Alert, Keyboard, StyleSheet, TouchableWithoutFeedback, View } from 'react-native' -import { useAgent } from '../agent/AgentProvider' -import { InvitationModal } from '../components' -import { BaseView } from './BaseView' - -const ScannerView = ({ navigation }): React.ReactElement => { - const [invitationUrl, setInvitationUrl] = useState('') - const [modalVisible, setModalVisible] = useState(false) - const [invitationObject, setInvitationObject] = useState(undefined) - const { agent } = useAgent() - - async function onPress(): Promise { - try { - Keyboard.dismiss() - const invitation = await decodeInvitationFromUrl(invitationUrl) - await showInvitationAlert(invitation) - } catch (e) { - console.error('Something went wrong while decoding invitation url') - throw e - } - } - - async function showInvitationAlert(invite: ConnectionInvitationMessage, newInvite = false): Promise { - Alert.alert( - 'Connection Invitation', - `ID:\t\t${invite.id}\n\nEndpoint:\t\t${invite.serviceEndpoint}`, - [ - { - text: 'Decline', - style: 'cancel', - onPress: async (): Promise => await onDecline(), - }, - { text: 'Accept', onPress: async (): Promise => await onAccept(invite) }, - ], - { - cancelable: true, - } - ) - } - - async function onAccept(invite: ConnectionInvitationMessage): Promise { - await agent.connections.receiveInvitation(invite.toJSON(), { autoAcceptConnection: true }) - navigation.navigate('Connections') - } - - async function onDecline(): Promise { - setModalVisible(false) - setInvitationObject(undefined) - } - - const renderIcon = props => ( - setInvitationUrl('')}> - - - ) - - return ( - - - - Invitation URL: - setInvitationUrl(nextValue)} - // accessoryRight={renderIcon} - /> - - - - - {modalVisible && ( - - )} - - ) -} - -const styles = StyleSheet.create({ - container: { - flex: 1, - alignItems: 'center', - }, - row: { - flexDirection: 'row', - alignItems: 'center', - }, - text: { - margin: 2, - }, -}) - -export { ScannerView } diff --git a/src/views/index.ts b/src/views/index.ts index edc6681..de31041 100644 --- a/src/views/index.ts +++ b/src/views/index.ts @@ -1,6 +1,6 @@ import { ConnectionsView } from './ConnectionsView' import { CredentialsView } from './CredentialsView' -import { ScannerView } from './ScannerView' +import { ScannerView } from './ScanInvitationView' import { LoaderView } from './LoaderView' export { ConnectionsView, CredentialsView, ScannerView, LoaderView } diff --git a/yarn.lock b/yarn.lock index 0210329..d8c940c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1114,6 +1114,11 @@ resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e" integrity sha512-l42BggppR6zLmpfU6fq9HEa2oGPEI8yrSPL3GITjfRInppYFahObbIQOQK3UGxEnyQpltZLaPe75046NOZQikw== +"@types/uuid@^8.3.0": + version "8.3.0" + resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-8.3.0.tgz#215c231dff736d5ba92410e6d602050cce7e273f" + integrity sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ== + "@types/validator@13.0.0": version "13.0.0" resolved "https://registry.yarnpkg.com/@types/validator/-/validator-13.0.0.tgz#365f1bf936aeaddd0856fc41aa1d6f82d88ee5b3" @@ -5711,6 +5716,11 @@ react-native-iphone-x-helper@^1.3.0: resolved "https://registry.yarnpkg.com/react-native-iphone-x-helper/-/react-native-iphone-x-helper-1.3.1.tgz#20c603e9a0e765fd6f97396638bdeb0e5a60b010" integrity sha512-HOf0jzRnq2/aFUcdCJ9w9JGzN3gdEg0zFE4FyYlp4jtidqU03D5X7ZegGKfT1EWteR0gPBGp9ye5T5FvSWi9Yg== +react-native-permissions@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/react-native-permissions/-/react-native-permissions-3.0.0.tgz#d9d107700741d41f8392f202f35a61f481fb0e68" + integrity sha512-zBvf+o3NhgKmBk1I06GzZXaDfc9SUyO4M5TMcaCF1pwG1h4sI+XAv3gWSbryl6WnaZQc1zA+g7SocSoYcpJN5g== + react-native-safe-area-context@^3.1.9: version "3.1.9" resolved "https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-3.1.9.tgz#48864ea976b0fa57142a2cc523e1fd3314e7247e" @@ -6108,6 +6118,12 @@ rn-indy-sdk@^0.1.7: dependencies: buffer "^6.0.2" +"rn-indy-sdk@file:rn-indy-sdk-v0.1.7.tgz": + version "0.1.7" + resolved "file:rn-indy-sdk-v0.1.7.tgz#981e8781dd66ee92944ad6555e8d464a42503436" + dependencies: + buffer "^6.0.2" + rsvp@^4.8.4: version "4.8.5" resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-4.8.5.tgz#c8f155311d167f68f21e168df71ec5b083113734" @@ -6983,7 +6999,7 @@ uuid@^3.3.2: resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== -uuid@^8.3.0: +uuid@^8.3.0, uuid@^8.3.2: version "8.3.2" resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==