-
Notifications
You must be signed in to change notification settings - Fork 391
Expand file tree
/
Copy pathrnCamera.js
More file actions
44 lines (39 loc) · 1017 Bytes
/
rnCamera.js
File metadata and controls
44 lines (39 loc) · 1017 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { noop, getFocusedNavigation } from '@mpxjs/utils'
export default class CreateCamera {
constructor () {
const navigation = getFocusedNavigation() || {}
this.camera = navigation.camera || {}
}
setZoom (options = {}) {
const { zoom, success = noop, fail = noop, complete = noop } = options
try {
if (this.camera.setZoom) {
const result = { errMsg: 'setZoom:ok' }
success(result)
complete(result)
this.camera.setZoom(zoom)
} else {
const result = {
errMsg: 'setZoom:fail camera instance not found'
}
fail(result)
complete(result)
}
} catch (error) {
const result = {
errMsg: 'setZoom:fail ' + (error?.message || '')
}
fail(result)
complete(result)
}
}
takePhoto (options) {
this.camera?.takePhoto(options)
}
startRecord (options) {
this.camera?.startRecord(options)
}
stopRecord (options) {
this.camera?.stopRecord(options)
}
}