mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
Merge pull request #109 from project-error/feature/notes-app-theme-provider
Feature / Notes and Dialer theme providers
This commit is contained in:
24 files changed
+376
-224
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,18 @@ 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;
|
||||||
|
referal?: string;
|
||||||
|
}
|
||||||
|
|
||||||
const useStyles = makeStyles((theme: Theme) => ({
|
const useStyles = makeStyles((theme: Theme) => ({
|
||||||
root: {
|
root: {
|
||||||
height: '100%',
|
height: '100%',
|
||||||
@@ -54,6 +60,7 @@ const ContactsInfoPage = () => {
|
|||||||
const { getContact } = useContacts();
|
const { getContact } = useContacts();
|
||||||
|
|
||||||
const { id } = useParams<ContactInfoRouteParams>();
|
const { id } = useParams<ContactInfoRouteParams>();
|
||||||
|
const { addNumber, referal } = useQueryParams<ContactInfoRouteQuery>({ referal: '/contacts' });
|
||||||
|
|
||||||
const contact = getContact(parseInt(id));
|
const contact = getContact(parseInt(id));
|
||||||
|
|
||||||
@@ -64,6 +71,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',
|
||||||
@@ -75,7 +88,7 @@ const ContactsInfoPage = () => {
|
|||||||
number,
|
number,
|
||||||
avatar,
|
avatar,
|
||||||
});
|
});
|
||||||
history.goBack();
|
history.replace(referal);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleContactSave = () => {
|
const handleContactSave = () => {
|
||||||
@@ -113,6 +126,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}&referal=/phone/contacts`)
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
@@ -12,9 +12,11 @@ const useStyles = makeStyles((theme) => ({
|
|||||||
mySms: {
|
mySms: {
|
||||||
float: 'right',
|
float: 'right',
|
||||||
margin: theme.spacing(1),
|
margin: theme.spacing(1),
|
||||||
padding: '6px 12px',
|
padding: '6px 16px',
|
||||||
height: 'auto',
|
height: 'auto',
|
||||||
width: '80%',
|
width: 'auto',
|
||||||
|
minWidth: '60%',
|
||||||
|
maxWidth: '85%',
|
||||||
background: theme.palette.background.default,
|
background: theme.palette.background.default,
|
||||||
color: theme.palette.text.primary,
|
color: theme.palette.text.primary,
|
||||||
borderRadius: '20px',
|
borderRadius: '20px',
|
||||||
@@ -24,7 +26,9 @@ const useStyles = makeStyles((theme) => ({
|
|||||||
float: 'left',
|
float: 'left',
|
||||||
margin: theme.spacing(1),
|
margin: theme.spacing(1),
|
||||||
padding: '6px 12px',
|
padding: '6px 12px',
|
||||||
width: '80%',
|
width: 'auto',
|
||||||
|
minWidth: '60%',
|
||||||
|
maxWidth: '85%',
|
||||||
height: 'auto',
|
height: 'auto',
|
||||||
background: theme.palette.primary.light,
|
background: theme.palette.primary.light,
|
||||||
color: theme.palette.getContrastText(theme.palette.primary.light),
|
color: theme.palette.getContrastText(theme.palette.primary.light),
|
||||||
@@ -62,7 +66,7 @@ export const MessageBubble = ({
|
|||||||
<div>{message.message}</div>
|
<div>{message.message}</div>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
<Box textAlign='right'>
|
<Box>
|
||||||
<Typography variant='subtitle1' color='secondary'>
|
<Typography variant='subtitle1' color='secondary'>
|
||||||
{isGroupChat && !message.isMine
|
{isGroupChat && !message.isMine
|
||||||
? message.display || message.phone_number
|
? message.display || message.phone_number
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
#notes-app .Mui-focused::after {
|
|
||||||
border-bottom: 3px solid #f9a825;
|
|
||||||
}
|
|
||||||
|
|
||||||
#notes-app .MuiOutlinedInput-root {
|
|
||||||
border: 2px soild #f9a825;
|
|
||||||
}
|
|
||||||
@@ -4,17 +4,45 @@ import { AppContent } from '../../ui/components/AppContent';
|
|||||||
import { AppTitle } from '../../ui/components/AppTitle';
|
import { AppTitle } from '../../ui/components/AppTitle';
|
||||||
import { useApp } from '../../os/apps/hooks/useApps';
|
import { useApp } from '../../os/apps/hooks/useApps';
|
||||||
import NoteList from './list/NoteList';
|
import NoteList from './list/NoteList';
|
||||||
|
|
||||||
import { useNotes } from './hooks/useNotes';
|
|
||||||
import { NoteModal } from './modal/NoteModal';
|
import { NoteModal } from './modal/NoteModal';
|
||||||
import { Fab } from '@material-ui/core';
|
import { Fab } from '@material-ui/core';
|
||||||
import AddIcon from '@material-ui/icons/Add';
|
import AddIcon from '@material-ui/icons/Add';
|
||||||
|
|
||||||
import { useNoteModal } from './hooks/useNoteModal';
|
|
||||||
import { useNoteDetail } from './hooks/useNoteDetail';
|
import { useNoteDetail } from './hooks/useNoteDetail';
|
||||||
|
|
||||||
import useStyles from './notes.styles';
|
import useStyles from './notes.styles';
|
||||||
import InjectDebugData from '../../os/debug/InjectDebugData';
|
import InjectDebugData from '../../os/debug/InjectDebugData';
|
||||||
|
import { NotesThemeProvider } from './providers/NotesThemeProvider';
|
||||||
|
import { Route, useHistory } from 'react-router-dom';
|
||||||
|
|
||||||
|
export const NotesApp = () => {
|
||||||
|
const classes = useStyles();
|
||||||
|
const history = useHistory();
|
||||||
|
const notesApp = useApp('NOTES');
|
||||||
|
const { setDetail } = useNoteDetail();
|
||||||
|
|
||||||
|
const onClickCreate = () => {
|
||||||
|
setDetail({ title: '', content: '' });
|
||||||
|
history.push('/notes/detail');
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<NotesThemeProvider>
|
||||||
|
<AppWrapper id='notes-app'>
|
||||||
|
<AppTitle app={notesApp} />
|
||||||
|
<Route path='/notes/detail' component={NoteModal} />
|
||||||
|
<AppContent>
|
||||||
|
<Route path='/notes' component={NoteList} />
|
||||||
|
<Fab
|
||||||
|
className={classes.absolute}
|
||||||
|
onClick={onClickCreate}
|
||||||
|
color='primary'
|
||||||
|
>
|
||||||
|
<AddIcon />
|
||||||
|
</Fab>
|
||||||
|
</AppContent>
|
||||||
|
</AppWrapper>
|
||||||
|
</NotesThemeProvider>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
InjectDebugData([
|
InjectDebugData([
|
||||||
{
|
{
|
||||||
@@ -34,37 +62,3 @@ InjectDebugData([
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export const NotesApp = () => {
|
|
||||||
const { setNoteModal } = useNoteModal();
|
|
||||||
const { detail, setDetail } = useNoteDetail();
|
|
||||||
const { notes } = useNotes();
|
|
||||||
const notesApp = useApp('NOTES');
|
|
||||||
|
|
||||||
const classes = useStyles();
|
|
||||||
|
|
||||||
const handleModal = () => {
|
|
||||||
setNoteModal(true);
|
|
||||||
setDetail(null);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<AppWrapper id='notes-app'>
|
|
||||||
<AppTitle app={notesApp} />
|
|
||||||
<NoteModal key={detail?.id} />
|
|
||||||
<AppContent>
|
|
||||||
<NoteList notes={notes} />
|
|
||||||
</AppContent>
|
|
||||||
<Fab
|
|
||||||
className={classes.absolute}
|
|
||||||
onClick={handleModal}
|
|
||||||
style={{
|
|
||||||
background: '#f9a825',
|
|
||||||
color: '#fff',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<AddIcon />
|
|
||||||
</Fab>
|
|
||||||
</AppWrapper>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1,18 +1,30 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { yellow } from '@material-ui/core/colors';
|
import { makeStyles, Paper } from '@material-ui/core';
|
||||||
|
|
||||||
import useStyles from './notes.styles';
|
|
||||||
|
|
||||||
import { Paper } from '@material-ui/core';
|
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import { faStickyNote } from '@fortawesome/free-solid-svg-icons';
|
import { faStickyNote } from '@fortawesome/free-solid-svg-icons';
|
||||||
|
|
||||||
|
const useStyles = makeStyles((theme) => ({
|
||||||
|
header: {
|
||||||
|
width: '100%',
|
||||||
|
display: 'flex',
|
||||||
|
flexFlow: 'row nowrap',
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
textAlign: 'center',
|
||||||
|
height: '60px',
|
||||||
|
},
|
||||||
|
icon: {
|
||||||
|
color: theme.palette.primary.main,
|
||||||
|
fontSize: 40,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
const NotesTitle = () => {
|
const NotesTitle = () => {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
return (
|
return (
|
||||||
<Paper elevation={24} square variant='outlined' className={classes.header}>
|
<Paper elevation={24} square variant='outlined' className={classes.header}>
|
||||||
<FontAwesomeIcon icon={faStickyNote} color={yellow[800]} size='lg' />
|
<FontAwesomeIcon icon={faStickyNote} className={classes.icon} size='lg' />
|
||||||
</Paper>
|
</Paper>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
import { useRecoilState } from 'recoil';
|
|
||||||
import { noteStates } from './state';
|
|
||||||
|
|
||||||
interface NoteModalProps {
|
|
||||||
noteModal: boolean;
|
|
||||||
setNoteModal: (show: boolean) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useNoteModal = (): NoteModalProps => {
|
|
||||||
const [noteModal, setNoteModal] = useRecoilState(noteStates.noteModal);
|
|
||||||
return { noteModal, setNoteModal };
|
|
||||||
};
|
|
||||||
@@ -1,18 +1,19 @@
|
|||||||
import { List, ListItem, ListItemText } from '@material-ui/core';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { List, ListItem, ListItemText } from '@material-ui/core';
|
||||||
import { useNoteModal } from '../hooks/useNoteModal';
|
|
||||||
import { useNoteDetail } from '../hooks/useNoteDetail';
|
import { useNoteDetail } from '../hooks/useNoteDetail';
|
||||||
|
import { useNotes } from '../hooks/useNotes';
|
||||||
|
import { useHistory } from 'react-router-dom';
|
||||||
|
|
||||||
// add search bar later
|
// add search bar later
|
||||||
// TODO: Add interface for note
|
// TODO: Add interface for note
|
||||||
const NoteList = ({ notes }) => {
|
const NoteList = () => {
|
||||||
const { setNoteModal } = useNoteModal();
|
const history = useHistory();
|
||||||
|
const { notes } = useNotes();
|
||||||
const { setDetail } = useNoteDetail();
|
const { setDetail } = useNoteDetail();
|
||||||
|
|
||||||
const handleNoteModal = (note) => {
|
const handleNoteModal = (note) => {
|
||||||
setNoteModal(true);
|
|
||||||
setDetail(note);
|
setDetail(note);
|
||||||
|
history.push('/notes/detail');
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,41 +1,39 @@
|
|||||||
import { Button, TextField, Slide } from '@material-ui/core';
|
import {
|
||||||
import React, { useState } from 'react';
|
Button,
|
||||||
|
TextField,
|
||||||
|
Slide,
|
||||||
|
Paper,
|
||||||
|
Typography,
|
||||||
|
Container,
|
||||||
|
CircularProgress,
|
||||||
|
Box,
|
||||||
|
} from '@material-ui/core';
|
||||||
|
import React from 'react';
|
||||||
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
|
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
|
||||||
|
|
||||||
import { useNoteModal } from '../hooks/useNoteModal';
|
|
||||||
import { useNoteDetail } from '../hooks/useNoteDetail';
|
import { useNoteDetail } from '../hooks/useNoteDetail';
|
||||||
|
|
||||||
import useStyles from './modal.styles';
|
import useStyles from './modal.styles';
|
||||||
|
|
||||||
import '../NotesApp.css';
|
|
||||||
import Nui from '../../../os/nui-events/utils/Nui';
|
import Nui from '../../../os/nui-events/utils/Nui';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { useHistory } from 'react-router-dom';
|
||||||
|
import { StatusButton } from '../../../ui/components/StatusButton';
|
||||||
|
|
||||||
// TODO: Fix input focus color
|
|
||||||
export const NoteModal = () => {
|
export const NoteModal = () => {
|
||||||
const { noteModal, setNoteModal } = useNoteModal();
|
const classes = useStyles();
|
||||||
|
const history = useHistory();
|
||||||
|
const { t } = useTranslation();
|
||||||
const { detail, setDetail } = useNoteDetail();
|
const { detail, setDetail } = useNoteDetail();
|
||||||
const [title, setTitle] = useState(detail ? detail.title : '');
|
|
||||||
const [content, setContent] = useState(detail ? detail.content : '');
|
|
||||||
|
|
||||||
const classes = useStyles()
|
|
||||||
|
|
||||||
|
|
||||||
|
const onClose = () => history.goBack();
|
||||||
|
|
||||||
const _handleClose = () => {
|
const _handleClose = () => {
|
||||||
setDetail(null);
|
setDetail(null);
|
||||||
setNoteModal(false);
|
onClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleNoteSave = () => {
|
const handleNoteSave = () => {
|
||||||
Nui.send('phone:addNote', {
|
Nui.send('phone:addNote', detail);
|
||||||
title,
|
|
||||||
content,
|
|
||||||
});
|
|
||||||
setDetail(null);
|
setDetail(null);
|
||||||
setNoteModal(false);
|
onClose();
|
||||||
|
|
||||||
setTitle('')
|
|
||||||
setContent('')
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDeleteNote = () => {
|
const handleDeleteNote = () => {
|
||||||
@@ -44,38 +42,46 @@ export const NoteModal = () => {
|
|||||||
id,
|
id,
|
||||||
});
|
});
|
||||||
setDetail(null);
|
setDetail(null);
|
||||||
setNoteModal(false);
|
onClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleUpdateNote = () => {
|
const handleUpdateNote = () => {
|
||||||
Nui.send('phone:updateNote', {
|
Nui.send('phone:updateNote', detail);
|
||||||
id: detail.id,
|
|
||||||
title,
|
|
||||||
content,
|
|
||||||
});
|
|
||||||
setDetail(null);
|
setDetail(null);
|
||||||
setNoteModal(false);
|
onClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={noteModal ? classes.modalRoot : classes.modalHide}>
|
<Slide direction='left' in={!!detail}>
|
||||||
<Slide direction='left' in={noteModal} mountOnEnter unmountOnExit>
|
<Paper className={classes.modalRoot}>
|
||||||
<div>
|
{!detail ? (
|
||||||
<Button className={classes.closeButton} onClick={_handleClose}>
|
<CircularProgress />
|
||||||
<ArrowBackIcon fontSize='large' />
|
) : (
|
||||||
|
<Container>
|
||||||
|
<Box>
|
||||||
|
<Box py={2}>
|
||||||
|
<Button
|
||||||
|
color='primary'
|
||||||
|
size='large'
|
||||||
|
startIcon={<ArrowBackIcon fontSize='large' />}
|
||||||
|
onClick={_handleClose}
|
||||||
|
>
|
||||||
|
{t('APPS_NOTES')}
|
||||||
</Button>
|
</Button>
|
||||||
<div id='notes-modal' className={classes.noteContainer}>
|
</Box>
|
||||||
<TextField
|
<TextField
|
||||||
className={classes.input}
|
className={classes.input}
|
||||||
rowsMax={1}
|
rowsMax={1}
|
||||||
placeholder='Title'
|
label={t('GENERIC_TITLE')}
|
||||||
inputProps={{
|
inputProps={{
|
||||||
className: classes.inputPropsTitle,
|
className: classes.inputPropsTitle,
|
||||||
maxLength: 25
|
maxLength: 25,
|
||||||
}}
|
}}
|
||||||
fullWidth
|
fullWidth
|
||||||
value={title}
|
value={detail.title}
|
||||||
onChange={(e) => setTitle(e.target.value)}
|
onChange={(e) =>
|
||||||
|
setDetail((d) => ({ ...d, title: e.target.value }))
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
className={classes.input}
|
className={classes.input}
|
||||||
@@ -83,39 +89,65 @@ export const NoteModal = () => {
|
|||||||
className: classes.inputPropsContent,
|
className: classes.inputPropsContent,
|
||||||
maxLength: 250,
|
maxLength: 250,
|
||||||
}}
|
}}
|
||||||
placeholder='Content'
|
label={t('GENERIC_CONTENT')}
|
||||||
multiline
|
multiline
|
||||||
fullWidth
|
fullWidth
|
||||||
rows={19}
|
rows={16}
|
||||||
variant='outlined'
|
variant='outlined'
|
||||||
value={content}
|
value={detail.content}
|
||||||
onChange={(e) => setContent(e.target.value)}
|
onChange={(e) =>
|
||||||
|
setDetail((d) => ({ ...d, content: e.target.value }))
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<p style={{ color: "#fff" }}>{content.length}/250</p>
|
<Typography paragraph>{detail.content.length}/250</Typography>
|
||||||
{!detail &&(
|
{!detail.id ? (
|
||||||
<Button disabled={title.length > 0 ? false : true} className={classes.saveButton} onClick={handleNoteSave}>
|
<>
|
||||||
Save
|
<Box display="inline" p={1}>
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
{detail && (
|
|
||||||
<Button
|
<Button
|
||||||
className={classes.updateButton}
|
color='primary'
|
||||||
|
variant='contained'
|
||||||
|
disabled={detail.title.length > 0 ? false : true}
|
||||||
|
onClick={handleNoteSave}
|
||||||
|
>
|
||||||
|
{t('GENERIC_SAVE')}
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
<Box display="inline" p={1}>
|
||||||
|
<StatusButton
|
||||||
|
color='error'
|
||||||
|
variant='contained'
|
||||||
|
onClick={_handleClose}
|
||||||
|
>
|
||||||
|
{t('GENERIC_CANCEL')}
|
||||||
|
</StatusButton>
|
||||||
|
</Box>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Box display="inline" p={1}>
|
||||||
|
<Button
|
||||||
|
color='primary'
|
||||||
|
variant='contained'
|
||||||
onClick={handleUpdateNote}
|
onClick={handleUpdateNote}
|
||||||
>
|
>
|
||||||
Update
|
{t('GENERIC_UPDATE')}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
</Box>
|
||||||
{detail && (
|
<Box display="inline" p={1}>
|
||||||
<Button
|
<StatusButton
|
||||||
className={classes.deleteButton}
|
color='error'
|
||||||
|
variant='contained'
|
||||||
onClick={handleDeleteNote}
|
onClick={handleDeleteNote}
|
||||||
>
|
>
|
||||||
Delete
|
{t('GENERIC_DELETE')}
|
||||||
</Button>
|
</StatusButton>
|
||||||
|
</Box>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</Box>
|
||||||
</div>
|
</Container>
|
||||||
|
)}
|
||||||
|
</Paper>
|
||||||
</Slide>
|
</Slide>
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -4,23 +4,9 @@ const useStyles = makeStyles((theme) => ({
|
|||||||
modalRoot: {
|
modalRoot: {
|
||||||
zIndex: 20,
|
zIndex: 20,
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
height: '100%',
|
height: '99%',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
background: '#232323',
|
background: theme.palette.background.default,
|
||||||
},
|
|
||||||
modalHide: {
|
|
||||||
display: 'none',
|
|
||||||
},
|
|
||||||
closeButton: {
|
|
||||||
width: '10%',
|
|
||||||
position: 'absolute',
|
|
||||||
top: 10,
|
|
||||||
left: 0,
|
|
||||||
},
|
|
||||||
noteContainer: {
|
|
||||||
width: '90%',
|
|
||||||
marginTop: 80,
|
|
||||||
margin: '0 auto',
|
|
||||||
},
|
},
|
||||||
input: {
|
input: {
|
||||||
marginBottom: 20,
|
marginBottom: 20,
|
||||||
@@ -30,19 +16,7 @@ const useStyles = makeStyles((theme) => ({
|
|||||||
},
|
},
|
||||||
inputPropsContent: {
|
inputPropsContent: {
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
},
|
lineHeight: 1.2,
|
||||||
saveButton: {
|
|
||||||
background: '#f9a825',
|
|
||||||
padding: '10px 30px',
|
|
||||||
},
|
|
||||||
updateButton: {
|
|
||||||
background: '#f9a825',
|
|
||||||
padding: '10px 30px',
|
|
||||||
marginRight: '8px',
|
|
||||||
},
|
|
||||||
deleteButton: {
|
|
||||||
background: '#c62828',
|
|
||||||
padding: '10px 30px',
|
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,6 @@
|
|||||||
import { makeStyles } from '@material-ui/core';
|
import { makeStyles } from '@material-ui/core';
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
const useStyles = makeStyles((theme) => ({
|
||||||
header: {
|
|
||||||
width: '100%',
|
|
||||||
display: 'flex',
|
|
||||||
flexFlow: 'row nowrap',
|
|
||||||
justifyContent: 'center',
|
|
||||||
alignItems: 'center',
|
|
||||||
textAlign: 'center',
|
|
||||||
height: '60px',
|
|
||||||
},
|
|
||||||
backgroundModal: {
|
backgroundModal: {
|
||||||
background: 'black',
|
background: 'black',
|
||||||
opacity: '0.6',
|
opacity: '0.6',
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { common, yellow } from "@material-ui/core/colors";
|
||||||
|
|
||||||
|
export const NOTES_APP_PRIMARY_COLOR = yellow[800];
|
||||||
|
export const NOTES_APP_ICON_COLOR = common.white;
|
||||||
|
export const NOTES_APP_TEXT_COLOR = common.black;
|
||||||
|
|
||||||
|
const theme = {
|
||||||
|
palette: {
|
||||||
|
primary: {
|
||||||
|
main: NOTES_APP_PRIMARY_COLOR,
|
||||||
|
dark: yellow[900],
|
||||||
|
light: yellow[500],
|
||||||
|
contrastText: NOTES_APP_TEXT_COLOR
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default theme;
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
import { createAppThemeProvider } from "../../../os/apps/utils/createAppThemeProvider";
|
||||||
|
import notesTheme from '../notes.theme';
|
||||||
|
|
||||||
|
export const NotesThemeProvider = createAppThemeProvider(notesTheme);
|
||||||
@@ -1,12 +1,16 @@
|
|||||||
import { common } from "@material-ui/core/colors";
|
import { common, red } from "@material-ui/core/colors";
|
||||||
|
|
||||||
|
export const SELLOUT_APP_PRIMARY_COLOR = red[500];
|
||||||
|
export const SELLOUT_APP_ICON_COLOR = common.white;
|
||||||
|
export const SELLOUT_APP_TEXT_COLOR = common.black;
|
||||||
|
|
||||||
const theme = {
|
const theme = {
|
||||||
palette: {
|
palette: {
|
||||||
primary: {
|
primary: {
|
||||||
main: '#f44336',
|
main: SELLOUT_APP_PRIMARY_COLOR,
|
||||||
dark: '#b3251b',
|
dark: red[700],
|
||||||
light: 'f87f76',
|
light: red[200],
|
||||||
contrastText: common.black
|
contrastText: SELLOUT_APP_TEXT_COLOR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,12 @@ import { useLocation } from 'react-router-dom';
|
|||||||
*
|
*
|
||||||
* const { id, title } = useQueryParams<{ id: string, title: string }>();
|
* const { id, title } = useQueryParams<{ id: string, title: string }>();
|
||||||
*/
|
*/
|
||||||
export function useQueryParams<T = Record<string, string>>() {
|
export function useQueryParams<T = Record<string, string>>(
|
||||||
return qs.parse(useLocation().search, { ignoreQueryPrefix: true }) as T &
|
defaultValues: T = null
|
||||||
Partial<ParsedQs>;
|
) {
|
||||||
|
const query = qs.parse(useLocation().search, { ignoreQueryPrefix: true });
|
||||||
|
if (!defaultValues) {
|
||||||
|
return query as T & Partial<ParsedQs>;
|
||||||
|
}
|
||||||
|
return { ...defaultValues, ...query } as T & Partial<ParsedQs>;
|
||||||
}
|
}
|
||||||
@@ -106,6 +106,9 @@
|
|||||||
"GENERIC_SAVE": "Save",
|
"GENERIC_SAVE": "Save",
|
||||||
"GENERIC_UPDATE": "Update",
|
"GENERIC_UPDATE": "Update",
|
||||||
"GENERIC_DELETE": "Delete",
|
"GENERIC_DELETE": "Delete",
|
||||||
"GENERIC_CLOSE": "Close"
|
"GENERIC_CLOSE": "Close",
|
||||||
|
"GENERIC_CANCEL": "Cancel",
|
||||||
|
"GENERIC_TITLE": "Title",
|
||||||
|
"GENERIC_CONTENT": "Content"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,10 +3,7 @@ import {
|
|||||||
blue,
|
blue,
|
||||||
common,
|
common,
|
||||||
grey,
|
grey,
|
||||||
green,
|
|
||||||
purple,
|
purple,
|
||||||
yellow,
|
|
||||||
red,
|
|
||||||
} from '@material-ui/core/colors';
|
} from '@material-ui/core/colors';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import {
|
import {
|
||||||
@@ -35,6 +32,7 @@ import { SelloutApp } from '../../../apps/sellout/components/SelloutApp';
|
|||||||
import { NotesApp } from '../../../apps/notes/NotesApp';
|
import { NotesApp } from '../../../apps/notes/NotesApp';
|
||||||
import CameraApp from '../../../apps/camera/components/CameraApp';
|
import CameraApp from '../../../apps/camera/components/CameraApp';
|
||||||
import { AppRoute } from '../components/AppRoute';
|
import { AppRoute } from '../components/AppRoute';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
MESSAGES_APP_PRIMARY_COLOR,
|
MESSAGES_APP_PRIMARY_COLOR,
|
||||||
MESSAGES_APP_TEXT_COLOR,
|
MESSAGES_APP_TEXT_COLOR,
|
||||||
@@ -43,6 +41,9 @@ import {
|
|||||||
CONTACTS_APP_PRIMARY_COLOR,
|
CONTACTS_APP_PRIMARY_COLOR,
|
||||||
CONTACTS_APP_TEXT_COLOR,
|
CONTACTS_APP_TEXT_COLOR,
|
||||||
} from '../../../apps/contacts/contacts.theme';
|
} from '../../../apps/contacts/contacts.theme';
|
||||||
|
import { SELLOUT_APP_PRIMARY_COLOR, SELLOUT_APP_ICON_COLOR } from '../../../apps/sellout/sellout.theme';
|
||||||
|
import { NOTES_APP_ICON_COLOR, NOTES_APP_PRIMARY_COLOR } from '../../../apps/notes/notes.theme';
|
||||||
|
import { DIALER_APP_PRIMARY_COLOR, DIALER_APP_TEXT_COLOR } from '../../../apps/dialer/dialer.theme';
|
||||||
|
|
||||||
export interface IAppConfig {
|
export interface IAppConfig {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -61,8 +62,8 @@ export const APPS: IAppConfig[] = [
|
|||||||
nameLocale: 'APPS_DIALER',
|
nameLocale: 'APPS_DIALER',
|
||||||
icon: <FontAwesomeIcon icon={faPhoneAlt} size='xs' />,
|
icon: <FontAwesomeIcon icon={faPhoneAlt} size='xs' />,
|
||||||
notificationIcon: <FontAwesomeIcon icon={faPhoneAlt} size='xs' />,
|
notificationIcon: <FontAwesomeIcon icon={faPhoneAlt} size='xs' />,
|
||||||
backgroundColor: green[600],
|
backgroundColor: DIALER_APP_PRIMARY_COLOR,
|
||||||
color: common.white,
|
color: DIALER_APP_TEXT_COLOR,
|
||||||
path: '/phone',
|
path: '/phone',
|
||||||
Route: () => <AppRoute id='DIALER' path='/phone' component={DialerApp} />,
|
Route: () => <AppRoute id='DIALER' path='/phone' component={DialerApp} />,
|
||||||
},
|
},
|
||||||
@@ -141,8 +142,8 @@ export const APPS: IAppConfig[] = [
|
|||||||
nameLocale: 'APPS_SELLOUT',
|
nameLocale: 'APPS_SELLOUT',
|
||||||
icon: <FontAwesomeIcon icon={faAd} fixedWidth />,
|
icon: <FontAwesomeIcon icon={faAd} fixedWidth />,
|
||||||
notificationIcon: <FontAwesomeIcon icon={faAd} fixedWidth size='xs' />,
|
notificationIcon: <FontAwesomeIcon icon={faAd} fixedWidth size='xs' />,
|
||||||
backgroundColor: red[500],
|
backgroundColor: SELLOUT_APP_PRIMARY_COLOR,
|
||||||
color: common.white,
|
color: SELLOUT_APP_ICON_COLOR,
|
||||||
path: '/sellout',
|
path: '/sellout',
|
||||||
Route: () => (
|
Route: () => (
|
||||||
<AppRoute id='SELLOUT' path='/sellout' component={SelloutApp} />
|
<AppRoute id='SELLOUT' path='/sellout' component={SelloutApp} />
|
||||||
@@ -155,8 +156,8 @@ export const APPS: IAppConfig[] = [
|
|||||||
notificationIcon: (
|
notificationIcon: (
|
||||||
<FontAwesomeIcon icon={faStickyNote} fixedWidth size='xs' />
|
<FontAwesomeIcon icon={faStickyNote} fixedWidth size='xs' />
|
||||||
),
|
),
|
||||||
backgroundColor: yellow[800],
|
backgroundColor: NOTES_APP_PRIMARY_COLOR,
|
||||||
color: common.white,
|
color: NOTES_APP_ICON_COLOR,
|
||||||
path: '/notes',
|
path: '/notes',
|
||||||
Route: () => <AppRoute id='NOTES' path='/notes' component={NotesApp} />,
|
Route: () => <AppRoute id='NOTES' path='/notes' component={NotesApp} />,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,8 +1,30 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import MuiAlert from '@material-ui/lab/Alert';
|
import MuiAlert from '@material-ui/lab/Alert';
|
||||||
|
import { makeStyles, Typography } from '@material-ui/core';
|
||||||
|
|
||||||
export function Alert(props) {
|
const useStyles = makeStyles({
|
||||||
return <MuiAlert style={{ zIndex: 10000 }} elevation={6} variant='filled' {...props} />;
|
root: {
|
||||||
|
zIndex: 10000,
|
||||||
|
},
|
||||||
|
msg: {
|
||||||
|
maxWidth: '300px',
|
||||||
|
wordWrap: 'break-word',
|
||||||
|
fontSize: '1em'
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export function Alert({ children, ...props }) {
|
||||||
|
const classes = useStyles();
|
||||||
|
return (
|
||||||
|
<MuiAlert
|
||||||
|
className={classes.root}
|
||||||
|
elevation={6}
|
||||||
|
variant='filled'
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<Typography className={classes.msg}>{children}</Typography>
|
||||||
|
</MuiAlert>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Alert;
|
export default Alert;
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
import { Button, ButtonProps, fade, makeStyles } from '@material-ui/core';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
type StatusButtonStyleColor = 'success' | 'error' | 'warning' | 'info';
|
||||||
|
|
||||||
|
interface IStatusButtonStyleProps {
|
||||||
|
color: StatusButtonStyleColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
const useStyles = makeStyles(
|
||||||
|
(theme) => ({
|
||||||
|
root: {
|
||||||
|
color: ({ color }: IStatusButtonStyleProps) => theme.palette[color].main,
|
||||||
|
'&:hover': {
|
||||||
|
backgroundColor: ({ color }: IStatusButtonStyleProps) =>
|
||||||
|
fade(theme.palette[color].light, theme.palette.action.hoverOpacity),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
outlined: {
|
||||||
|
border: ({ color }: IStatusButtonStyleProps) =>
|
||||||
|
`1px solid ${fade(theme.palette[color].main, 0.5)}`,
|
||||||
|
'&:hover': {
|
||||||
|
border: ({ color }: IStatusButtonStyleProps) =>
|
||||||
|
`1px solid ${theme.palette[color].main}`,
|
||||||
|
},
|
||||||
|
'&$disabled': {
|
||||||
|
border: `1px solid ${theme.palette.action.disabled}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
contained: {
|
||||||
|
color: ({ color }: IStatusButtonStyleProps) =>
|
||||||
|
theme.palette[color].contrastText,
|
||||||
|
backgroundColor: ({ color }: IStatusButtonStyleProps) =>
|
||||||
|
theme.palette[color].main,
|
||||||
|
'&:hover': {
|
||||||
|
backgroundColor: ({ color }: IStatusButtonStyleProps) =>
|
||||||
|
theme.palette[color].dark,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
{ name: 'MuiButton' }
|
||||||
|
);
|
||||||
|
|
||||||
|
export const StatusButton = ({
|
||||||
|
color = 'info',
|
||||||
|
variant,
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: Omit<ButtonProps, 'color'> & { color: StatusButtonStyleColor }) => {
|
||||||
|
const classes = useStyles({ color });
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
variant={variant}
|
||||||
|
className={`${classes.root} ${classes[variant] || ''} ${className}`}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
Reference in new issue
Block a user