react-native-okaycam 1.1.11 → 1.1.25

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.
Files changed (138) hide show
  1. package/README.md +31 -1
  2. package/android/.DS_Store +0 -0
  3. package/android/.gradle/6.8/executionHistory/executionHistory.bin +0 -0
  4. package/android/.gradle/6.8/executionHistory/executionHistory.lock +0 -0
  5. package/android/.gradle/6.8/fileChanges/last-build.bin +0 -0
  6. package/android/.gradle/6.8/fileHashes/fileHashes.bin +0 -0
  7. package/android/.gradle/6.8/fileHashes/fileHashes.lock +0 -0
  8. package/android/.gradle/6.8/fileHashes/resourceHashesCache.bin +0 -0
  9. package/android/.gradle/6.8/gc.properties +0 -0
  10. package/android/.gradle/6.8/javaCompile/classAnalysis.bin +0 -0
  11. package/android/.gradle/6.8/javaCompile/jarAnalysis.bin +0 -0
  12. package/android/.gradle/6.8/javaCompile/javaCompile.lock +0 -0
  13. package/android/.gradle/6.8/javaCompile/taskHistory.bin +0 -0
  14. package/android/.gradle/7.1.1/dependencies-accessors/dependencies-accessors.lock +0 -0
  15. package/android/.gradle/7.1.1/executionHistory/executionHistory.lock +0 -0
  16. package/android/.gradle/7.1.1/fileHashes/fileHashes.lock +0 -0
  17. package/android/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock +0 -0
  18. package/android/.gradle/7.2/dependencies-accessors/gc.properties +0 -0
  19. package/android/.gradle/7.2/fileChanges/last-build.bin +0 -0
  20. package/android/.gradle/7.2/fileHashes/fileHashes.lock +0 -0
  21. package/android/.gradle/7.2/gc.properties +0 -0
  22. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  23. package/android/.gradle/buildOutputCleanup/cache.properties +2 -2
  24. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  25. package/android/.gradle/checksums/checksums.lock +0 -0
  26. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  27. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  28. package/android/.idea/.gitignore +3 -0
  29. package/android/.idea/compiler.xml +6 -0
  30. package/android/.idea/gradle.xml +8 -4
  31. package/android/.idea/jarRepositories.xml +45 -0
  32. package/android/.idea/libraries/Gradle__androidx_activity_activity_1_0_0_aar.xml +13 -0
  33. package/android/.idea/libraries/Gradle__androidx_annotation_annotation_1_2_0.xml +11 -0
  34. package/android/.idea/libraries/Gradle__androidx_appcompat_appcompat_1_1_0_aar.xml +16 -0
  35. package/android/.idea/libraries/Gradle__androidx_appcompat_appcompat_resources_1_1_0_aar.xml +13 -0
  36. package/android/.idea/libraries/Gradle__androidx_arch_core_core_common_2_1_0.xml +11 -0
  37. package/android/.idea/libraries/Gradle__androidx_arch_core_core_runtime_2_1_0_aar.xml +13 -0
  38. package/android/.idea/libraries/Gradle__androidx_asynclayoutinflater_asynclayoutinflater_1_0_0_aar.xml +13 -0
  39. package/android/.idea/libraries/Gradle__androidx_collection_collection_1_1_0.xml +11 -0
  40. package/android/.idea/libraries/Gradle__androidx_coordinatorlayout_coordinatorlayout_1_0_0_aar.xml +16 -0
  41. package/android/.idea/libraries/Gradle__androidx_core_core_1_3_1_aar.xml +16 -0
  42. package/android/.idea/libraries/Gradle__androidx_cursoradapter_cursoradapter_1_0_0_aar.xml +13 -0
  43. package/android/.idea/libraries/Gradle__androidx_customview_customview_1_0_0_aar.xml +13 -0
  44. package/android/.idea/libraries/Gradle__androidx_documentfile_documentfile_1_0_0_aar.xml +13 -0
  45. package/android/.idea/libraries/Gradle__androidx_drawerlayout_drawerlayout_1_0_0_aar.xml +16 -0
  46. package/android/.idea/libraries/Gradle__androidx_fragment_fragment_1_1_0_aar.xml +16 -0
  47. package/android/.idea/libraries/Gradle__androidx_interpolator_interpolator_1_0_0_aar.xml +13 -0
  48. package/android/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_ui_1_0_0_aar.xml +13 -0
  49. package/android/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_utils_1_0_0_aar.xml +13 -0
  50. package/android/.idea/libraries/Gradle__androidx_legacy_legacy_support_v4_1_0_0_aar.xml +13 -0
  51. package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_common_2_1_0.xml +11 -0
  52. package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_2_1_0_aar.xml +13 -0
  53. package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_2_1_0_aar.xml +13 -0
  54. package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_2_1_0_aar.xml +13 -0
  55. package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_2_1_0_aar.xml +13 -0
  56. package/android/.idea/libraries/Gradle__androidx_loader_loader_1_0_0_aar.xml +13 -0
  57. package/android/.idea/libraries/Gradle__androidx_localbroadcastmanager_localbroadcastmanager_1_0_0_aar.xml +13 -0
  58. package/android/.idea/libraries/Gradle__androidx_media_media_1_0_0_aar.xml +16 -0
  59. package/android/.idea/libraries/Gradle__androidx_print_print_1_0_0_aar.xml +16 -0
  60. package/android/.idea/libraries/Gradle__androidx_recyclerview_recyclerview_1_0_0_aar.xml +16 -0
  61. package/android/.idea/libraries/Gradle__androidx_savedstate_savedstate_1_0_0_aar.xml +13 -0
  62. package/android/.idea/libraries/Gradle__androidx_slidingpanelayout_slidingpanelayout_1_0_0_aar.xml +13 -0
  63. package/android/.idea/libraries/Gradle__androidx_swiperefreshlayout_swiperefreshlayout_1_0_0_aar.xml +16 -0
  64. package/android/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_1_1_0_aar.xml +13 -0
  65. package/android/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_animated_1_1_0_aar.xml +13 -0
  66. package/android/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_0_aar.xml +13 -0
  67. package/android/.idea/libraries/Gradle__androidx_viewpager_viewpager_1_0_0_aar.xml +13 -0
  68. package/android/.idea/libraries/Gradle__com_caverock_androidsvg_aar_1_4_aar.xml +15 -0
  69. package/android/.idea/libraries/Gradle__com_facebook_fresco_drawee_0_8_1_aar.xml +15 -0
  70. package/android/.idea/libraries/Gradle__com_facebook_fresco_fbcore_0_8_1_aar.xml +15 -0
  71. package/android/.idea/libraries/Gradle__com_facebook_fresco_fresco_0_8_1_aar.xml +15 -0
  72. package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_0_8_1_aar.xml +16 -0
  73. package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_okhttp_0_8_1_aar.xml +15 -0
  74. package/android/.idea/libraries/Gradle__com_facebook_react_react_native_0_20_1_aar.xml +19 -0
  75. package/android/.idea/libraries/Gradle__com_facebook_stetho_stetho_1_2_0.xml +13 -0
  76. package/android/.idea/libraries/Gradle__com_facebook_stetho_stetho_okhttp_1_2_0.xml +13 -0
  77. package/android/.idea/libraries/Gradle__com_fasterxml_jackson_core_jackson_core_2_2_3.xml +13 -0
  78. package/android/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_3_0_0.xml +13 -0
  79. package/android/.idea/libraries/Gradle__com_googlecode_json_simple_json_simple_1_1_1.xml +13 -0
  80. package/android/.idea/libraries/Gradle__com_innov8tif_okaycam_OkayCam_1_1_10_aar.xml +15 -0
  81. package/android/.idea/libraries/Gradle__com_nineoldandroids_library_2_4_0.xml +13 -0
  82. package/android/.idea/libraries/Gradle__com_parse_bolts_bolts_android_1_1_4.xml +13 -0
  83. package/android/.idea/libraries/Gradle__com_squareup_okhttp_okhttp_2_5_0.xml +13 -0
  84. package/android/.idea/libraries/Gradle__com_squareup_okhttp_okhttp_ws_2_5_0.xml +13 -0
  85. package/android/.idea/libraries/Gradle__com_squareup_okio_okio_1_6_0.xml +13 -0
  86. package/android/.idea/libraries/Gradle__commons_cli_commons_cli_1_2.xml +13 -0
  87. package/android/.idea/libraries/Gradle__junit_junit_4_10.xml +13 -0
  88. package/android/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_1.xml +11 -0
  89. package/android/.idea/libraries/Gradle__org_jetbrains_annotations_13_0.xml +13 -0
  90. package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_4_21.xml +13 -0
  91. package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_4_21.xml +13 -0
  92. package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk7_1_4_21.xml +13 -0
  93. package/android/.idea/libraries/Gradle__org_webkit_android_jsc_r174650_aar.xml +11 -0
  94. package/android/.idea/misc.xml +1 -1
  95. package/android/.idea/modules/android.iml +93 -6
  96. package/android/build/generated/source/buildConfig/debug/com/innov8tif/RNOkayCam/BuildConfig.java +12 -0
  97. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +11 -0
  98. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output.json +27 -0
  99. package/android/build/intermediates/aar_main_jar/debug/classes.jar +0 -0
  100. package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +1 -0
  101. package/android/build/intermediates/annotations_typedef_file/debug/typedefs.txt +0 -0
  102. package/android/build/intermediates/compile_only_not_namespaced_r_class_jar/debug/R.jar +0 -0
  103. package/android/build/intermediates/compile_symbol_list/debug/R.txt +3230 -0
  104. package/android/build/intermediates/incremental/debug-mergeJavaRes/merge-state +0 -0
  105. package/android/build/intermediates/incremental/debug-mergeNativeLibs/merge-state +0 -0
  106. package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +2 -0
  107. package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +2 -0
  108. package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +2 -0
  109. package/android/build/intermediates/incremental/packageDebugResources/compile-file-map.properties +1 -0
  110. package/android/build/intermediates/incremental/packageDebugResources/merger.xml +2 -0
  111. package/android/build/intermediates/javac/debug/classes/com/innov8tif/RNOkayCam/BuildConfig.class +0 -0
  112. package/android/build/intermediates/javac/debug/classes/com/innov8tif/RNOkayCam/RNOkayCamModule.class +0 -0
  113. package/android/build/intermediates/javac/debug/classes/com/innov8tif/RNOkayCam/RNOkayCamPackage.class +0 -0
  114. package/android/build/intermediates/library_manifest/debug/AndroidManifest.xml +11 -0
  115. package/android/build/intermediates/local_only_symbol_list/debug/R-def.txt +2 -0
  116. package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +13 -0
  117. package/android/build/intermediates/merged_java_res/debug/out.jar +0 -0
  118. package/android/build/intermediates/merged_manifests/debug/output.json +27 -0
  119. package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +2248 -0
  120. package/android/build/outputs/aar/android-debug.aar +0 -0
  121. package/android/build/outputs/logs/manifest-merger-debug-report.txt +37 -0
  122. package/android/build/tmp/compileDebugJavaWithJavac/source-classes-mapping.txt +6 -0
  123. package/android/build.gradle +13 -5
  124. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  125. package/android/gradle/wrapper/gradle-wrapper.properties +6 -0
  126. package/android/gradle.properties +2 -0
  127. package/android/gradlew +185 -0
  128. package/android/gradlew.bat +89 -0
  129. package/android/src/main/java/com/innov8tif/RNOkayCam/RNOkayCamModule.java +453 -246
  130. package/index.ts +226 -151
  131. package/ios/RNOkayCam.swift +83 -0
  132. package/ios/RNOkayCam.xcodeproj/project.pbxproj +55 -2
  133. package/ios/RNOkayCam.xcodeproj/xcuserdata/thet.xcuserdatad/xcschemes/xcschememanagement.plist +1 -1
  134. package/ios/RNOkayCam.xcworkspace/contents.xcworkspacedata +3 -0
  135. package/ios/RNOkayCam.xcworkspace/xcuserdata/thet.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  136. package/package.json +1 -1
  137. package/react-native-okaycam.podspec +1 -1
  138. package/android/.idea/workspace.xml +0 -44
