import React, { useCallback, useEffect, useRef, useState } from 'react';
import { history, Link } from 'umi';
import classNames from 'classnames';
// import { getPersonList, exportPersonList } from '@/services/person';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { FullscreenOutlined } from '@ant-design/icons';
import { Button } from 'antd';
import { useFullScreen } from './hook';
import DateCommponetsLeft from './DateCommponetsLeft';
import DateCommponetsBottomRight from './DateCommponetsBottomRight';
import DateCommponetsBottomLeft from './DateCommponetsBottomLeft';
import Styles from './style.less';
import SquareBox from '@/components/ScreenBox/SquareBox';
import ScreenHeader from '@/components/ScreenBox/ScreenHeader';

export default (props) => {
  const screenRef = useRef();
  const [height, setHeight] = useState('auto');
  const { isFullScreen, toggleFullScreen } = useFullScreen(screenRef);

  useEffect(() => {
    const container = document.querySelector('main.ant-layout-content');
    const header = container.querySelector('.ant-pro-page-container-warp');

    setHeight(`${container.offsetHeight - header.offsetHeight}px`);
  }, []);

  return (
    <PageHeaderWrapper
      extra={
        <Button icon={<FullscreenOutlined />} onClick={toggleFullScreen}>
          全屏
        </Button>
      }
    >
      <div
        className={classNames(Styles['screen-page'], Styles['pd-lr-40'], {
          [Styles['full-screen']]: isFullScreen,
        })}
        style={{ height }}
        ref={screenRef}
      >
        <div className={Styles['grail-layout']}>
          <div className={Styles['grail-header']}>
            <ScreenHeader weather="多云 21-28 °C" />
          </div>
          <div className={classNames(Styles['grail-container'], Styles['mg-tp-40'])}>
            <div className={Styles['grail-left']}>
              <SquareBox>asdfasdf</SquareBox>
            </div>
            <div className={classNames(Styles['grail-content'], Styles['pd-lr-40'])}>
              <DateCommponetsLeft />
            </div>
            <div className={Styles['grail-right']}>
              <SquareBox>asdfasdf</SquareBox>
            </div>
          </div>
          <div className={classNames(Styles['grail-footer'], Styles['mg-tp-40'])}></div>
        </div>
      </div>
    </PageHeaderWrapper>
  );
};
