feat(SnackbarProvider): interface update | wrap around phone

This commit is contained in:
Christopher committed 2021-02-09 19:19:36 +01:00
1 parent babce2f568
commit c38fe9ef66
3 files changed
+39 -15

No files matched your search

+13 -10
View File
@@ -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 />
</>
+25 -4
View File
@@ -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>
)
}
+1 -1
View File
@@ -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);