expo-camera
Version:
A React component that renders a preview for the device's either front or back camera. Camera's parameters like zoom, auto focus, white balance and flash mode are adjustable. With expo-camera, one can also take photos and record videos that are saved to t
36 lines • 1.18 kB
JavaScript
import { Platform } from 'expo-modules-core';
import CameraManager from '../ExpoCameraManager';
// Values under keys from this object will be transformed to native options
export const ConversionTables = {
type: CameraManager.Type,
flash: CameraManager.FlashMode,
};
export function convertNativeProps(props) {
if (!props || typeof props !== 'object') {
return {};
}
const nativeProps = {};
for (const [key, value] of Object.entries(props)) {
const prop = key;
if (typeof value === 'string' && ConversionTables[prop]) {
nativeProps[key] =
ConversionTables[prop][value];
}
else {
nativeProps[key] = value;
}
}
return nativeProps;
}
export function ensureNativeProps(props) {
const newProps = convertNativeProps(props);
newProps.barcodeScannerEnabled = !!props?.onBarcodeScanned;
newProps.flashMode = props?.flash ?? 'off';
newProps.mute = props?.mute ?? false;
newProps.autoFocus = props?.autofocus ?? 'off';
if (Platform.OS !== 'web') {
delete newProps.poster;
}
return newProps;
}
//# sourceMappingURL=props.js.map