Notification alert stays on if it is an incoming call and phone is closed (#115)

* Phone now shows all the time slide a bit if incoming call exists | can close alerts!

* Improve animation

* Improve call controls

* Make alerts not overflow | Call modal is navigable out :)

* Open modal when accepting call

* Cant navigate back from homepage

* Avoid call route if no call active + rename things

* Impprove main apps icons sizes

* hover effect to app icons :)

* Revert interface change

* fix(phone/dialer): resolve not calling when adding contacts

Co-authored-by: Christopher <[email protected]>
This commit is contained in:
J Francisco RaderandChristopher authored and GitHub committed 2021-02-26 21:45:01 -05:00
1 parent d2461bab16
commit 41674968ab
24 files changed
+396 -206

No files matched your search

@@ -1,5 +1,6 @@
import React from 'react';
import { Box, makeStyles } from '@material-ui/core';
import CloseIcon from '@material-ui/icons/Close';
import { Box, IconButton, makeStyles, Slide } from '@material-ui/core';
import { useNotifications } from '../hooks/useNotifications';
import { Alert, AlertTitle } from '@material-ui/lab';
@@ -11,6 +12,11 @@ const useStyles = makeStyles((theme) => ({
alignItems: 'center',
},
alert: {
'& .MuiAlert-action': {
top: theme.spacing(1),
right: theme.spacing(2),
position: 'absolute',
},
position: 'relative',
cursor: 'pointer',
width: '370px',
@@ -22,6 +28,16 @@ const useStyles = makeStyles((theme) => ({
color: theme.palette.text.primary,
},
},
alertContent: {
display: '-webkit-box',
maxWidth: '360px',
height: '60px',
margin: '0 auto',
'-webkit-line-clamp': 3,
'-webkit-box-orient': 'vertical',
overflow: 'hidden',
textOverflow: 'ellipsis',
},
}));
export const NotificationAlert = () => {
@@ -30,17 +46,37 @@ export const NotificationAlert = () => {
return (
<div className={classes.snackbar}>
{currentAlert ? (
<Slide in={!!currentAlert} mountOnEnter unmountOnExit>
<Alert
onClick={() => currentAlert.onClick?.(currentAlert)}
icon={currentAlert.icon || false}
action={
<IconButton
color='primary'
size='small'
onClick={(e) => {
e.stopPropagation();
currentAlert?.onCloseAlert(e);
}}
>
<CloseIcon fontSize='small' />
</IconButton>
}
onClick={(e) => currentAlert?.onClickAlert(e)}
icon={currentAlert?.icon || false}
className={classes.alert}
elevation={6}
>
<AlertTitle>{currentAlert.title}</AlertTitle>
<Box width='100%'>{currentAlert.content}</Box>
<AlertTitle>
<Box width='282px' whiteSpace='nowrap'>
<Box overflow='hidden' component='div' textOverflow='ellipsis'>
{currentAlert?.title}
</Box>
</Box>
</AlertTitle>
<Box component='div' className={classes.alertContent}>
{currentAlert?.content}
</Box>
</Alert>
) : null}
</Slide>
</div>
);
};
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React from 'react';
import {
makeStyles,
Typography,
@@ -66,9 +66,13 @@ const useStyles = makeStyles((theme) => ({
export const NotificationBar = () => {
const classes = useStyles();
const { icons, notifications, removeNotification } = useNotifications();
const [uncollapsed, setUncollapsed] = useState<boolean>(false);
const {
icons,
notifications,
removeNotification,
barUncollapsed,
setBarUncollapsed,
} = useNotifications();
return (
<>
@@ -78,7 +82,7 @@ export const NotificationBar = () => {
justify='space-between'
wrap='nowrap'
onClick={() => {
setUncollapsed(!uncollapsed);
setBarUncollapsed((curr) => !curr);
}}
>
<Grid container item wrap='nowrap'>
@@ -115,28 +119,29 @@ export const NotificationBar = () => {
</Grid>
</Grid>
</Grid>
<Slide direction='down' in={uncollapsed}>
<Slide direction='down' in={barUncollapsed}>
<Paper square className={classes.drawer}>
<Box p={2}>
<Box py={2}>
<List>
<Divider />
{notifications.map((notification, idx) => (
<NotificationItem
key={idx}
{...notification}
onClose={(e) => {
e.stopPropagation();
notification.onClose?.(notification);
if (notifications.length === 1) {
setUncollapsed(false);
setBarUncollapsed(false);
}
removeNotification(idx);
}}
onClickClose={() => {
setUncollapsed(false);
setBarUncollapsed(false);
if (!notification.cantClose) {
removeNotification(idx);
}
}}
{...notification}
/>
))}
</List>
@@ -145,7 +150,7 @@ export const NotificationBar = () => {
<IconButton
className={classes.collapseBtn}
size='small'
onClick={() => setUncollapsed(false)}
onClick={() => setBarUncollapsed(false)}
>
<ArrowDropUpIcon />
</IconButton>
@@ -6,16 +6,18 @@ import {
ListItemAvatar,
ListItemText,
makeStyles,
Theme,
} from '@material-ui/core';
import { INotification } from '../providers/NotificationsProvider';
const useStyles = makeStyles((theme) => ({
const useStyles = makeStyles<Theme, { cantClose: boolean }>((theme) => ({
closeNotifBtn: {
position: 'absolute',
right: '8px',
top: '8px',
},
notificationItem: {
paddingRight: ({ cantClose }) => (cantClose ? '8px' : '28px'),
position: 'relative',
},
}));
@@ -29,7 +31,7 @@ export const NotificationItem = ({
onClickClose: (e: any) => void;
}) => {
const { title, icon, content, cantClose, onClick } = notification;
const classes = useStyles();
const classes = useStyles({ cantClose });
return (
<ListItem
divider