react-native-okaycam 1.1.21 → 1.1.26
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 +31 -1
- package/android/.gradle/6.8/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/checksums/sha1-checksums.bin +0 -0
- package/android/.idea/jarRepositories.xml +10 -0
- package/android/.idea/libraries/Gradle__com_innov8tif_okaycam_OkayCam_1_1_10_aar.xml +15 -0
- package/android/.idea/modules/android.iml +1 -1
- package/android/.idea/workspace.xml +65 -0
- package/android/build.gradle +2 -2
- package/android/src/main/java/com/innov8tif/RNOkayCam/RNOkayCamModule.java +108 -0
- package/index.ts +45 -0
- package/ios/RNOkayCam.swift +42 -0
- package/package.json +1 -1
- package/react-native-okaycam.podspec +1 -1
- package/android/.idea/libraries/Gradle__com_innov8tif_okaycam_OkayCam_1_1_8_aar.xml +0 -15
package/README.md
CHANGED
|
@@ -95,6 +95,17 @@ const license = Platform.select({
|
|
|
95
95
|
|-|captureBtnColor|color of the capture button|#ffffff|
|
|
96
96
|
|-|firstPhotoConfig|config for the first capture|delay:0s,onFlash:false,outputPath: null|
|
|
97
97
|
|-|secondPhotoConfig|config for the second capture|null|
|
|
98
|
+
|preview |title|title on preview screen|""(empty string)|
|
|
99
|
+
|preview |refImg|ref image on preview screen|null|
|
|
100
|
+
|preview |instruction1|instruction on preview screen|""(empty string)|
|
|
101
|
+
|preview|instruction2|instruction on preview screen|""(empty string)|
|
|
102
|
+
|preview |instruction3|instruction on preview screen|""(empty string)|
|
|
103
|
+
|preview |backgroundColor|background color of preview screen|null|
|
|
104
|
+
|instruction <sup>**New**</sup> |title|Instruction's title on camera caputre screen|""(empty string)|
|
|
105
|
+
|instruction <sup>**New**</sup> |refImage1|Instruction's reference image 1|null|
|
|
106
|
+
|instruction <sup>**New**</sup> |refImage2|Instruction's reference image 2|null|
|
|
107
|
+
|
|
108
|
+
|
|
98
109
|
|
|
99
110
|
## Usage
|
|
100
111
|
```
|
|
@@ -148,7 +159,26 @@ captureDocument(
|
|
|
148
159
|
},
|
|
149
160
|
crop: true,
|
|
150
161
|
width: 2000,
|
|
151
|
-
imageQuality: 1.0
|
|
162
|
+
imageQuality: 1.0,
|
|
163
|
+
preview: {
|
|
164
|
+
title: {text: 'testing', color: '#000000', size: 25},
|
|
165
|
+
refImage: require('./images/ref.png'),
|
|
166
|
+
instruction1: {text: 'instr1', color: '#000000', size: 14},
|
|
167
|
+
instruction2: {text: 'instr2', color: '#000000', size: 14},
|
|
168
|
+
instruction3: {text: 'instr3', color: '#000000', size: 14},
|
|
169
|
+
backgroundColor: '#374fff',
|
|
170
|
+
},
|
|
171
|
+
instruction: {
|
|
172
|
+
title: {text: 'instr1', color: '#ffffff', size: 14},
|
|
173
|
+
refImage1: {
|
|
174
|
+
title: {text: 'ref1', color: '#ffffff', size: 14},
|
|
175
|
+
img: require('./images/ref.png'),
|
|
176
|
+
},
|
|
177
|
+
refImage2: {
|
|
178
|
+
title: {text: 'ref2', color: '#ffffff', size: 14},
|
|
179
|
+
img: require('./images/ref.png'),
|
|
180
|
+
},
|
|
181
|
+
},
|
|
152
182
|
}
|
|
153
183
|
)
|
|
154
184
|
.then(result => {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -31,5 +31,15 @@
|
|
|
31
31
|
<option name="name" value="maven" />
|
|
32
32
|
<option name="url" value="https://s01.oss.sonatype.org/content/repositories/cominnov8tif-1062" />
|
|
33
33
|
</remote-repository>
|
|
34
|
+
<remote-repository>
|
|
35
|
+
<option name="id" value="maven" />
|
|
36
|
+
<option name="name" value="maven" />
|
|
37
|
+
<option name="url" value="https://s01.oss.sonatype.org/content/repositories/cominnov8tif-1063" />
|
|
38
|
+
</remote-repository>
|
|
39
|
+
<remote-repository>
|
|
40
|
+
<option name="id" value="maven" />
|
|
41
|
+
<option name="name" value="maven" />
|
|
42
|
+
<option name="url" value="https://s01.oss.sonatype.org/content/repositories/cominnov8tif-1064" />
|
|
43
|
+
</remote-repository>
|
|
34
44
|
</component>
|
|
35
45
|
</project>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<component name="libraryTable">
|
|
2
|
+
<library name="Gradle: com.innov8tif.okaycam:OkayCam:1.1.10@aar">
|
|
3
|
+
<CLASSES>
|
|
4
|
+
<root url="jar://$USER_HOME$/.gradle/caches/transforms-3/d475d7eab3beed356dcb43e92fe8afa3/transformed/jetified-OkayCam-1.1.10/jars/classes.jar!/" />
|
|
5
|
+
<root url="file://$USER_HOME$/.gradle/caches/transforms-3/d475d7eab3beed356dcb43e92fe8afa3/transformed/jetified-OkayCam-1.1.10/res" />
|
|
6
|
+
<root url="file://$USER_HOME$/.gradle/caches/transforms-3/d475d7eab3beed356dcb43e92fe8afa3/transformed/jetified-OkayCam-1.1.10/AndroidManifest.xml" />
|
|
7
|
+
</CLASSES>
|
|
8
|
+
<JAVADOC>
|
|
9
|
+
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.innov8tif.okaycam/OkayCam/1.1.10/d87bd11330b88497cefe8e10482aefbe6e25e795/OkayCam-1.1.10-javadoc.jar!/" />
|
|
10
|
+
</JAVADOC>
|
|
11
|
+
<SOURCES>
|
|
12
|
+
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.innov8tif.okaycam/OkayCam/1.1.10/d869c29d69b3fa6aaed3ea3025849f5a099de27f/OkayCam-1.1.10-sources.jar!/" />
|
|
13
|
+
</SOURCES>
|
|
14
|
+
</library>
|
|
15
|
+
</component>
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
<orderEntry type="library" name="Gradle: androidx.localbroadcastmanager:localbroadcastmanager:1.0.0@aar" level="project" />
|
|
100
100
|
<orderEntry type="library" name="Gradle: androidx.print:print:1.0.0@aar" level="project" />
|
|
101
101
|
<orderEntry type="library" name="Gradle: org.webkit:android-jsc:r174650@aar" level="project" />
|
|
102
|
-
<orderEntry type="library" name="Gradle: com.innov8tif.okaycam:OkayCam:1.1.
|
|
102
|
+
<orderEntry type="library" name="Gradle: com.innov8tif.okaycam:OkayCam:1.1.10@aar" level="project" />
|
|
103
103
|
<orderEntry type="library" name="Gradle: com.caverock:androidsvg-aar:1.4@aar" level="project" />
|
|
104
104
|
</component>
|
|
105
105
|
</module>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="AndroidLogFilters">
|
|
4
|
+
<option name="TOOL_WINDOW_CONFIGURED_FILTER" value="Show only selected application" />
|
|
5
|
+
</component>
|
|
6
|
+
<component name="AutoImportSettings">
|
|
7
|
+
<option name="autoReloadType" value="NONE" />
|
|
8
|
+
</component>
|
|
9
|
+
<component name="ChangeListManager">
|
|
10
|
+
<list default="true" id="dcd03e48-895c-4531-9c6b-999b4eb29984" name="Default Changelist" comment="">
|
|
11
|
+
<change beforePath="$PROJECT_DIR$/../ios/RNOkayCam.swift" beforeDir="false" afterPath="$PROJECT_DIR$/../ios/RNOkayCam.swift" afterDir="false" />
|
|
12
|
+
</list>
|
|
13
|
+
<option name="SHOW_DIALOG" value="false" />
|
|
14
|
+
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
15
|
+
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
|
16
|
+
<option name="LAST_RESOLUTION" value="IGNORE" />
|
|
17
|
+
</component>
|
|
18
|
+
<component name="ExternalProjectsData">
|
|
19
|
+
<projectState path="$PROJECT_DIR$">
|
|
20
|
+
<ProjectState />
|
|
21
|
+
</projectState>
|
|
22
|
+
</component>
|
|
23
|
+
<component name="Git.Settings">
|
|
24
|
+
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
|
|
25
|
+
</component>
|
|
26
|
+
<component name="GitSEFilterConfiguration">
|
|
27
|
+
<file-type-list>
|
|
28
|
+
<filtered-out-file-type name="LOCAL_BRANCH" />
|
|
29
|
+
<filtered-out-file-type name="REMOTE_BRANCH" />
|
|
30
|
+
<filtered-out-file-type name="TAG" />
|
|
31
|
+
<filtered-out-file-type name="COMMIT_BY_MESSAGE" />
|
|
32
|
+
</file-type-list>
|
|
33
|
+
</component>
|
|
34
|
+
<component name="ProjectId" id="20OnRh4fdjMjOrINVhdGIVlXNLA" />
|
|
35
|
+
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
|
36
|
+
<component name="ProjectViewState">
|
|
37
|
+
<option name="hideEmptyMiddlePackages" value="true" />
|
|
38
|
+
<option name="showLibraryContents" value="true" />
|
|
39
|
+
</component>
|
|
40
|
+
<component name="PropertiesComponent">
|
|
41
|
+
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
|
|
42
|
+
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
|
|
43
|
+
<property name="RunOnceActivity.cidr.known.project.marker" value="true" />
|
|
44
|
+
<property name="android.sdk.path" value="$USER_HOME$/Library/Android/sdk" />
|
|
45
|
+
<property name="cidr.known.project.marker" value="true" />
|
|
46
|
+
<property name="project.structure.last.edited" value="Dependencies" />
|
|
47
|
+
<property name="project.structure.proportion" value="0.17" />
|
|
48
|
+
<property name="project.structure.side.proportion" value="0.2" />
|
|
49
|
+
<property name="settings.editor.selected.configurable" value="reference.settingsdialog.project.gradle" />
|
|
50
|
+
</component>
|
|
51
|
+
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
|
52
|
+
<component name="SvnConfiguration">
|
|
53
|
+
<configuration />
|
|
54
|
+
</component>
|
|
55
|
+
<component name="TaskManager">
|
|
56
|
+
<task active="true" id="Default" summary="Default task">
|
|
57
|
+
<changelist id="dcd03e48-895c-4531-9c6b-999b4eb29984" name="Default Changelist" comment="" />
|
|
58
|
+
<created>1635924494769</created>
|
|
59
|
+
<option name="number" value="Default" />
|
|
60
|
+
<option name="presentableId" value="Default" />
|
|
61
|
+
<updated>1635924494769</updated>
|
|
62
|
+
</task>
|
|
63
|
+
<servers />
|
|
64
|
+
</component>
|
|
65
|
+
</project>
|
package/android/build.gradle
CHANGED
|
@@ -33,7 +33,7 @@ android {
|
|
|
33
33
|
|
|
34
34
|
repositories {
|
|
35
35
|
// jcenter({ url "https://dl.bintray.com/innov8tifekyc/OkayCam/" })
|
|
36
|
-
//
|
|
36
|
+
// maven { url "https://s01.oss.sonatype.org/content/repositories/cominnov8tif-1064" }
|
|
37
37
|
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -46,7 +46,7 @@ repositories {
|
|
|
46
46
|
|
|
47
47
|
dependencies {
|
|
48
48
|
implementation 'com.facebook.react:react-native:+'
|
|
49
|
-
implementation('com.innov8tif.okaycam:OkayCam:1.1.
|
|
49
|
+
implementation('com.innov8tif.okaycam:OkayCam:1.1.11@aar') {
|
|
50
50
|
transitive = true
|
|
51
51
|
}
|
|
52
52
|
implementation 'com.googlecode.json-simple:json-simple:1.1.1'
|
|
@@ -26,6 +26,8 @@ import com.innov8tif.okaycam.config.OkayCamBtnConfig;
|
|
|
26
26
|
import com.innov8tif.okaycam.config.OkayCamCaptureConfig;
|
|
27
27
|
import com.innov8tif.okaycam.config.OkayCamConfig;
|
|
28
28
|
import com.innov8tif.okaycam.config.OkayCamFrameConfig;
|
|
29
|
+
import com.innov8tif.okaycam.config.OkayCamInstruction;
|
|
30
|
+
import com.innov8tif.okaycam.config.OkayCamInstructionRefImg;
|
|
29
31
|
import com.innov8tif.okaycam.config.OkayCamLabelConfig;
|
|
30
32
|
import com.innov8tif.okaycam.config.OkayCamPreviewConfig;
|
|
31
33
|
import com.innov8tif.okaycam.config.OkayCamTimerConfig;
|
|
@@ -76,6 +78,7 @@ public class RNOkayCamModule extends ReactContextBaseJavaModule {
|
|
|
76
78
|
ReadableMap firstPhoto = captureConfigPair.getMap("firstPhoto");
|
|
77
79
|
ReadableMap secondPhoto = captureConfigPair.getMap("secondPhoto");
|
|
78
80
|
ReadableMap preview = userConfig.getMap("preview");
|
|
81
|
+
ReadableMap instruction = userConfig.getMap("instruction");
|
|
79
82
|
|
|
80
83
|
|
|
81
84
|
OkayCamConfig okayCamConfig = OkayCamConfig.init(this.getCurrentActivity());
|
|
@@ -136,6 +139,7 @@ public class RNOkayCamModule extends ReactContextBaseJavaModule {
|
|
|
136
139
|
|
|
137
140
|
|
|
138
141
|
okayCamConfig.setPreview(getPreviewConfig(preview, frameConfig));
|
|
142
|
+
okayCamConfig.setInstruction(getInstructionConfig(instruction, frameConfig));
|
|
139
143
|
|
|
140
144
|
OkayCamDoc.start(this.getCurrentActivity(), LICENSE_KEY, okayCamConfig, (success, images, exception) -> {
|
|
141
145
|
|
|
@@ -149,6 +153,14 @@ public class RNOkayCamModule extends ReactContextBaseJavaModule {
|
|
|
149
153
|
results.put("fullDocumentImage2", convertImgToBase64(base64, images.get(1)));
|
|
150
154
|
}
|
|
151
155
|
|
|
156
|
+
if (images.size() > 2) {
|
|
157
|
+
results.put("fullDocumentImage3", convertImgToBase64(base64, images.get(2)));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (images.size() > 3) {
|
|
161
|
+
results.put("fullDocumentImage4", convertImgToBase64(base64, images.get(3)));
|
|
162
|
+
}
|
|
163
|
+
|
|
152
164
|
promise.resolve(results.toString());
|
|
153
165
|
} catch (JSONException e) {
|
|
154
166
|
// TODO Auto-generated catch block
|
|
@@ -162,6 +174,102 @@ public class RNOkayCamModule extends ReactContextBaseJavaModule {
|
|
|
162
174
|
});
|
|
163
175
|
}
|
|
164
176
|
|
|
177
|
+
private OkayCamInstruction getInstructionConfig(ReadableMap instruction, OkayCamFrameConfig frameConfig) {
|
|
178
|
+
if (instruction == null) return null;
|
|
179
|
+
OkayCamLabelConfig title = mapToLabelConfig(instruction.getMap("title"));
|
|
180
|
+
|
|
181
|
+
ReadableMap refMap1 = instruction.getMap("refImage1");
|
|
182
|
+
OkayCamInstructionRefImg ref1 = mapToRef(refMap1, frameConfig, "instr1");
|
|
183
|
+
|
|
184
|
+
ReadableMap refMap2 = instruction.getMap("refImage2");
|
|
185
|
+
OkayCamInstructionRefImg ref2 = mapToRef(refMap2, frameConfig, "instr2");
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
return new OkayCamInstruction(
|
|
189
|
+
title,
|
|
190
|
+
ref1,
|
|
191
|
+
ref2
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
private OkayCamInstructionRefImg mapToRef(ReadableMap refMap, OkayCamFrameConfig frameConfig, String fileName) {
|
|
196
|
+
if (refMap == null) return null;
|
|
197
|
+
OkayCamLabelConfig title = mapToLabelConfig(refMap.getMap("title"));
|
|
198
|
+
String img1 = getImageFromJs(refMap.getString("img"), frameConfig, fileName);
|
|
199
|
+
|
|
200
|
+
return new OkayCamInstructionRefImg(title, img1);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
private String getImageFromJs(String refImage, OkayCamFrameConfig frameConfig, String fileName) {
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
Size size = frameConfig.getSize();
|
|
207
|
+
int frameWidth = size.getWidth();
|
|
208
|
+
int frameHeight = size.getHeight();
|
|
209
|
+
|
|
210
|
+
Bitmap contentBmp = null;
|
|
211
|
+
try {
|
|
212
|
+
if (refImage != null) {
|
|
213
|
+
|
|
214
|
+
// In debug, the image is returned as URL
|
|
215
|
+
if (BuildConfig.DEBUG) {
|
|
216
|
+
InputStream inputStream = new URL(refImage).openStream();
|
|
217
|
+
|
|
218
|
+
if (refImage.contains("svg")) {
|
|
219
|
+
|
|
220
|
+
SVG svg = SVG.getFromInputStream(inputStream);
|
|
221
|
+
|
|
222
|
+
svg.setDocumentWidth(frameWidth);
|
|
223
|
+
svg.setDocumentHeight(frameHeight);
|
|
224
|
+
|
|
225
|
+
if (svg.getDocumentWidth() != -1) {
|
|
226
|
+
contentBmp = Bitmap.createBitmap((int) Math.ceil(svg.getDocumentWidth()),
|
|
227
|
+
(int) Math.ceil(svg.getDocumentHeight()),
|
|
228
|
+
Bitmap.Config.ARGB_8888);
|
|
229
|
+
|
|
230
|
+
Canvas bmcanvas = new Canvas(contentBmp);
|
|
231
|
+
|
|
232
|
+
// Render our document onto our canvas
|
|
233
|
+
svg.renderToCanvas(bmcanvas, new RenderOptions().preserveAspectRatio(PreserveAspectRatio.FULLSCREEN));
|
|
234
|
+
}
|
|
235
|
+
} else {
|
|
236
|
+
contentBmp = BitmapFactory.decodeStream(inputStream);
|
|
237
|
+
}
|
|
238
|
+
} else {
|
|
239
|
+
// In release, the image is returned as raw (svg) or drawable (png, jpeg and etc)
|
|
240
|
+
int resourceId = this.getCurrentActivity().getResources().getIdentifier(refImage, "raw", this.getCurrentActivity().getPackageName());
|
|
241
|
+
|
|
242
|
+
if (resourceId != 0) {
|
|
243
|
+
SVG svg = SVG.getFromResource(getReactApplicationContext(), resourceId);
|
|
244
|
+
|
|
245
|
+
svg.setDocumentWidth(frameWidth);
|
|
246
|
+
svg.setDocumentHeight(frameHeight);
|
|
247
|
+
|
|
248
|
+
if (svg.getDocumentWidth() != -1) {
|
|
249
|
+
contentBmp = Bitmap.createBitmap((int) Math.ceil(svg.getDocumentWidth()),
|
|
250
|
+
(int) Math.ceil(svg.getDocumentHeight()),
|
|
251
|
+
Bitmap.Config.ARGB_8888);
|
|
252
|
+
|
|
253
|
+
Canvas bmcanvas = new Canvas(contentBmp);
|
|
254
|
+
|
|
255
|
+
// Render our document onto our canvas
|
|
256
|
+
svg.renderToCanvas(bmcanvas, new RenderOptions().preserveAspectRatio(PreserveAspectRatio.FULLSCREEN));
|
|
257
|
+
}
|
|
258
|
+
} else {
|
|
259
|
+
resourceId = this.getCurrentActivity().getResources().getIdentifier(refImage, "drawable", this.getCurrentActivity().getPackageName());
|
|
260
|
+
contentBmp = BitmapFactory.decodeResource(getReactApplicationContext().getResources(), resourceId);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
} catch (SVGParseException | MalformedURLException e) {
|
|
265
|
+
e.printStackTrace();
|
|
266
|
+
} catch (IOException e) {
|
|
267
|
+
e.printStackTrace();
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return generateFile(contentBmp, fileName);
|
|
271
|
+
}
|
|
272
|
+
|
|
165
273
|
private OkayCamPreviewConfig getPreviewConfig(ReadableMap preview, OkayCamFrameConfig frameConfig) {
|
|
166
274
|
if (preview == null) return null;
|
|
167
275
|
OkayCamLabelConfig title = mapToLabelConfig(preview.getMap("title"));
|
package/index.ts
CHANGED
|
@@ -26,6 +26,16 @@ interface OkayCamPreviewConfig {
|
|
|
26
26
|
backgroundColor: string;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
interface OkaycamInstructionRefImg {
|
|
30
|
+
title: LabelConfig;
|
|
31
|
+
img: ImageResolvedAssetSource;
|
|
32
|
+
}
|
|
33
|
+
interface OkayCamInstruction {
|
|
34
|
+
title: LabelConfig;
|
|
35
|
+
refImage1: OkaycamInstructionRefImg;
|
|
36
|
+
refImage2?: OkaycamInstructionRefImg;
|
|
37
|
+
}
|
|
38
|
+
|
|
29
39
|
interface FrameSize {
|
|
30
40
|
width: number;
|
|
31
41
|
height: number;
|
|
@@ -100,8 +110,41 @@ const captureConfigFirst: CaptureConfig = {
|
|
|
100
110
|
|
|
101
111
|
const defaultPreview: OkayCamPreviewConfig = null;
|
|
102
112
|
|
|
113
|
+
const defaultInstruction: OkayCamInstruction = null;
|
|
114
|
+
|
|
103
115
|
const captureConfigSecond: CaptureConfig = null;
|
|
104
116
|
|
|
117
|
+
const formatImage = (img: ImageResolvedAssetSource) => {
|
|
118
|
+
return Image.resolveAssetSource(img).uri;
|
|
119
|
+
// return img;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const formatInstruction = (
|
|
123
|
+
instruction: OkayCamInstruction
|
|
124
|
+
): OkayCamInstruction => {
|
|
125
|
+
if (instruction == null) return null;
|
|
126
|
+
|
|
127
|
+
const ref1: OkaycamInstructionRefImg = {
|
|
128
|
+
...instruction.refImage1,
|
|
129
|
+
img: formatImage(instruction.refImage1.img),
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
let ref2: OkaycamInstructionRefImg = null;
|
|
133
|
+
if (instruction.refImage2 != null) {
|
|
134
|
+
ref2 = {
|
|
135
|
+
...instruction.refImage2,
|
|
136
|
+
img: formatImage(instruction.refImage2.img),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const formattedInstruction: OkayCamInstruction = {
|
|
141
|
+
title: instruction.title,
|
|
142
|
+
refImage1: ref1,
|
|
143
|
+
refImage2: ref2,
|
|
144
|
+
};
|
|
145
|
+
return formattedInstruction;
|
|
146
|
+
};
|
|
147
|
+
|
|
105
148
|
// cal native capture document
|
|
106
149
|
export const captureDocument = (
|
|
107
150
|
license: string,
|
|
@@ -122,6 +165,7 @@ export const captureDocument = (
|
|
|
122
165
|
width = imageResizedWidth,
|
|
123
166
|
imageQuality = 1.0,
|
|
124
167
|
preview = defaultPreview,
|
|
168
|
+
instruction = defaultInstruction,
|
|
125
169
|
}
|
|
126
170
|
) => {
|
|
127
171
|
if (frame.size == undefined) {
|
|
@@ -174,6 +218,7 @@ export const captureDocument = (
|
|
|
174
218
|
width: width,
|
|
175
219
|
imageQuality: imageQuality,
|
|
176
220
|
preview: resultedPreview,
|
|
221
|
+
instruction: formatInstruction(instruction),
|
|
177
222
|
},
|
|
178
223
|
})
|
|
179
224
|
.then((result) => {
|
package/ios/RNOkayCam.swift
CHANGED
|
@@ -127,6 +127,10 @@ class RNOkayCam: NSObject {
|
|
|
127
127
|
let previewConfig = rnOkayCamConfig.object(forKey: "preview") as? NSDictionary
|
|
128
128
|
|
|
129
129
|
okayCamConfig.preview = self.getOkaycamPreview(previewConfig: previewConfig)
|
|
130
|
+
|
|
131
|
+
// instruction config
|
|
132
|
+
let instructionConfig = rnOkayCamConfig.object(forKey: "instruction") as? NSDictionary
|
|
133
|
+
okayCamConfig.instruction = self.getOkayCamInstruction(instructionConfig: instructionConfig)
|
|
130
134
|
|
|
131
135
|
// start the SDK
|
|
132
136
|
OkayCamDoc.start(
|
|
@@ -149,6 +153,14 @@ class RNOkayCam: NSObject {
|
|
|
149
153
|
if (filePaths!.count > 1) {
|
|
150
154
|
okayCamObject.setValue(self.convertImgToBase64(base64: base64, image: urls[1]), forKey: "fullDocumentImage2")
|
|
151
155
|
}
|
|
156
|
+
|
|
157
|
+
if (filePaths!.count > 2) {
|
|
158
|
+
okayCamObject.setValue(self.convertImgToBase64(base64: base64, image: urls[2]), forKey: "fullDocumentImage3")
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (filePaths!.count > 3) {
|
|
162
|
+
okayCamObject.setValue(self.convertImgToBase64(base64: base64, image: urls[3]), forKey: "fullDocumentImage4")
|
|
163
|
+
}
|
|
152
164
|
|
|
153
165
|
let jsonData = try JSONSerialization.data(withJSONObject: okayCamObject, options: .prettyPrinted)
|
|
154
166
|
let jsonString = String(data: jsonData, encoding: String.Encoding.ascii)!
|
|
@@ -191,6 +203,36 @@ class RNOkayCam: NSObject {
|
|
|
191
203
|
|
|
192
204
|
return OkayCamPreviewConfig(title: title, refImage: refUrl!, instruction1: instr1, instruction2: instr2, instruction3: instr3, backgroundColor: bgColor)
|
|
193
205
|
}
|
|
206
|
+
|
|
207
|
+
func getOkayCamInstruction(instructionConfig: NSDictionary?) -> OkayCamInstruction?{
|
|
208
|
+
if instructionConfig == nil {return nil}
|
|
209
|
+
|
|
210
|
+
let title = configToOkayCamLabel(config: instructionConfig?.object(forKey: "title") as! NSDictionary)
|
|
211
|
+
|
|
212
|
+
let ref1 = getInstructionRefImage(refImage: instructionConfig?.object(forKey: "refImage1") as! NSDictionary)
|
|
213
|
+
|
|
214
|
+
let ref2 = getInstructionRefImage(refImage: instructionConfig?.object(forKey: "refImage2") as? NSDictionary)
|
|
215
|
+
|
|
216
|
+
return OkayCamInstruction(title:title,refImage1:ref1!,refImage2:ref2)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
func getInstructionRefImage(refImage:NSDictionary?) -> OkaycamInstructionRefImg?{
|
|
220
|
+
if refImage == nil {return nil}
|
|
221
|
+
|
|
222
|
+
let title = configToOkayCamLabel(config: refImage?.object(forKey: "title") as! NSDictionary)
|
|
223
|
+
|
|
224
|
+
// frame contet
|
|
225
|
+
let ref = refImage?.object(forKey: "img") as? String
|
|
226
|
+
var refUrl:URL? = nil
|
|
227
|
+
if (ref != nil) {
|
|
228
|
+
#if DEBUG
|
|
229
|
+
refUrl = URL(string: ref!)!
|
|
230
|
+
#else
|
|
231
|
+
refUrl = URL(fileURLWithPath: ref!.replacingOccurrences(of: "file:///", with: ""))
|
|
232
|
+
#endif
|
|
233
|
+
}
|
|
234
|
+
return OkaycamInstructionRefImg(title:title,img:refUrl!)
|
|
235
|
+
}
|
|
194
236
|
|
|
195
237
|
func configToOkayCamLabel(config:NSDictionary) -> OkayCamLabelConfig{
|
|
196
238
|
let text = config.object(forKey: "text") as! String
|
package/package.json
CHANGED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<component name="libraryTable">
|
|
2
|
-
<library name="Gradle: com.innov8tif.okaycam:OkayCam:1.1.8@aar">
|
|
3
|
-
<CLASSES>
|
|
4
|
-
<root url="file://$USER_HOME$/.gradle/caches/transforms-3/e8e9871e8c8ab82181a74c8bcd87b577/transformed/jetified-OkayCam-1.1.8/AndroidManifest.xml" />
|
|
5
|
-
<root url="file://$USER_HOME$/.gradle/caches/transforms-3/e8e9871e8c8ab82181a74c8bcd87b577/transformed/jetified-OkayCam-1.1.8/res" />
|
|
6
|
-
<root url="jar://$USER_HOME$/.gradle/caches/transforms-3/e8e9871e8c8ab82181a74c8bcd87b577/transformed/jetified-OkayCam-1.1.8/jars/classes.jar!/" />
|
|
7
|
-
</CLASSES>
|
|
8
|
-
<JAVADOC>
|
|
9
|
-
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.innov8tif.okaycam/OkayCam/1.1.8/37e591e31bff93527249b0695a52bd66d1ce3f3e/OkayCam-1.1.8-javadoc.jar!/" />
|
|
10
|
-
</JAVADOC>
|
|
11
|
-
<SOURCES>
|
|
12
|
-
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.innov8tif.okaycam/OkayCam/1.1.8/3fd4ba8b4d86263b98e8f5d94708ce51ab6ad5e3/OkayCam-1.1.8-sources.jar!/" />
|
|
13
|
-
</SOURCES>
|
|
14
|
-
</library>
|
|
15
|
-
</component>
|