aboutsummaryrefslogtreecommitdiff
path: root/src/components/ModalScreen
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/ModalScreen')
-rw-r--r--src/components/ModalScreen/ModalScreen.tsx39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/components/ModalScreen/ModalScreen.tsx b/src/components/ModalScreen/ModalScreen.tsx
new file mode 100644
index 0000000..6b7c52c
--- /dev/null
+++ b/src/components/ModalScreen/ModalScreen.tsx
@@ -0,0 +1,39 @@
+import React, { useCallback } from 'react';
+import { useHistory } from 'react-router-dom';
+import {
+ Dialog,
+ Toolbar,
+ Typography,
+ IconButton,
+ useMediaQuery,
+ useTheme
+} from '@material-ui/core';
+import CloseIcon from '@material-ui/icons/Close';
+
+interface PropTypes {
+ title: string;
+}
+
+const ModalScreen: React.FC<PropTypes> = ({ title, children }) => {
+ const theme = useTheme();
+ const isMobile = useMediaQuery(theme.breakpoints.down('sm'));
+ const history = useHistory();
+
+ const handleClose = useCallback(() => history.goBack(), [history]);
+
+ return (
+ <Dialog fullScreen={isMobile} fullWidth open>
+ <Toolbar color="primary">
+ <IconButton edge="start" onClick={handleClose}>
+ <CloseIcon />
+ </IconButton>
+ <Typography variant="h6">
+ { title }
+ </Typography>
+ </Toolbar>
+ { children }
+ </Dialog>
+ );
+};
+
+export default ModalScreen;