Skip to content

Commit

Permalink
feat: add read-only dialog for mobile (#428)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimniels committed Apr 14, 2023
1 parent e350220 commit 8e29669
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/ui/QuadraticUI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import { GetCellsDBSetSheet } from '../grid/sheet/Cells/GetCellsDB';
import { PixiApp } from '../gridGL/pixiApp/PixiApp';
import { SheetController } from '../grid/controller/sheetController';
import { LocalFilesContext } from './QuadraticUIContext';
import ReadOnlyDialog from './components/ReadOnlyDialog';
import { IS_READONLY_MODE } from '../constants/app';

export default function QuadraticUI({ app, sheetController }: { app: PixiApp; sheetController: SheetController }) {
const [showDebugMenu] = useLocalStorage('showDebugMenu', false);
Expand Down Expand Up @@ -83,6 +85,8 @@ export default function QuadraticUI({ app, sheetController }: { app: PixiApp; sh
{presentationMode && <PresentationModeHint />}
<SnackBar {...snackBar} />
{hasInitialPageLoadError && <InitialPageLoadError />}

{IS_READONLY_MODE && <ReadOnlyDialog />}
</div>
);
}
30 changes: 30 additions & 0 deletions src/ui/components/ReadOnlyDialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle } from '@mui/material';
import useLocalStorage from '../../hooks/useLocalStorage';

export default function ReadOnlyDialog() {
const [showReadOnlyMsg, setShowReadOnlyMsg] = useLocalStorage('showReadOnlyMsg', true);
const handleClose = () => {
setShowReadOnlyMsg(false);
};
return (
<Dialog
open={showReadOnlyMsg}
onClose={handleClose}
aria-labelledby="alert-dialog-title"
aria-describedby="alert-dialog-description"
>
<DialogTitle id="alert-dialog-title">Quadratic is built for desktop</DialogTitle>
<DialogContent>
<DialogContentText id="alert-dialog-description">
On mobile, sheets are read-only. To edit sheets, run code, and use the full power of the app, open it on your
desktop computer.
</DialogContentText>
</DialogContent>
<DialogActions>
<Button onClick={handleClose} autoFocus>
Ok, thanks
</Button>
</DialogActions>
</Dialog>
);
}

0 comments on commit 8e29669

Please sign in to comment.