Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/api-proxy/src/platform/api/base/rnCanIUseConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,5 +224,13 @@ export const SUPPORTED_OBJECTS = {
'abort',
'onHeadersReceived',
'offHeadersReceived'
],

// camera
CameraContext: [
'setZoom',
'takePhoto',
'startRecord',
'stopRecord'
]
}
9 changes: 9 additions & 0 deletions packages/api-proxy/src/platform/api/camera/index.ios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import CreateCamera from './rnCamera'

function createCameraContext () {
return new CreateCamera()
}

export {
createCameraContext
}
7 changes: 7 additions & 0 deletions packages/api-proxy/src/platform/api/camera/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { ENV_OBJ, envError } from '../../../common/js'

const createCameraContext = ENV_OBJ.createCameraContext || envError('createCameraContext')

export {
createCameraContext
}
44 changes: 44 additions & 0 deletions packages/api-proxy/src/platform/api/camera/rnCamera.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,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)
}
}
3 changes: 3 additions & 0 deletions packages/api-proxy/src/platform/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,6 @@ export * from './api/keyboard'

// getSetting, openSetting, enableAlertBeforeUnload, disableAlertBeforeUnload, getMenuButtonBoundingClientRect
export * from './api/setting'

// createCameraContext
export * from './api/camera'
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ module.exports = function ({ print }) {

return {
test: TAG_NAME,
ios (tag, { el }) {
el.isBuiltIn = true
return 'mpx-camera'
},
android (tag, { el }) {
el.isBuiltIn = true
return 'mpx-camera'
},
harmony (tag, { el }) {
el.isBuiltIn = true
return 'mpx-camera'
},
props: [
{
test: 'mode',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const JD_UNSUPPORTED_TAG_NAME_ARR = ['functional-page-navigator', 'live-pusher',
// 快应用不支持的标签集合
const QA_UNSUPPORTED_TAG_NAME_ARR = ['movable-view', 'movable-area', 'open-data', 'official-account', 'editor', 'functional-page-navigator', 'live-player', 'live-pusher', 'ad', 'cover-image']
// RN不支持的标签集合
const RN_UNSUPPORTED_TAG_NAME_ARR = ['open-data', 'official-account', 'editor', 'functional-page-navigator', 'live-player', 'live-pusher', 'ad', 'audio', 'camera', 'match-media', 'page-container', 'editor', 'keyboard-accessory', 'map']
const RN_UNSUPPORTED_TAG_NAME_ARR = ['open-data', 'official-account', 'editor', 'functional-page-navigator', 'live-player', 'live-pusher', 'ad', 'audio', 'match-media', 'page-container', 'editor', 'keyboard-accessory', 'map']

/**
* @param {function(object): function} print
Expand Down
Loading