import * as React from 'react';
import {ImageSourcePropType} from 'react-native';
import {Component} from 'react';
import {ViewStyle, StyleProp} from 'react-native';
import {RNCameraProps, BarCodeReadEvent, Constants} from 'react-native-camera';

export interface GenerateQRCodeProps {
  jsonObject: object;
  sizeQRCode?: number;
  colorQRCode?: string;
  backgroundColorQRCode?: string;
  logo?: ImageSourcePropType;
  logoSize?: number;
  logoBackgroundColor?: string;
  logoMargin?: number;
  logoBorderRadius?: number;
  quietZone?: number;
  enableLinearGradient?: boolean;
  gradientDirection?: string[];
  linearGradient?: string[];
  getRef?: (c: any) => any;
  ecl?: 'L' | 'M' | 'Q' | 'H';
  onError?: Function;
}

export interface ScanQRCodeProps {
  onQRCodeScanned: (json: object) => void;
  vibrateAfterScan?: boolean;
  reactivateCamera?: boolean;
  reactivateScanTimeout?: number;
  fadeImageIn?: boolean;
  showScanMarker?: boolean;
  cameraType?: 'front' | 'back';
  customMarker?: JSX.Element;
  containerStyle?: StyleProp<ViewStyle>;
  cameraStyle?: StyleProp<ViewStyle>;
  cameraContainerStyle?: StyleProp<ViewStyle>;
  markerStyle?: StyleProp<ViewStyle>;
  topViewStyle?: StyleProp<ViewStyle>;
  bottomViewStyle?: StyleProp<ViewStyle>;
  topContent?: JSX.Element | string;
  bottomContent?: JSX.Element | string;
  notAuthorizedView?: JSX.Element;
  permissionDialogTitle?: string;
  permissionDialogMessage?: string;
  buttonPositive?: string;
  checkAndroid6Permissions?: boolean;
  lightMode?: keyof typeof RNCamera.Constants.FlashMode;
  cameraProps?: RNCameraProps;
  cameraScanTimeout?: number;
  cameraTimeoutView?: JSX.Element;
  onError?: (error: undefined) => void;
}

export interface ScanQRCodeState {
  readonly scanning: boolean;
  readonly fadeInOpacity: any;
  readonly isAuthorized: boolean;
  readonly isAuthorizationChecked: boolean;
  readonly disableVibrationByUser: boolean;
}

export declare class ScanQRCode extends Component<
  ScanQRCodeProps,
  ScanQRCodeState
> {
  disable(): void;
  enable(): void;
  setScanState(value: boolean): void;
  handleScanCodeRead(e: BarCodeReadEvent): void;
  renderTopContent(): JSX.Element | null;
  renderBottomContent(): JSX.Element | null;
  renderCameraMarker(): JSX.Element | null;
  renderCameraComponent(): JSX.Element | null;
  renderCamera(): JSX.Element;
  reactivate(): void;
}

export declare class GenerateQRCode extends React.PureComponent<GenerateQRCodeProps, any> {}
