mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
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:
1 parent
d2461bab16
commit
41674968ab
24 files changed
+396
-206
No files matched your search
@@ -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>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -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>
|
||||
|
||||
@@ -6,7 +6,7 @@ interface ModalProps {
|
||||
setModal: (show: boolean) => void;
|
||||
}
|
||||
|
||||
export const useModal = (): ModalProps => {
|
||||
export const useCallModal = (): ModalProps => {
|
||||
const [modal, setModal] = useRecoilState(callerState.callModal);
|
||||
return { modal, setModal }
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useNuiEvent } from '../../nui-events/hooks/useNuiEvent';
|
||||
import { useSetRecoilState } from 'recoil';
|
||||
import { callerState } from './state';
|
||||
@@ -9,10 +9,12 @@ import { useCall } from './useCall';
|
||||
import { CallProps } from '../../../common/typings/call';
|
||||
import { useApp } from '../../apps/hooks/useApps';
|
||||
import InjectDebugData from '../../debug/InjectDebugData';
|
||||
import { useCallModal } from './useCallModal';
|
||||
import { useHistory, useLocation } from 'react-router-dom';
|
||||
|
||||
const NOTIFICATION_ID = 'call:current';
|
||||
|
||||
InjectDebugData<CallProps>([
|
||||
/* InjectDebugData<CallProps | boolean>([
|
||||
{
|
||||
app: 'CALL',
|
||||
method: 'setCaller',
|
||||
@@ -20,14 +22,22 @@ InjectDebugData<CallProps>([
|
||||
accepted: false,
|
||||
isTransmitter: false,
|
||||
transmitter: 'Chip',
|
||||
receiver: 'Taso',
|
||||
receiver: 'Taso',
|
||||
active: true,
|
||||
},
|
||||
},
|
||||
]);
|
||||
{
|
||||
app: 'CALL',
|
||||
method: 'callModal',
|
||||
data: true,
|
||||
},
|
||||
]); */
|
||||
|
||||
export const useCallService = () => {
|
||||
const { t } = useTranslation();
|
||||
const { modal } = useCallModal();
|
||||
const history = useHistory();
|
||||
const { pathname } = useLocation();
|
||||
const {
|
||||
addNotificationAlert,
|
||||
removeId,
|
||||
@@ -40,14 +50,30 @@ export const useCallService = () => {
|
||||
|
||||
const setModal = useSetRecoilState(callerState.callModal);
|
||||
|
||||
const [modalHasBeenOpenedThisCall, setModalOpened] = useState<boolean>(false);
|
||||
|
||||
const callNotificationBase = {
|
||||
app: 'CALL',
|
||||
id: NOTIFICATION_ID,
|
||||
cantClose: true,
|
||||
icon,
|
||||
onClick: () => history.push('/call'),
|
||||
notificationIcon,
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setModalOpened(!!modal);
|
||||
}, [modal]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!modal && pathname === '/call') {
|
||||
history.replace('/');
|
||||
}
|
||||
if (modal && !modalHasBeenOpenedThisCall && pathname !== '/call') {
|
||||
history.push('/call');
|
||||
}
|
||||
}, [history, modal, pathname, modalHasBeenOpenedThisCall]);
|
||||
|
||||
const _setCall = (_call: CallProps) => {
|
||||
setCall(_call);
|
||||
if (!_call || !_call.active) {
|
||||
@@ -76,6 +102,7 @@ export const useCallService = () => {
|
||||
title: t('APPS_DIALER_INCOMING_CALL_TITLE', {
|
||||
transmitter: _call.transmitter,
|
||||
}),
|
||||
keepWhenPhoneClosed: true,
|
||||
content: (
|
||||
<CallNotification>
|
||||
{t('APPS_DIALER_TRANSMITTER_IS_CALLING', {
|
||||
|
||||
Reference in new issue
Block a user