9
9
message ,
10
10
theme ,
11
11
Tooltip ,
12
+ Switch ,
12
13
} from 'antd' ;
13
14
import { useLocation , useNavigate } from 'react-router-dom' ;
14
15
import { ReactNode , useEffect , useRef , useState } from 'react' ;
@@ -21,6 +22,8 @@ import {
21
22
QuestionOutlined ,
22
23
SettingOutlined ,
23
24
UserOutlined ,
25
+ MoonOutlined ,
26
+ SunOutlined ,
24
27
} from '@ant-design/icons' ;
25
28
import {
26
29
CSSTransition ,
@@ -33,6 +36,8 @@ import HeaderNav from './HeaderNav.tsx';
33
36
import FooterNav from './FooterNav.tsx' ;
34
37
import { NProgress } from '../../components' ;
35
38
import { PATH_LANDING } from '../../constants' ;
39
+ import { useSelector , useDispatch } from 'react-redux' ;
40
+ import { toggleTheme } from '../../redux/theme/themeSlice.ts' ;
36
41
37
42
const { Content } = Layout ;
38
43
@@ -52,7 +57,8 @@ export const AppLayout = ({ children }: AppLayoutProps) => {
52
57
const navigate = useNavigate ( ) ;
53
58
const nodeRef = useRef ( null ) ;
54
59
const floatBtnRef = useRef ( null ) ;
55
-
60
+ const dispatch = useDispatch ( ) ;
61
+ const { mytheme } = useSelector ( ( state : RootState ) => state . theme ) ;
56
62
const items : MenuProps [ 'items' ] = [
57
63
{
58
64
key : 'user-profile-link' ,
@@ -110,7 +116,7 @@ export const AppLayout = ({ children }: AppLayoutProps) => {
110
116
< Layout
111
117
style = { {
112
118
minHeight : '100vh' ,
113
- backgroundColor : 'white' ,
119
+ // backgroundColor: 'white',
114
120
} }
115
121
>
116
122
< SideNav
@@ -130,9 +136,11 @@ export const AppLayout = ({ children }: AppLayoutProps) => {
130
136
} }
131
137
/>
132
138
< Layout
133
- style = { {
134
- background : 'none' ,
135
- } }
139
+ style = {
140
+ {
141
+ // background: 'none',
142
+ }
143
+ }
136
144
>
137
145
< HeaderNav
138
146
style = { {
@@ -182,6 +190,15 @@ export const AppLayout = ({ children }: AppLayoutProps) => {
182
190
< Tooltip title = "Messages" >
183
191
< Button icon = { < MessageOutlined /> } type = "text" size = "large" />
184
192
</ Tooltip >
193
+ < Tooltip title = "Theme" >
194
+ < Switch
195
+ className = " hidden sm:inline py-1"
196
+ checkedChildren = { < MoonOutlined /> }
197
+ unCheckedChildren = { < SunOutlined /> }
198
+ checked = { mytheme === 'light' ? true : false }
199
+ onClick = { ( ) => dispatch ( toggleTheme ( ) ) }
200
+ />
201
+ </ Tooltip >
185
202
< Dropdown menu = { { items } } trigger = { [ 'click' ] } >
186
203
< Flex >
187
204
< img
@@ -198,7 +215,7 @@ export const AppLayout = ({ children }: AppLayoutProps) => {
198
215
< Content
199
216
style = { {
200
217
margin : `0 0 0 ${ collapsed ? 0 : '200px' } ` ,
201
- background : '#ebedf0' ,
218
+ // background: '#ebedf0',
202
219
borderRadius : collapsed ? 0 : borderRadius ,
203
220
transition : 'all .25s' ,
204
221
padding : '24px 32px' ,
0 commit comments