|
1 | 1 | import React from "react"; |
2 | | -import { createStyles, makeStyles } from "@material-ui/core/styles"; |
3 | | - |
4 | | -const useStyles = makeStyles(() => |
5 | | - createStyles({ |
6 | | - root: { |
7 | | - flexGrow: 1, |
8 | | - }, |
9 | | - }) |
10 | | -); |
| 2 | +import SwipeableViews from "react-swipeable-views"; |
| 3 | +import { makeStyles, Theme, useTheme } from "@material-ui/core/styles"; |
| 4 | +import AppBar from "@material-ui/core/AppBar"; |
| 5 | +import Tabs from "@material-ui/core/Tabs"; |
| 6 | +import Tab from "@material-ui/core/Tab"; |
| 7 | +import Box from "@material-ui/core/Box"; |
| 8 | + |
| 9 | +interface TabPanelProps { |
| 10 | + children?: React.ReactNode; |
| 11 | + dir?: string; |
| 12 | + index: number; |
| 13 | + value: number; |
| 14 | +} |
| 15 | + |
| 16 | +function TabPanel(props: TabPanelProps) { |
| 17 | + const { children, value, index, ...other } = props; |
| 18 | + |
| 19 | + return ( |
| 20 | + <div |
| 21 | + role="tabpanel" |
| 22 | + hidden={value !== index} |
| 23 | + id={`full-width-tabpanel-${index}`} |
| 24 | + aria-labelledby={`full-width-tab-${index}`} |
| 25 | + {...other} |
| 26 | + > |
| 27 | + {value === index && <Box p={2}>{children}</Box>} |
| 28 | + </div> |
| 29 | + ); |
| 30 | +} |
| 31 | + |
| 32 | +function a11yProps(index: number) { |
| 33 | + return { |
| 34 | + id: `full-width-tab-${index}`, |
| 35 | + "aria-controls": `full-width-tabpanel-${index}`, |
| 36 | + }; |
| 37 | +} |
| 38 | + |
| 39 | +const useStyles = makeStyles((theme: Theme) => ({ |
| 40 | + root: { |
| 41 | + width: "100vw", |
| 42 | + }, |
| 43 | + tabbar: { |
| 44 | + backgroundColor: theme.palette.background.paper, |
| 45 | + }, |
| 46 | +})); |
| 47 | + |
11 | 48 | const MeetingTabs: React.FC = () => { |
12 | 49 | const classes = useStyles(); |
13 | | - return <div className={classes.root}>yolo</div>; |
14 | | -}; |
| 50 | + const theme = useTheme(); |
| 51 | + const [value, setValue] = React.useState(0); |
| 52 | + |
| 53 | + // eslint-disable-next-line @typescript-eslint/ban-types |
| 54 | + const handleChange = (event: React.ChangeEvent<{}>, newValue: number) => { |
| 55 | + setValue(newValue); |
| 56 | + }; |
15 | 57 |
|
| 58 | + const handleChangeIndex = (index: number) => { |
| 59 | + setValue(index); |
| 60 | + }; |
| 61 | + |
| 62 | + return ( |
| 63 | + <div className={classes.root}> |
| 64 | + <AppBar position="static" color="default"> |
| 65 | + <Tabs |
| 66 | + className={classes.tabbar} |
| 67 | + value={value} |
| 68 | + onChange={handleChange} |
| 69 | + indicatorColor="primary" |
| 70 | + textColor="primary" |
| 71 | + variant="fullWidth" |
| 72 | + aria-label="full width tabs example" |
| 73 | + > |
| 74 | + <Tab label="Meetings" {...a11yProps(0)} /> |
| 75 | + <Tab label="Polls" {...a11yProps(1)} /> |
| 76 | + </Tabs> |
| 77 | + </AppBar> |
| 78 | + <SwipeableViews |
| 79 | + axis={theme.direction === "rtl" ? "x-reverse" : "x"} |
| 80 | + index={value} |
| 81 | + onChangeIndex={handleChangeIndex} |
| 82 | + > |
| 83 | + <TabPanel value={value} index={0} dir={theme.direction}> |
| 84 | + SecrET meETiNg |
| 85 | + </TabPanel> |
| 86 | + <TabPanel value={value} index={1} dir={theme.direction}> |
| 87 | + Pollllllling |
| 88 | + </TabPanel> |
| 89 | + </SwipeableViews> |
| 90 | + </div> |
| 91 | + ); |
| 92 | +}; |
16 | 93 | export default MeetingTabs; |
0 commit comments