55 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
66 */
77
8- import React from "react" ;
8+ import React , { useRef , useState } from "react" ;
99
1010import { FormattedMessage } from "react-intl" ;
1111import { useHistory } from 'react-router-dom' ;
@@ -26,10 +26,13 @@ import { withStyles } from '@material-ui/core/styles';
2626import ListItemIcon from '@material-ui/core/ListItemIcon' ;
2727import ListItemText from '@material-ui/core/ListItemText' ;
2828import AppsIcon from '@material-ui/icons/Apps' ;
29+ import FullscreenExitIcon from '@material-ui/icons/FullscreenExit' ;
2930
3031import { ReactComponent as PowsyblLogo } from "../images/powsybl_logo.svg" ;
3132import PropTypes from "prop-types" ;
3233import { useSelector } from "react-redux" ;
34+ import FullscreenIcon from '@material-ui/icons/Fullscreen' ;
35+ import FullScreen , { fullScreenSupported } from "react-request-fullscreen" ;
3336
3437const useStyles = makeStyles ( ( ) => ( {
3538 grow : {
@@ -90,6 +93,12 @@ const TopBar = (props) => {
9093
9194 const [ anchorElAppsMenu , setAnchorElAppsMenu ] = React . useState ( null ) ;
9295
96+ const fullScreenRef = useRef ( null ) ;
97+
98+ const [ isFullScreen , setIsFullScreen ] = useState ( false ) ;
99+
100+ const history = useHistory ( ) ;
101+
93102 const handleClickGeneralMenu = event => {
94103 setAnchorElGeneralMenu ( event . currentTarget ) ;
95104 } ;
@@ -105,8 +114,6 @@ const TopBar = (props) => {
105114 setAnchorElAppsMenu ( null ) ;
106115 } ;
107116
108- const history = useHistory ( ) ;
109-
110117 const onParametersClick = ( ) => {
111118 handleCloseGeneralMenu ( ) ;
112119 if ( props . onParametersClick ) {
@@ -119,8 +126,18 @@ const TopBar = (props) => {
119126 history . replace ( "/" ) ;
120127 } ;
121128
129+ function onFullScreenChange ( isFullScreen ) {
130+ setIsFullScreen ( isFullScreen ) ;
131+ }
132+
133+ function requestOrExitFullScreen ( ) {
134+ fullScreenRef . current . fullScreen ( ) ;
135+ }
136+
122137 return (
123138 < AppBar position = "static" color = "default" className = { classes . appBar } >
139+ < FullScreen ref = { fullScreenRef } onFullScreenChange = { onFullScreenChange } onFullScreenError = { ( e ) => console . debug ( "full screen error : " + e . message ) } >
140+ </ FullScreen >
124141 < Toolbar >
125142 < PowsyblLogo className = { classes . logo } onClick = { onLogoClick } />
126143 < Typography variant = "h6" className = { classes . title } onClick = { onLogoClick } >
@@ -184,6 +201,26 @@ const TopBar = (props) => {
184201 < FormattedMessage id = "settings" />
185202 </ ListItemText >
186203 </ StyledMenuItem >
204+ {
205+ fullScreenSupported ( ) ? (
206+ < StyledMenuItem onClick = { requestOrExitFullScreen } >
207+ {
208+ isFullScreen ? ( < >
209+ < ListItemIcon >
210+ < FullscreenExitIcon fontSize = "small" />
211+ </ ListItemIcon >
212+ < ListItemText >
213+ < FormattedMessage id = "exitFullScreen" />
214+ </ ListItemText > </ > ) : ( < >
215+ < ListItemIcon >
216+ < FullscreenIcon fontSize = "small" />
217+ </ ListItemIcon >
218+ < ListItemText >
219+ < FormattedMessage id = "goFullScreen" />
220+ </ ListItemText > </ > )
221+ }
222+ </ StyledMenuItem > ) : < > </ >
223+ }
187224 < StyledMenuItem onClick = { props . onLogoutClick } >
188225 < ListItemIcon >
189226 < ExitToAppIcon fontSize = "small" />
0 commit comments