@@ -14,14 +14,16 @@ import ListItem from '@mui/material/ListItem';
1414import ListItemButton from '@mui/material/ListItemButton' ;
1515import ListItemIcon from '@mui/material/ListItemIcon' ;
1616import ListItemText from '@mui/material/ListItemText' ;
17+ import Brightness5Icon from '@mui/icons-material/Brightness5' ;
18+ import Brightness7Icon from '@mui/icons-material/Brightness7' ;
1719import TravelExploreIcon from '@mui/icons-material/TravelExplore' ;
1820import SettingsIcon from '@mui/icons-material/Settings' ;
1921import AttachMoneyIcon from '@mui/icons-material/AttachMoney' ;
2022import InfoIcon from '@mui/icons-material/Info' ;
2123import { useNavigate } from 'react-router-dom' ;
2224import DrawerHeader from '../DrawerHeader' ;
2325import { MainContext } from '../../contexts/MainContextProvider' ;
24- import { openWebSite } from '../../reducers/MainReducer/Actions' ;
26+ import { openWebSite , setThemeType } from '../../reducers/MainReducer/Actions' ;
2527
2628const drawerWidth = 240 ;
2729
@@ -82,7 +84,8 @@ const Drawer = styled(MuiDrawer, { shouldForwardProp: (prop) => prop !== 'open'
8284) ;
8385
8486const TopBar = ( ) => {
85- const [ state ] = useContext ( MainContext ) ;
87+ const [ state , d1 ] = useContext ( MainContext ) ;
88+ const { themeType, themeToggle } = state ;
8689
8790 const [ open , setOpen ] = useState ( false ) ;
8891
@@ -132,6 +135,13 @@ const TopBar = () => {
132135 handleDrawerClose ( ) ;
133136 } ;
134137
138+ /**
139+ * Change the theme style
140+ */
141+ const changeThemeStyle = ( ) => {
142+ d1 ( setThemeType ( themeType === 'dark' ? 'light' : 'dark' ) ) ;
143+ } ;
144+
135145 return (
136146 < >
137147 < AppBar
@@ -161,6 +171,16 @@ const TopBar = () => {
161171 >
162172 { language . applicationName }
163173 </ Typography >
174+ < div style = { { flexGrow : 1 } } />
175+ { themeToggle ? (
176+ < IconButton
177+ aria-label = { language . theme }
178+ color = "inherit"
179+ onClick = { changeThemeStyle }
180+ >
181+ { themeType === 'dark' ? < Brightness5Icon /> : < Brightness7Icon /> }
182+ </ IconButton >
183+ ) : null }
164184 </ Toolbar >
165185 </ AppBar >
166186 < Drawer variant = "permanent" open = { open } >
0 commit comments