package/index.ts CHANGED
@@ -1,204 +1,279 @@
1
- import { NativeModules, Dimensions, PixelRatio, Image, ImageResolvedAssetSource, Platform } from 'react-native';
1
+ import {
2
+ NativeModules,
3
+ Dimensions,
4
+ PixelRatio,
5
+ Image,
6
+ ImageResolvedAssetSource,
7
+ Platform,
8
+ } from "react-native";
2
9
 
3
10
  const { RNOkayCam } = NativeModules;
4
11
 
5
- const screenWidth = Dimensions.get("screen").width
12
+ const screenWidth = Dimensions.get("screen").width;
6
13
 
7
14
  interface LabelConfig {
8
- text: string,
9
- color: string,
10
- size: number
15
+ text: string;
16
+ color: string;
17
+ size: number;
18
+ }
19
+
20
+ interface OkayCamPreviewConfig {
21
+ title: LabelConfig;
22
+ refImage: ImageResolvedAssetSource;
23
+ instruction1: LabelConfig;
24
+ instruction2: LabelConfig;
25
+ instruction3: LabelConfig;
26
+ backgroundColor: string;
27
+ }
28
+
29
+ interface OkaycamInstructionRefImg {
30
+ title: LabelConfig;
31
+ img: ImageResolvedAssetSource;
32
+ }
33
+ interface OkayCamInstruction {
34
+ title: LabelConfig;
35
+ refImage1: OkaycamInstructionRefImg;
36
+ refImage2?: OkaycamInstructionRefImg;
11
37
  }
