mirror of
https://github.com/RoboSats/robosats.git
synced 2024-12-14 11:26:24 +00:00
Add fullscreen mode for BookTable
This commit is contained in:
parent
ab4d83bf49
commit
68f35b3d35
@ -118,7 +118,7 @@ class BookPage extends Component {
|
|||||||
const chartWidthEm = width - bookTableWidth;
|
const chartWidthEm = width - bookTableWidth;
|
||||||
const tableWidthXS = (bookTableWidth / width) * 12;
|
const tableWidthXS = (bookTableWidth / width) * 12;
|
||||||
const chartWidthXS = (chartWidthEm / width) * 12;
|
const chartWidthXS = (chartWidthEm / width) * 12;
|
||||||
console.log(bookTableWidth, chartWidthEm, tableWidthXS, chartWidthXS);
|
|
||||||
return (
|
return (
|
||||||
<Grid
|
<Grid
|
||||||
container
|
container
|
||||||
@ -136,6 +136,9 @@ class BookPage extends Component {
|
|||||||
currency={this.props.currency}
|
currency={this.props.currency}
|
||||||
maxWidth={bookTableWidth} // EM units
|
maxWidth={bookTableWidth} // EM units
|
||||||
maxHeight={heightEm * 0.8 - 11} // EM units
|
maxHeight={heightEm * 0.8 - 11} // EM units
|
||||||
|
fullWidth={widthEm} // EM units
|
||||||
|
fullHeight={heightEm} // EM units
|
||||||
|
defaultFullscreen={false}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid
|
<Grid
|
||||||
@ -181,6 +184,9 @@ class BookPage extends Component {
|
|||||||
currency={this.props.currency}
|
currency={this.props.currency}
|
||||||
maxWidth={widthEm * 0.97} // EM units
|
maxWidth={widthEm * 0.97} // EM units
|
||||||
maxHeight={heightEm * 0.8 - 11} // EM units
|
maxHeight={heightEm * 0.8 - 11} // EM units
|
||||||
|
fullWidth={widthEm} // EM units
|
||||||
|
fullHeight={heightEm} // EM units
|
||||||
|
defaultFullscreen={false}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
|
Grid,
|
||||||
|
Dialog,
|
||||||
Typography,
|
Typography,
|
||||||
Paper,
|
Paper,
|
||||||
Stack,
|
Stack,
|
||||||
@ -11,8 +13,9 @@ import {
|
|||||||
ListItemAvatar,
|
ListItemAvatar,
|
||||||
useTheme,
|
useTheme,
|
||||||
CircularProgress,
|
CircularProgress,
|
||||||
|
IconButton,
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
import { DataGrid } from '@mui/x-data-grid';
|
import { DataGrid, GridFooterPlaceholder, GridPagination } from '@mui/x-data-grid';
|
||||||
import currencyDict from '../../static/assets/currencies.json';
|
import currencyDict from '../../static/assets/currencies.json';
|
||||||
import { Order } from '../models/Order.model';
|
import { Order } from '../models/Order.model';
|
||||||
|
|
||||||
@ -23,6 +26,10 @@ import RobotAvatar from './Robots/RobotAvatar';
|
|||||||
import hexToRgb from '../utils/hexToRgb';
|
import hexToRgb from '../utils/hexToRgb';
|
||||||
import statusBadgeColor from '../utils/statusBadgeColor';
|
import statusBadgeColor from '../utils/statusBadgeColor';
|
||||||
|
|
||||||
|
// Icons
|
||||||
|
import FullscreenIcon from '@mui/icons-material/Fullscreen';
|
||||||
|
import FullscreenExitIcon from '@mui/icons-material/FullscreenExit';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
orders: Order[];
|
orders: Order[];
|
||||||
@ -30,6 +37,9 @@ interface Props {
|
|||||||
currency: number;
|
currency: number;
|
||||||
maxWidth: number;
|
maxWidth: number;
|
||||||
maxHeight: number;
|
maxHeight: number;
|
||||||
|
fullWidth: number;
|
||||||
|
fullHeight: number;
|
||||||
|
defaultFullscreen: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const BookTable = ({
|
const BookTable = ({
|
||||||
@ -39,23 +49,26 @@ const BookTable = ({
|
|||||||
currency,
|
currency,
|
||||||
maxWidth,
|
maxWidth,
|
||||||
maxHeight,
|
maxHeight,
|
||||||
|
fullWidth,
|
||||||
|
fullHeight,
|
||||||
|
defaultFullscreen,
|
||||||
}: Props): JSX.Element => {
|
}: Props): JSX.Element => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
const [pageSize, setPageSize] = useState(0);
|
||||||
const fontSize = theme.typography.fontSize;
|
const [fullscreen, setFullscreen] = useState(defaultFullscreen);
|
||||||
|
|
||||||
// all sizes in 'em'
|
// all sizes in 'em'
|
||||||
|
const fontSize = theme.typography.fontSize;
|
||||||
const verticalHeightFrame = 6.9075;
|
const verticalHeightFrame = 6.9075;
|
||||||
const verticalHeightRow = 3.25;
|
const verticalHeightRow = 3.25;
|
||||||
const defaultPageSize = Math.max(
|
const defaultPageSize = Math.max(
|
||||||
Math.floor((maxHeight - verticalHeightFrame) / verticalHeightRow),
|
Math.floor(((fullscreen? fullHeight *0.875:maxHeight) - verticalHeightFrame) / verticalHeightRow),
|
||||||
1,
|
1,
|
||||||
);
|
);
|
||||||
const height = defaultPageSize * verticalHeightRow + verticalHeightFrame;
|
const height = defaultPageSize * verticalHeightRow + verticalHeightFrame;
|
||||||
|
|
||||||
const [pageSize, setPageSize] = useState(0);
|
|
||||||
const [useDefaultPageSize, setUseDefaultPageSize] = useState(true);
|
const [useDefaultPageSize, setUseDefaultPageSize] = useState(true);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (useDefaultPageSize) {
|
if (useDefaultPageSize) {
|
||||||
@ -564,9 +577,30 @@ const BookTable = ({
|
|||||||
return [columns, width * 0.875 + 0.15];
|
return [columns, width * 0.875 + 0.15];
|
||||||
};
|
};
|
||||||
|
|
||||||
const [columns, width] = filteredColumns(maxWidth);
|
const [columns, width] = filteredColumns(fullscreen? fullWidth : maxWidth);
|
||||||
|
|
||||||
return (
|
const gridComponents = {
|
||||||
|
NoResultsOverlay: () => (
|
||||||
|
<Stack height='100%' alignItems='center' justifyContent='center'>
|
||||||
|
{t('Filter has no results')}
|
||||||
|
</Stack>
|
||||||
|
),
|
||||||
|
Footer: () => (
|
||||||
|
<Grid container alignItems="center" direction="row" justifyContent="space-between">
|
||||||
|
<Grid item>
|
||||||
|
<IconButton onClick={() => setFullscreen(!fullscreen)}>
|
||||||
|
{fullscreen ? <FullscreenExitIcon/> : <FullscreenIcon/>}
|
||||||
|
</IconButton>
|
||||||
|
</Grid>
|
||||||
|
<Grid item>
|
||||||
|
<GridPagination/>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fullscreen){
|
||||||
|
return(
|
||||||
<Paper style={{ width: `${width}em`, height: `${height}em`, overflow: 'auto' }}>
|
<Paper style={{ width: `${width}em`, height: `${height}em`, overflow: 'auto' }}>
|
||||||
<DataGrid
|
<DataGrid
|
||||||
localeText={localeText}
|
localeText={localeText}
|
||||||
@ -576,13 +610,7 @@ const BookTable = ({
|
|||||||
)}
|
)}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
components={{
|
components={gridComponents}
|
||||||
NoResultsOverlay: () => (
|
|
||||||
<Stack height='100%' alignItems='center' justifyContent='center'>
|
|
||||||
{t('Filter has no results')}
|
|
||||||
</Stack>
|
|
||||||
),
|
|
||||||
}}
|
|
||||||
pageSize={loading ? 0 : pageSize}
|
pageSize={loading ? 0 : pageSize}
|
||||||
rowsPerPageOptions={[0, pageSize, defaultPageSize * 2, 50, 100]}
|
rowsPerPageOptions={[0, pageSize, defaultPageSize * 2, 50, 100]}
|
||||||
onPageSizeChange={(newPageSize) => {
|
onPageSizeChange={(newPageSize) => {
|
||||||
@ -592,7 +620,32 @@ const BookTable = ({
|
|||||||
onRowClick={(params) => history.push('/order/' + params.row.id)} // Whole row is clickable, but the mouse only looks clickly in some places.
|
onRowClick={(params) => history.push('/order/' + params.row.id)} // Whole row is clickable, but the mouse only looks clickly in some places.
|
||||||
/>
|
/>
|
||||||
</Paper>
|
</Paper>
|
||||||
);
|
)
|
||||||
|
} else {
|
||||||
|
return(
|
||||||
|
<Dialog open={fullscreen} fullScreen={true}>
|
||||||
|
<Paper style={{ width: '100%', height: '100%', overflow: 'auto' }}>
|
||||||
|
<DataGrid
|
||||||
|
localeText={localeText}
|
||||||
|
rows={orders.filter(
|
||||||
|
(order) =>
|
||||||
|
(order.type == type || type == null) && (order.currency == currency || currency == 0),
|
||||||
|
)}
|
||||||
|
loading={loading}
|
||||||
|
columns={columns}
|
||||||
|
components={gridComponents}
|
||||||
|
pageSize={loading ? 0 : pageSize}
|
||||||
|
rowsPerPageOptions={[0, pageSize, defaultPageSize * 2, 50, 100]}
|
||||||
|
onPageSizeChange={(newPageSize) => {
|
||||||
|
setPageSize(newPageSize);
|
||||||
|
setUseDefaultPageSize(false);
|
||||||
|
}}
|
||||||
|
onRowClick={(params) => history.push('/order/' + params.row.id)} // Whole row is clickable, but the mouse only looks clickly in some places.
|
||||||
|
/>
|
||||||
|
</Paper>
|
||||||
|
</Dialog>
|
||||||
|
)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default BookTable;
|
export default BookTable;
|
||||||
|
Loading…
Reference in New Issue
Block a user