@regulaforensics/document-reader 8.2.186-beta → 8.3.242-beta
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/RNDocumentReader.podspec +2 -2
- package/android/build.gradle +1 -1
- package/android/cordova.gradle +1 -1
- package/android/src/main/java/com/regula/plugin/documentreader/Config.kt +4 -0
- package/android/src/main/java/com/regula/plugin/documentreader/Main.kt +6 -0
- package/examples/capacitor/README.md +10 -0
- package/examples/capacitor/index.html +2 -7
- package/examples/capacitor/index.tsx +39 -0
- package/examples/capacitor/package.json +3 -3
- package/examples/capacitor/scripts/setup.sh +4 -0
- package/examples/capacitor/src/extra/bt_device.tsx +7 -6
- package/examples/capacitor/src/extra/custom_rfid.tsx +29 -42
- package/examples/capacitor/src/main.css +4 -1
- package/examples/capacitor/src/main.html +1 -4
- package/examples/capacitor/src/main.tsx +85 -86
- package/examples/cordova/README.md +10 -0
- package/examples/cordova/config.xml +6 -2
- package/examples/cordova/package-lock.json +459 -1
- package/examples/cordova/package.json +5 -4
- package/examples/cordova/scripts/bundle.sh +4 -0
- package/examples/cordova/www/bootstrap.js +30 -0
- package/examples/cordova/www/images/portrait.png +0 -0
- package/examples/cordova/www/index.html +2 -17
- package/examples/cordova/www/index.js +30 -0
- package/examples/cordova/www/src/extra/bt_device.js +32 -0
- package/examples/cordova/www/src/extra/custom_rfid.js +60 -0
- package/examples/cordova/www/src/main.css +11 -7
- package/examples/cordova/www/src/main.html +7 -32
- package/examples/cordova/www/src/main.js +154 -31
- package/examples/ionic/README.md +10 -0
- package/examples/ionic/config.xml +11 -4
- package/examples/ionic/index.ts +41 -4
- package/examples/ionic/package-lock.json +1862 -1638
- package/examples/ionic/package.json +3 -6
- package/examples/ionic/src/extra/bt_device.ts +33 -0
- package/examples/ionic/src/extra/custom_rfid.ts +61 -0
- package/examples/ionic/src/images/portrait.png +0 -0
- package/examples/ionic/src/main.css +11 -7
- package/examples/ionic/src/main.html +36 -61
- package/examples/ionic/src/main.ts +158 -50
- package/examples/react_native/README.md +10 -0
- package/examples/react_native/app.config.ts +3 -1
- package/examples/react_native/images/portrait.png +0 -0
- package/examples/react_native/index.tsx +34 -6
- package/examples/react_native/package-lock.json +476 -421
- package/examples/react_native/package.json +10 -10
- package/examples/react_native/src/extra/bt_device.tsx +34 -0
- package/examples/react_native/src/extra/custom_rfid.tsx +62 -0
- package/examples/react_native/src/main.css +11 -7
- package/examples/react_native/src/main.html +7 -32
- package/examples/react_native/src/main.tsx +152 -27
- package/ios/RGLWConfig.m +4 -0
- package/ios/RGLWMain.m +10 -0
- package/package.json +1 -1
- package/plugin.xml +2 -2
- package/www/capacitor/index.js +32 -16
- package/www/capacitor/params/customization/Customization.js +7 -0
- package/www/capacitor/params/process_params/ProcessParams.js +7 -0
- package/www/capacitor/results/visual_results/FieldType.js +3 -1
- package/www/cordova.js +49 -17
- package/www/react-native/index.js +32 -16
- package/www/react-native/internal/bridge.js +1 -1
- package/www/react-native/params/customization/Customization.js +7 -0
- package/www/react-native/params/process_params/ProcessParams.js +7 -0
- package/www/react-native/results/visual_results/FieldType.js +3 -1
- package/www/types/index.d.ts +14 -8
- package/www/types/params/customization/Customization.d.ts +5 -0
- package/www/types/params/process_params/ProcessParams.d.ts +4 -0
- package/www/types/results/visual_results/FieldType.d.ts +5 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
html,
|
|
2
2
|
body {
|
|
3
|
-
|
|
3
|
+
margin: 0;
|
|
4
|
+
width: 100%;
|
|
4
5
|
height: 99vh;
|
|
5
6
|
display: flex;
|
|
7
|
+
overflow: hidden;
|
|
6
8
|
flex-direction: column;
|
|
7
9
|
}
|
|
8
10
|
|
|
@@ -59,6 +61,7 @@ body {
|
|
|
59
61
|
color: white;
|
|
60
62
|
border: none;
|
|
61
63
|
padding: 10px 20px;
|
|
64
|
+
justify-content: center;
|
|
62
65
|
font-size: 16px;
|
|
63
66
|
border-radius: 100px;
|
|
64
67
|
cursor: pointer;
|
|
@@ -88,10 +91,12 @@ body {
|
|
|
88
91
|
top: 1px;
|
|
89
92
|
}
|
|
90
93
|
|
|
94
|
+
.radio {
|
|
95
|
+
align-items: baseline;
|
|
96
|
+
padding: 15px;
|
|
97
|
+
}
|
|
98
|
+
|
|
91
99
|
input[type="checkbox"] {
|
|
92
|
-
appearance: none;
|
|
93
|
-
-webkit-appearance: none;
|
|
94
|
-
-moz-appearance: none;
|
|
95
100
|
width: 20px;
|
|
96
101
|
height: 20px;
|
|
97
102
|
border: 2px solid black;
|
|
@@ -121,10 +126,9 @@ input[type="text"] {
|
|
|
121
126
|
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
|
|
122
127
|
}
|
|
123
128
|
|
|
124
|
-
|
|
129
|
+
#progress {
|
|
125
130
|
width: 0%;
|
|
126
131
|
height: 20px;
|
|
127
132
|
background-color: #4285F4;
|
|
128
133
|
border-radius: 5px;
|
|
129
|
-
|
|
130
|
-
}
|
|
134
|
+
}
|
|
@@ -7,50 +7,25 @@
|
|
|
7
7
|
<div class="row">
|
|
8
8
|
<div class="column" style="padding: 5px;">
|
|
9
9
|
<p>Portrait</p>
|
|
10
|
-
<img id="portrait-image" src="images/portrait.png" height="
|
|
10
|
+
<img id="portrait-image" src="images/portrait.png" height="160px" width="120px">
|
|
11
11
|
</div>
|
|
12
12
|
<div class="column" style="padding: 5px;">
|
|
13
13
|
<p>Document image</p>
|
|
14
|
-
<img id="document-image" src="images/document.png" height="
|
|
14
|
+
<img id="document-image" src="images/document.png" height="160px" width="200px">
|
|
15
15
|
</div>
|
|
16
16
|
</div>
|
|
17
|
-
<div id="scenario-container" class="column no-scroll"
|
|
18
|
-
|
|
19
|
-
<div id="scenarios" class="scroll">
|
|
20
|
-
<div class="row" style="align-items: baseline; padding: 15px;">
|
|
21
|
-
<input type="radio" name="scenario" value="Aaa">
|
|
22
|
-
<span style="width: 200px; padding-left: 5px;">Aaa</span>
|
|
23
|
-
</div>
|
|
24
|
-
<div class="row" style="align-items: baseline; padding: 15px;">
|
|
25
|
-
<input type="radio" name="scenario" value="Aaa">
|
|
26
|
-
<span style="width: 200px; padding-left: 5px;">Aaa</span>
|
|
27
|
-
</div>
|
|
28
|
-
<div class="row" style="align-items: baseline; padding: 15px;">
|
|
29
|
-
<input type="radio" name="scenario" value="Aaa">
|
|
30
|
-
<span style="width: 200px; padding-left: 5px;">Aaa</span>
|
|
31
|
-
</div>
|
|
32
|
-
<div class="row" style="align-items: baseline; padding: 15px;">
|
|
33
|
-
<input type="radio" name="scenario" value="Aaa">
|
|
34
|
-
<span style="width: 200px; padding-left: 5px;">Aaa</span>
|
|
35
|
-
</div>
|
|
36
|
-
<div class="row" style="align-items: baseline; padding: 15px;">
|
|
37
|
-
<input type="radio" name="scenario" value="Aaa">
|
|
38
|
-
<span style="width: 200px; padding-left: 5px;">Aaa</span>
|
|
39
|
-
</div>
|
|
40
|
-
</div>
|
|
17
|
+
<div id="scenario-container" class="column no-scroll" style="margin-top: 15px; background-color: rgba(0, 0, 0, 0.03);">
|
|
18
|
+
<div id="scenarios" class="scroll"></div>
|
|
41
19
|
</div>
|
|
42
20
|
<div class="row" style="width: 360px; padding-top: 15px;">
|
|
43
|
-
<span id="rfid-checkbox-description" style="font-size: 18px;">Process rfid reading</span>
|
|
44
|
-
<input id="rfid-checkbox" type="checkbox" style="margin-left: auto;" />
|
|
45
|
-
</div>
|
|
46
|
-
<div id="bt-device" class="row" style="display: none;">
|
|
47
|
-
<input type="text" placeholder="Regula 0000" />
|
|
48
|
-
<button class="button">Connect</button>
|
|
21
|
+
<span id="rfid-checkbox-description" style="font-size: 18px;width: 100%;">Process rfid reading(unavailable)</span>
|
|
22
|
+
<input id="rfid-checkbox" type="checkbox" style="margin-left: auto;" disabled />
|
|
49
23
|
</div>
|
|
50
24
|
<div class="row">
|
|
51
25
|
<button id="scan" class="button">Scan document</button>
|
|
52
26
|
<button id="recognize" class="button">Scan image</button>
|
|
53
27
|
</div>
|
|
28
|
+
<button id="connect" class="button" style="width: 360px; display: none;">Connect</button>
|
|
54
29
|
<div style="padding-top: 20px;"></div>
|
|
55
30
|
</div>
|
|
56
31
|
<div id="custom-rfid" class="column no-scroll" style="display: none;">
|
|
@@ -1,50 +1,173 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
InitConfig = DocumentReaderPlugin.InitConfig
|
|
1
|
+
import { loadAsset, pickImage } from '../index.js'
|
|
2
|
+
import { initializeWithBTDevice, setupBTDevice, useBtDevice } from './extra/bt_device.js'
|
|
3
|
+
import { useRfidSelfHostedUI, rfidSelfHostedUI } from './extra/custom_rfid.js'
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
var documentReader = DocumentReader.instance
|
|
6
|
+
var selectedScenario
|
|
7
|
+
var doRfid = false
|
|
8
|
+
var isReadingRfid = false
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
export async function init() {
|
|
11
|
+
if (!await initialize()) return
|
|
12
|
+
setScenarios(documentReader.availableScenarios)
|
|
13
|
+
setCanRfid(await documentReader.isRFIDAvailableForUse())
|
|
14
|
+
setStatus("Ready")
|
|
15
|
+
}
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
async function scan() {
|
|
18
|
+
if (!await documentReader.isReady()) return
|
|
19
|
+
clearResults()
|
|
20
|
+
documentReader.startScanner(
|
|
21
|
+
ScannerConfig.withScenario(selectedScenario),
|
|
22
|
+
handleCompletion,
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async function recognize() {
|
|
27
|
+
if (!await documentReader.isReady()) return
|
|
28
|
+
var image = await pickImage()
|
|
29
|
+
if (image == null) return
|
|
16
30
|
|
|
17
|
-
|
|
31
|
+
clearResults()
|
|
32
|
+
documentReader.recognize(
|
|
33
|
+
RecognizeConfig.withScenario(selectedScenario, { image: image }),
|
|
34
|
+
handleCompletion,
|
|
35
|
+
)
|
|
18
36
|
}
|
|
19
37
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
38
|
+
export function handleCompletion(action, results, error) {
|
|
39
|
+
handleException(error)
|
|
40
|
+
if (DocReaderAction.stopped(action) && !shouldRfid(results)) {
|
|
41
|
+
displayResults(results)
|
|
42
|
+
} else if (DocReaderAction.finished(action) && shouldRfid(results)) {
|
|
43
|
+
isReadingRfid = true
|
|
44
|
+
readRfid()
|
|
45
|
+
}
|
|
23
46
|
}
|
|
24
47
|
|
|
25
|
-
async function
|
|
48
|
+
export async function displayResults(results) {
|
|
49
|
+
isReadingRfid = false
|
|
50
|
+
clearResults()
|
|
51
|
+
if (results == null) return
|
|
52
|
+
|
|
53
|
+
var name = await results.textFieldValueByType(FieldType.SURNAME_AND_GIVEN_NAMES)
|
|
54
|
+
var docImage = await results.graphicFieldImageByType(GraphicFieldType.DOCUMENT_IMAGE)
|
|
55
|
+
var portrait = await results.graphicFieldImageByType(GraphicFieldType.PORTRAIT)
|
|
56
|
+
portrait = await results.graphicFieldImageByTypeSource(GraphicFieldType.PORTRAIT, ResultType.RFID_IMAGE_DATA) ?? portrait
|
|
57
|
+
|
|
58
|
+
setStatus(name)
|
|
59
|
+
setPortrait(portrait)
|
|
60
|
+
setDocImage(docImage)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
var readRfid = () => {
|
|
64
|
+
documentReader.rfid(new RFIDConfig(handleCompletion))
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function shouldRfid(results) {
|
|
68
|
+
return doRfid &&
|
|
69
|
+
!isReadingRfid &&
|
|
70
|
+
results != null && results.chipPage != 0
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
var initialize = async () => {
|
|
26
74
|
setStatus("Initializing...")
|
|
27
75
|
|
|
28
|
-
var license = await
|
|
76
|
+
var license = await loadAsset("regula.license")
|
|
29
77
|
var initConfig = new InitConfig(license)
|
|
30
78
|
var [success, error] = await documentReader.initialize(initConfig)
|
|
31
|
-
|
|
32
|
-
|
|
79
|
+
|
|
80
|
+
handleException(error)
|
|
81
|
+
return success
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function handleException(error) {
|
|
85
|
+
if (error != null) {
|
|
33
86
|
setStatus(error.message)
|
|
34
87
|
console.log(error.code + ": " + error.message)
|
|
35
88
|
}
|
|
36
|
-
return success
|
|
37
89
|
}
|
|
38
90
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
91
|
+
// --------------------------------------------------------------------------------------------------------------------
|
|
92
|
+
|
|
93
|
+
var documentUIImage
|
|
94
|
+
var portraitUIImage
|
|
95
|
+
export function main() {
|
|
96
|
+
documentUIImage = document.getElementById("document-image")
|
|
97
|
+
portraitUIImage = document.getElementById("portrait-image")
|
|
98
|
+
document.getElementById("scan").onclick = () => scan()
|
|
99
|
+
document.getElementById("recognize").onclick = () => recognize()
|
|
100
|
+
|
|
101
|
+
// custom rfid
|
|
102
|
+
if (useRfidSelfHostedUI) readRfid = () => rfidSelfHostedUI()
|
|
103
|
+
|
|
104
|
+
// bt device
|
|
105
|
+
if (!useBtDevice) init()
|
|
106
|
+
else {
|
|
107
|
+
setupBTDevice()
|
|
108
|
+
initialize = initializeWithBTDevice
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function setStatus(data) {
|
|
113
|
+
if (data != null)
|
|
114
|
+
document.getElementById("status").innerHTML = data
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function setPortrait(data) {
|
|
118
|
+
if (data != null)
|
|
119
|
+
portraitUIImage.src = "data:image/png;base64," + data
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function setDocImage(data) {
|
|
123
|
+
if (data != null)
|
|
124
|
+
documentUIImage.src = "data:image/png;base64," + data
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function clearResults() {
|
|
128
|
+
setStatus("Ready")
|
|
129
|
+
portraitUIImage.src = "images/portrait.png"
|
|
130
|
+
documentUIImage.src = "images/document.png"
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function setCanRfid(data) {
|
|
134
|
+
var checkbox // implicitly any, since cordova sample is pure js
|
|
135
|
+
checkbox = document.getElementById('rfid-checkbox')
|
|
136
|
+
var checkboxDescription = document.getElementById("rfid-checkbox-description")
|
|
137
|
+
if (data) {
|
|
138
|
+
checkbox.disabled = false
|
|
139
|
+
checkboxDescription.innerHTML = "Process rfid reading"
|
|
140
|
+
var onclick = () => {
|
|
141
|
+
doRfid = !doRfid
|
|
142
|
+
checkbox.checked = doRfid
|
|
143
|
+
}
|
|
144
|
+
checkbox.onclick = onclick
|
|
145
|
+
checkboxDescription.onclick = onclick
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function setScenarios(data) {
|
|
150
|
+
selectedScenario = Scenario.MRZ
|
|
151
|
+
var scenariosContainer = document.getElementById("scenarios")
|
|
152
|
+
|
|
153
|
+
data.forEach(scenario => {
|
|
154
|
+
var checked = selectedScenario == scenario.name ? "checked" : ""
|
|
155
|
+
var scenarioElement = `<div class="row radio">
|
|
156
|
+
<input type="radio" name="scenario" id="${scenario.name}" value="${scenario.name}" ${checked}>
|
|
157
|
+
<span id="${scenario.name}-caption" style="width: 200px; padding-left: 5px;">${scenario.caption}</span>
|
|
158
|
+
</div>`
|
|
159
|
+
scenariosContainer.insertAdjacentHTML("beforeend", scenarioElement)
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
data.forEach(scenario => {
|
|
163
|
+
var element
|
|
164
|
+
element = document.getElementById(scenario.name)
|
|
165
|
+
var elementCaption = document.getElementById(scenario.name + "-caption")
|
|
166
|
+
var onclick = () => {
|
|
167
|
+
selectedScenario = scenario.name
|
|
168
|
+
element.checked = true
|
|
169
|
+
}
|
|
170
|
+
element.onclick = onclick
|
|
171
|
+
elementCaption.onclick = onclick
|
|
49
172
|
})
|
|
50
173
|
}
|
package/examples/ionic/README.md
CHANGED
|
@@ -10,3 +10,13 @@
|
|
|
10
10
|
* Android: `npm run android`.
|
|
11
11
|
|
|
12
12
|
**Note**: this is just one way of running the app. You can also pass `-o` or `--open` argument to the command, and this will open Xcode/Android Studio, then run the app directly from the IDE. Overall, this is a more consistent way, so if you're having troubles running the app from terminal, try running it from the IDE.
|
|
13
|
+
|
|
14
|
+
## Additional examples
|
|
15
|
+
|
|
16
|
+
### Bluetooth device
|
|
17
|
+
|
|
18
|
+
In order to connect to an external scanning device, change the `useBtDevice` constant to true in `src/extra/bt_device`, and set `btDeviceName` to the name of you device. After running the app, click `Connect`.
|
|
19
|
+
|
|
20
|
+
### RFID self hosted UI
|
|
21
|
+
|
|
22
|
+
This app also demonstraits how you can implement you own UI for the RFID reading process. To enable it, change the `useRfidSelfHostedUI` constant to true in `src/extra/custom_rfid`. Run the app and initiate RFID reading.
|
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
<?xml version='1.0' encoding='utf-8'?>
|
|
2
|
-
<widget android-packageName="com.regula.dr.fullauthrfid" ios-CFBundleIdentifier="regula.DocumentReader" version="1.0.0"
|
|
2
|
+
<widget android-packageName="com.regula.dr.fullauthrfid" ios-CFBundleIdentifier="regula.DocumentReader" version="1.0.0"
|
|
3
|
+
xmlns:android="http://schemas.android.com/apk/res/android">
|
|
3
4
|
<name>DocumentReader</name>
|
|
4
5
|
<icon src="src/images/icon.png" />
|
|
5
6
|
<platform name="android">
|
|
7
|
+
<resource-file src="src/assets/db.dat" target="app/src/main/assets/Regula/db.dat"/>
|
|
6
8
|
<preference name="orientation" value="portrait" />
|
|
7
|
-
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
|
|
8
|
-
<application android:usesCleartextTraffic="true" />
|
|
9
|
-
</edit-config>
|
|
10
9
|
<preference name="android-minSdkVersion" value="24" />
|
|
11
10
|
<preference name="android-targetSdkVersion" value="35" />
|
|
12
11
|
<preference name="GradlePluginKotlinEnabled" value="true" />
|
|
12
|
+
<config-file parent="/*" target="AndroidManifest.xml">
|
|
13
|
+
<uses-permission android:name="android.permission.NFC" />
|
|
14
|
+
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
|
15
|
+
</config-file>
|
|
16
|
+
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
|
|
17
|
+
<application android:usesCleartextTraffic="true" />
|
|
18
|
+
</edit-config>
|
|
13
19
|
</platform>
|
|
14
20
|
<platform name="ios">
|
|
21
|
+
<resource-file src="src/assets/db.dat" />
|
|
15
22
|
<preference name="orientation" value="portrait" />
|
|
16
23
|
<allow-intent href="itms:*" />
|
|
17
24
|
<allow-intent href="itms-apps:*" />
|
package/examples/ionic/index.ts
CHANGED
|
@@ -2,14 +2,51 @@ import 'zone.js';
|
|
|
2
2
|
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
|
|
3
3
|
import { BrowserModule } from '@angular/platform-browser'
|
|
4
4
|
import { IonicModule, Platform } from '@ionic/angular'
|
|
5
|
-
import { Dialogs } from '@awesome-cordova-plugins/dialogs/ngx'
|
|
6
|
-
import { Camera } from '@awesome-cordova-plugins/camera/ngx'
|
|
7
|
-
import { Main } from './src/main'
|
|
8
5
|
import { NgModule } from '@angular/core'
|
|
9
6
|
|
|
7
|
+
import { Component } from '@angular/core'
|
|
8
|
+
import { File } from '@awesome-cordova-plugins/file'
|
|
9
|
+
import { Camera, DestinationType, MediaType, PictureSourceType } from '@awesome-cordova-plugins/camera/ngx'
|
|
10
|
+
|
|
11
|
+
import { main } from './src/main'
|
|
12
|
+
|
|
13
|
+
export async function loadAsset(path: string): Promise<string> {
|
|
14
|
+
var dir = await File.resolveDirectoryUrl(File.applicationDirectory + "www/assets")
|
|
15
|
+
var fileEntry = await File.getFile(dir, path, null)
|
|
16
|
+
var result = await new Promise<string>((resolve, _) => {
|
|
17
|
+
fileEntry.file(file => {
|
|
18
|
+
var reader = new FileReader()
|
|
19
|
+
reader.onloadend = (_) => resolve(reader.result as string)
|
|
20
|
+
reader.readAsDataURL(file)
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
return result
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export async function pickImage(): Promise<string | null> {
|
|
27
|
+
return await cameraInstance.getPicture({
|
|
28
|
+
destinationType: DestinationType.DATA_URL,
|
|
29
|
+
mediaType: MediaType.PICTURE,
|
|
30
|
+
sourceType: PictureSourceType.PHOTOLIBRARY
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
var cameraInstance: Camera
|
|
35
|
+
@Component({
|
|
36
|
+
selector: 'app-root',
|
|
37
|
+
templateUrl: 'src/main.html',
|
|
38
|
+
styleUrl: 'src/main.css'
|
|
39
|
+
})
|
|
40
|
+
class Main {
|
|
41
|
+
constructor(platform: Platform, camera: Camera) {
|
|
42
|
+
cameraInstance = camera
|
|
43
|
+
platform.ready().then(main)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
10
47
|
@NgModule({
|
|
11
48
|
bootstrap: [Main],
|
|
12
|
-
providers: [Platform,
|
|
49
|
+
providers: [Platform, Camera],
|
|
13
50
|
imports: [BrowserModule, IonicModule.forRoot()]
|
|
14
51
|
})
|
|
15
52
|
class MainModule { }
|