mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
feat(modals/call/nui): inital commit for calling modal
This commit is contained in:
1 parent
59ad36c7fd
commit
c35b5f2b84
6 files changed
+109
-26
No files matched your search
@@ -1,29 +1,68 @@
|
|||||||
import React from 'react';
|
import React, { useState } from 'react';
|
||||||
import { green } from '@material-ui/core/colors';
|
import { Button, Fab } from '@material-ui/core';
|
||||||
import { AppWrapper } from '../../ui/components/AppWrapper';
|
import { AppWrapper } from '../../ui/components/AppWrapper';
|
||||||
import { AppTitle } from '../../ui/components/AppTitle';
|
import { AppTitle } from '../../ui/components/AppTitle';
|
||||||
import { AppContent } from '../../ui/components/AppContent';
|
import { AppContent } from '../../ui/components/AppContent';
|
||||||
|
import { useCall } from '../hooks/useCall';
|
||||||
|
import CallIcon from '@material-ui/icons/Call';
|
||||||
|
import PhoneDisabledIcon from '@material-ui/icons/PhoneDisabled';
|
||||||
|
import CallEndIcon from '@material-ui/icons/CallEnd';
|
||||||
|
import useStyles from './modal.styles';
|
||||||
|
import { useModal } from '../hooks/useModal';
|
||||||
|
|
||||||
export const CallModal = () => {
|
export const CallModal = () => {
|
||||||
|
const { call, setCall } = useCall();
|
||||||
|
const { setModal } = useModal()
|
||||||
|
const [accepted, setAccepted] = useState(false)
|
||||||
|
|
||||||
|
const classes = useStyles()
|
||||||
|
|
||||||
|
const handleAcceptCall = () => {
|
||||||
|
setAccepted(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleRejectCall = () => {
|
||||||
|
setModal(false)
|
||||||
|
setCall(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleEndCall = () => {
|
||||||
|
setModal(false)
|
||||||
|
setCall(null)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppWrapper>
|
<AppWrapper>
|
||||||
<AppTitle
|
|
||||||
app={{
|
|
||||||
backgroundColor: green[400],
|
|
||||||
color: green[50],
|
|
||||||
nameLocale: 'Call',
|
|
||||||
}}
|
|
||||||
variant='h4'
|
|
||||||
/>
|
|
||||||
<AppContent>
|
<AppContent>
|
||||||
<h1
|
<h1 style={{ textAlign: 'center' }}>{call.target}</h1>
|
||||||
style={{
|
|
||||||
display: 'flex',
|
<div className={classes.actions}>
|
||||||
justifyContent: 'center',
|
{!accepted ? (
|
||||||
}}
|
<>
|
||||||
>
|
<Fab
|
||||||
Call
|
onClick={handleRejectCall}
|
||||||
</h1>
|
style={{ backgroundColor: '#e74c3c', color: '#fff' }}
|
||||||
|
className={classes.actionButton}>
|
||||||
|
<CallEndIcon />
|
||||||
|
</Fab>
|
||||||
|
<Fab
|
||||||
|
onClick={handleAcceptCall}
|
||||||
|
style={{ backgroundColor: '#27ae60', color: '#fff' }}
|
||||||
|
className={classes.actionButton}
|
||||||
|
>
|
||||||
|
<CallIcon />
|
||||||
|
</Fab>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<Fab
|
||||||
|
onClick={handleEndCall}
|
||||||
|
style={{ backgroundColor: '#e74c3c', color: '#fff' }}
|
||||||
|
className={classes.actionButton}
|
||||||
|
>
|
||||||
|
<CallEndIcon />
|
||||||
|
</Fab>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</AppContent>
|
</AppContent>
|
||||||
</AppWrapper>
|
</AppWrapper>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { makeStyles, Theme } from '@material-ui/core/styles';
|
||||||
|
|
||||||
|
const useStyles = makeStyles((theme: Theme) => ({
|
||||||
|
actions: {
|
||||||
|
width: '100%',
|
||||||
|
margin: 'auto',
|
||||||
|
display: 'flex',
|
||||||
|
alignContent: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
marginTop: '5em'
|
||||||
|
},
|
||||||
|
actionButton: {
|
||||||
|
margin: 20
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
|
|
||||||
|
export default useStyles;
|
||||||
@@ -1,8 +1,12 @@
|
|||||||
import { atom } from 'recoil';
|
import { atom } from 'recoil';
|
||||||
|
|
||||||
export const callerState = {
|
export const callerState = {
|
||||||
caller: atom({
|
currentCall: atom({
|
||||||
key: 'callerList',
|
key: 'currentCall',
|
||||||
default: [],
|
default: null
|
||||||
}),
|
}),
|
||||||
|
callModal: atom({
|
||||||
|
key: 'callingModal',
|
||||||
|
default: false
|
||||||
|
})
|
||||||
};
|
};
|
||||||
@@ -1,7 +1,13 @@
|
|||||||
import { useRecoilState } from 'recoil';
|
import { useRecoilState } from 'recoil';
|
||||||
|
import { CallProps } from '../../common/typings/call';
|
||||||
import { callerState } from './state';
|
import { callerState } from './state';
|
||||||
|
|
||||||
export const useCall = () => {
|
interface CallHook {
|
||||||
const caller = useRecoilState(callerState.caller);
|
call: CallProps;
|
||||||
return { caller };
|
setCall: (details: any) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useCall = (): CallHook => {
|
||||||
|
const [call, setCall] = useRecoilState(callerState.currentCall);
|
||||||
|
return { call, setCall };
|
||||||
};
|
};
|
||||||
@@ -2,9 +2,13 @@ import { useNuiEvent } from '../../os/nui-events/hooks/useNuiEvent';
|
|||||||
import { useSetRecoilState } from 'recoil';
|
import { useSetRecoilState } from 'recoil';
|
||||||
import { callerState } from './state';
|
import { callerState } from './state';
|
||||||
import { useCall } from './useCall';
|
import { useCall } from './useCall';
|
||||||
|
import { useModal } from './useModal';
|
||||||
|
|
||||||
export const useCallService = () => {
|
export const useCallService = () => {
|
||||||
const setCaller = useSetRecoilState(callerState.caller);
|
const setCaller = useSetRecoilState(callerState.currentCall);
|
||||||
|
const setModal= useSetRecoilState(callerState.callModal);
|
||||||
|
|
||||||
useNuiEvent('CALL', 'setCaller', setCaller);
|
useNuiEvent('CALL', 'setCaller', setCaller);
|
||||||
return useCall();
|
useNuiEvent('CALL', 'callModal', setModal);
|
||||||
|
return { useCall, useModal };
|
||||||
};
|
};
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import { useRecoilState } from 'recoil';
|
||||||
|
import { callerState } from './state';
|
||||||
|
|
||||||
|
interface ModalProps {
|
||||||
|
modal: boolean;
|
||||||
|
setModal: (show: boolean) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useModal = (): ModalProps => {
|
||||||
|
const [modal, setModal] = useRecoilState(callerState.callModal);
|
||||||
|
return { modal, setModal }
|
||||||
|
}
|
||||||
Reference in new issue
Block a user