import React from 'react';
import {StyleProp, ViewStyle} from 'react-native';
import {EngineMode, MSIPlesseyChecksumAlgorithm} from '../../enum';
import {FinderAspectRatio} from '../../model';
import {BarcodeDocumentFormat, BarcodeFormat} from '../../configuration';

export interface ScanbotBarcodeCameraViewProperties {
  onBarcodeScannerResult?: (result: ScanbotBarcodeCameraViewResult) => void;
  requestComponentReload?: () => void;
  configuration?: ScanbotBarcodeCameraViewConfiguration;
  style: StyleProp<ViewStyle>;
  children: React.ReactNode;
}

export interface ScanbotBarcodeCameraViewBarcode {
  text: string;
  type: string;
}

export type ScanbotBarcodeCameraViewResult = {
  status: 'OK' | 'CANCELED';
  barcodes: ScanbotBarcodeCameraViewBarcode[];
};

export interface ScanbotBarcodeCameraViewConfiguration {
  /**
   * The finder view is a rectangular overlay view that clips the camera view,
   * so that the detection will focus just a specific area. You can specify
   * the size and positioning, as well as other UI properties.
   * Set this property to `true` if you want to use the Finder View, `false` otherwise (default: false)
   */
  shouldUseFinderView?: boolean;
  /**
   * The finder view rectangular overlay border width
   */
  finderLineWidth?: number;
  /**
   * The finder view rectangular overlay border color
   */
  finderLineColor?: string;
  /**
   * The overlay background color, around the finder view rectangle
   */
  finderBackgroundColor?: string;
  /**
   * The overlay background color opacity, around the finder view rectangle
   */
  finderBackgroundOpacity?: number;
  /**
   * The finder view rectangle aspect ratio
   */
  finderAspectRatio?: FinderAspectRatio;
  /**
   * The finder view minimum padding from the bounds of the screen
   */
  finderMinimumPadding?: number;
  /**
   * How many pixel units the finder view should be moved vertically;
   *
   * Positive values -> (UP); Negative values -> (DOWN)
   */
  finderVerticalOffset?: number;
  /**
   * Whether flash is toggled on or off.
   */
  flashEnabled?: boolean;
  /**
   * List of accepted Barcode Formats; any formats that are not included in this
   * list will not be detected by the `BarcodeCameraView`. By default, the list
   * includes all supported barcode types.
   */
  barcodeFormats?: BarcodeFormat[];
  /**
   * List of accepted Document Formats; any document formats that are not included
   * in this list will be ignored by the `BarcodeCameraView`. By default, the list
   * includes all supported document types.
   */
  acceptedDocumentFormats?: BarcodeDocumentFormat[];
  /**
   * The checksum algorithm for MSI Plessey barcodes.
   * The default value is `Mod10'
   */
  msiPlesseyChecksumAlgorithm?: MSIPlesseyChecksumAlgorithm;
  /**
   * The engine mode of the barcode recognizer. Defaults to NEXT_GEN.
   * To use legacy recognizer, please specify LEGACY
   */
  engineMode?: EngineMode;
  /**
   * The relative initial zoom level of the camera in the range [0,1], where 0 is zoomed out and 1 is zoomed in.
   * The default value is 0.
   */
  cameraZoomFactor?: number;
  /**
   * When set to `true`, the scanner assumes that the barcode can be a GS1 barcode.
   * Turn it off, if you don't want to see decoded FNC1 characters ("]C1" and ASCII char 29).
   * The default value is `true`.
   * NOTE: Currently works for CODE128 barcodes only.
   */
  gs1DecodingEnabled?: boolean;
  /**
   * Optional minimum required text length of the detected barcode.
   * The default is 0 (setting is turned off).
   * NOTE: This feature works on ITF barcodes only.
   */
  minimumTextLength?: number;
  /**
   * Optional maximum required text length of the detected barcode.
   * The default is 0 (setting is turned off).
   * NOTE: This feature works on ITF barcodes only.
   */
  maximumTextLength?: number;
  /**
   * With this option enabled, the scanner removes checks digits for UPC, EAN and MSI Plessey codes.
   * Has no effect if both single and double digit MSI Plessey checksums are enabled.
   * The default is `false`
   */
  stripCheckDigits?: boolean;
}
