import React, { useEffect, useContext, useState } from 'react'; import GridLayout, { type Layout } from 'react-grid-layout'; import { Grid, styled, useTheme } from '@mui/material'; import { PlaceholderWidget, MakerWidget, BookWidget, DepthChartWidget, SettingsWidget, } from '../pro/Widgets'; import ToolBar from '../pro/ToolBar'; import LandingDialog from '../pro/LandingDialog'; import { AppContext, type UseAppStoreType } from '../contexts/AppContext'; // To Do. Add dotted grid when layout is not frozen // ${freeze ? // `background: radial-gradient(${theme.palette.text.disabled} 1px, transparent 0px); // background-size: ${gridCellSize}em ${gridCellSize}em; // background-position: left 1em bottom 1.5em;` // :''} const StyledRGL = styled(GridLayout)( ({ theme, gridCellSize, height, width, freeze }) => ` height: ${height}em; width: ${width}px; max-height: ${height}em; `, ); const defaultLayout: Layout = [ { i: 'Maker', w: 10, h: 16, x: 67, y: 0, minW: 8, maxW: 22, minH: 10, maxH: 28 }, { i: 'Book', w: 43, h: 15, x: 34, y: 16, minW: 6, maxW: 70, minH: 9, maxH: 25 }, { i: 'DepthChart', w: 15, h: 10, x: 19, y: 16, minW: 6, maxW: 22, minH: 9, maxH: 25 }, { i: 'Garage', w: 52, h: 16, x: 0, y: 0, minW: 15, maxW: 78, minH: 8, maxH: 30 }, { i: 'History', w: 8, h: 10, x: 11, y: 16, minW: 6, maxW: 22, minH: 9, maxH: 25 }, { i: 'Trade', w: 15, h: 16, x: 52, y: 0, minW: 6, maxW: 22, minH: 9, maxH: 25 }, { i: 'Settings', w: 11, h: 15, x: 0, y: 16, minW: 6, maxW: 22, minH: 9, maxH: 25 }, { i: 'Other', w: 23, h: 5, x: 11, y: 26, minW: 2, maxW: 50, minH: 4, maxH: 25 }, ]; const Main = (): JSX.Element => { const { book, fetchBook, maker, setMaker, setSettings, clearOrder, torStatus, settings, limits, fetchLimits, robot, setRobot, fetchRobot, setOrder, setDelay, info, fav, setFav, baseUrl, order, currentOrder, setCurrentOrder, open, setOpen, windowSize, badOrder, setBadOrder, } = useContext(AppContext); const theme = useTheme(); const em: number = theme.typography.fontSize; const toolbarHeight: number = 3; const gridCellSize: number = 2; const [openLanding, setOpenLanding] = useState(true); const [layout, setLayout] = useState(defaultLayout); return ( { setOpenLanding(!openLanding); }} /> { setLayout(layout); }} >
); }; export default Main;