12
38
 
13
39
  interface FrameSize {
14
- width: number,
15
- height: number
40
+ width: number;
41
+ height: number;
16
42
  }
17
43
 
18
44
  interface Frame {
19
- size: FrameSize,
20
- color: string,
21
- content: ImageResolvedAssetSource
45
+ size: FrameSize;
46
+ color: string;
47
+ content: ImageResolvedAssetSource;
22
48
  }
23
49
 
24
50
  interface TimerConfig {
25
- backgroundColor: string,
26
- textColor: string
51
+ backgroundColor: string;
52
+ textColor: string;
27
53
  }
28
54
 
29
55
  interface OkayCamBtnConfig {
30
- backgroundColor: string,
31
- contentColor: string
56
+ backgroundColor: string;
57
+ contentColor: string;
32
58
  }
33
59
 
34
60
  interface CaptureConfig {
35
- delay: number,
36
- onFlash: Boolean,
37
- outputPath?: string
61
+ delay: number;
62
+ onFlash: Boolean;
63
+ outputPath?: string;
38
64
  }
39
65
 
40
66
  interface SwitchBtnConfig {
41
- color: string,
42
- show: Boolean
67
+ color: string;
68
+ show: Boolean;
43
69
  }
44
70
 
45
- type cameraFacingType = "front" | "back"
71
+ type cameraFacingType = "front" | "back";
46
72
 
