mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +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 Paper from '@material-ui/core/Paper';
|
||||||
import Snackbar from '@material-ui/core/Snackbar';
|
import Snackbar from '@material-ui/core/Snackbar';
|
||||||
import Fade from '@material-ui/core/Fade';
|
import Fade from '@material-ui/core/Fade';
|
||||||
|
import { createMuiTheme, ThemeProvider } from '@material-ui/core';
|
||||||
import { makeStyles } from '@material-ui/core/styles';
|
import { makeStyles } from '@material-ui/core/styles';
|
||||||
import { usePhone } from '../../os/phone/hooks/usePhone';
|
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({
|
const useStyles = makeStyles({
|
||||||
paper: {
|
paper: {
|
||||||
width: '350px',
|
width: '350px',
|
||||||
@@ -20,27 +25,32 @@ function Notification({ children, handleClose, open }) {
|
|||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const { config } = usePhone();
|
const { config } = usePhone();
|
||||||
|
|
||||||
|
const [settings] = useRecoilState(settingsState);
|
||||||
|
|
||||||
if (!config) return null;
|
if (!config) return null;
|
||||||
|
|
||||||
const { horizontal, vertical } = config.notificationPosition;
|
const { horizontal, vertical } = config.notificationPosition;
|
||||||
|
const currentTheme = () => createMuiTheme(themeConfig.themes[settings.theme]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Snackbar
|
<ThemeProvider theme={currentTheme()}>
|
||||||
className={classes.snackBar}
|
<Snackbar
|
||||||
anchorOrigin={{ horizontal, vertical }}
|
className={classes.snackBar}
|
||||||
ClickAwayListenerProps={{
|
anchorOrigin={{ horizontal, vertical }}
|
||||||
onClickAway: () =>
|
ClickAwayListenerProps={{
|
||||||
setTimeout(() => {
|
onClickAway: () =>
|
||||||
handleClose();
|
setTimeout(() => {
|
||||||
}, 5000),
|
handleClose();
|
||||||
}}
|
}, 5000),
|
||||||
onClose={handleClose}
|
}}
|
||||||
open={open}
|
onClose={handleClose}
|
||||||
TransitionComponent={Fade}
|
open={open}
|
||||||
autoHideDuration={6000}
|
TransitionComponent={Fade}
|
||||||
>
|
autoHideDuration={6000}
|
||||||
<Paper className={classes.paper}>{children}</Paper>
|
>
|
||||||
</Snackbar>
|
<Paper className={classes.paper}>{children}</Paper>
|
||||||
|
</Snackbar>
|
||||||
|
</ThemeProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user