"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _reactNativeOrientation = _interopRequireDefault(require("react-native-orientation"));

var _reactNative = require("react-native");

var _react = _interopRequireWildcard(require("react"));

var _Colors = _interopRequireDefault(require("./Colors"));

var _reactNativeCamera = require("react-native-camera");

var _FontAwesome = _interopRequireDefault(require("react-native-vector-icons/FontAwesome"));

var _reactMoment = _interopRequireDefault(require("react-moment"));

var _geolocation = _interopRequireDefault(require("@react-native-community/geolocation"));

var _reactNativeImageMarker = _interopRequireDefault(require("react-native-image-marker"));

var Progress = _interopRequireWildcard(require("react-native-progress"));

var _reactRedux = require("react-redux");

var _reactNativeVideoPlayer = _interopRequireDefault(require("react-native-video-player"));

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

let SCREEN_HEIGHT;
let SCREEN_WIDTH;

const crossMark = require('./Image/crossMark.png');

const tickMark = require('./Image/tickMark.png');

class DocumentUpload extends _react.Component {
  constructor(props) {
    super(props);

    _defineProperty(this, "_orientationDidChange", orientation => {
      console.log(" Orieentation >>>>>  " + orientation);

      if (orientation === 'LANDSCAPE') {
        // do something with landscape layoutr
        SCREEN_HEIGHT = Math.round(_reactNative.Dimensions.get('window').height);
        SCREEN_WIDTH = Math.round(_reactNative.Dimensions.get('window').width);
      } else {
        // do something with portrait layout   
        SCREEN_HEIGHT = Math.round(_reactNative.Dimensions.get('window').width);
        SCREEN_WIDTH = Math.round(_reactNative.Dimensions.get('window').height);
      }
    });

    _defineProperty(this, "uploadedDocumentStatus", ({
      index,
      item
    }) => {
      return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        key: index
      }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: {
          margin: 16,
          flexDirection: 'row'
        }
      }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: {
          flex: 0.3
        }
      }, this.uploadedDocumentImageOrVideo(item)), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: {
          flex: 0.7,
          paddingLeft: 5
        }
      }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
        style: {
          fontFamily: 'Muli-Regular',
          paddingBottom: 15
        }
      }, item.stepTitle), /*#__PURE__*/_react.default.createElement(Progress.Bar, {
        progress: item.upLoadStatus,
        color: _Colors.default.digitYellow,
        height: 3,
        borderColor: _Colors.default.white
      }), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: {
          flexDirection: 'row'
        }
      }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
        style: {
          fontSize: 10,
          fontFamily: 'Muli-Regular'
        }
      }, (item.imageSize / 1024).toString().split('.')[0], " KB"), /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
        style: {
          fontSize: 10,
          paddingLeft: 20,
          fontFamily: 'Muli-Regular',
          color: _Colors.default.digitYellow
        }
      }, (item.upLoadStatus * 100).toString().split('.')[0], " % Completed")))), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: {
          borderRadius: 1,
          height: 1,
          backgroundColor: '#F5F5F5'
        }
      }));
    });

    this.state = {
      isDisplayQuoteInstruction: true,
      isWithQuote: true,
      isWithOutQuote: false,
      isDisplayInstruction: false,
      torchon: '',
      isDisplayCameraPreview: false,
      isDisplayCamera: false,
      localPath: '',
      flashState: true,
      //for flash
      dateAndTime: '',
      //date and time
      currentLongitude: 'unknown',
      //Initial Longitude
      currentLatitude: 'unknown',
      //Initial Latitude
      isDisplayVideoRecorder: false,
      instructionData: '',
      fullDataSource: '',
      assets: '',
      headerShown: false,
      count: 0,
      dataSource: '',
      cameraState: '',
      buttonText: '',
      skipdata: '',
      isBackButtonPressed: false,
      isSkipButtonPressed: false,
      extention: '',
      screenShotPath: '',
      isDisplayUploadDocument: false,
      documentUploadPercentage: 0,
      odometerReading: '',
      ANDROID_ID: '',
      CurrentDate: '',
      showError: false,
      isLoading: true,
      registrationNumber: '',
      isSelected: false,
      isFocused: false
    };
  }

  componentDidMount() {
    // this locks the view to Portrait Mode
    const initial = _reactNativeOrientation.default.getInitialOrientation();

    _reactNativeOrientation.default.addOrientationListener(this._orientationDidChange);

    _reactNativeOrientation.default.lockToPortrait();

    if (initial === 'PORTRAIT') {
      // do something
      SCREEN_HEIGHT = Math.round(_reactNative.Dimensions.get('window').height);
      SCREEN_WIDTH = Math.round(_reactNative.Dimensions.get('window').width);
    } else {
      // do something else
      SCREEN_HEIGHT = Math.round(_reactNative.Dimensions.get('window').height);
      SCREEN_WIDTH = Math.round(_reactNative.Dimensions.get('window').width);
    }
  }

  //Checking the document image or Video
  uploadedDocumentImageOrVideo(item) {
    const type = item.imagePath.split('.');

    if (type.length > 1 && type[1] == 'mp4') {
      return /*#__PURE__*/_react.default.createElement(_reactNativeVideoPlayer.default, {
        video: {
          uri: item.imagePath
        },
        pauseOnPress: true,
        autoplay: true,
        disableSeek: true,
        style: {
          flex: 1,
          height: 100,
          width: 70
        }
      });
    } else {
      return /*#__PURE__*/_react.default.createElement(_reactNative.Image, {
        source: {
          uri: item.imagePath
        },
        resizeMethod: "auto",
        resizeMode: "contain",
        style: {
          flex: 1,
          height: 100,
          width: 70,
          resizeMode: 'contain'
        }
      });
    }
  }

  render() {
    // console.log("Lenght!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + this.state.upLoadIamgeDataSource)
    console.log("SSSSSSSSSSSSSSSSSSSSSSSS" + JSON.stringify(this.props.UploadImageData.uploadImageDatasource.slice(1))); // const dataSource=[]
    // this.props.UploadImageData.uploadImageDatasource.map(item=>{
    //     dataSource.push(item)
    //     console.log(dataSource.length)
    // })

    return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
      style: {
        flex: 1
      }
    }, /*#__PURE__*/_react.default.createElement(_reactNative.StatusBar, {
      hidden: true
    }), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
      style: styles.documentProcessView
    }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
      style: styles.documentProcessHeader
    }, "Documents being processed !")), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
      style: {
        flex: 0.85
      }
    }, /*#__PURE__*/_react.default.createElement(_reactNative.FlatList, {
      data: this.props.UploadImageData.uploadImageDatasource.slice(1),
      keyExtractor: (item, index) => item.index,
      renderItem: this.uploadedDocumentStatus,
      maxToRenderPerBatch: 100,
      updateCellsBatchingPeriod: 1000,
      style: {
        backgroundColor: 'white',
        marginBottom: 10,
        fontFamily: 'Mulli-Regular'
      }
    })));
  }

}

