@@ -10,7 +10,8 @@ import useKey from "use-key-hook"
1010import classnames from "classnames"
1111import { useSettings } from "../SettingsProvider"
1212import SettingsDialog from "../SettingsDialog"
13- import Fullscreen from "../Fullscreen"
13+ // import Fullscreen from "../Fullscreen"
14+ import { FullScreen , useFullScreenHandle } from "react-full-screen"
1415import getActiveImage from "../Annotator/reducers/get-active-image"
1516import useImpliedVideoRegions from "./use-implied-video-regions"
1617import { useDispatchHotkeyHandlers } from "../ShortcutsManager"
@@ -55,6 +56,7 @@ export const MainLayout = ({
5556} : Props ) => {
5657 const classes = useStyles ( )
5758 const settings = useSettings ( )
59+ const fullScreenHandle = useFullScreenHandle ( )
5860
5961 const memoizedActionFns = useRef ( { } )
6062 const action = ( type : string , ...params : Array < string > ) => {
@@ -165,6 +167,11 @@ export const MainLayout = ({
165167 } )
166168
167169 const onClickHeaderItem = useEventCallback ( ( item ) => {
170+ if ( item . name === "Fullscreen" ) {
171+ fullScreenHandle . enter ( )
172+ } else if ( item . name === "Window" ) {
173+ fullScreenHandle . exit ( )
174+ }
168175 dispatch ( { type : "HEADER_BUTTON_CLICKED" , buttonName : item . name } )
169176 } )
170177
@@ -173,11 +180,12 @@ export const MainLayout = ({
173180 ! nextImage || ( nextImage . regions && nextImage . regions . length > 0 )
174181
175182 return (
176- < Fullscreen
177- enabled = { state . fullScreen }
183+ < FullScreen
184+ handle = { fullScreenHandle }
178185 onChange = { ( open ) => {
179186 if ( ! open ) {
180- action ( "HEADER_BUTTON_CLICKED" , "buttonName" ) ( "Exit Fullscreen" )
187+ fullScreenHandle . exit ( )
188+ action ( "HEADER_BUTTON_CLICKED" , "buttonName" ) ( "Window" )
181189 }
182190 } }
183191 >
@@ -323,7 +331,7 @@ export const MainLayout = ({
323331 }
324332 />
325333 </ HotkeyDiv >
326- </ Fullscreen >
334+ </ FullScreen >
327335 )
328336}
329337
0 commit comments