29 lines
917 B
TypeScript
29 lines
917 B
TypeScript
import { requireNativeViewManager, requireNativeModule } from 'expo-modules-core';
|
|
import * as React from 'react';
|
|
import { ViewProps, Platform } from 'react-native';
|
|
|
|
const viewName = 'UsbCamera';
|
|
export const UsbCamera = requireNativeModule('UsbCamera');
|
|
|
|
export async function getUsbCameraLogcat(): Promise<string> {
|
|
if (UsbCamera && UsbCamera.getLogcat) {
|
|
return await UsbCamera.getLogcat();
|
|
}
|
|
return 'Not supported';
|
|
}
|
|
|
|
export interface UsbCameraViewProps extends ViewProps {
|
|
// Add props here if we decide to pass them from JS
|
|
}
|
|
|
|
export interface UsbCameraRef {
|
|
takePicture(savePath: string): Promise<string>;
|
|
isCameraConnected(): Promise<boolean>;
|
|
}
|
|
|
|
// Export the native view manager component
|
|
export const UsbCameraView: React.ComponentType<UsbCameraViewProps & { ref?: React.RefObject<any> }> =
|
|
Platform.OS === 'android'
|
|
? requireNativeViewManager(viewName)
|
|
: (() => null) as any;
|