mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-05 06:28:51 +00:00
tweak(dial/nui): useContext instead of Consumer
This commit is contained in:
1 parent
ae1715f173
commit
42cdbaab4f
3 files changed
+7
-11
No files matched your search
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { useContext } from 'react';
|
||||||
import { Box, Button, Grid } from '@material-ui/core';
|
import { Box, Button, Grid } from '@material-ui/core';
|
||||||
import { makeStyles, Theme } from '@material-ui/core/styles';
|
import { makeStyles, Theme } from '@material-ui/core/styles';
|
||||||
import { DialInputCtx } from '../context/InputContext';
|
import { DialInputCtx } from '../context/InputContext';
|
||||||
@@ -27,9 +27,9 @@ const ButtonItem = ({ label, onClick }: IBtnItem) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const DialGrid = () => {
|
export const DialGrid = () => {
|
||||||
|
const { add, removeOne, clear} = useContext(DialInputCtx)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DialInputCtx.Consumer>
|
|
||||||
{({ add, removeOne, clear }) => (
|
|
||||||
<Box>
|
<Box>
|
||||||
<Grid container justify='space-around'>
|
<Grid container justify='space-around'>
|
||||||
<ButtonItem label={1} onClick={() => add(1)} />
|
<ButtonItem label={1} onClick={() => add(1)} />
|
||||||
@@ -47,8 +47,6 @@ export const DialGrid = () => {
|
|||||||
<ButtonItem label='-' onClick={() => add('-')} />
|
<ButtonItem label='-' onClick={() => add('-')} />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
|
||||||
</DialInputCtx.Consumer>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { useContext } from 'react';
|
||||||
import { Box, IconButton, InputBase, Paper } from '@material-ui/core';
|
import { Box, IconButton, InputBase, Paper } from '@material-ui/core';
|
||||||
import { makeStyles, Theme } from '@material-ui/core/styles';
|
import { makeStyles, Theme } from '@material-ui/core/styles';
|
||||||
import PhoneIcon from '@material-ui/icons/Phone';
|
import PhoneIcon from '@material-ui/icons/Phone';
|
||||||
@@ -27,6 +27,8 @@ const useStyles = makeStyles((theme: Theme) => ({
|
|||||||
export const DialerInput = () => {
|
export const DialerInput = () => {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
|
||||||
|
const { inputVal } = useContext(DialInputCtx)
|
||||||
|
|
||||||
const handleCall = (number: string) => {
|
const handleCall = (number: string) => {
|
||||||
Nui.send('phone:beginCall', {
|
Nui.send('phone:beginCall', {
|
||||||
number,
|
number,
|
||||||
@@ -34,8 +36,6 @@ export const DialerInput = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DialInputCtx.Consumer>
|
|
||||||
{({ inputVal, add }) => (
|
|
||||||
<Box component={Paper} className={classes.root}>
|
<Box component={Paper} className={classes.root}>
|
||||||
<InputBase
|
<InputBase
|
||||||
placeholder='Enter a number'
|
placeholder='Enter a number'
|
||||||
@@ -46,7 +46,5 @@ export const DialerInput = () => {
|
|||||||
<PhoneIcon onClick={() => handleCall(inputVal)} />
|
<PhoneIcon onClick={() => handleCall(inputVal)} />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
|
||||||
</DialInputCtx.Consumer>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -7,7 +7,7 @@ export const callerState = {
|
|||||||
}),
|
}),
|
||||||
callModal: atom({
|
callModal: atom({
|
||||||
key: 'callingModal',
|
key: 'callingModal',
|
||||||
default: true
|
default: false
|
||||||
}),
|
}),
|
||||||
callDuration: atom({
|
callDuration: atom({
|
||||||
key: 'callDuration',
|
key: 'callDuration',
|
||||||
|
|||||||
Reference in new issue
Block a user