mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
Add dialer app theme | Add new contact button from dialer after you type number
This commit is contained in:
7 files changed
+76
-29
No files matched your search
@@ -1,4 +1,4 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
Avatar as MuiAvatar,
|
Avatar as MuiAvatar,
|
||||||
Box,
|
Box,
|
||||||
@@ -13,12 +13,17 @@ import { useContacts } from '../../hooks/useContacts';
|
|||||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||||
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
|
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
|
||||||
import LogDebugEvent from '../../../../os/debug/LogDebugEvents';
|
import LogDebugEvent from '../../../../os/debug/LogDebugEvents';
|
||||||
|
import { useQueryParams } from '../../../../common/hooks/useQueryParams';
|
||||||
|
|
||||||
interface ContactInfoRouteParams {
|
interface ContactInfoRouteParams {
|
||||||
mode: string;
|
mode: string;
|
||||||
id: string;
|
id: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ContactInfoRouteQuery {
|
||||||
|
addNumber: string;
|
||||||
|
}
|
||||||
|
|
||||||
const useStyles = makeStyles((theme: Theme) => ({
|
const useStyles = makeStyles((theme: Theme) => ({
|
||||||
root: {
|
root: {
|
||||||
height: '100%',
|
height: '100%',
|
||||||
@@ -54,6 +59,7 @@ const ContactsInfoPage = () => {
|
|||||||
const { getContact } = useContacts();
|
const { getContact } = useContacts();
|
||||||
|
|
||||||
const { id } = useParams<ContactInfoRouteParams>();
|
const { id } = useParams<ContactInfoRouteParams>();
|
||||||
|
const { addNumber } = useQueryParams<ContactInfoRouteQuery>();
|
||||||
|
|
||||||
const contact = getContact(parseInt(id));
|
const contact = getContact(parseInt(id));
|
||||||
|
|
||||||
@@ -64,6 +70,12 @@ const ContactsInfoPage = () => {
|
|||||||
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (addNumber) {
|
||||||
|
setNumber(addNumber);
|
||||||
|
}
|
||||||
|
}, [addNumber]);
|
||||||
|
|
||||||
const handleContactAdd = () => {
|
const handleContactAdd = () => {
|
||||||
LogDebugEvent({
|
LogDebugEvent({
|
||||||
action: 'Handling Contact Add',
|
action: 'Handling Contact Add',
|
||||||
@@ -113,6 +125,7 @@ const ContactsInfoPage = () => {
|
|||||||
<div className={classes.listContainer}>
|
<div className={classes.listContainer}>
|
||||||
<MuiAvatar className={classes.avatar} src={avatar} />
|
<MuiAvatar className={classes.avatar} src={avatar} />
|
||||||
<TextField
|
<TextField
|
||||||
|
autoFocus
|
||||||
className={classes.input}
|
className={classes.input}
|
||||||
value={name}
|
value={name}
|
||||||
onChange={(e) => setName(e.target.value)}
|
onChange={(e) => setName(e.target.value)}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { makeStyles, Theme } from '@material-ui/core/styles';
|
|||||||
|
|
||||||
const useStyles = makeStyles((theme: Theme) => ({
|
const useStyles = makeStyles((theme: Theme) => ({
|
||||||
root: {
|
root: {
|
||||||
backgroundColor: '#e9e9e9',
|
backgroundColor: theme.palette.background.default,
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,32 @@ import DialerNavBar from './DialerNavBar';
|
|||||||
import { useDialHistory } from '../hooks/useDialHistory';
|
import { useDialHistory } from '../hooks/useDialHistory';
|
||||||
import InjectDebugData from '../../../os/debug/InjectDebugData';
|
import InjectDebugData from '../../../os/debug/InjectDebugData';
|
||||||
import { ContactList } from '../../contacts/components/List/ContactList';
|
import { ContactList } from '../../contacts/components/List/ContactList';
|
||||||
|
import { DialerThemeProvider } from '../providers/DialerThemeProvider';
|
||||||
|
|
||||||
|
export const DialerApp = () => {
|
||||||
|
const history = useDialHistory();
|
||||||
|
|
||||||
|
const dialer = useApp('DIALER');
|
||||||
|
return (
|
||||||
|
<DialerThemeProvider>
|
||||||
|
<AppWrapper>
|
||||||
|
<AppTitle app={dialer} />
|
||||||
|
<AppContent>
|
||||||
|
<Switch>
|
||||||
|
<Route path='/phone/dial'>
|
||||||
|
<DialPage />
|
||||||
|
</Route>
|
||||||
|
<Route exact path='/phone'>
|
||||||
|
<DialerHistory calls={history} />
|
||||||
|
</Route>
|
||||||
|
<Route path='/phone/contacts' component={ContactList}></Route>
|
||||||
|
</Switch>
|
||||||
|
</AppContent>
|
||||||
|
<DialerNavBar />
|
||||||
|
</AppWrapper>
|
||||||
|
</DialerThemeProvider>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
InjectDebugData([
|
InjectDebugData([
|
||||||
{
|
{
|
||||||
@@ -29,26 +55,3 @@ InjectDebugData([
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export const DialerApp = () => {
|
|
||||||
const history = useDialHistory();
|
|
||||||
|
|
||||||
const dialer = useApp('DIALER');
|
|
||||||
return (
|
|
||||||
<AppWrapper>
|
|
||||||
<AppTitle app={dialer} />
|
|
||||||
<AppContent>
|
|
||||||
<Switch>
|
|
||||||
<Route path='/phone/dial'>
|
|
||||||
<DialPage />
|
|
||||||
</Route>
|
|
||||||
<Route exact path='/phone'>
|
|
||||||
<DialerHistory calls={history} />
|
|
||||||
</Route>
|
|
||||||
<Route path='/phone/contacts' component={ContactList}></Route>
|
|
||||||
</Switch>
|
|
||||||
</AppContent>
|
|
||||||
<DialerNavBar />
|
|
||||||
</AppWrapper>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -2,8 +2,10 @@ 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';
|
||||||
|
import PersonAddIcon from '@material-ui/icons/PersonAdd';
|
||||||
import { DialInputCtx } from '../context/InputContext';
|
import { DialInputCtx } from '../context/InputContext';
|
||||||
import Nui from '../../../os/nui-events/utils/Nui';
|
import Nui from '../../../os/nui-events/utils/Nui';
|
||||||
|
import { useHistory } from 'react-router-dom';
|
||||||
|
|
||||||
const useStyles = makeStyles((theme: Theme) => ({
|
const useStyles = makeStyles((theme: Theme) => ({
|
||||||
root: {
|
root: {
|
||||||
@@ -26,8 +28,9 @@ const useStyles = makeStyles((theme: Theme) => ({
|
|||||||
|
|
||||||
export const DialerInput = () => {
|
export const DialerInput = () => {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
const history = useHistory();
|
||||||
|
|
||||||
const { inputVal } = useContext(DialInputCtx)
|
const { inputVal } = useContext(DialInputCtx);
|
||||||
|
|
||||||
const handleCall = (number: string) => {
|
const handleCall = (number: string) => {
|
||||||
Nui.send('phone:beginCall', {
|
Nui.send('phone:beginCall', {
|
||||||
@@ -35,6 +38,10 @@ export const DialerInput = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleNewContact = (number: string) => {
|
||||||
|
history.push(`/contacts/-1/?addNumber=${number}`)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box component={Paper} className={classes.root}>
|
<Box component={Paper} className={classes.root}>
|
||||||
<InputBase
|
<InputBase
|
||||||
@@ -42,8 +49,11 @@ export const DialerInput = () => {
|
|||||||
className={classes.input}
|
className={classes.input}
|
||||||
value={inputVal}
|
value={inputVal}
|
||||||
/>
|
/>
|
||||||
|
<IconButton color='primary' className={classes.iconBtn}>
|
||||||
|
<PhoneIcon fontSize="large" onClick={() => handleCall(inputVal)} />
|
||||||
|
</IconButton>
|
||||||
<IconButton className={classes.iconBtn}>
|
<IconButton className={classes.iconBtn}>
|
||||||
<PhoneIcon onClick={() => handleCall(inputVal)} />
|
<PersonAddIcon fontSize="large" onClick={() => handleNewContact(inputVal)} />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ import HistoryIcon from '@material-ui/icons/History';
|
|||||||
const useStyles = makeStyles((theme: Theme) => ({
|
const useStyles = makeStyles((theme: Theme) => ({
|
||||||
root: {
|
root: {
|
||||||
width: '100%',
|
width: '100%',
|
||||||
backgroundColor: theme.palette.background.default,
|
backgroundColor: theme.palette.background.paper,
|
||||||
},
|
},
|
||||||
icon: {
|
icon: {
|
||||||
color: '#43a047',
|
color: theme.palette.primary.main,
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { common, green } from "@material-ui/core/colors";
|
||||||
|
|
||||||
|
export const DIALER_APP_PRIMARY_COLOR = green[600];
|
||||||
|
export const DIALER_APP_TEXT_COLOR = common.white;
|
||||||
|
|
||||||
|
const theme = {
|
||||||
|
palette: {
|
||||||
|
primary: {
|
||||||
|
main: DIALER_APP_PRIMARY_COLOR,
|
||||||
|
dark: green[800],
|
||||||
|
light: green[400],
|
||||||
|
contrastText: DIALER_APP_TEXT_COLOR
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default theme;
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
import { createAppThemeProvider } from '../../../os/apps/utils/createAppThemeProvider';
|
||||||
|
import dialerTheme from '../dialer.theme';
|
||||||
|
|
||||||
|
export const DialerThemeProvider = createAppThemeProvider(dialerTheme);
|
||||||
Reference in new issue
Block a user