47
73
  // Set default values
48
- const defaultColor = "#ffffff"
49
- const defaultColor2 = "#ffa500"
50
- const imageResizedWidth = -1
74
+ const defaultColor = "#ffffff";
75
+ const defaultColor2 = "#ffa500";
76
+ const imageResizedWidth = -1;
51
77
 
52
78
  const labelConfig: LabelConfig = {
53
- text: "",
54
- color: defaultColor,
55
- size: 20
56
- }
79
+ text: "",
80
+ color: defaultColor,
81
+ size: 20,
82
+ };
57
83
 
58
84
  const defaultFrame: Frame = {
59
- size: {
60
- width: screenWidth * 0.9,
61
- height: screenWidth * 54 / 85
62
- },
63
- color: defaultColor,
64
- content: null
65
- }
85
+ size: {
86
+ width: screenWidth * 0.9,
87
+ height: (screenWidth * 54) / 85,
88
+ },
89
+ color: defaultColor,
90
+ content: null,
91
+ };
66
92
 
67
93
  const timerConfig: TimerConfig = {
68
- backgroundColor: defaultColor2,
69
- textColor: defaultColor
70
- }
94
+ backgroundColor: defaultColor2,
95
+ textColor: defaultColor,
96
+ };
71
97
 
72
98
  const okayCamBtnConfig: OkayCamBtnConfig = {
73
- backgroundColor: defaultColor2,
74
- contentColor: defaultColor
75
- }
99
+ backgroundColor: defaultColor2,
100
+ contentColor: defaultColor,
101
+ };
76
102
 
77
- const defaultCaptureBtnColor: string = defaultColor
103
+ const defaultCaptureBtnColor: string = defaultColor;
78
104
 
79
105
  const captureConfigFirst: CaptureConfig = {
80
- delay: 0,
81
- onFlash: false,
82
- outputPath: null
83
- }
106
+ delay: 0,
107
+ onFlash: false,
108
+ outputPath: null,
109
+ };
110
+
111
+ const defaultPreview: OkayCamPreviewConfig = null;
84
112
 
85
- const captureConfigSecond: CaptureConfig = null
113
+ const defaultInstruction: OkayCamInstruction = null;
114
+
115
+ const captureConfigSecond: CaptureConfig = null;
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
+ };
86
147
 
87
148
  // cal native capture document