const styles = _reactNative.StyleSheet.create({
  main: {
    flex: 1,
    flexDirection: 'row',
    backgroundColor: '#FFFFFF'
  },
  productImageView: {
    flex: 0.475
  },
  blankView: {
    flex: 0.05
  },
  productInfoView: {
    flex: 0.475,
    width: SCREEN_WIDTH,
    height: SCREEN_HEIGHT
  },
  headerView: {
    backgroundColor: '#F5F5F5',
    height: 60,
    justifyContent: 'center'
  },
  headerText: {
    marginLeft: 16,
    fontSize: 16,
    fontFamily: 'Muli-Black',
    marginRight: 16
  },
  documentProcessHeader: {
    marginLeft: 16,
    fontSize: 26,
    fontFamily: 'Muli-Black',
    marginRight: 16,
    justifyContent: 'center'
  },
  documentProcessView: {
    flex: 0.15,
    justifyContent: 'center',
    backgroundColor: '#F5F5F5'
  },
  productImageStyle: {
    marginTop: 8,
    marginLeft: 16,
    marginBottom: 40,
    height: SCREEN_HEIGHT - 70
  },
  backButtonImageStyle: {
    marginLeft: 32,
    height: 30,
    width: 40,
    backgroundColor: 'red'
  },
  subHeaderText: {
    fontFamily: 'Mulli-Regular',
    fontSize: 16,
    marginLeft: 16,
    marginRight: 16
  },
  instructionText: {
    fontFamily: 'Mulli-Regular',
    fontSize: 16,
    marginLeft: 32,
    marginBottom: 20,
    marginRight: 16
  },
  captureImageButtonView: {
    height: 48,
    borderRadius: 4,
    backgroundColor: _Colors.default.digitYellow,
    marginTop: 2,
    flexDirection: 'row',
    justifyContent: 'center',
    marginRight: 16
  },
  captureImageButtonText: {
    fontSize: 16,
    fontFamily: 'Muli-Black',
    alignSelf: 'center'
  },
  container: {
    flex: 1 // flexDirection: 'row',
    // backgroundColor: 'black',

  },
  preview: {
    flex: 1,
    justifyContent: 'flex-end',
    alignItems: 'center'
  }
}); //Redux Action


const mapDispatchToProps = dispatch => {
  return {// addUploadImageDatasource: uploadImageDatasource => dispatch(addUploadImageDatasource(uploadImageDatasource)),
  };
}; //Redux State


const mapReductStateToProps = reduxState => {
  const {
    UploadImageData
  } = reduxState;
  return {
    UploadImageData
  };
};

var _default = (0, _reactRedux.connect)(mapReductStateToProps, mapDispatchToProps)(DocumentUpload);

exports.default = _default;
//# sourceMappingURL=DocumentUpload.js.map