// Type definitions for react-native-camera 1.0 // Definitions by Felipe Constantino // If you modify this file, put your GitHub info here as well (for easy contacting purposes) /* * Author notes: * I've tried to find a easy tool to convert from Flow to Typescript definition files (.d.ts). * So we woudn't have to do it manually... Sadly, I haven't found it. * * If you are seeing this from the future, please, send us your cutting-edge technology :) (if it exists) */ import { Component } from 'react'; import { ViewProperties } from "react-native"; type AutoFocus = { on: any, off: any }; type FlashMode = { on: any, off: any, torch: any, auto: any }; type CameraType = { front: any, back: any }; type WhiteBalance = { sunny: any, cloudy: any, shadow: any, incandescent: any, fluorescent: any, auto: any }; type BarCodeType = { aztec: any, code128: any, code39: any, code39mod43: any, code93: any, ean13: any, ean8: any, pdf417: any, qr: any, upce: any, interleaved2of5: any, itf14: any, datamatrix: any }; type VideoQuality = { '2160p': any, '1080p': any, '720p': any, '480p': any, '4:3': any }; type FaceDetectionClassifications = { all: any, none: any }; type FaceDetectionLandmarks = { all: any, none: any }; type FaceDetectionMode = { fast: any, accurate: any }; export interface Constants { AutoFocus: AutoFocus; FlashMode: FlashMode; Type: CameraType; WhiteBalance: WhiteBalance; VideoQuality: VideoQuality; BarCodeType: BarCodeType; FaceDetection: { Classifications: FaceDetectionClassifications; Landmarks: FaceDetectionLandmarks; Mode: FaceDetectionMode; } } export interface RNCameraProps { autoFocus?: keyof AutoFocus; type?: keyof CameraType; flashMode?: keyof FlashMode; notAuthorizedView?: JSX.Element; pendingAuthorizationView?: JSX.Element; onCameraReady?(): void; onMountError?(): void; /** Value: float from 0 to 1.0 */ zoom?: number; /** Value: float from 0 to 1.0 */ focusDepth?: number; // -- BARCODE PROPS barCodeTypes?: Array; onBarCodeRead?(event: { data: string type: keyof BarCodeType }): void; // -- FACE DETECTION PROPS onFacesDetected?(response: { faces: Face[] }): void; onFaceDetectionError?(response: { isOperational: boolean }): void; faceDetectionMode?: keyof FaceDetectionMode; faceDetectionLandmarks?: keyof FaceDetectionLandmarks; faceDetectionClassifications?: keyof FaceDetectionClassifications; // -- ANDROID ONLY PROPS /** Android only */ ratio?: string; /** Android only */ permissionDialogTitle?: string; /** Android only */ permissionDialogMessage?: string; // -- IOS ONLY PROPS /** iOS Only */ captureAudio?: boolean; } interface Point { x: number, y: number } interface Face { faceID?: number, bounds: { size: { width: number; height: number; }; origin: Point; }; smilingProbability?: number; leftEarPosition?: Point; rightEarPosition?: Point; leftEyePosition?: Point; leftEyeOpenProbability?: number; rightEyePosition?: Point; rightEyeOpenProbability?: number; leftCheekPosition?: Point; rightCheekPosition?: Point; leftMouthPosition?: Point; mouthPosition?: Point; rightMouthPosition?: Point; bottomMouthPosition?: Point; noseBasePosition?: Point; yawAngle?: number; rollAngle?: number; } interface TakePictureOptions { quality?: number; base64?: boolean; exif?: boolean; width?: number; mirrorImage?: boolean; /** Android only */ fixOrientation?: boolean; /** iOS only */ forceUpOrientation?: boolean; } interface TakePictureResponse { width: number; height: number; uri: string; base64?: string; exif?: { [name: string]: any }; } interface RecordOptions { quality?: keyof VideoQuality; maxDuration?: number; maxFileSize?: number; mute?: boolean; } interface RecordResponse { /** Path to the video saved on your app's cache directory. */ uri: string; } export class RNCamera extends Component { static Constants: Constants; takePictureAsync(options?: TakePictureOptions): Promise; recordAsync(options?: RecordOptions): Promise; stopRecording(): void; /** Android only */ getSupportedRatiosAsync(): Promise; } interface DetectionOptions { mode?: keyof FaceDetectionMode, detectLandmarks?: keyof FaceDetectionLandmarks, runClassifications?: keyof FaceDetectionClassifications } export class FaceDetector { private constructor(); static Constants: Constants['FaceDetection']; static detectFacesAsync(uri: string, options?: DetectionOptions): Promise; } // -- DEPRECATED CONTENT BELOW /** * @deprecated As of 1.0.0 release, RCTCamera is deprecated. Please use RNCamera for the latest fixes and improvements. */ export default class RCTCamera extends Component { static constants: any; }