88
149
  export const captureDocument = (
89
- license: string,
90
- base64: Boolean,
91
- {
92
- showOverlay = true,
93
- topLabel = labelConfig,
94
- bottomLabel = labelConfig,
95
- frame = defaultFrame,
96
- timer = timerConfig,
97
- torchBtnEnabled = false,
98
- confirmBtnConfig = okayCamBtnConfig,
99
- retakeBtnConfig = okayCamBtnConfig,
100
- captureBtnColor = defaultCaptureBtnColor,
101
- firstPhotoConfig = captureConfigFirst,
102
- secondPhotoConfig = captureConfigSecond,
103
- crop = false,
104
- width = imageResizedWidth,
105
- imageQuality = 1.0
106
- }
150
+ license: string,
151
+ base64: Boolean,
152
+ {
153
+ showOverlay = true,
154
+ topLabel = labelConfig,
155
+ bottomLabel = labelConfig,
156
+ frame = defaultFrame,
157
+ timer = timerConfig,
158
+ torchBtnEnabled = false,
159
+ confirmBtnConfig = okayCamBtnConfig,
160
+ retakeBtnConfig = okayCamBtnConfig,
161
+ captureBtnColor = defaultCaptureBtnColor,
162
+ firstPhotoConfig = captureConfigFirst,
163
+ secondPhotoConfig = captureConfigSecond,
164
+ crop = false,
165
+ width = imageResizedWidth,
166
+ imageQuality = 1.0,
167
+ preview = defaultPreview,
168
+ instruction = defaultInstruction,
169
+ }
107
170
  ) => {
171
+ if (frame.size == undefined) {
172
+ frame.size = defaultFrame.size;
173
+ }
174
+
175
+ const resultedPreview =
176
+ preview == null
177
+ ? null
178
+ : {
179
+ ...preview,
180
+ refImage: Image.resolveAssetSource(preview.refImage).uri,
181
+ };
108
182
 
109
- if (frame.size == undefined) {
110
- frame.size = defaultFrame.size
111
- }
112
-
113
- return new Promise(function (resolve, reject) {
114
- RNOkayCam.captureDocument({
115
- license: license,
116
- base64: base64,
117
- config: {
118
- showOverlay: showOverlay,
119
- topLabel: topLabel,
120
- bottomLabel: bottomLabel,
121
- frame: {
122
- size: Platform.select({
123
- android: {
124
- width: PixelRatio.getPixelSizeForLayoutSize(frame.size.width),
125
- height: PixelRatio.getPixelSizeForLayoutSize(frame.size.height)
126
- },
127
- ios: {
128
- width: frame.size.width,
129
- height: frame.size.height
130
- }
131
- }),
132
- color: frame.color != null ? frame.color : defaultFrame.color,
133
- content: frame.content != null ? Image.resolveAssetSource(frame.content).uri : null
134
- },
135
- timer: timer,
136
- torchBtnEnabled: torchBtnEnabled,
137
- confirmBtnConfig: confirmBtnConfig,
138
- retakeBtnConfig: retakeBtnConfig,
139
- captureBtnColor: captureBtnColor,
140
- captureConfigPair: {
141
- firstPhoto: firstPhotoConfig,
142
- secondPhoto: secondPhotoConfig
143
- },
144
- crop: crop,
145
- width: width,
146
- imageQuality: imageQuality
147
- }
148
- })
149
- .then(result => {
150
- resolve(JSON.parse(result))
151
- })
152
- .catch(error => {
153
- reject(error)
154
- })
183
+ return new Promise(function (resolve, reject) {
184
+ RNOkayCam.captureDocument({
185
+ license: license,
186
+ base64: base64,
187
+ config: {
188
+ showOverlay: showOverlay,
189
+ topLabel: topLabel,
190
+ bottomLabel: bottomLabel,
191
+ frame: {
192
+ size: Platform.select({
193
+ android: {
194
+ width: PixelRatio.getPixelSizeForLayoutSize(frame.size.width),
195
+ height: PixelRatio.getPixelSizeForLayoutSize(frame.size.height),
196
+ },
197
+ ios: {
198
+ width: frame.size.width,
199
+ height: frame.size.height,
200
+ },
201
+ }),
202
+ color: frame.color != null ? frame.color : defaultFrame.color,
203
+ content:
204
+ frame.content != null
205
+ ? Image.resolveAssetSource(frame.content).uri
206
+ : null,
207
+ },
208
+ timer: timer,
209
+ torchBtnEnabled: torchBtnEnabled,
210
+ confirmBtnConfig: confirmBtnConfig,
211
+ retakeBtnConfig: retakeBtnConfig,
212
+ captureBtnColor: captureBtnColor,
213
+ captureConfigPair: {
214
+ firstPhoto: firstPhotoConfig,
215
+ secondPhoto: secondPhotoConfig,
216
+ },
217
+ crop: crop,
218
+ width: width,
219
+ imageQuality: imageQuality,
220
+ preview: resultedPreview,
221
+ instruction: formatInstruction(instruction),
222
+ },
155
223
  })
156
- }
224
+ .then((result) => {
225
+ resolve(JSON.parse(result));
226
+ })
227
+ .catch((error) => {
228
+ reject(error);
229
+ });
230
+ });
231
+ };
157
232
 
158
233
  const defaultSwitchBtnConfig: SwitchBtnConfig = {
159
- show: true,
160
- color: defaultColor
161
- }
234
+ show: true,
235
+ color: defaultColor,
236
+ };
162
237
 
163
- const cameraFacing: cameraFacingType = 'front'
238
+ const cameraFacing: cameraFacingType = "front";
164
239
 
165
240
  // call native capture selfie
