mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 06:28:51 +00:00
feat(SnackbarProvider): interface update | wrap around phone
This commit is contained in:
1 parent
babce2f568
commit
c38fe9ef66
3 files changed
+39
-15
No files matched your search
+13
-10
@@ -32,6 +32,7 @@ import { useModal } from './modal/hooks/useModal';
|
||||
import { useDialService } from './apps/dialer/hooks/useDialService';
|
||||
import InjectDebugData from './os/debug/InjectDebugData';
|
||||
import { useQuickAccess } from './os/notifications/hooks/useQuickAccess';
|
||||
import SnackbarProvider from './ui/components/SnackbarProvider';
|
||||
|
||||
InjectDebugData([
|
||||
{
|
||||
@@ -151,16 +152,18 @@ function Phone() {
|
||||
}))}
|
||||
/>
|
||||
<div className='PhoneAppContainer'>
|
||||
{modal ? (
|
||||
<CallModal />
|
||||
) : (
|
||||
<>
|
||||
<Route exact path='/' component={HomeApp} />
|
||||
{allApps.map((App) => (
|
||||
<App.Route key={App.id} />
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
<SnackbarProvider>
|
||||
{modal ? (
|
||||
<CallModal />
|
||||
) : (
|
||||
<>
|
||||
<Route exact path='/' component={HomeApp} />
|
||||
{allApps.map((App) => (
|
||||
<App.Route key={App.id} />
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
</SnackbarProvider>
|
||||
</div>
|
||||
<Navigation />
|
||||
</>
|
||||
|
||||
@@ -1,12 +1,25 @@
|
||||
import React, { createContext, useState, useEffect, useMemo, useCallback } from 'react';
|
||||
import { SnackBar } from './SnackBar';
|
||||
import Alert from './Alert';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import { Snackbar } from '@material-ui/core';
|
||||
|
||||
const useStyles = makeStyles(() => ({
|
||||
alert: {
|
||||
position: 'absolute',
|
||||
bottom: '15%',
|
||||
right: '25%',
|
||||
margin: '0 auto',
|
||||
textAlign: 'center'
|
||||
}
|
||||
}))
|
||||
|
||||
|
||||
export const SnackbarContext = createContext(null);
|
||||
const AUTO_HIDE = 2000;
|
||||
const AUTO_HIDE = 1500;
|
||||
|
||||
function SnackbarProvider({ children }) {
|
||||
const [alerts, setAlerts] = useState([]);
|
||||
const classes = useStyles();
|
||||
|
||||
const alertIdx = alerts.join(',');
|
||||
|
||||
@@ -21,8 +34,16 @@ function SnackbarProvider({ children }) {
|
||||
|
||||
return (
|
||||
<SnackbarContext.Provider value={value}>
|
||||
{children}
|
||||
{alerts.map((alert) => <SnackBar key={alert}>{alert}</SnackBar>)}
|
||||
<>
|
||||
{children}
|
||||
{alerts.map((alert) => (
|
||||
<div className={classes.alert}>
|
||||
<Alert auto key={alert} severity="success" variant="filled">
|
||||
{alert}
|
||||
</Alert>
|
||||
</div>
|
||||
))}
|
||||
</>
|
||||
</SnackbarContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useContext } from 'react';
|
||||
import { SnackbarContext } from '../components/SnackbarProvider';
|
||||
|
||||
interface ISnackBar {
|
||||
addAlert: (message: string, severity: string) => void;
|
||||
addAlert: (message: string, type: string) => void;
|
||||
}
|
||||
|
||||
export const useSnackbar = (): ISnackBar => useContext(SnackbarContext);
|
||||
Reference in new issue
Block a user