2022-09-16 09:46:11 -05:00
|
|
|
import { styled } from '@mui/material/styles'
|
2023-01-24 03:50:14 +00:00
|
|
|
|
|
|
|
import IconButton from '@mui/material/IconButton'
|
2022-09-16 09:46:11 -05:00
|
|
|
import MuiAppBar, { AppBarProps as MuiAppBarProps } from '@mui/material/AppBar'
|
2023-01-24 03:50:14 +00:00
|
|
|
import Fab from '@mui/material/Fab'
|
2022-09-16 09:46:11 -05:00
|
|
|
import StepIcon from '@mui/material/StepIcon'
|
2023-01-24 03:50:14 +00:00
|
|
|
import Toolbar from '@mui/material/Toolbar'
|
2022-09-16 09:46:11 -05:00
|
|
|
import Tooltip from '@mui/material/Tooltip'
|
2023-01-24 03:50:14 +00:00
|
|
|
import Typography from '@mui/material/Typography'
|
|
|
|
import Slide from '@mui/material/Slide'
|
|
|
|
import Zoom from '@mui/material/Zoom'
|
|
|
|
|
|
|
|
import ExpandMore from '@mui/icons-material/ExpandMore'
|
|
|
|
import Fullscreen from '@mui/icons-material/Fullscreen'
|
|
|
|
import FullscreenExit from '@mui/icons-material/FullscreenExit'
|
|
|
|
import Link from '@mui/icons-material/Link'
|
|
|
|
import Menu from '@mui/icons-material/Menu'
|
|
|
|
import QrCode2 from '@mui/icons-material/QrCode2'
|
|
|
|
import RoomPreferences from '@mui/icons-material/RoomPreferences'
|
2022-09-16 09:46:11 -05:00
|
|
|
|
|
|
|
import { drawerWidth } from './Drawer'
|
2022-10-05 01:08:38 +11:00
|
|
|
import { peerListWidth } from './PeerList'
|
2022-09-16 09:46:11 -05:00
|
|
|
|
|
|
|
interface AppBarProps extends MuiAppBarProps {
|
2022-10-05 01:08:38 +11:00
|
|
|
isDrawerOpen?: boolean
|
|
|
|
isPeerListOpen?: boolean
|
2022-09-16 09:46:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export const AppBar = styled(MuiAppBar, {
|
2022-10-05 01:08:38 +11:00
|
|
|
shouldForwardProp: prop =>
|
|
|
|
prop !== 'isDrawerOpen' && prop !== 'isPeerListOpen',
|
|
|
|
})<AppBarProps>(({ theme, isDrawerOpen, isPeerListOpen }) => ({
|
2022-09-16 09:46:11 -05:00
|
|
|
transition: theme.transitions.create(['margin', 'width'], {
|
|
|
|
easing: theme.transitions.easing.sharp,
|
|
|
|
duration: theme.transitions.duration.leavingScreen,
|
|
|
|
}),
|
2022-10-05 01:08:38 +11:00
|
|
|
...(isDrawerOpen && {
|
2022-09-16 09:46:11 -05:00
|
|
|
width: `calc(100% - ${drawerWidth}px)`,
|
|
|
|
marginLeft: `${drawerWidth}px`,
|
|
|
|
}),
|
2022-10-05 01:08:38 +11:00
|
|
|
...(isPeerListOpen && {
|
|
|
|
width: `calc(100% - ${peerListWidth}px)`,
|
|
|
|
marginRight: `${peerListWidth}px`,
|
2022-11-26 09:49:02 -06:00
|
|
|
}),
|
|
|
|
...((isDrawerOpen || isPeerListOpen) && {
|
2022-10-05 01:08:38 +11:00
|
|
|
transition: theme.transitions.create(['margin', 'width'], {
|
|
|
|
easing: theme.transitions.easing.easeOut,
|
|
|
|
duration: theme.transitions.duration.enteringScreen,
|
|
|
|
}),
|
|
|
|
}),
|
2022-11-26 09:49:02 -06:00
|
|
|
...(isDrawerOpen &&
|
|
|
|
isPeerListOpen && {
|
|
|
|
width: `calc(100% - ${drawerWidth}px - ${peerListWidth}px)`,
|
|
|
|
}),
|
2022-09-16 09:46:11 -05:00
|
|
|
}))
|
|
|
|
|
|
|
|
interface ShellAppBarProps {
|
|
|
|
doShowPeers: boolean
|
2022-10-05 01:08:38 +11:00
|
|
|
onDrawerOpen: () => void
|
|
|
|
onLinkButtonClick: () => Promise<void>
|
2022-09-16 09:46:11 -05:00
|
|
|
isDrawerOpen: boolean
|
2022-10-05 01:08:38 +11:00
|
|
|
isPeerListOpen: boolean
|
2022-09-16 09:46:11 -05:00
|
|
|
numberOfPeers: number
|
|
|
|
title: string
|
2022-10-25 21:49:27 -05:00
|
|
|
onPeerListClick: () => void
|
2023-01-24 03:50:14 +00:00
|
|
|
onRoomControlsClick: () => void
|
2022-11-06 12:41:24 +11:00
|
|
|
setIsQRCodeDialogOpen: (isOpen: boolean) => void
|
2023-01-24 03:50:14 +00:00
|
|
|
showAppBar: boolean
|
|
|
|
isFullscreen: boolean
|
|
|
|
setIsFullscreen: (isFullscreen: boolean) => void
|
2022-09-16 09:46:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export const ShellAppBar = ({
|
|
|
|
doShowPeers,
|
2022-10-05 01:08:38 +11:00
|
|
|
onDrawerOpen,
|
|
|
|
onLinkButtonClick,
|
2022-09-16 09:46:11 -05:00
|
|
|
isDrawerOpen,
|
2022-10-05 01:08:38 +11:00
|
|
|
isPeerListOpen,
|
2022-11-06 12:41:24 +11:00
|
|
|
setIsQRCodeDialogOpen,
|
2022-09-16 09:46:11 -05:00
|
|
|
numberOfPeers,
|
|
|
|
title,
|
2022-10-25 21:49:27 -05:00
|
|
|
onPeerListClick,
|
2023-01-24 03:50:14 +00:00
|
|
|
onRoomControlsClick,
|
|
|
|
showAppBar,
|
|
|
|
isFullscreen,
|
|
|
|
setIsFullscreen,
|
2022-09-16 09:46:11 -05:00
|
|
|
}: ShellAppBarProps) => {
|
2022-11-06 12:41:24 +11:00
|
|
|
const handleQRCodeClick = () => setIsQRCodeDialogOpen(true)
|
2023-01-24 03:50:14 +00:00
|
|
|
const onClickFullscreen = () => setIsFullscreen(!isFullscreen)
|
2022-09-16 09:46:11 -05:00
|
|
|
return (
|
2023-01-24 03:50:14 +00:00
|
|
|
<>
|
|
|
|
<Slide appear={false} in={showAppBar} mountOnEnter unmountOnExit>
|
|
|
|
<AppBar
|
|
|
|
position="fixed"
|
|
|
|
isDrawerOpen={isDrawerOpen}
|
|
|
|
isPeerListOpen={isPeerListOpen}
|
2022-09-16 09:46:11 -05:00
|
|
|
>
|
2023-01-24 03:50:14 +00:00
|
|
|
<Toolbar
|
|
|
|
variant="regular"
|
|
|
|
sx={{
|
|
|
|
display: 'flex',
|
|
|
|
flexDirection: 'row',
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
}}
|
2022-11-06 20:52:56 -06:00
|
|
|
>
|
2023-01-24 03:50:14 +00:00
|
|
|
<IconButton
|
|
|
|
size="large"
|
|
|
|
edge="start"
|
|
|
|
color="inherit"
|
|
|
|
aria-label="Open menu"
|
|
|
|
sx={{ mr: 2, ...(isDrawerOpen && { display: 'none' }) }}
|
|
|
|
onClick={onDrawerOpen}
|
|
|
|
>
|
|
|
|
<Menu />
|
|
|
|
</IconButton>
|
|
|
|
<Typography
|
|
|
|
variant="h6"
|
|
|
|
noWrap
|
|
|
|
component="div"
|
|
|
|
sx={{ marginRight: 'auto' }}
|
|
|
|
>
|
|
|
|
{title}
|
|
|
|
</Typography>
|
|
|
|
<Tooltip title="Copy current URL">
|
2022-11-06 12:41:24 +11:00
|
|
|
<IconButton
|
|
|
|
size="large"
|
|
|
|
color="inherit"
|
2023-01-24 03:50:14 +00:00
|
|
|
aria-label="Copy current URL"
|
|
|
|
onClick={onLinkButtonClick}
|
2022-11-06 12:41:24 +11:00
|
|
|
>
|
2023-01-24 03:50:14 +00:00
|
|
|
<Link />
|
2022-11-06 12:41:24 +11:00
|
|
|
</IconButton>
|
|
|
|
</Tooltip>
|
2023-01-24 03:50:14 +00:00
|
|
|
{doShowPeers ? (
|
|
|
|
<>
|
|
|
|
<Tooltip title="Show QR Code">
|
|
|
|
<IconButton
|
|
|
|
size="large"
|
|
|
|
color="inherit"
|
|
|
|
aria-label="Show QR Code"
|
|
|
|
onClick={handleQRCodeClick}
|
|
|
|
>
|
|
|
|
<QrCode2 />
|
|
|
|
</IconButton>
|
|
|
|
</Tooltip>
|
|
|
|
<Tooltip title="Show Room Controls">
|
|
|
|
<IconButton
|
|
|
|
size="large"
|
|
|
|
color="inherit"
|
|
|
|
aria-label="show room controls"
|
|
|
|
onClick={onRoomControlsClick}
|
|
|
|
>
|
|
|
|
<RoomPreferences />
|
|
|
|
</IconButton>
|
|
|
|
</Tooltip>
|
|
|
|
<Tooltip
|
|
|
|
title={isFullscreen ? 'Exit fullscreen' : 'Enter fullscreen'}
|
|
|
|
>
|
|
|
|
<IconButton
|
|
|
|
size="large"
|
|
|
|
edge="end"
|
|
|
|
color="inherit"
|
|
|
|
aria-label="fullscreen"
|
|
|
|
onClick={onClickFullscreen}
|
|
|
|
>
|
|
|
|
{isFullscreen ? <FullscreenExit /> : <Fullscreen />}
|
|
|
|
</IconButton>
|
|
|
|
</Tooltip>
|
|
|
|
<Tooltip title="Click to show peer list">
|
|
|
|
<IconButton
|
|
|
|
size="large"
|
|
|
|
edge="end"
|
|
|
|
color="inherit"
|
|
|
|
aria-label="Peer list"
|
|
|
|
onClick={onPeerListClick}
|
|
|
|
>
|
|
|
|
<StepIcon icon={numberOfPeers} />
|
|
|
|
</IconButton>
|
|
|
|
</Tooltip>
|
|
|
|
</>
|
|
|
|
) : null}
|
|
|
|
</Toolbar>
|
|
|
|
</AppBar>
|
|
|
|
</Slide>
|
|
|
|
<Zoom
|
|
|
|
style={{ position: 'absolute', left: '16px', top: '16px' }}
|
|
|
|
in={!showAppBar}
|
|
|
|
unmountOnExit
|
|
|
|
>
|
|
|
|
<Tooltip title="Show room controls">
|
|
|
|
<Fab
|
|
|
|
size="small"
|
|
|
|
aria-label="show room controls"
|
|
|
|
color="primary"
|
|
|
|
onClick={onRoomControlsClick}
|
|
|
|
>
|
|
|
|
<ExpandMore />
|
|
|
|
</Fab>
|
|
|
|
</Tooltip>
|
|
|
|
</Zoom>
|
|
|
|
</>
|
2022-09-16 09:46:11 -05:00
|
|
|
)
|
|
|
|
}
|