166
241
  export const captureSelfie = (
167
- license: string,
168
- base64: Boolean,
169
- {
170
- topLabel = labelConfig,
171
- bottomFrameColor = defaultColor2,
172
- captureBtnColor = defaultColor,
173
- switchBtnConfig = defaultSwitchBtnConfig,
174
- confirmBtnConfig = okayCamBtnConfig,
175
- retakeBtnConfig = okayCamBtnConfig,
176
- defaultCameraFacing = cameraFacing,
177
- width = imageResizedWidth,
178
- imageQuality = 1.0
179
- }
242
+ license: string,
243
+ base64: Boolean,
244
+ {
245
+ topLabel = labelConfig,
246
+ bottomFrameColor = defaultColor2,
247
+ captureBtnColor = defaultColor,
248
+ switchBtnConfig = defaultSwitchBtnConfig,
249
+ confirmBtnConfig = okayCamBtnConfig,
250
+ retakeBtnConfig = okayCamBtnConfig,
251
+ defaultCameraFacing = cameraFacing,
252
+ width = imageResizedWidth,
253
+ imageQuality = 1.0,
254
+ }
180
255
  ) => {
181
- return new Promise(function (resolve, reject) {
182
- RNOkayCam.captureSelfie({
183
- license: license,
184
- base64: base64,
185
- config: {
186
- topLabel: topLabel,
187
- bottomFrameColor: bottomFrameColor,
188
- captureBtnColor: captureBtnColor,
189
- switchBtnConfig: switchBtnConfig,
190
- confirmBtnConfig: confirmBtnConfig,
191
- retakeBtnConfig: retakeBtnConfig,
192
- defaultCameraFacing: defaultCameraFacing,
193
- width: width,
194
- imageQuality: imageQuality
195
- }
196
- })
197
- .then(result => {
198
- resolve(JSON.parse(result))
199
- })
200
- .catch(error => {
201
- reject(error)
202
- })
256
+ return new Promise(function (resolve, reject) {
257
+ RNOkayCam.captureSelfie({
258
+ license: license,
259
+ base64: base64,
260
+ config: {
261
+ topLabel: topLabel,
262
+ bottomFrameColor: bottomFrameColor,
263
+ captureBtnColor: captureBtnColor,
264
+ switchBtnConfig: switchBtnConfig,
265
+ confirmBtnConfig: confirmBtnConfig,
266
+ retakeBtnConfig: retakeBtnConfig,
267
+ defaultCameraFacing: defaultCameraFacing,
268
+ width: width,
269
+ imageQuality: imageQuality,
270
+ },
203
271
  })
204
- }
272
+ .then((result) => {
273
+ resolve(JSON.parse(result));
274
+ })
275
+ .catch((error) => {
276
+ reject(error);
277
+ });
278
+ });
279
+ };
@@ -122,6 +122,16 @@ class RNOkayCam: NSObject {
122
122
  okayCamConfig.width = width
123
123
  }
124
124
 
125
+ // preview config
126
+
127
+ let previewConfig = rnOkayCamConfig.object(forKey: "preview") as? NSDictionary
128
+
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)
134
+
125
135
  // start the SDK
126
136
  OkayCamDoc.start(
127
137
  okayCamConfig: okayCamConfig,
@@ -143,6 +153,14 @@ class RNOkayCam: NSObject {
143
153
  if (filePaths!.count > 1) {
144
154
  okayCamObject.setValue(self.convertImgToBase64(base64: base64, image: urls[1]), forKey: "fullDocumentImage2")
145
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
+ }
146
164
 
147
165
  let jsonData = try JSONSerialization.data(withJSONObject: okayCamObject, options: .prettyPrinted)
148
166
  let jsonString = String(data: jsonData, encoding: String.Encoding.ascii)!
@@ -158,6 +176,71 @@ class RNOkayCam: NSObject {
158
176
  }
159
177
  }
160
178
 
179
+ func getOkaycamPreview(previewConfig: NSDictionary?) -> OkayCamPreviewConfig?{
180
+ if previewConfig == nil { return nil}
181
+
182
+
183
+ let title = configToOkayCamLabel(config: previewConfig?.object(forKey: "title") as! NSDictionary)
184
+
185
+ let instr1 = configToOkayCamLabel(config: previewConfig?.object(forKey: "instruction1") as! NSDictionary)
186
+
187
+ let instr2 = configToOkayCamLabel(config: previewConfig?.object(forKey: "instruction2") as! NSDictionary)
188
+
189
+ let instr3 = configToOkayCamLabel(config: previewConfig?.object(forKey: "instruction3") as! NSDictionary)
190
+
191
+ let bgColor = self.hexStringToUIColor(hex: previewConfig?.object(forKey: "backgroundColor") as! String)
192
+
193
+ // frame contet
194
+ let ref = previewConfig?.object(forKey: "refImage") as? String
195
+ var refUrl:URL? = nil
196
+ if (ref != nil) {
197
+ #if DEBUG
198
+ refUrl = URL(string: ref!)!
199
+ #else
200
+ refUrl = URL(fileURLWithPath: ref!.replacingOccurrences(of: "file:///", with: ""))
201
+ #endif
202
+ }
203
+
204
+ return OkayCamPreviewConfig(title: title, refImage: refUrl!, instruction1: instr1, instruction2: instr2, instruction3: instr3, backgroundColor: bgColor)
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
+ }
236
+
237
+ func configToOkayCamLabel(config:NSDictionary) -> OkayCamLabelConfig{
238
+ let text = config.object(forKey: "text") as! String
239
+ let color = self.hexStringToUIColor(hex: config.object(forKey: "color") as! String)
240
+ let size = CGFloat(config.object(forKey: "size") as! Int)
241
+ return OkayCamLabelConfig(text: text, color: color, size: size)
242
+ }
243
+
161
244
  @objc func captureSelfie(_ configs: NSDictionary, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
162
245
 
163
246
  let license = configs.object(forKey: "license")! as! String
@@ -9,6 +9,7 @@
9
9
  /* Begin PBXBuildFile section */
10
10
  4D47E5C025C083810038D7EC /* RNOkayCam.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D47E5BF25C083810038D7EC /* RNOkayCam.swift */; };
11
11
  B3E7B58A1CC2AC0600A0062D /* RNOkayCam.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* RNOkayCam.m */; };
