Added full screen button

This commit is contained in:
Mitchell McCaffrey 2020-09-06 15:18:05 +10:00
parent 24a3387b51
commit 58cb92d432
7 changed files with 138 additions and 56 deletions

View File

@ -16,6 +16,10 @@ import BrushToolIcon from "../../icons/BrushToolIcon";
import MeasureToolIcon from "../../icons/MeasureToolIcon"; import MeasureToolIcon from "../../icons/MeasureToolIcon";
import ExpandMoreIcon from "../../icons/ExpandMoreIcon"; import ExpandMoreIcon from "../../icons/ExpandMoreIcon";
import PointerToolIcon from "../../icons/PointerToolIcon"; import PointerToolIcon from "../../icons/PointerToolIcon";
import FullScreenIcon from "../../icons/FullScreenIcon";
import FullScreenExitIcon from "../../icons/FullScreenExitIcon";
import useSetting from "../../helpers/useSetting";
function MapContols({ function MapContols({
onMapChange, onMapChange,
@ -31,6 +35,7 @@ function MapContols({
disabledSettings, disabledSettings,
}) { }) {
const [isExpanded, setIsExpanded] = useState(true); const [isExpanded, setIsExpanded] = useState(true);
const [fullScreen, setFullScreen] = useSetting("map.fullScreen");
const toolsById = { const toolsById = {
pan: { pan: {
@ -190,6 +195,24 @@ function MapContols({
{controls} {controls}
</Flex> </Flex>
{getToolSettings()} {getToolSettings()}
<Box
sx={{
position: "absolute",
right: 0,
bottom: 0,
backgroundColor: "overlay",
borderRadius: "50%",
}}
m={2}
>
<IconButton
onClick={() => setFullScreen(!fullScreen)}
aria-label={fullScreen ? "Exit Full Screen" : "Enter Full Screen"}
title={fullScreen ? "Exit Full Screen" : "Enter Full Screen"}
>
{fullScreen ? <FullScreenExitIcon /> : <FullScreenIcon />}
</IconButton>
</Box>
</> </>
); );
} }

View File

@ -6,6 +6,8 @@ import DiceTrayOverlay from "../dice/DiceTrayOverlay";
import { DiceLoadingProvider } from "../../contexts/DiceLoadingContext"; import { DiceLoadingProvider } from "../../contexts/DiceLoadingContext";
import useSetting from "../../helpers/useSetting";
function DiceTrayButton({ function DiceTrayButton({
shareDice, shareDice,
onShareDiceChage, onShareDiceChage,
@ -13,13 +15,14 @@ function DiceTrayButton({
onDiceRollsChange, onDiceRollsChange,
}) { }) {
const [isExpanded, setIsExpanded] = useState(false); const [isExpanded, setIsExpanded] = useState(false);
const [fullScreen] = useSetting("map.fullScreen");
return ( return (
<Flex <Flex
sx={{ sx={{
position: "absolute", position: "absolute",
top: 0, top: 0,
left: "100%", left: fullScreen ? "0" : "100%",
bottom: 0, bottom: 0,
flexDirection: "column", flexDirection: "column",
alignItems: "flex-start", alignItems: "flex-start",

View File

@ -11,6 +11,8 @@ import StartTimerButton from "./StartTimerButton";
import Timer from "./Timer"; import Timer from "./Timer";
import DiceTrayButton from "./DiceTrayButton"; import DiceTrayButton from "./DiceTrayButton";
import useSetting from "../../helpers/useSetting";
function Party({ function Party({
nickname, nickname,
partyNicknames, partyNicknames,
@ -30,81 +32,95 @@ function Party({
onDiceRollsChange, onDiceRollsChange,
partyDiceRolls, partyDiceRolls,
}) { }) {
const [fullScreen] = useSetting("map.fullScreen");
return ( return (
<Flex <Box
p={3}
bg="background" bg="background"
sx={{ sx={{
flexDirection: "column",
overflow: "visible",
alignItems: "center",
position: "relative", position: "relative",
width: "112px", // width: fullScreen ? "0" : "112px",
minWidth: "112px", // minWidth: fullScreen ? "0" : "112px",
}} }}
> >
<Box <Box
sx={{ sx={{
width: "100%", flexDirection: "column",
}} overflow: "visible",
> alignItems: "center",
<Text mb={1} variant="heading" as="h1"> height: "100%",
Party display: fullScreen ? "none" : "flex",
</Text> width: "112px",
</Box>
<SimpleBar
style={{
flexGrow: 1,
width: "100%",
minWidth: "112px", minWidth: "112px",
padding: "0 16px",
height: "calc(100% - 232px)",
}} }}
p={3}
> >
<Nickname <Box
nickname={`${nickname} (you)`} sx={{
diceRolls={shareDice && diceRolls} width: "100%",
/> }}
{Object.entries(partyNicknames).map(([id, partyNickname]) => ( >
<Text mb={1} variant="heading" as="h1">
Party
</Text>
</Box>
<SimpleBar
style={{
flexGrow: 1,
width: "100%",
minWidth: "112px",
padding: "0 16px",
height: "calc(100% - 232px)",
}}
>
<Nickname <Nickname
nickname={partyNickname} nickname={`${nickname} (you)`}
key={id} diceRolls={shareDice && diceRolls}
stream={partyStreams[id]}
diceRolls={partyDiceRolls[id]}
/> />
))} {Object.entries(partyNicknames).map(([id, partyNickname]) => (
{timer && <Timer timer={timer} index={0} />} <Nickname
{Object.entries(partyTimers).map(([id, partyTimer], index) => ( nickname={partyNickname}
<Timer key={id}
timer={partyTimer} stream={partyStreams[id]}
key={id} diceRolls={partyDiceRolls[id]}
// Put party timers above your timer if there is one />
index={timer ? index + 1 : index} ))}
{timer && <Timer timer={timer} index={0} />}
{Object.entries(partyTimers).map(([id, partyTimer], index) => (
<Timer
timer={partyTimer}
key={id}
// Put party timers above your timer if there is one
index={timer ? index + 1 : index}
/>
))}
</SimpleBar>
<Flex sx={{ flexDirection: "column" }}>
<ChangeNicknameButton
nickname={nickname}
onChange={onNicknameChange}
/> />
))} <AddPartyMemberButton gameId={gameId} />
</SimpleBar> <StartStreamButton
<Flex sx={{ flexDirection: "column" }}> onStreamStart={onStreamStart}
<ChangeNicknameButton nickname={nickname} onChange={onNicknameChange} /> onStreamEnd={onStreamEnd}
<AddPartyMemberButton gameId={gameId} /> stream={stream}
<StartStreamButton />
onStreamStart={onStreamStart} <StartTimerButton
onStreamEnd={onStreamEnd} onTimerStart={onTimerStart}
stream={stream} onTimerStop={onTimerStop}
/> timer={timer}
<StartTimerButton />
onTimerStart={onTimerStart} <SettingsButton />
onTimerStop={onTimerStop} </Flex>
timer={timer} </Box>
/>
<SettingsButton />
</Flex>
<DiceTrayButton <DiceTrayButton
shareDice={shareDice} shareDice={shareDice}
onShareDiceChage={onShareDiceChage} onShareDiceChage={onShareDiceChage}
diceRolls={diceRolls} diceRolls={diceRolls}
onDiceRollsChange={onDiceRollsChange} onDiceRollsChange={onDiceRollsChange}
/> />
</Flex> </Box>
); );
} }

View File

@ -9,6 +9,7 @@ import ProxyToken from "./ProxyToken";
import SelectTokensButton from "./SelectTokensButton"; import SelectTokensButton from "./SelectTokensButton";
import { fromEntries } from "../../helpers/shared"; import { fromEntries } from "../../helpers/shared";
import useSetting from "../../helpers/useSetting";
import AuthContext from "../../contexts/AuthContext"; import AuthContext from "../../contexts/AuthContext";
import TokenDataContext from "../../contexts/TokenDataContext"; import TokenDataContext from "../../contexts/TokenDataContext";
@ -18,6 +19,7 @@ const listTokenClassName = "list-token";
function Tokens({ onMapTokenStateCreate }) { function Tokens({ onMapTokenStateCreate }) {
const { userId } = useContext(AuthContext); const { userId } = useContext(AuthContext);
const { ownedTokens, tokens } = useContext(TokenDataContext); const { ownedTokens, tokens } = useContext(TokenDataContext);
const [fullScreen] = useSetting("map.fullScreen");
function handleProxyDragEnd(isOnMap, token) { function handleProxyDragEnd(isOnMap, token) {
if (isOnMap && onMapTokenStateCreate) { if (isOnMap && onMapTokenStateCreate) {
@ -48,6 +50,7 @@ function Tokens({ onMapTokenStateCreate }) {
width: "80px", width: "80px",
minWidth: "80px", minWidth: "80px",
overflow: "hidden", overflow: "hidden",
display: fullScreen ? "none" : "block",
}} }}
> >
<SimpleBar style={{ height: "calc(100% - 48px)", overflowX: "hidden" }}> <SimpleBar style={{ height: "calc(100% - 48px)", overflowX: "hidden" }}>

View File

@ -0,0 +1,18 @@
import React from "react";
function FullScreenIcon() {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
height="24"
viewBox="0 0 24 24"
width="24"
fill="currentcolor"
>
<path d="M0 0h24v24H0V0z" fill="none" />
<path d="M6 16h2v2c0 .55.45 1 1 1s1-.45 1-1v-3c0-.55-.45-1-1-1H6c-.55 0-1 .45-1 1s.45 1 1 1zm2-8H6c-.55 0-1 .45-1 1s.45 1 1 1h3c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1s-1 .45-1 1v2zm7 11c.55 0 1-.45 1-1v-2h2c.55 0 1-.45 1-1s-.45-1-1-1h-3c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1zm1-11V6c0-.55-.45-1-1-1s-1 .45-1 1v3c0 .55.45 1 1 1h3c.55 0 1-.45 1-1s-.45-1-1-1h-2z" />
</svg>
);
}
export default FullScreenIcon;

View File

@ -0,0 +1,18 @@
import React from "react";
function FullScreenIcon() {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
height="24"
viewBox="0 0 24 24"
width="24"
fill="currentcolor"
>
<path d="M0 0h24v24H0V0z" fill="none" />
<path d="M6 14c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1h3c.55 0 1-.45 1-1s-.45-1-1-1H7v-2c0-.55-.45-1-1-1zm0-4c.55 0 1-.45 1-1V7h2c.55 0 1-.45 1-1s-.45-1-1-1H6c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1zm11 7h-2c-.55 0-1 .45-1 1s.45 1 1 1h3c.55 0 1-.45 1-1v-3c0-.55-.45-1-1-1s-1 .45-1 1v2zM14 6c0 .55.45 1 1 1h2v2c0 .55.45 1 1 1s1-.45 1-1V6c0-.55-.45-1-1-1h-3c-.55 0-1 .45-1 1z" />
</svg>
);
}
export default FullScreenIcon;

View File

@ -27,6 +27,7 @@ function loadVersions(settings) {
style: "galaxy", style: "galaxy",
}, },
})); }));
settings.version(2, (prev) => ({ ...prev, map: { fullScreen: false } }));
} }
export function getSettings() { export function getSettings() {