//@ts-nocheck
import React, { useEffect, useState } from 'react';
import {
  View,
  StatusBar,
  SafeAreaView,
  Image,
  Dimensions,
  ScrollView,
  ActivityIndicator,
  Platform,
} from 'react-native';
import { CommonActions, useNavigation } from '@react-navigation/native';
import { observer } from 'mobx-react-lite';
import WebView from 'react-native-webview';
import { commonStyles } from '../CommonStyles';
import MButton from '../../components/MButton';
import { MText, MTextInput } from '../../components/MText';
import { color } from '../../theme';
import { IconBack } from '../assets/icons';
import { Formik } from 'formik';
import { myLog } from '../../utils/log';
import * as yup from 'yup';
import ImageView from 'react-native-image-viewing';
import eSignStore from '../eSign/Store';
import customerStore from '../customerInfo/Store';
import { ScreenNames } from '../../navigation';
import Pdf from 'react-native-pdf';

export const Contract = observer(function Contract(props) {
  const navigation = useNavigation();
  const [visible, setIsVisible] = useState(false);

  const complete = () => {
    navigation.dispatch(
      CommonActions.reset({
        index: 1,
        routes: [{ name: ScreenNames.Main }],
      })
    );
  };

  return (
    <View style={{ flex: 1, backgroundColor: 'white' }}>
      <SafeAreaView style={{ flex: 1 }}>
        <View style={{ flex: 1 }}>
          <View
            style={[
              commonStyles.row,
              commonStyles.alignCenter,
              { paddingHorizontal: 16, height: 55 },
            ]}
          >
            <MButton
              onPress={() => {
                // back()
              }}
              style={{
                width: 30,
                height: 55,
                justifyContent: 'center',
                alignItems: 'center',
              }}
            >
              {/* <IconBack width={18} height={18} fill={'black'}/> */}
            </MButton>

            <MText
              style={{
                marginRight: 30,
                fontSize: 16,
                paddingHorizontal: 4,
                color: color.headerColor,
                fontWeight: 'bold',
                textAlign: 'center',
                flex: 1,
              }}
            >
              {'Hợp đồng đã ký'}
            </MText>
          </View>
          <View style={{ backgroundColor: color.border }} />
          <Pdf
            source={{ uri: props.route.params?.uri, cache: true }}
            onLoadComplete={(numberOfPages, filePath) => {
              console.log(`number of pages: ${numberOfPages}`);
            }}
            onPageChanged={(page, numberOfPages) => {
              console.log(`current page: ${page}`);
            }}
            onError={(error) => {
              console.log(error);
            }}
            onPressLink={(uri) => {
              console.log(`Link presse: ${uri}`);
            }}
            style={commonStyles.fill}
          />
        </View>
        <MButton
          onPress={complete}
          style={[
            commonStyles.alignCenter,
            commonStyles.justifyCenter,
            {
              marginHorizontal: 16,
              marginVertical: 10,
              backgroundColor: color.primary,
              height: 50,
              borderRadius: 4,
            },
          ]}
        >
          <MText style={[commonStyles.textNormalBold, { color: 'white' }]}>
            Đóng
          </MText>
        </MButton>
      </SafeAreaView>
    </View>
  );
});
