mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
Add email app UI
This commit is contained in:
1 parent
804c9982b2
commit
6569f94cd5
7 files changed
+212
-13
No files matched your search
@@ -33,6 +33,7 @@ import WindowSnackbar from './ui/components/WindowSnackbar';
|
|||||||
import { usePhone } from './os/phone/hooks/usePhone';
|
import { usePhone } from './os/phone/hooks/usePhone';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useSnackbar } from './ui/hooks/useSnackbar';
|
import { useSnackbar } from './ui/hooks/useSnackbar';
|
||||||
|
import { useEmailService } from './apps/email/hooks/useEmailService';
|
||||||
|
|
||||||
function Phone() {
|
function Phone() {
|
||||||
const { t, i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
@@ -75,6 +76,7 @@ function Phone() {
|
|||||||
usePhotoService();
|
usePhotoService();
|
||||||
useCallService();
|
useCallService();
|
||||||
useDialService();
|
useDialService();
|
||||||
|
useEmailService();
|
||||||
|
|
||||||
const { modal: callModal } = useCallModal();
|
const { modal: callModal } = useCallModal();
|
||||||
const { bottom, visibility } = usePhoneVisibility();
|
const { bottom, visibility } = usePhoneVisibility();
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { Box, makeStyles } from '@material-ui/core';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { AppWrapper } from '../../../ui/components';
|
import { AppWrapper } from '../../../ui/components';
|
||||||
import { AppContent } from '../../../ui/components/AppContent';
|
import { AppContent } from '../../../ui/components/AppContent';
|
||||||
@@ -7,6 +6,7 @@ import EmailNavBar from './EmailNavBar';
|
|||||||
import { Route, Switch } from 'react-router-dom';
|
import { Route, Switch } from 'react-router-dom';
|
||||||
import { InboxPage } from './InboxPage';
|
import { InboxPage } from './InboxPage';
|
||||||
import { EmailAppHeader } from './EmailAppHeader';
|
import { EmailAppHeader } from './EmailAppHeader';
|
||||||
|
import { NewEmailPage } from './NewEmailPage';
|
||||||
|
|
||||||
export const EmailApp = () => {
|
export const EmailApp = () => {
|
||||||
return (
|
return (
|
||||||
@@ -18,6 +18,9 @@ export const EmailApp = () => {
|
|||||||
<Route path="/email" exact>
|
<Route path="/email" exact>
|
||||||
<InboxPage />
|
<InboxPage />
|
||||||
</Route>
|
</Route>
|
||||||
|
<Route path="/email/new" exact>
|
||||||
|
<NewEmailPage />
|
||||||
|
</Route>
|
||||||
</Switch>
|
</Switch>
|
||||||
</AppContent>
|
</AppContent>
|
||||||
<EmailNavBar />
|
<EmailNavBar />
|
||||||
|
|||||||
@@ -1,18 +1,38 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { Box, makeStyles } from '@material-ui/core';
|
import {
|
||||||
import { SearchField } from '../../../ui/components/SearchField';
|
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 { 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: {
|
search: {
|
||||||
|
zIndex: 5,
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
|
backgroundColor: theme.palette.primary.light,
|
||||||
top: 0,
|
top: 0,
|
||||||
margin: '0 auto',
|
|
||||||
},
|
},
|
||||||
});
|
}));
|
||||||
|
|
||||||
export const InboxPage = () => {
|
export const InboxPage = () => {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const { emails } = useEmail();
|
||||||
|
|
||||||
const [search, setSearch] = useState<string>('');
|
const [search, setSearch] = useState<string>('');
|
||||||
|
|
||||||
const { autoSearch } = useQueryParams<{ autoSearch }>();
|
const { autoSearch } = useQueryParams<{ autoSearch }>();
|
||||||
@@ -21,10 +41,47 @@ export const InboxPage = () => {
|
|||||||
setSearch(e.target.value);
|
setSearch(e.target.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getSendDate = (email) => dayjs.unix(email.sendDate).format(t('DATE_FORMAT'));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box height="100%" pt="60px">
|
<Box height="100%" pt="80px" position="relative">
|
||||||
<Box className={classes.search}>
|
<Box width="100%" p={2} className={classes.search}>
|
||||||
<SearchField autoFocus={!!autoSearch} onChange={handleSearch} value={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>
|
||||||
</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>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -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_PRIMARY_COLOR = '#00695c';
|
||||||
export const EMAIL_APP_DEFAULT_TEXT_COLOR = common.white;
|
export const EMAIL_APP_DEFAULT_TEXT_COLOR = common.white;
|
||||||
@@ -8,12 +8,16 @@ const theme = {
|
|||||||
primary: {
|
primary: {
|
||||||
main: EMAIL_APP_DEFAULT_PRIMARY_COLOR,
|
main: EMAIL_APP_DEFAULT_PRIMARY_COLOR,
|
||||||
dark: '#004940',
|
dark: '#004940',
|
||||||
light: '#33877c',
|
light: '#99d5cf',
|
||||||
contrastText: EMAIL_APP_DEFAULT_TEXT_COLOR,
|
contrastText: EMAIL_APP_DEFAULT_TEXT_COLOR,
|
||||||
},
|
},
|
||||||
text: {
|
text: {
|
||||||
primary: grey[900],
|
primary: grey[900],
|
||||||
|
secondary: grey[700],
|
||||||
|
disabled: grey[600],
|
||||||
|
hint: grey[800],
|
||||||
},
|
},
|
||||||
|
divider: '#99d5cf',
|
||||||
background: {
|
background: {
|
||||||
default: grey[100],
|
default: grey[100],
|
||||||
paper: grey[50],
|
paper: grey[50],
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import { useSetRecoilState } from 'recoil';
|
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 { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent';
|
||||||
import { emailState } from './state';
|
import { emailState } from './state';
|
||||||
|
|
||||||
@@ -7,3 +9,84 @@ export const useEmailService = () => {
|
|||||||
|
|
||||||
useNuiEvent('EMAIL', 'phone:fetchAllEmailsSuccess', setEmails);
|
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,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]);
|
||||||
@@ -10,11 +10,12 @@ export interface IEmailExternalAction {
|
|||||||
|
|
||||||
export interface IEmail {
|
export interface IEmail {
|
||||||
id: number;
|
id: number;
|
||||||
|
isRead: boolean;
|
||||||
receivers: string[];
|
receivers: string[];
|
||||||
sender: string;
|
sender: string;
|
||||||
sendDate: number;
|
sendDate: number;
|
||||||
subject: string;
|
subject: string;
|
||||||
body: string;
|
body: string;
|
||||||
phoneActions: Array<IEmailPhoneAction>;
|
phoneActions?: Array<IEmailPhoneAction>;
|
||||||
externalActions: Array<IEmailExternalAction>;
|
externalActions?: Array<IEmailExternalAction>;
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user