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; }

import Orientation from 'react-native-orientation';
import { View, Text, StyleSheet, ScrollView, TouchableOpacity, StatusBar, FlatList, Dimensions } from 'react-native';
import React, { Component } from 'react';
import { Image } from 'react-native';
import Colors from './Colors';
import { RNCamera } from 'react-native-camera';
import Icon from 'react-native-vector-icons/FontAwesome';
import moment from 'react-moment';
import Geolocation from '@react-native-community/geolocation';
import Marker from "react-native-image-marker";
import * as Progress from 'react-native-progress';
import { connect } from 'react-redux';
import VideoPlayer from 'react-native-video-player';
let SCREEN_HEIGHT;
let SCREEN_WIDTH;

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

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

class DocumentUpload extends 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(Dimensions.get('window').height);
        SCREEN_WIDTH = Math.round(Dimensions.get('window').width);
      } else {
        // do something with portrait layout   
        SCREEN_HEIGHT = Math.round(Dimensions.get('window').width);
        SCREEN_WIDTH = Math.round(Dimensions.get('window').height);
      }
    });

    _defineProperty(this, "uploadedDocumentStatus", ({
      index,
      item
    }) => {
      return /*#__PURE__*/React.createElement(View, {
        key: index
      }, /*#__PURE__*/React.createElement(View, {
        style: {
          margin: 16,
          flexDirection: 'row'
        }
      }, /*#__PURE__*/React.createElement(View, {
        style: {
          flex: 0.3
        }
      }, this.uploadedDocumentImageOrVideo(item)), /*#__PURE__*/React.createElement(View, {
        style: {
          flex: 0.7,
          paddingLeft: 5
        }
      }, /*#__PURE__*/React.createElement(Text, {
        style: {
          fontFamily: 'Muli-Regular',
          paddingBottom: 15
        }
      }, item.stepTitle), /*#__PURE__*/React.createElement(Progress.Bar, {
        progress: item.upLoadStatus,
        color: Colors.digitYellow,
        height: 3,
        borderColor: Colors.white
      }), /*#__PURE__*/React.createElement(View, {
        style: {
          flexDirection: 'row'
        }
      }, /*#__PURE__*/React.createElement(Text, {
        style: {
          fontSize: 10,
          fontFamily: 'Muli-Regular'
        }
      }, (item.imageSize / 1024).toString().split('.')[0], " KB"), /*#__PURE__*/React.createElement(Text, {
        style: {
          fontSize: 10,
          paddingLeft: 20,
          fontFamily: 'Muli-Regular',
          color: Colors.digitYellow
        }
      }, (item.upLoadStatus * 100).toString().split('.')[0], " % Completed")))), /*#__PURE__*/React.createElement(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 = Orientation.getInitialOrientation();
    Orientation.addOrientationListener(this._orientationDidChange);
    Orientation.lockToPortrait();

    if (initial === 'PORTRAIT') {
      // do something
      SCREEN_HEIGHT = Math.round(Dimensions.get('window').height);
      SCREEN_WIDTH = Math.round(Dimensions.get('window').width);
    } else {
      // do something else
      SCREEN_HEIGHT = Math.round(Dimensions.get('window').height);
      SCREEN_WIDTH = Math.round(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.createElement(VideoPlayer, {
        video: {
          uri: item.imagePath
        },
        pauseOnPress: true,
        autoplay: true,
        disableSeek: true,
        style: {
          flex: 1,
          height: 100,
          width: 70
        }
      });
    } else {
      return /*#__PURE__*/React.createElement(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.createElement(View, {
      style: {
        flex: 1
      }
    }, /*#__PURE__*/React.createElement(StatusBar, {
      hidden: true
    }), /*#__PURE__*/React.createElement(View, {
      style: styles.documentProcessView
    }, /*#__PURE__*/React.createElement(Text, {
      style: styles.documentProcessHeader
    }, "Documents being processed !")), /*#__PURE__*/React.createElement(View, {
      style: {
        flex: 0.85
      }
    }, /*#__PURE__*/React.createElement(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 = 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.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
  };
};

export default connect(mapReductStateToProps, mapDispatchToProps)(DocumentUpload);
//# sourceMappingURL=DocumentUpload.js.map