Add email app UI

This commit is contained in:
J Francisco Rader committed 2021-03-30 02:07:04 -03:00
1 parent 804c9982b2
commit 6569f94cd5
7 files changed
+212 -13

No files matched your search

+2
View File
@@ -33,6 +33,7 @@ import WindowSnackbar from './ui/components/WindowSnackbar';
import { usePhone } from './os/phone/hooks/usePhone';
import { useTranslation } from 'react-i18next';
import { useSnackbar } from './ui/hooks/useSnackbar';
import { useEmailService } from './apps/email/hooks/useEmailService';
function Phone() {
const { t, i18n } = useTranslation();
@@ -75,6 +76,7 @@ function Phone() {
usePhotoService();
useCallService();
useDialService();
useEmailService();
const { modal: callModal } = useCallModal();
const { bottom, visibility } = usePhoneVisibility();
+4 -1
View File
@@ -1,4 +1,3 @@
import { Box, makeStyles } from '@material-ui/core';
import React from 'react';
import { AppWrapper } from '../../../ui/components';
import { AppContent } from '../../../ui/components/AppContent';
@@ -7,6 +6,7 @@ import EmailNavBar from './EmailNavBar';
import { Route, Switch } from 'react-router-dom';
import { InboxPage } from './InboxPage';
import { EmailAppHeader } from './EmailAppHeader';
import { NewEmailPage } from './NewEmailPage';
export const EmailApp = () => {
return (
@@ -18,6 +18,9 @@ export const EmailApp = () => {
<Route path="/email" exact>
<InboxPage />
</Route>
<Route path="/email/new" exact>
<NewEmailPage />
</Route>
</Switch>
</AppContent>
<EmailNavBar />
+65 -8
View File
@@ -1,18 +1,38 @@
import React, { useState } from 'react';
import { Box, makeStyles } from '@material-ui/core';
import { SearchField } from '../../../ui/components/SearchField';
import {
Avatar,
Box,
IconButton,
List,
ListItem,
ListItemAvatar,
ListItemSecondaryAction,
ListItemText,
makeStyles,
TextField,
} from '@material-ui/core';
import MarkRead from '@material-ui/icons/Markunread';
import MarkUnread from '@material-ui/icons/MarkunreadMailbox';
import { useQueryParams } from '../../../common/hooks/useQueryParams';
import { useEmail } from '../hooks/useEmail';
import dayjs from 'dayjs';
import { useTranslation } from 'react-i18next';
const useStyles = makeStyles({
const useStyles = makeStyles((theme) => ({
search: {
zIndex: 5,
position: 'absolute',
backgroundColor: theme.palette.primary.light,
top: 0,
margin: '0 auto',
},
});
}));
export const InboxPage = () => {
const classes = useStyles();
const { t } = useTranslation();
const { emails } = useEmail();
const [search, setSearch] = useState<string>('');
const { autoSearch } = useQueryParams<{ autoSearch }>();
@@ -21,10 +41,47 @@ export const InboxPage = () => {
setSearch(e.target.value);
};
const getSendDate = (email) => dayjs.unix(email.sendDate).format(t('DATE_FORMAT'));
return (
<Box height="100%" pt="60px">
<Box className={classes.search}>
<SearchField autoFocus={!!autoSearch} onChange={handleSearch} value={search} />
<Box height="100%" pt="80px" position="relative">
<Box width="100%" p={2} className={classes.search}>
<TextField
placeholder="Search e-mails"
fullWidth
variant="outlined"
autoFocus={!!autoSearch}
onChange={handleSearch}
value={search}
/>
</Box>
<Box overflow="auto" maxHeight="100%">
<List>
{emails &&
emails.map((email) => (
<ListItem button divider key={email.id}>
<ListItemAvatar>
<Avatar>{email.sender.charAt(0).toUpperCase()}</Avatar>
</ListItemAvatar>
<ListItemText
secondary={
email.isRead ? (
<span>{getSendDate(email)}</span>
) : (
<strong>{getSendDate(email)}</strong>
)
}
>
{email.isRead ? <span>{email.subject}</span> : <strong>{email.subject}</strong>}
</ListItemText>
<ListItemSecondaryAction>
<IconButton>
{email.isRead ? <MarkUnread color="primary" /> : <MarkRead color="primary" />}
</IconButton>
</ListItemSecondaryAction>
</ListItem>
))}
</List>
</Box>
</Box>
);
@@ -0,0 +1,49 @@
import React from 'react';
import { Box, makeStyles, TextField } from '@material-ui/core';
const useStyles = makeStyles((theme) => ({
search: {
backgroundColor: theme.palette.primary.light,
color: theme.palette.common.white,
position: 'absolute',
width: '100%',
top: 0,
},
}));
export const NewEmailPage = () => {
const classes = useStyles();
// const [subject, setSubject] = useState<string>('');
// const [receivers, setReceivers] = useState<string>('');
const handleSubject = (e) => {
// setSubject(e.target.value || '');
};
const handleReceiver = (e) => {
// setReceivers(e.target.value || '');
};
return (
<Box height="100%" pt="120px">
<Box p={2} className={classes.search}>
<TextField
variant="outlined"
placeholder="To"
color="primary"
helperText="Add receivers separated by a comma"
fullWidth
onChange={handleReceiver}
/>
<TextField
variant="outlined"
placeholder="Subject"
color="primary"
fullWidth
onChange={handleSubject}
/>
</Box>
<Box>New Email</Box>
</Box>
);
};
+6 -2
View File
@@ -1,4 +1,4 @@
import { red, common, grey } from '@material-ui/core/colors';
import { common, grey } from '@material-ui/core/colors';
export const EMAIL_APP_DEFAULT_PRIMARY_COLOR = '#00695c';
export const EMAIL_APP_DEFAULT_TEXT_COLOR = common.white;
@@ -8,12 +8,16 @@ const theme = {
primary: {
main: EMAIL_APP_DEFAULT_PRIMARY_COLOR,
dark: '#004940',
light: '#33877c',
light: '#99d5cf',
contrastText: EMAIL_APP_DEFAULT_TEXT_COLOR,
},
text: {
primary: grey[900],
secondary: grey[700],
disabled: grey[600],
hint: grey[800],
},
divider: '#99d5cf',
background: {
default: grey[100],
paper: grey[50],
@@ -1,4 +1,6 @@
import { useSetRecoilState } from 'recoil';
import { IEmail } from '../../../common/typings/email';
import InjectDebugData from '../../../os/debug/InjectDebugData';
import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent';
import { emailState } from './state';
@@ -7,3 +9,84 @@ export const useEmailService = () => {
useNuiEvent('EMAIL', 'phone:fetchAllEmailsSuccess', setEmails);
};
InjectDebugData<IEmail[]>([
{
app: 'EMAIL',
method: 'phone:fetchAllEmailsSuccess',
data: [
{
id: 1,
subject: 'Try this great app!',
body: 'Hey did you try this email app? Looking good bruh',
receivers: ['[email protected]'],
sender: '[email protected]',
sendDate: Date.now() / 1000,
isRead: false,
},
{
id: 2,
subject: 'Try this great app!',
body: 'Hey did you try this email app? Looking good bruh',
receivers: ['[email protected]'],
sender: '[email protected]',
sendDate: Date.now() / 1000,
isRead: false,
},
{
id: 3,
subject: 'Try this great app!',
body: 'Hey did you try this email app? Looking good bruh',
receivers: ['[email protected]'],
sender: '[email protected]',
sendDate: Date.now() / 1000,
isRead: true,
},
{
id: 4,
subject: 'Try this great app!',
body: 'Hey did you try this email app? Looking good bruh',
receivers: ['[email protected]'],
sender: '[email protected]',
sendDate: Date.now() / 1000,
isRead: true,
},
{
id: 5,
subject: 'Try this great app!',
body: 'Hey did you try this email app? Looking good bruh',
receivers: ['[email protected]'],
sender: '[email protected]',
sendDate: Date.now() / 1000,
isRead: true,
},
{
id: 6,
subject: 'Try this great app!',
body: 'Hey did you try this email app? Looking good bruh',
receivers: ['[email protected]'],
sender: '[email protected]',
sendDate: Date.now() / 1000,
isRead: false,
},
{
id: 7,
subject: 'Try this great app!',
body: 'Hey did you try this email app? Looking good bruh',
receivers: ['[email protected]'],
sender: '[email protected]',
sendDate: Date.now() / 1000,
isRead: false,
},
{
id: 8,
subject: 'Try this great app!',
body: 'Hey did you try this email app? Looking good bruh',
receivers: ['[email protected]'],
sender: '[email protected]',
sendDate: Date.now() / 1000,
isRead: false,
},
],
},
]);
+3 -2
View File
@@ -10,11 +10,12 @@ export interface IEmailExternalAction {
export interface IEmail {
id: number;
isRead: boolean;
receivers: string[];
sender: string;
sendDate: number;
subject: string;
body: string;
phoneActions: Array<IEmailPhoneAction>;
externalActions: Array<IEmailExternalAction>;
phoneActions?: Array<IEmailPhoneAction>;
externalActions?: Array<IEmailExternalAction>;
}