mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
Merge branch 'master' of https://github.com/project-error/new-phone-who-dis
This commit is contained in:
commit
fed7b2c13a
15 files changed
+248
-136
No files matched your search
@@ -46,7 +46,8 @@ InjectDebugData([
|
|||||||
{
|
{
|
||||||
id: 3,
|
id: 3,
|
||||||
display: 'Chip',
|
display: 'Chip',
|
||||||
number: '111-1111',
|
number: '603-275-8373',
|
||||||
|
avatar: 'http://i.tasoagc.dev/2QYV',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 4,
|
id: 4,
|
||||||
|
|||||||
@@ -9,10 +9,11 @@ interface IUseContacts {
|
|||||||
getDisplayByNumber: (number: string) => string;
|
getDisplayByNumber: (number: string) => string;
|
||||||
getContactByNumber: (number: string) => Contact | null;
|
getContactByNumber: (number: string) => Contact | null;
|
||||||
getContact: (id: number) => Contact | null;
|
getContact: (id: number) => Contact | null;
|
||||||
|
getPictureByNumber: (number: string) => string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useContacts = (): IUseContacts => {
|
export const useContacts = (): IUseContacts => {
|
||||||
const contacts = useRecoilValue(contactsState.contacts);
|
const contacts = useRecoilValue<Contact[]>(contactsState.contacts);
|
||||||
|
|
||||||
const getDisplayByNumber = useCallback(
|
const getDisplayByNumber = useCallback(
|
||||||
(number: string) => {
|
(number: string) => {
|
||||||
@@ -22,6 +23,14 @@ export const useContacts = (): IUseContacts => {
|
|||||||
[contacts],
|
[contacts],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const getPictureByNumber = useCallback(
|
||||||
|
(number: string) => {
|
||||||
|
const found = contacts.find((contact) => contact.number === number);
|
||||||
|
return found ? found.avatar : null;
|
||||||
|
},
|
||||||
|
[contacts],
|
||||||
|
);
|
||||||
|
|
||||||
const getContactByNumber = useCallback(
|
const getContactByNumber = useCallback(
|
||||||
(number: string): Contact | null => {
|
(number: string): Contact | null => {
|
||||||
for (const contact of contacts) {
|
for (const contact of contacts) {
|
||||||
@@ -42,5 +51,5 @@ export const useContacts = (): IUseContacts => {
|
|||||||
[contacts],
|
[contacts],
|
||||||
);
|
);
|
||||||
|
|
||||||
return { contacts, getDisplayByNumber, getContact, getContactByNumber };
|
return { contacts, getDisplayByNumber, getContact, getContactByNumber, getPictureByNumber };
|
||||||
};
|
};
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
const getBackgroundPath = (bg: string) => `media/backgrounds/${bg}`;
|
||||||
|
|
||||||
|
export default getBackgroundPath;
|
||||||
@@ -2,6 +2,13 @@
|
|||||||
"translation": {
|
"translation": {
|
||||||
"DATE_FORMAT": "MM/DD/YYYY",
|
"DATE_FORMAT": "MM/DD/YYYY",
|
||||||
"DATE_TIME_FORMAT": "MM/DD/YYYY hh:mm A",
|
"DATE_TIME_FORMAT": "MM/DD/YYYY hh:mm A",
|
||||||
|
"CALLS": {
|
||||||
|
"MESSAGES": {
|
||||||
|
"RINGING": "Ringing",
|
||||||
|
"OUTGOING": "Outgoing call",
|
||||||
|
"INCOMING": "Incoming call"
|
||||||
|
}
|
||||||
|
},
|
||||||
"SETTINGS": {
|
"SETTINGS": {
|
||||||
"CATEGORY": {
|
"CATEGORY": {
|
||||||
"APPEARANCE": "Appearance",
|
"APPEARANCE": "Appearance",
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Avatar, Box, Typography } from '@material-ui/core';
|
||||||
|
import { makeStyles } from '@material-ui/core/styles';
|
||||||
|
import { useContacts } from '../../../apps/contacts/hooks/useContacts';
|
||||||
|
import { useCall } from '../hooks/useCall';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
const useStyles = makeStyles({
|
||||||
|
image: {
|
||||||
|
width: 80,
|
||||||
|
height: 80,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const CallContactContainer = () => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { call } = useCall();
|
||||||
|
const classes = useStyles();
|
||||||
|
|
||||||
|
const { getDisplayByNumber, getPictureByNumber } = useContacts();
|
||||||
|
|
||||||
|
const getDisplayOrNumber = () =>
|
||||||
|
call.isTransmitter ? getDisplayByNumber(call?.receiver) : getDisplayByNumber(call?.transmitter);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box display="flex" alignItems="center">
|
||||||
|
<Box style={{ flexGrow: 1 }}>
|
||||||
|
<Typography variant="body1">
|
||||||
|
{call.isTransmitter
|
||||||
|
? t('CALLS.MESSAGES.OUTGOING').toUpperCase()
|
||||||
|
: t('CALLS.MESSAGES.INCOMING').toUpperCase()}
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="h4">{getDisplayOrNumber()}</Typography>
|
||||||
|
</Box>
|
||||||
|
<Avatar
|
||||||
|
className={classes.image}
|
||||||
|
alt={getDisplayOrNumber()}
|
||||||
|
src={
|
||||||
|
call.isTransmitter
|
||||||
|
? getPictureByNumber(call.receiver)
|
||||||
|
: getPictureByNumber(call?.transmitter)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CallContactContainer;
|
||||||
@@ -10,24 +10,24 @@ import { useHistory } from 'react-router-dom';
|
|||||||
const useStyles = makeStyles((theme) => ({
|
const useStyles = makeStyles((theme) => ({
|
||||||
icon: {
|
icon: {
|
||||||
color: theme.palette.secondary.contrastText,
|
color: theme.palette.secondary.contrastText,
|
||||||
|
boxShadow: '0 .5rem 3rem -.25em rgba(0,0,0,.3)',
|
||||||
|
},
|
||||||
|
iconWrapper: {
|
||||||
|
height: 60,
|
||||||
|
width: 60,
|
||||||
|
},
|
||||||
|
smallIconWrapper: {
|
||||||
|
height: 40,
|
||||||
|
width: 40,
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const SIZES_SPACING = {
|
export const CallControls = ({ isSmall }: { isSmall?: boolean }) => {
|
||||||
small: 1,
|
|
||||||
medium: 3,
|
|
||||||
};
|
|
||||||
|
|
||||||
export const CallControls = ({ size }: { size?: 'small' | 'medium' }) => {
|
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const { setModal } = useCallModal();
|
const { setModal } = useCallModal();
|
||||||
const { call, endCall, acceptCall, rejectCall } = useCall();
|
const { call, endCall, acceptCall, rejectCall } = useCall();
|
||||||
|
|
||||||
if (!call) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleAcceptCall = (e) => {
|
const handleAcceptCall = (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
history.push('/call');
|
history.push('/call');
|
||||||
@@ -46,27 +46,40 @@ export const CallControls = ({ size }: { size?: 'small' | 'medium' }) => {
|
|||||||
endCall();
|
endCall();
|
||||||
};
|
};
|
||||||
|
|
||||||
const { accepted, isTransmitter } = call;
|
// We display only the hang up if the call is accepted
|
||||||
|
// or we are the one calling
|
||||||
if (accepted || isTransmitter) {
|
if (call.accepted || call.isTransmitter)
|
||||||
return (
|
return (
|
||||||
<StatusIconButton color="error" size={size} onClick={handleEndCall}>
|
<Box display="flex" justifyContent="center" px={2} my={2}>
|
||||||
<CallEndIcon />
|
<StatusIconButton
|
||||||
</StatusIconButton>
|
color="error"
|
||||||
);
|
size={isSmall ? 'small' : 'medium'}
|
||||||
}
|
onClick={handleEndCall}
|
||||||
return (
|
className={isSmall ? classes.smallIconWrapper : classes.iconWrapper}
|
||||||
<>
|
>
|
||||||
<Box m={SIZES_SPACING[size] || 1} display="inline">
|
|
||||||
<StatusIconButton color="error" size={size} onClick={handleRejectCall}>
|
|
||||||
<CallEndIcon className={classes.icon} />
|
<CallEndIcon className={classes.icon} />
|
||||||
</StatusIconButton>
|
</StatusIconButton>
|
||||||
</Box>
|
</Box>
|
||||||
<Box m={SIZES_SPACING[size] || 1} display="inline">
|
);
|
||||||
<StatusIconButton color="success" size={size} onClick={handleAcceptCall}>
|
|
||||||
<CallIcon className={classes.icon} />
|
return (
|
||||||
</StatusIconButton>
|
<Box display="flex" alignItems="center" justifyContent="space-between" px={2} my={2}>
|
||||||
</Box>
|
<StatusIconButton
|
||||||
</>
|
color="error"
|
||||||
|
size={isSmall ? 'small' : 'medium'}
|
||||||
|
onClick={handleRejectCall}
|
||||||
|
className={isSmall ? classes.smallIconWrapper : classes.iconWrapper}
|
||||||
|
>
|
||||||
|
<CallEndIcon className={classes.icon} />
|
||||||
|
</StatusIconButton>
|
||||||
|
<StatusIconButton
|
||||||
|
color="success"
|
||||||
|
size={isSmall ? 'small' : 'medium'}
|
||||||
|
onClick={handleAcceptCall}
|
||||||
|
className={isSmall ? classes.smallIconWrapper : classes.iconWrapper}
|
||||||
|
>
|
||||||
|
<CallIcon className={classes.icon} />
|
||||||
|
</StatusIconButton>
|
||||||
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -2,29 +2,45 @@ import React from 'react';
|
|||||||
import { AppWrapper } from '../../../ui/components/AppWrapper';
|
import { AppWrapper } from '../../../ui/components/AppWrapper';
|
||||||
import { AppContent } from '../../../ui/components/AppContent';
|
import { AppContent } from '../../../ui/components/AppContent';
|
||||||
import { useCall } from '../hooks/useCall';
|
import { useCall } from '../hooks/useCall';
|
||||||
import useStyles from './modal.styles';
|
import { CallTimer } from './CallTimer';
|
||||||
import CallTimer from './CallTimer';
|
|
||||||
import { CallControls } from './CallControls';
|
import { CallControls } from './CallControls';
|
||||||
import { Box } from '@material-ui/core';
|
import { Box } from '@material-ui/core';
|
||||||
import { useSimcard } from '../../simcard/hooks/useSimcard';
|
import { useSettings } from '../../../apps/settings/hooks/useSettings';
|
||||||
|
import getBackgroundPath from '../../../apps/settings/utils/getBackgroundPath';
|
||||||
|
import CallContactContainer from './CallContactContainer';
|
||||||
|
import { makeStyles } from '@material-ui/core/styles';
|
||||||
|
import RingingText from './RingingText';
|
||||||
|
|
||||||
|
const useStyles = makeStyles({
|
||||||
|
root: {
|
||||||
|
height: '100%',
|
||||||
|
backdropFilter: 'blur(20px) brightness(0.6)',
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
export const CallModal = () => {
|
export const CallModal = () => {
|
||||||
const classes = useStyles();
|
const [settings] = useSettings();
|
||||||
const { call } = useCall();
|
const { call } = useCall();
|
||||||
const { number: myNumber } = useSimcard();
|
|
||||||
|
const classes = useStyles();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppWrapper>
|
<AppWrapper>
|
||||||
<AppContent>
|
<AppContent
|
||||||
<Box pt={24}>
|
paperStyle={{
|
||||||
<h1 style={{ textAlign: 'center' }}>
|
backgroundImage: `url(${getBackgroundPath(settings.wallpaper.value)})`,
|
||||||
{myNumber === call?.transmitter ? call?.receiver : call?.transmitter}
|
}}
|
||||||
</h1>
|
>
|
||||||
<CallTimer isAccepted={call?.accepted} />
|
<Box className={classes.root} padding={5}>
|
||||||
|
<Box>
|
||||||
|
<CallContactContainer />
|
||||||
|
{call.accepted ? <CallTimer /> : call.isTransmitter && <RingingText />}
|
||||||
|
</Box>
|
||||||
|
<CallControls />
|
||||||
</Box>
|
</Box>
|
||||||
<div className={classes.actions}>
|
|
||||||
<CallControls size="medium" />
|
|
||||||
</div>
|
|
||||||
</AppContent>
|
</AppContent>
|
||||||
</AppWrapper>
|
</AppWrapper>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export const CallNotification = ({ children }: { children: React.ReactNode }) =>
|
|||||||
<div className={classes.root}>
|
<div className={classes.root}>
|
||||||
<Box>{children}</Box>
|
<Box>{children}</Box>
|
||||||
<Box className={classes.controls}>
|
<Box className={classes.controls}>
|
||||||
<CallControls size="small" />
|
<CallControls isSmall />
|
||||||
</Box>
|
</Box>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,58 +1,16 @@
|
|||||||
import React, { useEffect, useRef } from 'react';
|
import React from 'react';
|
||||||
import { useDuration } from '../hooks/useDuration';
|
import { Box, Typography } from '@material-ui/core';
|
||||||
|
import useTimer from '../hooks/useTimer';
|
||||||
|
|
||||||
const runTimer = (updatedTime, setDuration) => {
|
const formatTime = (time: number) => (time < 10 ? `0${time}` : time);
|
||||||
let newTime = { ...updatedTime.current };
|
|
||||||
if (newTime.m >= 60) {
|
|
||||||
newTime = { ...newTime, h: newTime.h + 1, m: 0 };
|
|
||||||
}
|
|
||||||
if (newTime.s >= 60) {
|
|
||||||
newTime = { ...newTime, m: newTime.m + 1, s: 0 };
|
|
||||||
}
|
|
||||||
if (newTime.ms >= 100) {
|
|
||||||
newTime = { ...newTime, s: newTime.s + 1, ms: 0 };
|
|
||||||
}
|
|
||||||
|
|
||||||
newTime = { ...newTime, ms: newTime.ms + 1 };
|
|
||||||
updatedTime.current = newTime;
|
|
||||||
setDuration(newTime);
|
|
||||||
};
|
|
||||||
|
|
||||||
function CallTimer({ isAccepted }) {
|
|
||||||
const { duration, setDuration } = useDuration();
|
|
||||||
const updatedTime = useRef({ ms: 0, s: 0, m: 0, h: 0 });
|
|
||||||
const timer = useRef(null);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (isAccepted) {
|
|
||||||
runTimer(updatedTime, setDuration);
|
|
||||||
timer.current = setInterval(() => {
|
|
||||||
runTimer(updatedTime, setDuration);
|
|
||||||
}, 10);
|
|
||||||
} else {
|
|
||||||
clearInterval(timer.current);
|
|
||||||
timer.current = null;
|
|
||||||
}
|
|
||||||
return () => clearInterval(timer.current);
|
|
||||||
}, [isAccepted, setDuration]);
|
|
||||||
|
|
||||||
if (!duration || !isAccepted) return null;
|
|
||||||
|
|
||||||
|
export const CallTimer = () => {
|
||||||
|
const { seconds, hours, minutes } = useTimer();
|
||||||
return (
|
return (
|
||||||
<div
|
<Box>
|
||||||
style={{
|
<Typography variant="body1">
|
||||||
textAlign: 'center',
|
{`${formatTime(hours)}:${formatTime(minutes)}:${formatTime(seconds)}`}
|
||||||
marginTop: '2em',
|
</Typography>
|
||||||
fontSize: 30,
|
</Box>
|
||||||
}}
|
|
||||||
>
|
|
||||||
<span>{duration.h >= 10 ? duration.h : '0' + duration.h}</span>
|
|
||||||
:
|
|
||||||
<span>{duration.m >= 10 ? duration.m : '0' + duration.m}</span>
|
|
||||||
:
|
|
||||||
<span>{duration.s >= 10 ? duration.s : '0' + duration.s}</span>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default CallTimer;
|
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import React, { useState, useEffect } from 'react';
|
||||||
|
import { Typography } from '@material-ui/core';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
const RingingText = () => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const [text, setText] = useState<string>(t('CALLS.MESSAGES.RINGING'));
|
||||||
|
const [step, setStep] = useState<number>(0);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const id = setInterval(() => {
|
||||||
|
if (step < 3) {
|
||||||
|
setStep(step + 1);
|
||||||
|
setText(text + '.');
|
||||||
|
} else {
|
||||||
|
setText(t('CALLS.MESSSAGES.RINGING'));
|
||||||
|
setStep(0);
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
|
return () => clearInterval(id);
|
||||||
|
}, [step, text, t]);
|
||||||
|
|
||||||
|
return <Typography>{text}</Typography>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default RingingText;
|
||||||
@@ -3,31 +3,30 @@ import { useNuiEvent } from '../../nui-events/hooks/useNuiEvent';
|
|||||||
import { useSetRecoilState } from 'recoil';
|
import { useSetRecoilState } from 'recoil';
|
||||||
import { useCall } from './useCall';
|
import { useCall } from './useCall';
|
||||||
import { CallEvents, CallProps } from '../../../../../typings/call';
|
import { CallEvents, CallProps } from '../../../../../typings/call';
|
||||||
import InjectDebugData from '../../debug/InjectDebugData';
|
// import InjectDebugData from '../../debug/InjectDebugData';
|
||||||
import { useCallModal } from './useCallModal';
|
import { useCallModal } from './useCallModal';
|
||||||
import { useHistory, useLocation } from 'react-router-dom';
|
import { useHistory, useLocation } from 'react-router-dom';
|
||||||
import { callerState } from './state';
|
import { callerState } from './state';
|
||||||
import { useCallNotifications } from './useCallNotifications';
|
import { useCallNotifications } from './useCallNotifications';
|
||||||
import { useDuration } from './useDuration';
|
|
||||||
|
|
||||||
InjectDebugData<CallProps | boolean>([
|
// InjectDebugData<CallProps | boolean>([
|
||||||
/* {
|
// {
|
||||||
app: 'CALL',
|
// app: 'CALL',
|
||||||
method: 'setCaller',
|
// method: CallEvents.SET_CALLER,
|
||||||
data: {
|
// data: {
|
||||||
accepted: true,
|
// accepted: true,
|
||||||
isTransmitter: false,
|
// isTransmitter: false,
|
||||||
transmitter: 'Chip',
|
// transmitter: '603-275-8373',
|
||||||
receiver: 'Taso',
|
// receiver: '603-275-4747',
|
||||||
active: true,
|
// active: true,
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
app: 'CALL',
|
// app: 'CALL',
|
||||||
method: 'callModal',
|
// method: CallEvents.SET_CALL_MODAL,
|
||||||
data: true,
|
// data: true,
|
||||||
}, */
|
// },
|
||||||
]);
|
// ]);
|
||||||
|
|
||||||
export const useCallService = () => {
|
export const useCallService = () => {
|
||||||
const { modal } = useCallModal();
|
const { modal } = useCallModal();
|
||||||
@@ -35,7 +34,6 @@ export const useCallService = () => {
|
|||||||
const { pathname } = useLocation();
|
const { pathname } = useLocation();
|
||||||
|
|
||||||
const { call, setCall } = useCall();
|
const { call, setCall } = useCall();
|
||||||
const { resetDuration } = useDuration();
|
|
||||||
|
|
||||||
const { setNotification } = useCallNotifications();
|
const { setNotification } = useCallNotifications();
|
||||||
|
|
||||||
@@ -57,7 +55,6 @@ export const useCallService = () => {
|
|||||||
}, [history, modal, pathname, modalHasBeenOpenedThisCall]);
|
}, [history, modal, pathname, modalHasBeenOpenedThisCall]);
|
||||||
|
|
||||||
const _setCall = (_call: CallProps) => {
|
const _setCall = (_call: CallProps) => {
|
||||||
resetDuration();
|
|
||||||
setCall(_call);
|
setCall(_call);
|
||||||
setNotification(_call);
|
setNotification(_call);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
import { useCallback } from 'react';
|
|
||||||
import { useRecoilState } from 'recoil';
|
|
||||||
import { callerState } from './state';
|
|
||||||
|
|
||||||
export const useDuration = () => {
|
|
||||||
const [duration, setDuration] = useRecoilState(callerState.callDuration);
|
|
||||||
|
|
||||||
const resetDuration = useCallback(() => setDuration({ ms: 0, s: 0, m: 0, h: 0 }), [setDuration]);
|
|
||||||
|
|
||||||
return { duration, setDuration, resetDuration };
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
import { useEffect, useRef, useState } from 'react';
|
||||||
|
|
||||||
|
const getTimeFromSeconds = (secs: number) => {
|
||||||
|
const totalSeconds = Math.ceil(secs);
|
||||||
|
const hours = Math.floor((totalSeconds % (60 * 60 * 24)) / (60 * 60));
|
||||||
|
const minutes = Math.floor((totalSeconds % (60 * 60)) / 60);
|
||||||
|
const seconds = Math.floor(totalSeconds % 60);
|
||||||
|
|
||||||
|
return {
|
||||||
|
seconds,
|
||||||
|
minutes,
|
||||||
|
hours,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const useTimer = () => {
|
||||||
|
const intervalRef = useRef<NodeJS.Timer>();
|
||||||
|
const [seconds, setSeconds] = useState(0);
|
||||||
|
|
||||||
|
const clearIntervalRef = () => {
|
||||||
|
if (intervalRef.current) {
|
||||||
|
clearInterval(intervalRef.current);
|
||||||
|
intervalRef.current = undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const startTimer = () => {
|
||||||
|
if (!intervalRef.current) {
|
||||||
|
intervalRef.current = setInterval(() => setSeconds((prevSeconds) => prevSeconds + 1), 1000);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const resetTimer = () => {
|
||||||
|
clearIntervalRef();
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
startTimer();
|
||||||
|
return clearIntervalRef;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return { ...getTimeFromSeconds(seconds), startTimer, resetTimer };
|
||||||
|
};
|
||||||
|
|
||||||
|
export default useTimer;
|
||||||
@@ -23,7 +23,7 @@ const useStyles = makeStyles(() => ({
|
|||||||
|
|
||||||
export const AppContent = ({
|
export const AppContent = ({
|
||||||
children,
|
children,
|
||||||
style,
|
paperStyle,
|
||||||
backdrop,
|
backdrop,
|
||||||
onClickBackdrop,
|
onClickBackdrop,
|
||||||
...props
|
...props
|
||||||
@@ -38,7 +38,7 @@ export const AppContent = ({
|
|||||||
>
|
>
|
||||||
<Backdrop className={classes.backdrop} open={backdrop || false} onClick={onClickBackdrop} />
|
<Backdrop className={classes.backdrop} open={backdrop || false} onClick={onClickBackdrop} />
|
||||||
<Box flexGrow={1} className={classes.box} {...props}>
|
<Box flexGrow={1} className={classes.box} {...props}>
|
||||||
<Paper square elevation={0} className={classes.paper}>
|
<Paper square elevation={0} className={classes.paper} style={paperStyle}>
|
||||||
{children}
|
{children}
|
||||||
</Paper>
|
</Paper>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { CSSProperties } from 'react';
|
|||||||
|
|
||||||
export interface AppContentTypes {
|
export interface AppContentTypes {
|
||||||
children?: JSX.Element | JSX.Element[];
|
children?: JSX.Element | JSX.Element[];
|
||||||
style?: CSSProperties;
|
paperStyle?: CSSProperties;
|
||||||
backdrop?: boolean;
|
backdrop?: boolean;
|
||||||
onClickBackdrop?: (...args: any[]) => void;
|
onClickBackdrop?: (...args: any[]) => void;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user