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

+44 -34
View File
@@ -1,30 +1,47 @@
import React from 'react';
import CallIcon from '@material-ui/icons/Call';
import CallEndIcon from '@material-ui/icons/CallEnd';
import { Fab } from '@material-ui/core';
import { useCall } from '../hooks/useCall';
import useStyles from './modal.styles';
import { useModal } from '../hooks/useModal';
import { useCallModal } from '../hooks/useCallModal';
import { StatusIconButton } from '../../../ui/components/StatusIconButton';
import { Box, makeStyles } from '@material-ui/core';
import { useHistory } from 'react-router-dom';
export const CallControls = ({
size,
}: {
size?: 'small' | 'medium' | 'large';
}) => {
const useStyles = makeStyles((theme) => ({
icon: {
color: theme.palette.secondary.contrastText,
},
}));
const SIZES_SPACING = {
small: 1,
medium: 3,
};
export const CallControls = ({ size }: { size?: 'small' | 'medium' }) => {
const classes = useStyles();
const { setModal } = useModal();
const history = useHistory();
const { setModal } = useCallModal();
const { call, endCall, acceptCall, rejectCall } = useCall();
if (!call) {
return null;
}
const handleRejectCall = () => {
const handleAcceptCall = (e) => {
e.stopPropagation();
history.push('/call');
acceptCall();
};
const handleRejectCall = (e) => {
e.stopPropagation();
setModal(false);
rejectCall();
};
const handleEndCall = () => {
const handleEndCall = (e) => {
e.stopPropagation();
setModal(false);
endCall();
};
@@ -33,34 +50,27 @@ export const CallControls = ({
if (accepted || isTransmitter) {
return (
<Fab
size={size}
onClick={handleEndCall}
style={{ backgroundColor: '#e74c3c', color: '#fff' }}
className={classes.actionButton}
>
<StatusIconButton color='error' size={size} onClick={handleEndCall}>
<CallEndIcon />
</Fab>
</StatusIconButton>
);
}
return (
<>
<Fab
size={size}
onClick={handleRejectCall}
style={{ backgroundColor: '#e74c3c', color: '#fff' }}
className={classes.actionButton}
>
<CallEndIcon />
</Fab>
<Fab
size={size}
onClick={acceptCall}
style={{ backgroundColor: '#27ae60', color: '#fff' }}
className={classes.actionButton}
>
<CallIcon />
</Fab>
<Box m={SIZES_SPACING[size] || 1} display='inline'>
<StatusIconButton color='error' size={size} onClick={handleRejectCall}>
<CallEndIcon className={classes.icon} />
</StatusIconButton>
</Box>
<Box m={SIZES_SPACING[size] || 1} display='inline'>
<StatusIconButton
color='success'
size={size}
onClick={handleAcceptCall}
>
<CallIcon className={classes.icon} />
</StatusIconButton>
</Box>
</>
);
};
+2 -2
View File
@@ -14,12 +14,12 @@ export const CallModal = () => {
return (
<AppWrapper>
<AppContent>
<Box pt={16}>
<Box pt={24}>
<h1 style={{ textAlign: 'center' }}>{call?.transmitter}</h1>
<CallTimer isAccepted={call?.accepted} />
</Box>
<div className={classes.actions}>
<CallControls />
<CallControls size="medium" />
</div>
</AppContent>
</AppWrapper>
@@ -1,5 +1,5 @@
import React from 'react';
import { Box } from '@material-ui/core';
import { Box, makeStyles } from '@material-ui/core';
import { CallControls } from './CallControls';
interface ICallNotificationProps {
@@ -7,15 +7,27 @@ interface ICallNotificationProps {
onReject(): void;
}
const useStyles = makeStyles((theme) => ({
root: {
paddingBottom: '48px',
},
controls: {
position: 'absolute',
bottom: theme.spacing(1),
right: '4px',
},
}));
export const CallNotification = ({
children,
}: {
children: React.ReactNode;
}) => {
const classes = useStyles();
return (
<div style={{ paddingBottom: '48px' }}>
<div className={classes.root}>
<Box>{children}</Box>
<Box style={{ position: 'absolute', bottom: 0, right: 0 }}>
<Box className={classes.controls}>
<CallControls size='small' />
</Box>
</div>