Skip to content

RN下支持camera#2262

Merged
hiyuki merged 28 commits intomasterfrom
feat-camera
Mar 6, 2026
Merged

RN下支持camera#2262
hiyuki merged 28 commits intomasterfrom
feat-camera

Conversation

@wangxiaokou
Copy link
Collaborator

  1. api-proxy补充createCameraContext
  2. core中增加同一个页面引入多个camera异常
  3. webpack-plugin中增加camera组件

bindstop && bindstop()
}, [bindstop])

const camera: CameraRef = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

包裹个useMemo只需要创建一次

layoutRef
}
)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camera = useMemo(()=>{
return {...}
}, [])

useEffect(()=>{
return ()=>{
if(navigation.camera === camera){
delete navigation.camera
}
}
}, [])

if(navigation.camera && navigation.camera !== camera ) {
warn()
return null
} else {
navigation.camera = camera
}

return createElement(Camera)

device,
format,
codeScanner: !isPhoto ? codeScanner : undefined,
zoom: zoomValue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要传递 torch 属性给相机组件:torch: flash === 'on' ? 'on' : flash === 'off' ? 'off' : undefined

@@ -0,0 +1,44 @@
import { noop, getFocusedNavigation } from '@mpxjs/utils'

export default class CreateCamera {
Copy link
Collaborator

@hiyuki hiyuki Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

类名改为CameraContext


const _camera = forwardRef<HandlerRef<any, CameraProps>, CameraProps>((props: CameraProps, ref): JSX.Element | null => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { Camera, useCameraDevice, useCodeScanner, useCameraFormat } = require('react-native-vision-camera')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

正常在组件外部引用就好

}
const checkCameraPermission = async () => {
try {
const cameraPermission = global?.__mpx?.config?.rnConfig?.cameraPermission
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

添加运行时ts类型声明

@hiyuki hiyuki merged commit cfec2bc into master Mar 6, 2026
6 checks passed
@hiyuki hiyuki deleted the feat-camera branch March 6, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants