Add dialer app theme | Add new contact button from dialer after you type number

This commit is contained in:
J Francisco Rader committed 2021-02-21 19:24:38 -05:00
1 parent 2c6358e4c3
commit ada49700e5
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 {
Avatar as MuiAvatar,
Box,
@@ -13,12 +13,17 @@ import { useContacts } from '../../hooks/useContacts';
import Nui from '../../../../os/nui-events/utils/Nui';
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
import LogDebugEvent from '../../../../os/debug/LogDebugEvents';
import { useQueryParams } from '../../../../common/hooks/useQueryParams';
interface ContactInfoRouteParams {
mode: string;
id: string;
}
interface ContactInfoRouteQuery {
addNumber: string;
}
const useStyles = makeStyles((theme: Theme) => ({
root: {
height: '100%',
@@ -54,6 +59,7 @@ const ContactsInfoPage = () => {
const { getContact } = useContacts();
const { id } = useParams<ContactInfoRouteParams>();
const { addNumber } = useQueryParams<ContactInfoRouteQuery>();
const contact = getContact(parseInt(id));
@@ -64,6 +70,12 @@ const ContactsInfoPage = () => {
const { t } = useTranslation();
useEffect(() => {
if (addNumber) {
setNumber(addNumber);
}
}, [addNumber]);
const handleContactAdd = () => {
LogDebugEvent({
action: 'Handling Contact Add',
@@ -113,6 +125,7 @@ const ContactsInfoPage = () => {
<div className={classes.listContainer}>
<MuiAvatar className={classes.avatar} src={avatar} />
<TextField
autoFocus
className={classes.input}
value={name}
onChange={(e) => setName(e.target.value)}
@@ -4,7 +4,7 @@ import { makeStyles, Theme } from '@material-ui/core/styles';
const useStyles = makeStyles((theme: Theme) => ({
root: {
backgroundColor: '#e9e9e9',
backgroundColor: theme.palette.background.default,
},
}));
+26 -23
View File
@@ -10,6 +10,32 @@ import DialerNavBar from './DialerNavBar';
import { useDialHistory } from '../hooks/useDialHistory';
import InjectDebugData from '../../../os/debug/InjectDebugData';
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([
{
@@ -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 { makeStyles, Theme } from '@material-ui/core/styles';
import PhoneIcon from '@material-ui/icons/Phone';
import PersonAddIcon from '@material-ui/icons/PersonAdd';
import { DialInputCtx } from '../context/InputContext';
import Nui from '../../../os/nui-events/utils/Nui';
import { useHistory } from 'react-router-dom';
const useStyles = makeStyles((theme: Theme) => ({
root: {
@@ -26,8 +28,9 @@ const useStyles = makeStyles((theme: Theme) => ({
export const DialerInput = () => {
const classes = useStyles();
const history = useHistory();
const { inputVal } = useContext(DialInputCtx)
const { inputVal } = useContext(DialInputCtx);
const handleCall = (number: string) => {
Nui.send('phone:beginCall', {
@@ -35,6 +38,10 @@ export const DialerInput = () => {
});
};
const handleNewContact = (number: string) => {
history.push(`/contacts/-1/?addNumber=${number}`)
}
return (
<Box component={Paper} className={classes.root}>
<InputBase
@@ -42,8 +49,11 @@ export const DialerInput = () => {
className={classes.input}
value={inputVal}
/>
<IconButton color='primary' className={classes.iconBtn}>
<PhoneIcon fontSize="large" onClick={() => handleCall(inputVal)} />
</IconButton>
<IconButton className={classes.iconBtn}>
<PhoneIcon onClick={() => handleCall(inputVal)} />
<PersonAddIcon fontSize="large" onClick={() => handleNewContact(inputVal)} />
</IconButton>
</Box>
);
@@ -9,10 +9,10 @@ import HistoryIcon from '@material-ui/icons/History';
const useStyles = makeStyles((theme: Theme) => ({
root: {
width: '100%',
backgroundColor: theme.palette.background.default,
backgroundColor: theme.palette.background.paper,
},
icon: {
color: '#43a047',
color: theme.palette.primary.main,
},
}));
+17
View File
@@ -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);