12
+ DB20EA94C7207FA4A153737A /* Pods_RNOkayCam.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FF8168FCF180DE99D3443D56 /* Pods_RNOkayCam.framework */; };
12
13
  /* End PBXBuildFile section */
13
14
 
14
15
  /* Begin PBXCopyFilesBuildPhase section */
@@ -28,6 +29,9 @@
28
29
  4D47E5BD25C083530038D7EC /* RNOkayCam-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RNOkayCam-Bridging-Header.h"; sourceTree = "<group>"; };
29
30
  4D47E5BF25C083810038D7EC /* RNOkayCam.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RNOkayCam.swift; sourceTree = "<group>"; };
30
31
  B3E7B5891CC2AC0600A0062D /* RNOkayCam.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNOkayCam.m; sourceTree = "<group>"; };
32
+ CB6B4CC187A245DF02C1905A /* Pods-RNOkayCam.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNOkayCam.release.xcconfig"; path = "Target Support Files/Pods-RNOkayCam/Pods-RNOkayCam.release.xcconfig"; sourceTree = "<group>"; };
33
+ FED8765FCB8A0E8CACFC386E /* Pods-RNOkayCam.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNOkayCam.debug.xcconfig"; path = "Target Support Files/Pods-RNOkayCam/Pods-RNOkayCam.debug.xcconfig"; sourceTree = "<group>"; };
34
+ FF8168FCF180DE99D3443D56 /* Pods_RNOkayCam.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RNOkayCam.framework; sourceTree = BUILT_PRODUCTS_DIR; };
31
35
  /* End PBXFileReference section */
32
36
 
33
37
  /* Begin PBXFrameworksBuildPhase section */
@@ -35,12 +39,23 @@
35
39
  isa = PBXFrameworksBuildPhase;
36
40
  buildActionMask = 2147483647;
37
41
  files = (
42
+ DB20EA94C7207FA4A153737A /* Pods_RNOkayCam.framework in Frameworks */,
38
43
  );
39
44
  runOnlyForDeploymentPostprocessing = 0;
40
45
  };
41
46
  /* End PBXFrameworksBuildPhase section */
42
47
 
43
48
  /* Begin PBXGroup section */
49
+ 0968FBA9E90D8EE56660C935 /* Pods */ = {
50
+ isa = PBXGroup;
51
+ children = (
52
+ FED8765FCB8A0E8CACFC386E /* Pods-RNOkayCam.debug.xcconfig */,
53
+ CB6B4CC187A245DF02C1905A /* Pods-RNOkayCam.release.xcconfig */,
54
+ );
55
+ name = Pods;
56
+ path = Pods;
57
+ sourceTree = "<group>";
58
+ };
44
59
  134814211AA4EA7D00B7C361 /* Products */ = {
45
60
  isa = PBXGroup;
46
61
  children = (
@@ -56,7 +71,17 @@
56
71
  4D47E5BF25C083810038D7EC /* RNOkayCam.swift */,
57
72
  134814211AA4EA7D00B7C361 /* Products */,
58
73
  4D47E5BD25C083530038D7EC /* RNOkayCam-Bridging-Header.h */,
74
+ 0968FBA9E90D8EE56660C935 /* Pods */,
75
+ E382AF4271A2883E64F698E0 /* Frameworks */,
76
+ );
77
+ sourceTree = "<group>";
78
+ };
79
+ E382AF4271A2883E64F698E0 /* Frameworks */ = {
80
+ isa = PBXGroup;
81
+ children = (
82
+ FF8168FCF180DE99D3443D56 /* Pods_RNOkayCam.framework */,
59
83
  );
84
+ name = Frameworks;
60
85
  sourceTree = "<group>";
61
86
  };
