feat: add RNCamera
add RNCamera module and fix a bug on iOS which lead to crash. See react-native #28583, #28545
Showing
15 changed files
with
432 additions
and
58 deletions
| @@ -135,6 +135,8 @@ android { | @@ -135,6 +135,8 @@ android { | ||
| 135 | targetSdkVersion rootProject.ext.targetSdkVersion | 135 | targetSdkVersion rootProject.ext.targetSdkVersion |
| 136 | versionCode 1 | 136 | versionCode 1 |
| 137 | versionName "1.0" | 137 | versionName "1.0" |
| 138 | + missingDimensionStrategy 'react-native-camera', 'general' | ||
| 139 | + multiDexEnabled true | ||
| 138 | } | 140 | } |
| 139 | splits { | 141 | splits { |
| 140 | abi { | 142 | abi { |
| 1 | -<manifest xmlns:android="http://schemas.android.com/apk/res/android" | 1 | +<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.ngplay"> |
| 2 | - package="com.ngplay"> | ||
| 3 | 2 | ||
| 4 | - <uses-permission android:name="android.permission.INTERNET" /> | 3 | + <uses-permission android:name="android.permission.INTERNET" /> |
| 5 | 4 | ||
| 6 | - <application | 5 | + <!-- 🚨 Permissioins start 🚨 --> |
| 7 | - android:name=".MainApplication" | 6 | + |
| 8 | - android:label="@string/app_name" | 7 | + <!-- <uses-permission android:name="android.permission.ACCEPT_HANDOVER" />--> |
| 9 | - android:icon="@mipmap/ic_launcher" | 8 | + <!-- <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />--> |
| 10 | - android:roundIcon="@mipmap/ic_launcher_round" | 9 | + <!-- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />--> |
| 11 | - android:allowBackup="false" | 10 | + <!-- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />--> |
| 12 | - android:theme="@style/AppTheme"> | 11 | + <!-- <uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />--> |
| 13 | - <activity | 12 | + <!-- <uses-permission android:name="android.permission.ANSWER_PHONE_CALLS" />--> |
| 14 | - android:name=".MainActivity" | 13 | + <!-- <uses-permission android:name="android.permission.BODY_SENSORS" />--> |
| 15 | - android:label="@string/app_name" | 14 | + <!-- <uses-permission android:name="android.permission.CALL_PHONE" />--> |
| 16 | - android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" | 15 | + <uses-permission android:name="android.permission.CAMERA" /> |
| 17 | - android:launchMode="singleTask" | 16 | + <!-- <uses-permission android:name="android.permission.GET_ACCOUNTS" />--> |
| 18 | - android:windowSoftInputMode="adjustResize"> | 17 | + <!-- <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />--> |
| 19 | - <intent-filter> | 18 | + <!-- <uses-permission android:name="android.permission.READ_CALENDAR" />--> |
| 20 | - <action android:name="android.intent.action.MAIN" /> | 19 | + <!-- <uses-permission android:name="android.permission.READ_CALL_LOG" />--> |
| 21 | - <category android:name="android.intent.category.LAUNCHER" /> | 20 | + <!-- <uses-permission android:name="android.permission.READ_CONTACTS" />--> |
| 22 | - </intent-filter> | 21 | + <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> |
| 23 | - </activity> | 22 | + <!-- <uses-permission android:name="android.permission.READ_PHONE_NUMBERS" />--> |
| 24 | - <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" /> | 23 | + <!-- <uses-permission android:name="android.permission.READ_PHONE_STATE" />--> |
| 25 | - </application> | 24 | + <!-- <uses-permission android:name="android.permission.READ_SMS" />--> |
| 25 | + <!-- <uses-permission android:name="android.permission.RECEIVE_MMS" />--> | ||
| 26 | + <!-- <uses-permission android:name="android.permission.RECEIVE_SMS" />--> | ||
| 27 | + <!-- <uses-permission android:name="android.permission.RECEIVE_WAP_PUSH" />--> | ||
| 28 | + <!-- <uses-permission android:name="android.permission.RECORD_AUDIO" />--> | ||
| 29 | + <!-- <uses-permission android:name="android.permission.SEND_SMS" />--> | ||
| 30 | + <!-- <uses-permission android:name="android.permission.USE_SIP" />--> | ||
| 31 | + <!-- <uses-permission android:name="android.permission.WRITE_CALENDAR" />--> | ||
| 32 | + <!-- <uses-permission android:name="android.permission.WRITE_CALL_LOG" />--> | ||
| 33 | + <!-- <uses-permission android:name="android.permission.WRITE_CONTACTS" />--> | ||
| 34 | + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
| 35 | + | ||
| 36 | + <!-- … --> | ||
| 37 | + | ||
| 38 | + <application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="false" android:theme="@style/AppTheme"> | ||
| 39 | + <activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize"> | ||
| 40 | + <intent-filter> | ||
| 41 | + <action android:name="android.intent.action.MAIN" /> | ||
| 42 | + <category android:name="android.intent.category.LAUNCHER" /> | ||
| 43 | + </intent-filter> | ||
| 44 | + </activity> | ||
| 45 | + <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" /> | ||
| 46 | + </application> | ||
| 26 | 47 | ||
| 27 | </manifest> | 48 | </manifest> |
This diff is collapsed. Click to expand it.
| @@ -37,8 +37,14 @@ | @@ -37,8 +37,14 @@ | ||
| 37 | </dict> | 37 | </dict> |
| 38 | </dict> | 38 | </dict> |
| 39 | </dict> | 39 | </dict> |
| 40 | + <key>NSCameraUsageDescription</key> | ||
| 41 | + <string>Use your camera to take a photo or scan codes</string> | ||
| 40 | <key>NSLocationWhenInUseUsageDescription</key> | 42 | <key>NSLocationWhenInUseUsageDescription</key> |
| 41 | - <string></string> | 43 | + <string>Use your location to check security</string> |
| 44 | + <key>NSPhotoLibraryAddUsageDescription</key> | ||
| 45 | + <string>Add photos to your photo library</string> | ||
| 46 | + <key>NSPhotoLibraryUsageDescription</key> | ||
| 47 | + <string>Read images from your photo library to set a avatar or scan codes</string> | ||
| 42 | <key>UIAppFonts</key> | 48 | <key>UIAppFonts</key> |
| 43 | <array> | 49 | <array> |
| 44 | <string>AntDesign.ttf</string> | 50 | <string>AntDesign.ttf</string> |
| @@ -2,7 +2,7 @@ platform :ios, '9.0' | @@ -2,7 +2,7 @@ platform :ios, '9.0' | ||
| 2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' | 2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' |
| 3 | 3 | ||
| 4 | def add_flipper_pods! | 4 | def add_flipper_pods! |
| 5 | - version = '~> 0.33.1' | 5 | + version = '~> 0.37.0' |
| 6 | pod 'FlipperKit', version, :configuration => 'Debug' | 6 | pod 'FlipperKit', version, :configuration => 'Debug' |
| 7 | pod 'FlipperKit/FlipperKitLayoutPlugin', version, :configuration => 'Debug' | 7 | pod 'FlipperKit/FlipperKitLayoutPlugin', version, :configuration => 'Debug' |
| 8 | pod 'FlipperKit/SKIOSNetworkPlugin', version, :configuration => 'Debug' | 8 | pod 'FlipperKit/SKIOSNetworkPlugin', version, :configuration => 'Debug' |
| @@ -54,6 +54,27 @@ target 'NGPlay' do | @@ -54,6 +54,27 @@ target 'NGPlay' do | ||
| 54 | pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec' | 54 | pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec' |
| 55 | pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec' | 55 | pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec' |
| 56 | 56 | ||
| 57 | + # RNPermission start | ||
| 58 | + permissions_path = '../node_modules/react-native-permissions/ios' | ||
| 59 | + | ||
| 60 | + # pod 'Permission-BluetoothPeripheral', :path => "#{permissions_path}/BluetoothPeripheral.podspec" | ||
| 61 | + # pod 'Permission-Calendars', :path => "#{permissions_path}/Calendars.podspec" | ||
| 62 | + pod 'Permission-Camera', :path => "#{permissions_path}/Camera.podspec" | ||
| 63 | + # pod 'Permission-Contacts', :path => "#{permissions_path}/Contacts.podspec" | ||
| 64 | + # pod 'Permission-FaceID', :path => "#{permissions_path}/FaceID.podspec" | ||
| 65 | + # pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways.podspec" | ||
| 66 | + pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse.podspec" | ||
| 67 | + # pod 'Permission-MediaLibrary', :path => "#{permissions_path}/MediaLibrary.podspec" | ||
| 68 | + # pod 'Permission-Microphone', :path => "#{permissions_path}/Microphone.podspec" | ||
| 69 | + # pod 'Permission-Motion', :path => "#{permissions_path}/Motion.podspec" | ||
| 70 | + # pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications.podspec" | ||
| 71 | + pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary.podspec" | ||
| 72 | + # pod 'Permission-Reminders', :path => "#{permissions_path}/Reminders.podspec" | ||
| 73 | + # pod 'Permission-Siri', :path => "#{permissions_path}/Siri.podspec" | ||
| 74 | + # pod 'Permission-SpeechRecognition', :path => "#{permissions_path}/SpeechRecognition.podspec" | ||
| 75 | + # pod 'Permission-StoreKit', :path => "#{permissions_path}/StoreKit.podspec" | ||
| 76 | + # RNPermission end | ||
| 77 | + | ||
| 57 | target 'NGPlayTests' do | 78 | target 'NGPlayTests' do |
| 58 | inherit! :complete | 79 | inherit! :complete |
| 59 | # Pods for testing | 80 | # Pods for testing |
| @@ -11,11 +11,11 @@ PODS: | @@ -11,11 +11,11 @@ PODS: | ||
| 11 | - React-Core (= 0.62.1) | 11 | - React-Core (= 0.62.1) |
| 12 | - React-jsi (= 0.62.1) | 12 | - React-jsi (= 0.62.1) |
| 13 | - ReactCommon/turbomodule/core (= 0.62.1) | 13 | - ReactCommon/turbomodule/core (= 0.62.1) |
| 14 | - - Flipper (0.33.1): | 14 | + - Flipper (0.37.0): |
| 15 | - - Flipper-Folly (~> 2.1) | 15 | + - Flipper-Folly (~> 2.2) |
| 16 | - - Flipper-RSocket (~> 1.0) | 16 | + - Flipper-RSocket (~> 1.1) |
| 17 | - Flipper-DoubleConversion (1.1.7) | 17 | - Flipper-DoubleConversion (1.1.7) |
| 18 | - - Flipper-Folly (2.1.1): | 18 | + - Flipper-Folly (2.2.0): |
| 19 | - boost-for-react-native | 19 | - boost-for-react-native |
| 20 | - CocoaLibEvent (~> 1.0) | 20 | - CocoaLibEvent (~> 1.0) |
| 21 | - Flipper-DoubleConversion | 21 | - Flipper-DoubleConversion |
| @@ -23,38 +23,38 @@ PODS: | @@ -23,38 +23,38 @@ PODS: | ||
| 23 | - OpenSSL-Universal (= 1.0.2.19) | 23 | - OpenSSL-Universal (= 1.0.2.19) |
| 24 | - Flipper-Glog (0.3.6) | 24 | - Flipper-Glog (0.3.6) |
| 25 | - Flipper-PeerTalk (0.0.4) | 25 | - Flipper-PeerTalk (0.0.4) |
| 26 | - - Flipper-RSocket (1.0.0): | 26 | + - Flipper-RSocket (1.1.0): |
| 27 | - - Flipper-Folly (~> 2.0) | 27 | + - Flipper-Folly (~> 2.2) |
| 28 | - - FlipperKit (0.33.1): | 28 | + - FlipperKit (0.37.0): |
| 29 | - - FlipperKit/Core (= 0.33.1) | 29 | + - FlipperKit/Core (= 0.37.0) |
| 30 | - - FlipperKit/Core (0.33.1): | 30 | + - FlipperKit/Core (0.37.0): |
| 31 | - - Flipper (~> 0.33.1) | 31 | + - Flipper (~> 0.37.0) |
| 32 | - FlipperKit/CppBridge | 32 | - FlipperKit/CppBridge |
| 33 | - FlipperKit/FBCxxFollyDynamicConvert | 33 | - FlipperKit/FBCxxFollyDynamicConvert |
| 34 | - FlipperKit/FBDefines | 34 | - FlipperKit/FBDefines |
| 35 | - FlipperKit/FKPortForwarding | 35 | - FlipperKit/FKPortForwarding |
| 36 | - - FlipperKit/CppBridge (0.33.1): | 36 | + - FlipperKit/CppBridge (0.37.0): |
| 37 | - - Flipper (~> 0.33.1) | 37 | + - Flipper (~> 0.37.0) |
| 38 | - - FlipperKit/FBCxxFollyDynamicConvert (0.33.1): | 38 | + - FlipperKit/FBCxxFollyDynamicConvert (0.37.0): |
| 39 | - - Flipper-Folly (~> 2.1) | 39 | + - Flipper-Folly (~> 2.2) |
| 40 | - - FlipperKit/FBDefines (0.33.1) | 40 | + - FlipperKit/FBDefines (0.37.0) |
| 41 | - - FlipperKit/FKPortForwarding (0.33.1): | 41 | + - FlipperKit/FKPortForwarding (0.37.0): |
| 42 | - CocoaAsyncSocket (~> 7.6) | 42 | - CocoaAsyncSocket (~> 7.6) |
| 43 | - Flipper-PeerTalk (~> 0.0.4) | 43 | - Flipper-PeerTalk (~> 0.0.4) |
| 44 | - - FlipperKit/FlipperKitHighlightOverlay (0.33.1) | 44 | + - FlipperKit/FlipperKitHighlightOverlay (0.37.0) |
| 45 | - - FlipperKit/FlipperKitLayoutPlugin (0.33.1): | 45 | + - FlipperKit/FlipperKitLayoutPlugin (0.37.0): |
| 46 | - FlipperKit/Core | 46 | - FlipperKit/Core |
| 47 | - FlipperKit/FlipperKitHighlightOverlay | 47 | - FlipperKit/FlipperKitHighlightOverlay |
| 48 | - FlipperKit/FlipperKitLayoutTextSearchable | 48 | - FlipperKit/FlipperKitLayoutTextSearchable |
| 49 | - YogaKit (~> 1.18) | 49 | - YogaKit (~> 1.18) |
| 50 | - - FlipperKit/FlipperKitLayoutTextSearchable (0.33.1) | 50 | + - FlipperKit/FlipperKitLayoutTextSearchable (0.37.0) |
| 51 | - - FlipperKit/FlipperKitNetworkPlugin (0.33.1): | 51 | + - FlipperKit/FlipperKitNetworkPlugin (0.37.0): |
| 52 | - FlipperKit/Core | 52 | - FlipperKit/Core |
| 53 | - - FlipperKit/FlipperKitReactPlugin (0.33.1): | 53 | + - FlipperKit/FlipperKitReactPlugin (0.37.0): |
| 54 | - FlipperKit/Core | 54 | - FlipperKit/Core |
| 55 | - - FlipperKit/FlipperKitUserDefaultsPlugin (0.33.1): | 55 | + - FlipperKit/FlipperKitUserDefaultsPlugin (0.37.0): |
| 56 | - FlipperKit/Core | 56 | - FlipperKit/Core |
| 57 | - - FlipperKit/SKIOSNetworkPlugin (0.33.1): | 57 | + - FlipperKit/SKIOSNetworkPlugin (0.37.0): |
| 58 | - FlipperKit/Core | 58 | - FlipperKit/Core |
| 59 | - FlipperKit/FlipperKitNetworkPlugin | 59 | - FlipperKit/FlipperKitNetworkPlugin |
| 60 | - Folly (2018.10.22.00): | 60 | - Folly (2018.10.22.00): |
| @@ -70,6 +70,12 @@ PODS: | @@ -70,6 +70,12 @@ PODS: | ||
| 70 | - OpenSSL-Universal (1.0.2.19): | 70 | - OpenSSL-Universal (1.0.2.19): |
| 71 | - OpenSSL-Universal/Static (= 1.0.2.19) | 71 | - OpenSSL-Universal/Static (= 1.0.2.19) |
| 72 | - OpenSSL-Universal/Static (1.0.2.19) | 72 | - OpenSSL-Universal/Static (1.0.2.19) |
| 73 | + - Permission-Camera (2.1.2): | ||
| 74 | + - RNPermissions | ||
| 75 | + - Permission-LocationWhenInUse (2.1.2): | ||
| 76 | + - RNPermissions | ||
| 77 | + - Permission-PhotoLibrary (2.1.2): | ||
| 78 | + - RNPermissions | ||
| 73 | - RCTRequired (0.62.1) | 79 | - RCTRequired (0.62.1) |
| 74 | - RCTTypeSafety (0.62.1): | 80 | - RCTTypeSafety (0.62.1): |
| 75 | - FBLazyVector (= 0.62.1) | 81 | - FBLazyVector (= 0.62.1) |
| @@ -233,6 +239,14 @@ PODS: | @@ -233,6 +239,14 @@ PODS: | ||
| 233 | - React-cxxreact (= 0.62.1) | 239 | - React-cxxreact (= 0.62.1) |
| 234 | - React-jsi (= 0.62.1) | 240 | - React-jsi (= 0.62.1) |
| 235 | - React-jsinspector (0.62.1) | 241 | - React-jsinspector (0.62.1) |
| 242 | + - react-native-camera (3.23.1): | ||
| 243 | + - React | ||
| 244 | + - react-native-camera/RCT (= 3.23.1) | ||
| 245 | + - react-native-camera/RN (= 3.23.1) | ||
| 246 | + - react-native-camera/RCT (3.23.1): | ||
| 247 | + - React | ||
| 248 | + - react-native-camera/RN (3.23.1): | ||
| 249 | + - React | ||
| 236 | - react-native-netinfo (5.7.1): | 250 | - react-native-netinfo (5.7.1): |
| 237 | - React | 251 | - React |
| 238 | - react-native-safe-area-context (0.7.3): | 252 | - react-native-safe-area-context (0.7.3): |
| @@ -310,6 +324,8 @@ PODS: | @@ -310,6 +324,8 @@ PODS: | ||
| 310 | - React | 324 | - React |
| 311 | - RNLocalize (1.4.0): | 325 | - RNLocalize (1.4.0): |
| 312 | - React | 326 | - React |
| 327 | + - RNPermissions (2.1.2): | ||
| 328 | + - React | ||
| 313 | - RNReanimated (1.7.1): | 329 | - RNReanimated (1.7.1): |
| 314 | - React | 330 | - React |
| 315 | - RNScreens (2.4.0): | 331 | - RNScreens (2.4.0): |
| @@ -324,13 +340,16 @@ DEPENDENCIES: | @@ -324,13 +340,16 @@ DEPENDENCIES: | ||
| 324 | - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`) | 340 | - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`) |
| 325 | - FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`) | 341 | - FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`) |
| 326 | - FBReactNativeSpec (from `../node_modules/react-native/Libraries/FBReactNativeSpec`) | 342 | - FBReactNativeSpec (from `../node_modules/react-native/Libraries/FBReactNativeSpec`) |
| 327 | - - FlipperKit (~> 0.33.1) | 343 | + - FlipperKit (~> 0.37.0) |
| 328 | - - FlipperKit/FlipperKitLayoutPlugin (~> 0.33.1) | 344 | + - FlipperKit/FlipperKitLayoutPlugin (~> 0.37.0) |
| 329 | - - FlipperKit/FlipperKitReactPlugin (~> 0.33.1) | 345 | + - FlipperKit/FlipperKitReactPlugin (~> 0.37.0) |
| 330 | - - FlipperKit/FlipperKitUserDefaultsPlugin (~> 0.33.1) | 346 | + - FlipperKit/FlipperKitUserDefaultsPlugin (~> 0.37.0) |
| 331 | - - FlipperKit/SKIOSNetworkPlugin (~> 0.33.1) | 347 | + - FlipperKit/SKIOSNetworkPlugin (~> 0.37.0) |
| 332 | - Folly (from `../node_modules/react-native/third-party-podspecs/Folly.podspec`) | 348 | - Folly (from `../node_modules/react-native/third-party-podspecs/Folly.podspec`) |
| 333 | - glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`) | 349 | - glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`) |
| 350 | + - Permission-Camera (from `../node_modules/react-native-permissions/ios/Camera.podspec`) | ||
| 351 | + - Permission-LocationWhenInUse (from `../node_modules/react-native-permissions/ios/LocationWhenInUse.podspec`) | ||
| 352 | + - Permission-PhotoLibrary (from `../node_modules/react-native-permissions/ios/PhotoLibrary.podspec`) | ||
| 334 | - RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`) | 353 | - RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`) |
| 335 | - RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`) | 354 | - RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`) |
| 336 | - React (from `../node_modules/react-native/`) | 355 | - React (from `../node_modules/react-native/`) |
| @@ -342,6 +361,7 @@ DEPENDENCIES: | @@ -342,6 +361,7 @@ DEPENDENCIES: | ||
| 342 | - React-jsi (from `../node_modules/react-native/ReactCommon/jsi`) | 361 | - React-jsi (from `../node_modules/react-native/ReactCommon/jsi`) |
| 343 | - React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`) | 362 | - React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`) |
| 344 | - React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`) | 363 | - React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`) |
| 364 | + - react-native-camera (from `../node_modules/react-native-camera`) | ||
| 345 | - "react-native-netinfo (from `../node_modules/@react-native-community/netinfo`)" | 365 | - "react-native-netinfo (from `../node_modules/@react-native-community/netinfo`)" |
| 346 | - react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`) | 366 | - react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`) |
| 347 | - react-native-webview (from `../node_modules/react-native-webview`) | 367 | - react-native-webview (from `../node_modules/react-native-webview`) |
| @@ -362,6 +382,7 @@ DEPENDENCIES: | @@ -362,6 +382,7 @@ DEPENDENCIES: | ||
| 362 | - RNDeviceInfo (from `../node_modules/react-native-device-info`) | 382 | - RNDeviceInfo (from `../node_modules/react-native-device-info`) |
| 363 | - RNGestureHandler (from `../node_modules/react-native-gesture-handler`) | 383 | - RNGestureHandler (from `../node_modules/react-native-gesture-handler`) |
| 364 | - RNLocalize (from `../node_modules/react-native-localize`) | 384 | - RNLocalize (from `../node_modules/react-native-localize`) |
| 385 | + - RNPermissions (from `../node_modules/react-native-permissions`) | ||
| 365 | - RNReanimated (from `../node_modules/react-native-reanimated`) | 386 | - RNReanimated (from `../node_modules/react-native-reanimated`) |
| 366 | - RNScreens (from `../node_modules/react-native-screens`) | 387 | - RNScreens (from `../node_modules/react-native-screens`) |
| 367 | - RNVectorIcons (from `../node_modules/react-native-vector-icons`) | 388 | - RNVectorIcons (from `../node_modules/react-native-vector-icons`) |
| @@ -393,6 +414,12 @@ EXTERNAL SOURCES: | @@ -393,6 +414,12 @@ EXTERNAL SOURCES: | ||
| 393 | :podspec: "../node_modules/react-native/third-party-podspecs/Folly.podspec" | 414 | :podspec: "../node_modules/react-native/third-party-podspecs/Folly.podspec" |
| 394 | glog: | 415 | glog: |
| 395 | :podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec" | 416 | :podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec" |
| 417 | + Permission-Camera: | ||
| 418 | + :path: "../node_modules/react-native-permissions/ios/Camera.podspec" | ||
| 419 | + Permission-LocationWhenInUse: | ||
| 420 | + :path: "../node_modules/react-native-permissions/ios/LocationWhenInUse.podspec" | ||
| 421 | + Permission-PhotoLibrary: | ||
| 422 | + :path: "../node_modules/react-native-permissions/ios/PhotoLibrary.podspec" | ||
| 396 | RCTRequired: | 423 | RCTRequired: |
| 397 | :path: "../node_modules/react-native/Libraries/RCTRequired" | 424 | :path: "../node_modules/react-native/Libraries/RCTRequired" |
| 398 | RCTTypeSafety: | 425 | RCTTypeSafety: |
| @@ -411,6 +438,8 @@ EXTERNAL SOURCES: | @@ -411,6 +438,8 @@ EXTERNAL SOURCES: | ||
| 411 | :path: "../node_modules/react-native/ReactCommon/jsiexecutor" | 438 | :path: "../node_modules/react-native/ReactCommon/jsiexecutor" |
| 412 | React-jsinspector: | 439 | React-jsinspector: |
| 413 | :path: "../node_modules/react-native/ReactCommon/jsinspector" | 440 | :path: "../node_modules/react-native/ReactCommon/jsinspector" |
| 441 | + react-native-camera: | ||
| 442 | + :path: "../node_modules/react-native-camera" | ||
| 414 | react-native-netinfo: | 443 | react-native-netinfo: |
| 415 | :path: "../node_modules/@react-native-community/netinfo" | 444 | :path: "../node_modules/@react-native-community/netinfo" |
| 416 | react-native-safe-area-context: | 445 | react-native-safe-area-context: |
| @@ -449,6 +478,8 @@ EXTERNAL SOURCES: | @@ -449,6 +478,8 @@ EXTERNAL SOURCES: | ||
| 449 | :path: "../node_modules/react-native-gesture-handler" | 478 | :path: "../node_modules/react-native-gesture-handler" |
| 450 | RNLocalize: | 479 | RNLocalize: |
| 451 | :path: "../node_modules/react-native-localize" | 480 | :path: "../node_modules/react-native-localize" |
| 481 | + RNPermissions: | ||
| 482 | + :path: "../node_modules/react-native-permissions" | ||
| 452 | RNReanimated: | 483 | RNReanimated: |
| 453 | :path: "../node_modules/react-native-reanimated" | 484 | :path: "../node_modules/react-native-reanimated" |
| 454 | RNScreens: | 485 | RNScreens: |
| @@ -465,16 +496,19 @@ SPEC CHECKSUMS: | @@ -465,16 +496,19 @@ SPEC CHECKSUMS: | ||
| 465 | DoubleConversion: 5805e889d232975c086db112ece9ed034df7a0b2 | 496 | DoubleConversion: 5805e889d232975c086db112ece9ed034df7a0b2 |
| 466 | FBLazyVector: 95ee3e58937a6052f86b0e32f142388c22fa22c5 | 497 | FBLazyVector: 95ee3e58937a6052f86b0e32f142388c22fa22c5 |
| 467 | FBReactNativeSpec: 26dd6459299e48cd64eb397c45635e466dba9f45 | 498 | FBReactNativeSpec: 26dd6459299e48cd64eb397c45635e466dba9f45 |
| 468 | - Flipper: 6c1f484f9a88d30ab3e272800d53688439e50f69 | 499 | + Flipper: 1670db365568191bd123a0c905b834e77ba9e3d3 |
| 469 | Flipper-DoubleConversion: 38631e41ef4f9b12861c67d17cb5518d06badc41 | 500 | Flipper-DoubleConversion: 38631e41ef4f9b12861c67d17cb5518d06badc41 |
| 470 | - Flipper-Folly: 2de3d03e0acc7064d5e4ed9f730e2f217486f162 | 501 | + Flipper-Folly: c12092ea368353b58e992843a990a3225d4533c3 |
| 471 | Flipper-Glog: 1dfd6abf1e922806c52ceb8701a3599a79a200a6 | 502 | Flipper-Glog: 1dfd6abf1e922806c52ceb8701a3599a79a200a6 |
| 472 | Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 | 503 | Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 |
| 473 | - Flipper-RSocket: 1260a31c05c238eabfa9bb8a64e3983049048371 | 504 | + Flipper-RSocket: 64e7431a55835eb953b0bf984ef3b90ae9fdddd7 |
| 474 | - FlipperKit: 6dc9b8f4ef60d9e5ded7f0264db299c91f18832e | 505 | + FlipperKit: afd4259ef9eadeeb2d30250b37d95cb3b6b97a69 |
| 475 | Folly: 30e7936e1c45c08d884aa59369ed951a8e68cf51 | 506 | Folly: 30e7936e1c45c08d884aa59369ed951a8e68cf51 |
| 476 | glog: 1f3da668190260b06b429bb211bfbee5cd790c28 | 507 | glog: 1f3da668190260b06b429bb211bfbee5cd790c28 |
| 477 | OpenSSL-Universal: 8b48cc0d10c1b2923617dfe5c178aa9ed2689355 | 508 | OpenSSL-Universal: 8b48cc0d10c1b2923617dfe5c178aa9ed2689355 |
| 509 | + Permission-Camera: ebdba00e6926aface672cc547b19fa317c3d956e | ||
| 510 | + Permission-LocationWhenInUse: cfd0d39a1c8ab2e9aeb0a1460800f85f74705404 | ||
| 511 | + Permission-PhotoLibrary: e29736d903e867d278747eb30951528303425f64 | ||
| 478 | RCTRequired: e291538a455f5ad1afc2139a4288990be0cadd46 | 512 | RCTRequired: e291538a455f5ad1afc2139a4288990be0cadd46 |
| 479 | RCTTypeSafety: 8b6237185765dd9a03a3647807e08864105b1f95 | 513 | RCTTypeSafety: 8b6237185765dd9a03a3647807e08864105b1f95 |
| 480 | React: 7b33e15fab929c47ac9c3c94c409258b13cfe452 | 514 | React: 7b33e15fab929c47ac9c3c94c409258b13cfe452 |
| @@ -484,6 +518,7 @@ SPEC CHECKSUMS: | @@ -484,6 +518,7 @@ SPEC CHECKSUMS: | ||
| 484 | React-jsi: 600d8e42510c3254fd2abd702f4b9d3f598d8f52 | 518 | React-jsi: 600d8e42510c3254fd2abd702f4b9d3f598d8f52 |
| 485 | React-jsiexecutor: e9698dee4fd43ceb44832baf15d5745f455b0157 | 519 | React-jsiexecutor: e9698dee4fd43ceb44832baf15d5745f455b0157 |
| 486 | React-jsinspector: f74a62727e5604119abd4a1eda52c0a12144bcd5 | 520 | React-jsinspector: f74a62727e5604119abd4a1eda52c0a12144bcd5 |
| 521 | + react-native-camera: 1b52abea404d04e040edb3e74b7c5523c01a3089 | ||
| 487 | react-native-netinfo: 4fa023c153d582aeae8435df95c9a975c5986449 | 522 | react-native-netinfo: 4fa023c153d582aeae8435df95c9a975c5986449 |
| 488 | react-native-safe-area-context: e200d4433aba6b7e60b52da5f37af11f7a0b0392 | 523 | react-native-safe-area-context: e200d4433aba6b7e60b52da5f37af11f7a0b0392 |
| 489 | react-native-webview: 0633fd7861a9bd7a80bacaee7da763c3afc248fa | 524 | react-native-webview: 0633fd7861a9bd7a80bacaee7da763c3afc248fa |
| @@ -503,12 +538,13 @@ SPEC CHECKSUMS: | @@ -503,12 +538,13 @@ SPEC CHECKSUMS: | ||
| 503 | RNDeviceInfo: 6a3d16fce033f6979c4a6a41e62244d183e8c765 | 538 | RNDeviceInfo: 6a3d16fce033f6979c4a6a41e62244d183e8c765 |
| 504 | RNGestureHandler: 8f09cd560f8d533eb36da5a6c5a843af9f056b38 | 539 | RNGestureHandler: 8f09cd560f8d533eb36da5a6c5a843af9f056b38 |
| 505 | RNLocalize: b6df30cc25ae736d37874f9bce13351db2f56796 | 540 | RNLocalize: b6df30cc25ae736d37874f9bce13351db2f56796 |
| 541 | + RNPermissions: a96580116f7894146552e92b000ac30bf1661947 | ||
| 506 | RNReanimated: 4e102df74a9674fa943e05f97f3362b6e44d0b48 | 542 | RNReanimated: 4e102df74a9674fa943e05f97f3362b6e44d0b48 |
| 507 | RNScreens: b5c0e1b2b04512919e78bd3898e144a157ce2363 | 543 | RNScreens: b5c0e1b2b04512919e78bd3898e144a157ce2363 |
| 508 | RNVectorIcons: 0bb4def82230be1333ddaeee9fcba45f0b288ed4 | 544 | RNVectorIcons: 0bb4def82230be1333ddaeee9fcba45f0b288ed4 |
| 509 | Yoga: 50fb6eb13d2152e7363293ff603385db380815b1 | 545 | Yoga: 50fb6eb13d2152e7363293ff603385db380815b1 |
| 510 | YogaKit: f782866e155069a2cca2517aafea43200b01fd5a | 546 | YogaKit: f782866e155069a2cca2517aafea43200b01fd5a |
| 511 | 547 | ||
| 512 | -PODFILE CHECKSUM: be6f1c915e19e27904229555c28ac7d81a2caf5a | 548 | +PODFILE CHECKSUM: e597d8e8194d3baf3ffcf09c60685a36eaabf88f |
| 513 | 549 | ||
| 514 | COCOAPODS: 1.9.1 | 550 | COCOAPODS: 1.9.1 |
ios/en.lproj/InfoPlist.strings
0 → 100644
| 1 | +/* | ||
| 2 | + InfoPlist.strings | ||
| 3 | + NGPlay | ||
| 4 | + | ||
| 5 | + Created by Phecda on 2020/4/16. | ||
| 6 | + | ||
| 7 | +*/ | ||
| 8 | +"NSCameraUsageDescription" = "Use your camera to take a photo or scan codes"; | ||
| 9 | +"NSLocationWhenInUseUsageDescription" = "Use your location to check security"; | ||
| 10 | +"NSPhotoLibraryAddUsageDescription" = "Add photos to your photo library"; | ||
| 11 | +"NSPhotoLibraryUsageDescription" = "Read images from your photo library to set a avatar or scan codes"; |
ios/zh-Hans.lproj/InfoPlist.strings
0 → 100644
| 1 | +/* | ||
| 2 | + InfoPlist.strings | ||
| 3 | + NGPlay | ||
| 4 | + | ||
| 5 | + Created by Phecda on 2020/4/16. | ||
| 6 | + | ||
| 7 | +*/ | ||
| 8 | +"NSCameraUsageDescription" = "拍照或扫码功能需要使用相机"; | ||
| 9 | +"NSLocationWhenInUseUsageDescription" = "为保证安全,需要定位"; | ||
| 10 | +"NSPhotoLibraryAddUsageDescription" = "向照片图库中添加照片"; | ||
| 11 | +"NSPhotoLibraryUsageDescription" = "诸如扫码、设置头像等功能需要从照片图库中读取图片"; |
| @@ -25,11 +25,13 @@ | @@ -25,11 +25,13 @@ | ||
| 25 | "immer": "^6.0.3", | 25 | "immer": "^6.0.3", |
| 26 | "react": "16.11.0", | 26 | "react": "16.11.0", |
| 27 | "react-native": "0.62.1", | 27 | "react-native": "0.62.1", |
| 28 | + "react-native-camera": "^3.23.1", | ||
| 28 | "react-native-dark-mode": "^0.2.2", | 29 | "react-native-dark-mode": "^0.2.2", |
| 29 | "react-native-device-info": "^5.5.4", | 30 | "react-native-device-info": "^5.5.4", |
| 30 | "react-native-elements": "^1.2.7", | 31 | "react-native-elements": "^1.2.7", |
| 31 | "react-native-gesture-handler": "^1.6.1", | 32 | "react-native-gesture-handler": "^1.6.1", |
| 32 | "react-native-localize": "^1.4.0", | 33 | "react-native-localize": "^1.4.0", |
| 34 | + "react-native-permissions": "^2.1.2", | ||
| 33 | "react-native-progress": "^4.1.2", | 35 | "react-native-progress": "^4.1.2", |
| 34 | "react-native-reanimated": "^1.7.1", | 36 | "react-native-reanimated": "^1.7.1", |
| 35 | "react-native-safe-area-context": "^0.7.3", | 37 | "react-native-safe-area-context": "^0.7.3", |
| @@ -41,6 +41,7 @@ export const ListItem = ({ | @@ -41,6 +41,7 @@ export const ListItem = ({ | ||
| 41 | subtitleStyle, | 41 | subtitleStyle, |
| 42 | rightTitleStyle, | 42 | rightTitleStyle, |
| 43 | rightSubtitleStyle, | 43 | rightSubtitleStyle, |
| 44 | + chevron, | ||
| 44 | ...props | 45 | ...props |
| 45 | }: ListItemProps) => { | 46 | }: ListItemProps) => { |
| 46 | const styles = useDynamicStyleSheet(dynamicStyles); | 47 | const styles = useDynamicStyleSheet(dynamicStyles); |
| @@ -51,6 +52,7 @@ export const ListItem = ({ | @@ -51,6 +52,7 @@ export const ListItem = ({ | ||
| 51 | subtitleStyle={[styles.subtitleStyle, subtitleStyle]} | 52 | subtitleStyle={[styles.subtitleStyle, subtitleStyle]} |
| 52 | rightTitleStyle={[styles.rightTitleStyle, rightTitleStyle]} | 53 | rightTitleStyle={[styles.rightTitleStyle, rightTitleStyle]} |
| 53 | rightSubtitleStyle={[styles.rightSubtitleStyle, rightSubtitleStyle]} | 54 | rightSubtitleStyle={[styles.rightSubtitleStyle, rightSubtitleStyle]} |
| 55 | + chevron={chevron ?? !!props.onPress} | ||
| 54 | {...props} | 56 | {...props} |
| 55 | /> | 57 | /> |
| 56 | ); | 58 | ); |
| @@ -20,6 +20,7 @@ import WebviewScreen from './WebviewScreen'; | @@ -20,6 +20,7 @@ import WebviewScreen from './WebviewScreen'; | ||
| 20 | import { Platform } from 'react-native'; | 20 | import { Platform } from 'react-native'; |
| 21 | import RNLocalize from './RNLocalize'; | 21 | import RNLocalize from './RNLocalize'; |
| 22 | import { useI18nStrings } from '../i18n'; | 22 | import { useI18nStrings } from '../i18n'; |
| 23 | +import CameraScreen from './CameraScreen'; | ||
| 23 | 24 | ||
| 24 | const MainTab = createBottomTabNavigator<MainTabParamList>(); | 25 | const MainTab = createBottomTabNavigator<MainTabParamList>(); |
| 25 | 26 | ||
| @@ -111,6 +112,7 @@ const Container = () => { | @@ -111,6 +112,7 @@ const Container = () => { | ||
| 111 | })} | 112 | })} |
| 112 | /> | 113 | /> |
| 113 | <MainStack.Screen name="RNLocalize" component={RNLocalize} /> | 114 | <MainStack.Screen name="RNLocalize" component={RNLocalize} /> |
| 115 | + <MainStack.Screen name="RNCamera" component={CameraScreen} /> | ||
| 114 | </MainStack.Navigator> | 116 | </MainStack.Navigator> |
| 115 | </NavigationContainer> | 117 | </NavigationContainer> |
| 116 | ); | 118 | ); |
src/screen/CameraScreen.tsx
0 → 100644
| 1 | +import React, { useRef, useCallback, useState } from 'react'; | ||
| 2 | +import { | ||
| 3 | + RNCamera, | ||
| 4 | + TakePictureResponse, | ||
| 5 | + RNCameraProps, | ||
| 6 | +} from 'react-native-camera'; | ||
| 7 | +import { BGScroll, ListItem, Card, Divider } from '../component/View'; | ||
| 8 | +import { useSwitch, useToggle } from '@huse/boolean'; | ||
| 9 | +import { | ||
| 10 | + Image, | ||
| 11 | + useWindowDimensions, | ||
| 12 | + View, | ||
| 13 | + SafeAreaView, | ||
| 14 | + ActivityIndicator, | ||
| 15 | + Modal, | ||
| 16 | +} from 'react-native'; | ||
| 17 | +import { Icon } from 'react-native-elements'; | ||
| 18 | +import { | ||
| 19 | + DynamicStyleSheet, | ||
| 20 | + useDynamicStyleSheet, | ||
| 21 | +} from 'react-native-dark-mode'; | ||
| 22 | +import { colorPreset } from '../design'; | ||
| 23 | + | ||
| 24 | +const dynamicStyles = new DynamicStyleSheet({ | ||
| 25 | + cameraContainerPortrait: { | ||
| 26 | + flex: 1, | ||
| 27 | + backgroundColor: colorPreset.backgroundColor.primary, | ||
| 28 | + }, | ||
| 29 | + topBar: { flex: 0.5 }, | ||
| 30 | + bottomBar: { | ||
| 31 | + justifyContent: 'space-evenly', | ||
| 32 | + alignItems: 'center', | ||
| 33 | + flex: 1, | ||
| 34 | + }, | ||
| 35 | + loadingButton: { | ||
| 36 | + width: 52, | ||
| 37 | + height: 52, | ||
| 38 | + borderRadius: 28, | ||
| 39 | + backgroundColor: 'white', | ||
| 40 | + margin: 7, | ||
| 41 | + justifyContent: 'center', | ||
| 42 | + alignItems: 'center', | ||
| 43 | + }, | ||
| 44 | + photoResult: { | ||
| 45 | + flex: 1, | ||
| 46 | + height: 240, | ||
| 47 | + resizeMode: 'contain', | ||
| 48 | + margin: 16, | ||
| 49 | + }, | ||
| 50 | +}); | ||
| 51 | + | ||
| 52 | +const CameraModal = ({ | ||
| 53 | + visible, | ||
| 54 | + onCancel, | ||
| 55 | + onTakenPicture, | ||
| 56 | +}: { | ||
| 57 | + onCancel: () => void; | ||
| 58 | + visible: boolean; | ||
| 59 | + onTakenPicture: (picture: TakePictureResponse) => void; | ||
| 60 | +}) => { | ||
| 61 | + const styles = useDynamicStyleSheet(dynamicStyles); | ||
| 62 | + | ||
| 63 | + const camera = useRef<RNCamera>(null); | ||
| 64 | + const [loading, toggleLoading] = useToggle(false); | ||
| 65 | + const [isBackCamera, toggleCameraType] = useToggle(true); | ||
| 66 | + const { width, height } = useWindowDimensions(); | ||
| 67 | + const inPortrait = width <= height; | ||
| 68 | + const previewDimension = inPortrait | ||
| 69 | + ? { width, height: (width * 4) / 3 } | ||
| 70 | + : { height, width: (height * 4) / 3 }; | ||
| 71 | + | ||
| 72 | + const bottomDirection = inPortrait ? 'row' : 'column'; | ||
| 73 | + const containerDirection = inPortrait ? 'column' : 'row'; | ||
| 74 | + | ||
| 75 | + const onShot = useCallback(async () => { | ||
| 76 | + if (camera.current) { | ||
| 77 | + toggleLoading(); | ||
| 78 | + const result = await camera.current.takePictureAsync({ | ||
| 79 | + base64: true, | ||
| 80 | + quality: 0.8, | ||
| 81 | + pauseAfterCapture: true, | ||
| 82 | + doNotSave: true, | ||
| 83 | + }); | ||
| 84 | + toggleLoading(); | ||
| 85 | + onTakenPicture(result); | ||
| 86 | + } | ||
| 87 | + }, [onTakenPicture, toggleLoading]); | ||
| 88 | + | ||
| 89 | + return ( | ||
| 90 | + <Modal visible={visible} onRequestClose={onCancel} animationType="slide"> | ||
| 91 | + <View | ||
| 92 | + style={[ | ||
| 93 | + styles.cameraContainerPortrait, | ||
| 94 | + { flexDirection: containerDirection }, | ||
| 95 | + ]} | ||
| 96 | + > | ||
| 97 | + <SafeAreaView style={styles.topBar} /> | ||
| 98 | + <RNCamera | ||
| 99 | + ref={camera} | ||
| 100 | + type={isBackCamera ? 'back' : 'front'} | ||
| 101 | + style={previewDimension} | ||
| 102 | + captureAudio={false} | ||
| 103 | + /> | ||
| 104 | + <SafeAreaView | ||
| 105 | + style={[ | ||
| 106 | + styles.bottomBar, | ||
| 107 | + { | ||
| 108 | + flexDirection: bottomDirection, | ||
| 109 | + }, | ||
| 110 | + ]} | ||
| 111 | + > | ||
| 112 | + <Icon name="close" raised onPress={onCancel} /> | ||
| 113 | + {loading ? ( | ||
| 114 | + <View style={styles.loadingButton}> | ||
| 115 | + <ActivityIndicator /> | ||
| 116 | + </View> | ||
| 117 | + ) : ( | ||
| 118 | + <Icon name="camera" raised onPress={onShot} /> | ||
| 119 | + )} | ||
| 120 | + <Icon | ||
| 121 | + type="ionicon" | ||
| 122 | + name="ios-reverse-camera" | ||
| 123 | + raised | ||
| 124 | + onPress={toggleCameraType} | ||
| 125 | + /> | ||
| 126 | + </SafeAreaView> | ||
| 127 | + </View> | ||
| 128 | + </Modal> | ||
| 129 | + ); | ||
| 130 | +}; | ||
| 131 | + | ||
| 132 | +type ParamsOf<T extends (...args: any[]) => any> = T extends ( | ||
| 133 | + ...args: infer U | ||
| 134 | +) => any | ||
| 135 | + ? U | ||
| 136 | + : never; | ||
| 137 | + | ||
| 138 | +const Scanner = ({ | ||
| 139 | + visible, | ||
| 140 | + onCancel, | ||
| 141 | + onScanCode, | ||
| 142 | +}: { | ||
| 143 | + visible: boolean; | ||
| 144 | + onCancel: () => void; | ||
| 145 | + onScanCode: ( | ||
| 146 | + ...args: ParamsOf<Required<RNCameraProps>['onBarCodeRead']> | ||
| 147 | + ) => void; | ||
| 148 | +}) => { | ||
| 149 | + const styles = useDynamicStyleSheet(dynamicStyles); | ||
| 150 | + | ||
| 151 | + const camera = useRef<RNCamera>(null); | ||
| 152 | + const { width, height } = useWindowDimensions(); | ||
| 153 | + const inPortrait = width <= height; | ||
| 154 | + const previewDimension = inPortrait | ||
| 155 | + ? { width, height: (width * 4) / 3 } | ||
| 156 | + : { height, width: (height * 4) / 3 }; | ||
| 157 | + | ||
| 158 | + const bottomDirection = inPortrait ? 'row' : 'column'; | ||
| 159 | + const containerDirection = inPortrait ? 'column' : 'row'; | ||
| 160 | + return ( | ||
| 161 | + <Modal visible={visible} onRequestClose={onCancel} animationType="slide"> | ||
| 162 | + <View | ||
| 163 | + style={[ | ||
| 164 | + styles.cameraContainerPortrait, | ||
| 165 | + { flexDirection: containerDirection }, | ||
| 166 | + ]} | ||
| 167 | + > | ||
| 168 | + <SafeAreaView style={styles.topBar} /> | ||
| 169 | + <RNCamera | ||
| 170 | + ref={camera} | ||
| 171 | + style={previewDimension} | ||
| 172 | + captureAudio={false} | ||
| 173 | + onBarCodeRead={onScanCode} | ||
| 174 | + /> | ||
| 175 | + <SafeAreaView | ||
| 176 | + style={[ | ||
| 177 | + styles.bottomBar, | ||
| 178 | + { | ||
| 179 | + flexDirection: bottomDirection, | ||
| 180 | + }, | ||
| 181 | + ]} | ||
| 182 | + > | ||
| 183 | + <Icon name="close" raised onPress={onCancel} /> | ||
| 184 | + </SafeAreaView> | ||
| 185 | + </View> | ||
| 186 | + </Modal> | ||
| 187 | + ); | ||
| 188 | +}; | ||
| 189 | + | ||
| 190 | +const CameraScreen = () => { | ||
| 191 | + const styles = useDynamicStyleSheet(dynamicStyles); | ||
| 192 | + const [cameraVisible, openCamera, closeCamera] = useSwitch(false); | ||
| 193 | + const [scannerVisible, openScanner, closeScanner] = useSwitch(false); | ||
| 194 | + const [tempPicture, setTempPicture] = useState<TakePictureResponse>(); | ||
| 195 | + const [codeData, setCodeData] = useState<string>(); | ||
| 196 | + const [codeType, setCodeType] = useState<string>(); | ||
| 197 | + return ( | ||
| 198 | + <> | ||
| 199 | + <BGScroll> | ||
| 200 | + <Card round> | ||
| 201 | + <ListItem title="Camera Modal" onPress={openCamera} /> | ||
| 202 | + {tempPicture && <Divider />} | ||
| 203 | + {tempPicture && ( | ||
| 204 | + <Image | ||
| 205 | + style={styles.photoResult} | ||
| 206 | + source={{ | ||
| 207 | + uri: `data:image/jpeg;base64,${tempPicture.base64}`, | ||
| 208 | + }} | ||
| 209 | + /> | ||
| 210 | + )} | ||
| 211 | + </Card> | ||
| 212 | + <Card round> | ||
| 213 | + <ListItem title="Scanner Modal" onPress={openScanner} /> | ||
| 214 | + <Divider /> | ||
| 215 | + <ListItem title="data" rightTitle={codeData} /> | ||
| 216 | + <Divider /> | ||
| 217 | + <ListItem title="type" rightTitle={codeType} /> | ||
| 218 | + </Card> | ||
| 219 | + </BGScroll> | ||
| 220 | + <CameraModal | ||
| 221 | + visible={cameraVisible} | ||
| 222 | + onTakenPicture={(picture) => { | ||
| 223 | + setTempPicture(picture); | ||
| 224 | + closeCamera(); | ||
| 225 | + }} | ||
| 226 | + onCancel={closeCamera} | ||
| 227 | + /> | ||
| 228 | + <Scanner | ||
| 229 | + visible={scannerVisible} | ||
| 230 | + onCancel={closeScanner} | ||
| 231 | + onScanCode={(e) => { | ||
| 232 | + setCodeData(e.data); | ||
| 233 | + setCodeType(e.type); | ||
| 234 | + closeScanner(); | ||
| 235 | + }} | ||
| 236 | + /> | ||
| 237 | + </> | ||
| 238 | + ); | ||
| 239 | +}; | ||
| 240 | + | ||
| 241 | +export default CameraScreen; |
| @@ -84,6 +84,12 @@ const SystemInfo = ({ | @@ -84,6 +84,12 @@ const SystemInfo = ({ | ||
| 84 | rightTitle={strings.name} | 84 | rightTitle={strings.name} |
| 85 | chevron | 85 | chevron |
| 86 | /> | 86 | /> |
| 87 | + <Divider /> | ||
| 88 | + <ListItem | ||
| 89 | + title={'Camera'} | ||
| 90 | + onPress={() => navigation.navigate('RNCamera')} | ||
| 91 | + chevron | ||
| 92 | + /> | ||
| 87 | </Card> | 93 | </Card> |
| 88 | </BGScroll> | 94 | </BGScroll> |
| 89 | ); | 95 | ); |
| @@ -12,6 +12,7 @@ export type MainStackParamList = { | @@ -12,6 +12,7 @@ export type MainStackParamList = { | ||
| 12 | RNDeviceInfoList: undefined; | 12 | RNDeviceInfoList: undefined; |
| 13 | WebviewScreen: { uri: string } | undefined; | 13 | WebviewScreen: { uri: string } | undefined; |
| 14 | RNLocalize: undefined; | 14 | RNLocalize: undefined; |
| 15 | + RNCamera: undefined; | ||
| 15 | }; | 16 | }; |
| 16 | 17 | ||
| 17 | export type MainTabScreenProps<RouteName extends keyof MainTabParamList> = { | 18 | export type MainTabScreenProps<RouteName extends keyof MainTabParamList> = { |
| @@ -6880,6 +6880,13 @@ react-is@^16.12.0, react-is@^16.13.0, react-is@^16.7.0, react-is@^16.8.1, react- | @@ -6880,6 +6880,13 @@ react-is@^16.12.0, react-is@^16.13.0, react-is@^16.7.0, react-is@^16.8.1, react- | ||
| 6880 | resolved "https://registry.npm.taobao.org/react-is/download/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" | 6880 | resolved "https://registry.npm.taobao.org/react-is/download/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" |
| 6881 | integrity sha1-eJcppNw23imZ3BVt1sHZwYzqVqQ= | 6881 | integrity sha1-eJcppNw23imZ3BVt1sHZwYzqVqQ= |
| 6882 | 6882 | ||
| 6883 | +react-native-camera@^3.23.1: | ||
| 6884 | + version "3.23.1" | ||
| 6885 | + resolved "https://registry.npm.taobao.org/react-native-camera/download/react-native-camera-3.23.1.tgz#fb6fe52f8a357852de6dcd81d0d187cd632dc7dd" | ||
| 6886 | + integrity sha1-+2/lL4o1eFLebc2B0NGHzWMtx90= | ||
| 6887 | + dependencies: | ||
| 6888 | + prop-types "^15.6.2" | ||
| 6889 | + | ||
| 6883 | react-native-dark-mode@^0.2.2: | 6890 | react-native-dark-mode@^0.2.2: |
| 6884 | version "0.2.2" | 6891 | version "0.2.2" |
| 6885 | resolved "https://registry.npm.taobao.org/react-native-dark-mode/download/react-native-dark-mode-0.2.2.tgz#4faa335e36330bfca832ba8b3d2bd84c7b880381" | 6892 | resolved "https://registry.npm.taobao.org/react-native-dark-mode/download/react-native-dark-mode-0.2.2.tgz#4faa335e36330bfca832ba8b3d2bd84c7b880381" |
| @@ -6930,6 +6937,11 @@ react-native-localize@^1.4.0: | @@ -6930,6 +6937,11 @@ react-native-localize@^1.4.0: | ||
| 6930 | resolved "https://registry.npm.taobao.org/react-native-localize/download/react-native-localize-1.4.0.tgz#4653596d066d0941c48f5404dc1c0d08b6950443" | 6937 | resolved "https://registry.npm.taobao.org/react-native-localize/download/react-native-localize-1.4.0.tgz#4653596d066d0941c48f5404dc1c0d08b6950443" |
| 6931 | integrity sha1-RlNZbQZtCUHEj1QE3BwNCLaVBEM= | 6938 | integrity sha1-RlNZbQZtCUHEj1QE3BwNCLaVBEM= |
| 6932 | 6939 | ||
| 6940 | +react-native-permissions@^2.1.2: | ||
| 6941 | + version "2.1.2" | ||
| 6942 | + resolved "https://registry.npm.taobao.org/react-native-permissions/download/react-native-permissions-2.1.2.tgz#14f30a6cfa0851ecb210d7eadcc590f8823c8585" | ||
| 6943 | + integrity sha1-FPMKbPoIUeyyENfq3MWQ+II8hYU= | ||
| 6944 | + | ||
| 6933 | react-native-progress@^4.1.2: | 6945 | react-native-progress@^4.1.2: |
| 6934 | version "4.1.2" | 6946 | version "4.1.2" |
| 6935 | resolved "https://registry.npm.taobao.org/react-native-progress/download/react-native-progress-4.1.2.tgz#ffb2264ddfeba409c730e36a9791bb7bbe07a00d" | 6947 | resolved "https://registry.npm.taobao.org/react-native-progress/download/react-native-progress-4.1.2.tgz#ffb2264ddfeba409c730e36a9791bb7bbe07a00d" |
-
Please register or login to post a comment