omnipay-reactnative-sdk 1.2.2-beta.0 → 1.2.2-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -136
- package/android/build.gradle +13 -0
- package/android/src/main/AndroidManifest.xml +5 -0
- package/android/src/main/java/com/omniretail/omnipay/LivenessCameraViewManager.java +116 -0
- package/android/src/main/java/com/omniretail/omnipay/LivenessDetectionModule.java +588 -0
- package/android/src/main/java/com/omniretail/omnipay/OmnipayActivityPackage.java +4 -1
- package/ios/LivenessCameraView.h +22 -0
- package/ios/LivenessCameraView.m +135 -0
- package/ios/LivenessCameraViewManager.h +12 -0
- package/ios/LivenessCameraViewManager.m +24 -0
- package/ios/LivenessDetectionModule.h +46 -0
- package/ios/LivenessDetectionModule.m +603 -0
- package/lib/commonjs/components/OmnipayProvider.js +48 -104
- package/lib/commonjs/components/OmnipayProvider.js.map +1 -1
- package/lib/commonjs/components/OmnipayView.js +11 -14
- package/lib/commonjs/components/OmnipayView.js.map +1 -1
- package/lib/commonjs/components/biometrics/FaceVerification.js +435 -0
- package/lib/commonjs/components/biometrics/FaceVerification.js.map +1 -0
- package/lib/commonjs/components/biometrics/LivenessCameraView.js +45 -0
- package/lib/commonjs/components/biometrics/LivenessCameraView.js.map +1 -0
- package/lib/commonjs/components/biometrics/LivenessDetection.js +251 -0
- package/lib/commonjs/components/biometrics/LivenessDetection.js.map +1 -0
- package/lib/commonjs/components/views/BvnVerification.js +10 -12
- package/lib/commonjs/components/views/BvnVerification.js.map +1 -1
- package/lib/commonjs/components/views/PaylaterAgreement.js +14 -16
- package/lib/commonjs/components/views/PaylaterAgreement.js.map +1 -1
- package/lib/commonjs/components/views/Registration.js +13 -11
- package/lib/commonjs/components/views/Registration.js.map +1 -1
- package/lib/commonjs/functions.js.map +1 -1
- package/lib/commonjs/hooks/useOmnipay.js.map +1 -1
- package/lib/commonjs/index.js +30 -3
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/lib/colors.js +1 -2
- package/lib/commonjs/lib/colors.js.map +1 -1
- package/lib/commonjs/lib/config.js +2 -4
- package/lib/commonjs/lib/config.js.map +1 -1
- package/lib/module/components/OmnipayProvider.js +45 -99
- package/lib/module/components/OmnipayProvider.js.map +1 -1
- package/lib/module/components/OmnipayView.js +9 -10
- package/lib/module/components/OmnipayView.js.map +1 -1
- package/lib/module/components/biometrics/FaceVerification.js +427 -0
- package/lib/module/components/biometrics/FaceVerification.js.map +1 -0
- package/lib/module/components/biometrics/LivenessCameraView.js +39 -0
- package/lib/module/components/biometrics/LivenessCameraView.js.map +1 -0
- package/lib/module/components/biometrics/LivenessDetection.js +245 -0
- package/lib/module/components/biometrics/LivenessDetection.js.map +1 -0
- package/lib/module/components/views/BvnVerification.js +9 -10
- package/lib/module/components/views/BvnVerification.js.map +1 -1
- package/lib/module/components/views/PaylaterAgreement.js +13 -14
- package/lib/module/components/views/PaylaterAgreement.js.map +1 -1
- package/lib/module/components/views/Registration.js +13 -9
- package/lib/module/components/views/Registration.js.map +1 -1
- package/lib/module/functions.js.map +1 -1
- package/lib/module/hooks/useOmnipay.js.map +1 -1
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/lib/colors.js.map +1 -1
- package/lib/module/lib/config.js.map +1 -1
- package/lib/typescript/demo/src/App.d.ts +3 -0
- package/lib/typescript/demo/src/App.d.ts.map +1 -0
- package/lib/typescript/demo/src/Body.d.ts +3 -0
- package/lib/typescript/demo/src/Body.d.ts.map +1 -0
- package/lib/typescript/demo/src/NotificationsExample.d.ts +4 -0
- package/lib/typescript/demo/src/NotificationsExample.d.ts.map +1 -0
- package/lib/typescript/{components → src/components}/OmnipayProvider.d.ts +5 -5
- package/lib/typescript/src/components/OmnipayProvider.d.ts.map +1 -0
- package/lib/typescript/{components → src/components}/OmnipayView.d.ts +1 -3
- package/lib/typescript/src/components/OmnipayView.d.ts.map +1 -0
- package/lib/typescript/src/components/biometrics/FaceVerification.d.ts +12 -0
- package/lib/typescript/src/components/biometrics/FaceVerification.d.ts.map +1 -0
- package/lib/typescript/src/components/biometrics/LivenessCameraView.d.ts +22 -0
- package/lib/typescript/src/components/biometrics/LivenessCameraView.d.ts.map +1 -0
- package/lib/typescript/src/components/biometrics/LivenessDetection.d.ts +73 -0
- package/lib/typescript/src/components/biometrics/LivenessDetection.d.ts.map +1 -0
- package/lib/typescript/{components → src/components}/views/BvnVerification.d.ts +1 -3
- package/lib/typescript/src/components/views/BvnVerification.d.ts.map +1 -0
- package/lib/typescript/{components → src/components}/views/PaylaterAgreement.d.ts +2 -4
- package/lib/typescript/src/components/views/PaylaterAgreement.d.ts.map +1 -0
- package/lib/typescript/{components → src/components}/views/Registration.d.ts +2 -4
- package/lib/typescript/src/components/views/Registration.d.ts.map +1 -0
- package/lib/typescript/src/functions.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useOmnipay.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +8 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/lib/colors.d.ts.map +1 -0
- package/lib/typescript/src/lib/config.d.ts.map +1 -0
- package/omnipay-reactnative-sdk.podspec +47 -0
- package/package.json +6 -11
- package/src/components/OmnipayProvider.tsx +9 -66
- package/src/components/biometrics/FaceVerification.tsx +484 -0
- package/src/components/biometrics/LivenessCameraView.tsx +61 -0
- package/src/components/biometrics/LivenessDetection.ts +305 -0
- package/src/index.tsx +18 -0
- package/lib/commonjs/components/FaceVerification.js +0 -755
- package/lib/commonjs/components/FaceVerification.js.map +0 -1
- package/lib/commonjs/types/faceVerification.js +0 -2
- package/lib/commonjs/types/faceVerification.js.map +0 -1
- package/lib/commonjs/types/index.js +0 -17
- package/lib/commonjs/types/index.js.map +0 -1
- package/lib/module/components/FaceVerification.js +0 -746
- package/lib/module/components/FaceVerification.js.map +0 -1
- package/lib/module/types/faceVerification.js +0 -2
- package/lib/module/types/faceVerification.js.map +0 -1
- package/lib/module/types/index.js +0 -2
- package/lib/module/types/index.js.map +0 -1
- package/lib/typescript/components/FaceVerification.d.ts +0 -10
- package/lib/typescript/components/FaceVerification.d.ts.map +0 -1
- package/lib/typescript/components/OmnipayProvider.d.ts.map +0 -1
- package/lib/typescript/components/OmnipayView.d.ts.map +0 -1
- package/lib/typescript/components/views/BvnVerification.d.ts.map +0 -1
- package/lib/typescript/components/views/PaylaterAgreement.d.ts.map +0 -1
- package/lib/typescript/components/views/Registration.d.ts.map +0 -1
- package/lib/typescript/functions.d.ts.map +0 -1
- package/lib/typescript/hooks/useOmnipay.d.ts.map +0 -1
- package/lib/typescript/index.d.ts +0 -5
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/lib/colors.d.ts.map +0 -1
- package/lib/typescript/lib/config.d.ts.map +0 -1
- package/lib/typescript/types/faceVerification.d.ts +0 -18
- package/lib/typescript/types/faceVerification.d.ts.map +0 -1
- package/lib/typescript/types/index.d.ts +0 -2
- package/lib/typescript/types/index.d.ts.map +0 -1
- package/src/components/FaceVerification.tsx +0 -884
- package/src/types/faceVerification.ts +0 -27
- package/src/types/index.ts +0 -1
- /package/lib/typescript/{functions.d.ts → src/functions.d.ts} +0 -0
- /package/lib/typescript/{hooks → src/hooks}/useOmnipay.d.ts +0 -0
- /package/lib/typescript/{lib → src/lib}/colors.d.ts +0 -0
- /package/lib/typescript/{lib → src/lib}/config.d.ts +0 -0
package/README.md
CHANGED
|
@@ -11,25 +11,14 @@ yarn add omnipay-reactnative-sdk
|
|
|
11
11
|
## Dependencies
|
|
12
12
|
|
|
13
13
|
```sh
|
|
14
|
-
yarn add react-native-select-contact react-native-webview react-native-share
|
|
14
|
+
yarn add react-native-select-contact react-native-webview react-native-share
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
Make sure your manifest files includes
|
|
17
|
+
Make sure your manifest files includes permission to read contacts
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
```xml
|
|
19
|
+
```sh
|
|
22
20
|
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
|
23
|
-
<uses-permission android:name="android.permission.CAMERA" />
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
**iOS (ios/YourApp/Info.plist):**
|
|
27
21
|
|
|
28
|
-
```xml
|
|
29
|
-
<key>NSContactsUsageDescription</key>
|
|
30
|
-
<string>This app needs access to contacts to help you select recipients.</string>
|
|
31
|
-
<key>NSCameraUsageDescription</key>
|
|
32
|
-
<string>This app needs camera access for face verification.</string>
|
|
33
22
|
```
|
|
34
23
|
|
|
35
24
|
Also add this for Android 11+ support below the application tag in your AndroidManifest.xml file
|
|
@@ -113,48 +102,45 @@ initiateWallet({
|
|
|
113
102
|
### Properties
|
|
114
103
|
|
|
115
104
|
#### OmnipayProvider Props
|
|
116
|
-
|
|
117
|
-
|
|
|
118
|
-
|
|
|
119
|
-
|
|
|
120
|
-
|
|
|
121
|
-
| publicKey | String | public key of the company on omnipay |
|
|
105
|
+
| Name | Type | Description |
|
|
106
|
+
| --------------- | -------- | -------------------------------------------------------- |
|
|
107
|
+
| color | String | color of primary buttons and links |
|
|
108
|
+
| env | String | dev or prod |
|
|
109
|
+
| publicKey | String | public key of the company on omnipay |
|
|
122
110
|
|
|
123
111
|
#### initiateBills Props
|
|
124
|
-
|
|
125
|
-
|
|
|
126
|
-
|
|
|
127
|
-
|
|
|
128
|
-
| onClose | Function | this is used to notify you when the sdk closes |
|
|
112
|
+
| Name | Type | Description |
|
|
113
|
+
| --------------- | -------- | -------------------------------------------------------- |
|
|
114
|
+
| phoneNumber | String | phone number of the customer |
|
|
115
|
+
| onClose | Function | this is used to notify you when the sdk closes |
|
|
129
116
|
|
|
130
117
|
#### initiateWallet Props
|
|
118
|
+
| Name | Type | Description |
|
|
119
|
+
| ----------------------- | -------- | ---------------------------------------------------------------- |
|
|
120
|
+
| phoneNumber | String | phone number of the customer |
|
|
121
|
+
| customerRef | String | unique reference for the customer |
|
|
122
|
+
| userRef | String | unique reference for the user |
|
|
123
|
+
| onClose | Function | this is used to notify you when the sdk closes |
|
|
124
|
+
| usesPaylater | Boolean | whether to show paylater tab in wallet view |
|
|
125
|
+
| usesPromo | Boolean | whether to show promo tab in wallet view |
|
|
126
|
+
| usesAirtimeData | Boolean | whether to show airtime and data shortcut in wallet view |
|
|
127
|
+
| usesTransfer | Boolean | whether to show transfer shortcut in wallet view |
|
|
128
|
+
| usesBills | Boolean | whether to show bills shortcut in wallet view |
|
|
129
|
+
| usesPos | Boolean | whether to show pos shortcut in wallet view |
|
|
130
|
+
| promoBalanceOffset | Number | offset for promo balance display |
|
|
131
|
+
| deviceId | String | unique identifier for the device |
|
|
132
|
+
| deviceName | String | name of the device |
|
|
133
|
+
| hideWalletTransfer | Boolean | whether to hide wallet transfer functionality |
|
|
134
|
+
| isBvnValidationRequired | Boolean | whether BVN validation is required |
|
|
135
|
+
| walletTab | String | initial wallet tab to display ('Paylater', 'Account', 'Omoni') |
|
|
136
|
+
| sessionId | String | unique session identifier |
|
|
137
|
+
| kycStatus | String | KYC status of the user ('verified', 'unverified') |
|
|
138
|
+
| launchPage | String | page to launch in the wallet |
|
|
131
139
|
|
|
132
|
-
| Name | Type | Description |
|
|
133
|
-
| ----------------------- | -------- | -------------------------------------------------------------- |
|
|
134
|
-
| phoneNumber | String | phone number of the customer |
|
|
135
|
-
| customerRef | String | unique reference for the customer |
|
|
136
|
-
| userRef | String | unique reference for the user |
|
|
137
|
-
| onClose | Function | this is used to notify you when the sdk closes |
|
|
138
|
-
| usesPaylater | Boolean | whether to show paylater tab in wallet view |
|
|
139
|
-
| usesPromo | Boolean | whether to show promo tab in wallet view |
|
|
140
|
-
| usesAirtimeData | Boolean | whether to show airtime and data shortcut in wallet view |
|
|
141
|
-
| usesTransfer | Boolean | whether to show transfer shortcut in wallet view |
|
|
142
|
-
| usesBills | Boolean | whether to show bills shortcut in wallet view |
|
|
143
|
-
| usesPos | Boolean | whether to show pos shortcut in wallet view |
|
|
144
|
-
| promoBalanceOffset | Number | offset for promo balance display |
|
|
145
|
-
| deviceId | String | unique identifier for the device |
|
|
146
|
-
| deviceName | String | name of the device |
|
|
147
|
-
| hideWalletTransfer | Boolean | whether to hide wallet transfer functionality |
|
|
148
|
-
| isBvnValidationRequired | Boolean | whether BVN validation is required |
|
|
149
|
-
| walletTab | String | initial wallet tab to display ('Paylater', 'Account', 'Omoni') |
|
|
150
|
-
| sessionId | String | unique session identifier |
|
|
151
|
-
| kycStatus | String | KYC status of the user ('verified', 'unverified') |
|
|
152
|
-
| launchPage | String | page to launch in the wallet |
|
|
153
140
|
|
|
154
141
|
## Registration Sdk
|
|
155
|
-
|
|
156
142
|
```js
|
|
157
|
-
import { Omnipay } from
|
|
143
|
+
import { Omnipay } from "omnipay-reactnative-sdk";
|
|
158
144
|
|
|
159
145
|
//render it anywhere on your page where you want to display the registration sdk
|
|
160
146
|
<Omnipay.Registration
|
|
@@ -164,9 +150,9 @@ import { Omnipay } from 'omnipay-reactnative-sdk';
|
|
|
164
150
|
phoneNumber="09031234571"
|
|
165
151
|
onRegistrationSuccessful={({ customerRef, walletId }) => {
|
|
166
152
|
/**
|
|
167
|
-
* the customer ref and walletid can be saved
|
|
153
|
+
* the customer ref and walletid can be saved
|
|
168
154
|
* to your database at this point
|
|
169
|
-
*
|
|
155
|
+
*
|
|
170
156
|
* we will also be sending a webhook notification
|
|
171
157
|
* so, you can either save at this point or via the webhook
|
|
172
158
|
*/
|
|
@@ -177,94 +163,17 @@ import { Omnipay } from 'omnipay-reactnative-sdk';
|
|
|
177
163
|
* the user is done with registration.
|
|
178
164
|
* you can navigate them else where at this point
|
|
179
165
|
*/
|
|
166
|
+
|
|
180
167
|
}}
|
|
181
|
-
|
|
168
|
+
/>
|
|
182
169
|
```
|
|
183
170
|
|
|
184
171
|
### Properties
|
|
185
172
|
|
|
186
|
-
| Name
|
|
187
|
-
|
|
|
188
|
-
| color
|
|
189
|
-
| env
|
|
190
|
-
| phoneNumber
|
|
191
|
-
| publicKey
|
|
192
|
-
| view
|
|
193
|
-
|
|
194
|
-
## Face Verification Feature
|
|
195
|
-
|
|
196
|
-
The SDK now includes face verification functionality that can be triggered from the webview. This feature provides liveness detection with multiple verification steps including blinking, smiling, and final position verification.
|
|
197
|
-
|
|
198
|
-
### Usage from WebView
|
|
199
|
-
|
|
200
|
-
The webview can trigger face verification by sending a message:
|
|
201
|
-
|
|
202
|
-
```javascript
|
|
203
|
-
// From webview JavaScript
|
|
204
|
-
window.ReactNativeWebView.postMessage(
|
|
205
|
-
JSON.stringify({
|
|
206
|
-
dataKey: 'startFaceVerification',
|
|
207
|
-
dataValue: JSON.stringify({
|
|
208
|
-
// additional options can be passed here
|
|
209
|
-
customData: {
|
|
210
|
-
/* any custom data */
|
|
211
|
-
},
|
|
212
|
-
}),
|
|
213
|
-
})
|
|
214
|
-
);
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
### Handling Face Verification Results
|
|
218
|
-
|
|
219
|
-
The SDK will post back results to the webview:
|
|
220
|
-
|
|
221
|
-
```javascript
|
|
222
|
-
// Listen for results in webview
|
|
223
|
-
window.addEventListener('message', function (event) {
|
|
224
|
-
const data = JSON.parse(event.data);
|
|
225
|
-
|
|
226
|
-
if (data.dataKey === 'faceVerificationComplete') {
|
|
227
|
-
if (data.dataValue.success) {
|
|
228
|
-
// Verification successful
|
|
229
|
-
const base64Image = data.dataValue.image;
|
|
230
|
-
// Handle success
|
|
231
|
-
} else {
|
|
232
|
-
// Verification failed
|
|
233
|
-
console.error(data.dataValue.error);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
if (data.dataKey === 'faceVerificationCancelled') {
|
|
238
|
-
// User cancelled verification
|
|
239
|
-
console.log('Face verification cancelled');
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
### Required Setup for Face Verification
|
|
245
|
-
|
|
246
|
-
1. **Install additional dependencies** (already included if you followed the Dependencies section above):
|
|
247
|
-
|
|
248
|
-
- `react-native-vision-camera` for camera access
|
|
249
|
-
- `react-native-vision-camera-face-detector` for face detection
|
|
250
|
-
- `react-native-svg` for UI components
|
|
251
|
-
|
|
252
|
-
2. **Permissions** (already included if you followed the Dependencies section above):
|
|
253
|
-
|
|
254
|
-
- Camera permissions are required on both iOS and Android
|
|
255
|
-
|
|
256
|
-
3. **Platform-specific setup**:
|
|
257
|
-
- Follow the setup instructions for `react-native-vision-camera` in your project
|
|
258
|
-
- Ensure camera permissions are properly configured
|
|
259
|
-
|
|
260
|
-
### Face Verification Flow
|
|
261
|
-
|
|
262
|
-
1. User triggers verification from webview
|
|
263
|
-
2. SDK displays face verification modal with "Proceed" button
|
|
264
|
-
3. User goes through verification steps:
|
|
265
|
-
- Position face in frame
|
|
266
|
-
- Blink eyes
|
|
267
|
-
- Smile
|
|
268
|
-
- Hold still for final capture
|
|
269
|
-
4. SDK captures image and shows preview with "Continue" and "Retake" options
|
|
270
|
-
5. SDK returns base64 image data to webview when user selects "Continue"
|
|
173
|
+
| Name | Type | Description |
|
|
174
|
+
| --------------- | -------- | -------------------------------------------------------- |
|
|
175
|
+
| color | String | color of primary buttons and links |
|
|
176
|
+
| env | String | dev or prod |
|
|
177
|
+
| phoneNumber | String | phone number of the customer |
|
|
178
|
+
| publicKey | String | public key of the company on omnipay |
|
|
179
|
+
| view | String | the view to render on the sdk |
|
package/android/build.gradle
CHANGED
|
@@ -43,4 +43,17 @@ repositories {
|
|
|
43
43
|
|
|
44
44
|
dependencies {
|
|
45
45
|
implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
|
|
46
|
+
|
|
47
|
+
// CameraX dependencies for liveness detection
|
|
48
|
+
implementation 'androidx.camera:camera-core:1.3.1'
|
|
49
|
+
implementation 'androidx.camera:camera-camera2:1.3.1'
|
|
50
|
+
implementation 'androidx.camera:camera-lifecycle:1.3.1'
|
|
51
|
+
implementation 'androidx.camera:camera-view:1.3.1'
|
|
52
|
+
|
|
53
|
+
// ML Kit for face detection
|
|
54
|
+
implementation 'com.google.mlkit:face-detection:16.1.5'
|
|
55
|
+
|
|
56
|
+
// Additional required dependencies
|
|
57
|
+
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.7.0'
|
|
58
|
+
implementation 'androidx.core:core-ktx:1.12.0'
|
|
46
59
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
2
|
package="com.omniretail.omnipay">
|
|
3
3
|
|
|
4
|
+
<!-- Camera permissions for liveness detection -->
|
|
5
|
+
<uses-permission android:name="android.permission.CAMERA" />
|
|
6
|
+
<uses-feature android:name="android.hardware.camera" android:required="true" />
|
|
7
|
+
<uses-feature android:name="android.hardware.camera.front" android:required="false" />
|
|
8
|
+
|
|
4
9
|
<application>
|
|
5
10
|
<service
|
|
6
11
|
android:name=".OmnipayActivityModule"
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
package com.omniretail.omnipay;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.view.View;
|
|
5
|
+
import android.widget.FrameLayout;
|
|
6
|
+
|
|
7
|
+
import androidx.annotation.NonNull;
|
|
8
|
+
import androidx.annotation.Nullable;
|
|
9
|
+
import androidx.camera.view.PreviewView;
|
|
10
|
+
|
|
11
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
12
|
+
import com.facebook.react.bridge.ReactContext;
|
|
13
|
+
import com.facebook.react.common.MapBuilder;
|
|
14
|
+
import com.facebook.react.uimanager.SimpleViewManager;
|
|
15
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
16
|
+
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
17
|
+
|
|
18
|
+
import java.util.Map;
|
|
19
|
+
|
|
20
|
+
public class LivenessCameraViewManager extends SimpleViewManager<FrameLayout> {
|
|
21
|
+
public static final String REACT_CLASS = "LivenessCameraView";
|
|
22
|
+
private ReactApplicationContext reactContext;
|
|
23
|
+
|
|
24
|
+
public LivenessCameraViewManager(ReactApplicationContext reactContext) {
|
|
25
|
+
this.reactContext = reactContext;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@Override
|
|
29
|
+
@NonNull
|
|
30
|
+
public String getName() {
|
|
31
|
+
return REACT_CLASS;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@Override
|
|
35
|
+
@NonNull
|
|
36
|
+
public FrameLayout createViewInstance(@NonNull ThemedReactContext context) {
|
|
37
|
+
FrameLayout frameLayout = new FrameLayout(context);
|
|
38
|
+
frameLayout.setLayoutParams(new FrameLayout.LayoutParams(
|
|
39
|
+
FrameLayout.LayoutParams.MATCH_PARENT,
|
|
40
|
+
FrameLayout.LayoutParams.MATCH_PARENT
|
|
41
|
+
));
|
|
42
|
+
|
|
43
|
+
// Get the camera preview from the LivenessDetectionModule
|
|
44
|
+
try {
|
|
45
|
+
LivenessDetectionModule livenessModule = reactContext.getNativeModule(LivenessDetectionModule.class);
|
|
46
|
+
if (livenessModule != null) {
|
|
47
|
+
PreviewView previewView = livenessModule.getPreviewView();
|
|
48
|
+
if (previewView != null) {
|
|
49
|
+
// Remove from any existing parent
|
|
50
|
+
if (previewView.getParent() != null) {
|
|
51
|
+
((FrameLayout) previewView.getParent()).removeView(previewView);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
frameLayout.addView(previewView, new FrameLayout.LayoutParams(
|
|
55
|
+
FrameLayout.LayoutParams.MATCH_PARENT,
|
|
56
|
+
FrameLayout.LayoutParams.MATCH_PARENT
|
|
57
|
+
));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
} catch (Exception e) {
|
|
61
|
+
// Handle gracefully - the camera view will be set up later
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return frameLayout;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@ReactProp(name = "scaleType")
|
|
68
|
+
public void setScaleType(FrameLayout view, @Nullable String scaleType) {
|
|
69
|
+
// Find the PreviewView child and set scale type
|
|
70
|
+
for (int i = 0; i < view.getChildCount(); i++) {
|
|
71
|
+
View child = view.getChildAt(i);
|
|
72
|
+
if (child instanceof PreviewView) {
|
|
73
|
+
PreviewView previewView = (PreviewView) child;
|
|
74
|
+
if ("fillStart".equals(scaleType)) {
|
|
75
|
+
previewView.setScaleType(PreviewView.ScaleType.FILL_START);
|
|
76
|
+
} else if ("fillCenter".equals(scaleType)) {
|
|
77
|
+
previewView.setScaleType(PreviewView.ScaleType.FILL_CENTER);
|
|
78
|
+
} else if ("fillEnd".equals(scaleType)) {
|
|
79
|
+
previewView.setScaleType(PreviewView.ScaleType.FILL_END);
|
|
80
|
+
} else if ("fitStart".equals(scaleType)) {
|
|
81
|
+
previewView.setScaleType(PreviewView.ScaleType.FIT_START);
|
|
82
|
+
} else if ("fitCenter".equals(scaleType)) {
|
|
83
|
+
previewView.setScaleType(PreviewView.ScaleType.FIT_CENTER);
|
|
84
|
+
} else if ("fitEnd".equals(scaleType)) {
|
|
85
|
+
previewView.setScaleType(PreviewView.ScaleType.FIT_END);
|
|
86
|
+
} else {
|
|
87
|
+
// Default to fill center
|
|
88
|
+
previewView.setScaleType(PreviewView.ScaleType.FILL_CENTER);
|
|
89
|
+
}
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@Override
|
|
96
|
+
public void onDropViewInstance(@NonNull FrameLayout view) {
|
|
97
|
+
super.onDropViewInstance(view);
|
|
98
|
+
// Clean up camera resources if needed
|
|
99
|
+
try {
|
|
100
|
+
LivenessDetectionModule livenessModule = reactContext.getNativeModule(LivenessDetectionModule.class);
|
|
101
|
+
if (livenessModule != null) {
|
|
102
|
+
// The module will handle cleanup when detection stops
|
|
103
|
+
}
|
|
104
|
+
} catch (Exception e) {
|
|
105
|
+
// Handle gracefully
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@Override
|
|
110
|
+
public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
|
|
111
|
+
return MapBuilder.<String, Object>builder()
|
|
112
|
+
.put("onCameraReady", MapBuilder.of("registrationName", "onCameraReady"))
|
|
113
|
+
.put("onCameraError", MapBuilder.of("registrationName", "onCameraError"))
|
|
114
|
+
.build();
|
|
115
|
+
}
|
|
116
|
+
}
|