62
87
  /* End PBXGroup section */
@@ -66,6 +91,7 @@
66
91
  isa = PBXNativeTarget;
67
92
  buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNOkayCam" */;
68
93
  buildPhases = (
94
+ 693E4AB06E794461882BF8F3 /* [CP] Check Pods Manifest.lock */,
69
95
  58B511D71A9E6C8500147676 /* Sources */,
70
96
  58B511D81A9E6C8500147676 /* Frameworks */,
71
97
  58B511D91A9E6C8500147676 /* CopyFiles */,
@@ -112,6 +138,31 @@
112
138
  };
113
139
  /* End PBXProject section */
114
140
 
141
+ /* Begin PBXShellScriptBuildPhase section */
142
+ 693E4AB06E794461882BF8F3 /* [CP] Check Pods Manifest.lock */ = {
143
+ isa = PBXShellScriptBuildPhase;
144
+ buildActionMask = 2147483647;
145
+ files = (
146
+ );
147
+ inputFileListPaths = (
148
+ );
149
+ inputPaths = (
150
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
151
+ "${PODS_ROOT}/Manifest.lock",
152
+ );
153
+ name = "[CP] Check Pods Manifest.lock";
154
+ outputFileListPaths = (
155
+ );
156
+ outputPaths = (
157
+ "$(DERIVED_FILE_DIR)/Pods-RNOkayCam-checkManifestLockResult.txt",
158
+ );
159
+ runOnlyForDeploymentPostprocessing = 0;
160
+ shellPath = /bin/sh;
161
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
162
+ showEnvVarsInLog = 0;
163
+ };
164
+ /* End PBXShellScriptBuildPhase section */
165
+
115
166
  /* Begin PBXSourcesBuildPhase section */
116
167
  58B511D71A9E6C8500147676 /* Sources */ = {
117
168
  isa = PBXSourcesBuildPhase;
@@ -162,7 +213,7 @@
162
213
  GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
163
214
  GCC_WARN_UNUSED_FUNCTION = YES;
164
215
  GCC_WARN_UNUSED_VARIABLE = YES;
165
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
216
+ IPHONEOS_DEPLOYMENT_TARGET = 9.0;
166
217
  MTL_ENABLE_DEBUG_INFO = YES;
167
218
  ONLY_ACTIVE_ARCH = YES;
168
219
  SDKROOT = iphoneos;
@@ -199,7 +250,7 @@
199
250
  GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
200
251
  GCC_WARN_UNUSED_FUNCTION = YES;
201
252
  GCC_WARN_UNUSED_VARIABLE = YES;
202
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
253
+ IPHONEOS_DEPLOYMENT_TARGET = 9.0;
203
254
  MTL_ENABLE_DEBUG_INFO = NO;
204
255
  SDKROOT = iphoneos;
205
256
  VALIDATE_PRODUCT = YES;
@@ -208,6 +259,7 @@
208
259
  };
209
260
  58B511F01A9E6C8500147676 /* Debug */ = {
210
261
  isa = XCBuildConfiguration;
262
+ baseConfigurationReference = FED8765FCB8A0E8CACFC386E /* Pods-RNOkayCam.debug.xcconfig */;
211
263
  buildSettings = {
212
264
  CLANG_ENABLE_MODULES = YES;
213
265
  HEADER_SEARCH_PATHS = (
@@ -229,6 +281,7 @@
229
281
  };
230
282
  58B511F11A9E6C8500147676 /* Release */ = {
231
283
  isa = XCBuildConfiguration;
284
+ baseConfigurationReference = CB6B4CC187A245DF02C1905A /* Pods-RNOkayCam.release.xcconfig */;
232
285
  buildSettings = {
233
286
  CLANG_ENABLE_MODULES = YES;
234
287
  HEADER_SEARCH_PATHS = (
@@ -7,7 +7,7 @@
7
7
  <key>RNOkayCam.xcscheme_^#shared#^_</key>
8
8
  <dict>
9
9
  <key>orderHint</key>
10
- <integer>0</integer>
10
+ <integer>3</integer>
11
11
  </dict>
12
12
  </dict>
13
13
  </dict>
@@ -4,4 +4,7 @@
4
4
  <FileRef
5
5
  location = "group:RNOkayCam.xcodeproj">
6
6
  </FileRef>
7
+ <FileRef
8
+ location = "group:Pods/Pods.xcodeproj">
9
+ </FileRef>
7
10
  </Workspace>