mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 06:28:51 +00:00
fix(Notification): resolved ThemeProvider issue
This commit is contained in:
1 parent
20f125c9c8
commit
5563125d2c
1 file changed
+26
-16
@@ -2,9 +2,14 @@ import React from 'react';
|
||||
import Paper from '@material-ui/core/Paper';
|
||||
import Snackbar from '@material-ui/core/Snackbar';
|
||||
import Fade from '@material-ui/core/Fade';
|
||||
import { createMuiTheme, ThemeProvider } from '@material-ui/core';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import { usePhone } from '../../os/phone/hooks/usePhone';
|
||||
|
||||
import { useRecoilState } from 'recoil';
|
||||
import { settingsState } from '../../apps/settings/hooks/useSettings';
|
||||
import themeConfig from '../../config/default.json';
|
||||
|
||||
const useStyles = makeStyles({
|
||||
paper: {
|
||||
width: '350px',
|
||||
@@ -20,27 +25,32 @@ function Notification({ children, handleClose, open }) {
|
||||
const classes = useStyles();
|
||||
const { config } = usePhone();
|
||||
|
||||
const [settings] = useRecoilState(settingsState);
|
||||
|
||||
if (!config) return null;
|
||||
|
||||
const { horizontal, vertical } = config.notificationPosition;
|
||||
const currentTheme = () => createMuiTheme(themeConfig.themes[settings.theme]);
|
||||
|
||||
return (
|
||||
<Snackbar
|
||||
className={classes.snackBar}
|
||||
anchorOrigin={{ horizontal, vertical }}
|
||||
ClickAwayListenerProps={{
|
||||
onClickAway: () =>
|
||||
setTimeout(() => {
|
||||
handleClose();
|
||||
}, 5000),
|
||||
}}
|
||||
onClose={handleClose}
|
||||
open={open}
|
||||
TransitionComponent={Fade}
|
||||
autoHideDuration={6000}
|
||||
>
|
||||
<Paper className={classes.paper}>{children}</Paper>
|
||||
</Snackbar>
|
||||
<ThemeProvider theme={currentTheme()}>
|
||||
<Snackbar
|
||||
className={classes.snackBar}
|
||||
anchorOrigin={{ horizontal, vertical }}
|
||||
ClickAwayListenerProps={{
|
||||
onClickAway: () =>
|
||||
setTimeout(() => {
|
||||
handleClose();
|
||||
}, 5000),
|
||||
}}
|
||||
onClose={handleClose}
|
||||
open={open}
|
||||
TransitionComponent={Fade}
|
||||
autoHideDuration={6000}
|
||||
>
|
||||
<Paper className={classes.paper}>{children}</Paper>
|
||||
</Snackbar>
|
||||
</ThemeProvider>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user