mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 14:38:45 +00:00
Add EMAIL app
This commit is contained in:
1 parent
107dc43624
commit
804c9982b2
13 files changed
+271
-3
No files matched your search
@@ -0,0 +1,27 @@
|
||||
import { Box, makeStyles } from '@material-ui/core';
|
||||
import React from 'react';
|
||||
import { AppWrapper } from '../../../ui/components';
|
||||
import { AppContent } from '../../../ui/components/AppContent';
|
||||
import { EmailThemeProvider } from '../providers/EmailThemeProvider';
|
||||
import EmailNavBar from './EmailNavBar';
|
||||
import { Route, Switch } from 'react-router-dom';
|
||||
import { InboxPage } from './InboxPage';
|
||||
import { EmailAppHeader } from './EmailAppHeader';
|
||||
|
||||
export const EmailApp = () => {
|
||||
return (
|
||||
<EmailThemeProvider>
|
||||
<AppWrapper>
|
||||
<EmailAppHeader />
|
||||
<AppContent>
|
||||
<Switch>
|
||||
<Route path="/email" exact>
|
||||
<InboxPage />
|
||||
</Route>
|
||||
</Switch>
|
||||
</AppContent>
|
||||
<EmailNavBar />
|
||||
</AppWrapper>
|
||||
</EmailThemeProvider>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
import React from 'react';
|
||||
import { Box, IconButton, makeStyles } from '@material-ui/core';
|
||||
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
|
||||
import SearchIcon from '@material-ui/icons/Search';
|
||||
import { useApp } from '../../../os/apps/hooks/useApps';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
position: 'relative',
|
||||
backgroundColor: theme.palette.primary.main,
|
||||
color: theme.palette.primary.contrastText,
|
||||
},
|
||||
back: {
|
||||
position: 'absolute',
|
||||
left: '12px',
|
||||
},
|
||||
search: {
|
||||
position: 'absolute',
|
||||
right: '12px',
|
||||
},
|
||||
}));
|
||||
|
||||
export const EmailAppHeader = () => {
|
||||
const classes = useStyles();
|
||||
const { icon } = useApp('EMAIL');
|
||||
|
||||
return (
|
||||
<Box
|
||||
className={classes.root}
|
||||
height="60px"
|
||||
display="flex"
|
||||
alignItems="center"
|
||||
justifyContent="center"
|
||||
>
|
||||
<IconButton className={classes.back}>
|
||||
<ArrowBackIcon />
|
||||
</IconButton>
|
||||
{icon}
|
||||
<IconButton className={classes.search}>
|
||||
<SearchIcon />
|
||||
</IconButton>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,62 @@
|
||||
import React, { useState } from 'react';
|
||||
import { BottomNavigation, BottomNavigationAction } from '@material-ui/core';
|
||||
import { NavLink, useLocation } from 'react-router-dom';
|
||||
import { makeStyles, Theme } from '@material-ui/core/styles';
|
||||
import AllInboxIcon from '@material-ui/icons/AllInbox';
|
||||
import DraftsIcon from '@material-ui/icons/Drafts';
|
||||
import SentIcon from '@material-ui/icons/LabelImportant';
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) => ({
|
||||
root: {
|
||||
width: '100%',
|
||||
backgroundColor: theme.palette.primary.main,
|
||||
},
|
||||
icon: {
|
||||
color: theme.palette.primary.contrastText,
|
||||
'&.Mui-selected': {
|
||||
color: theme.palette.primary.light,
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
const EmailNavBar = () => {
|
||||
const classes = useStyles();
|
||||
const { pathname } = useLocation();
|
||||
const [page, setPage] = useState(pathname);
|
||||
|
||||
const handleChange = (_e, newPage) => {
|
||||
setPage(newPage);
|
||||
};
|
||||
|
||||
return (
|
||||
<BottomNavigation value={page} onChange={handleChange} showLabels className={classes.root}>
|
||||
<BottomNavigationAction
|
||||
className={classes.icon}
|
||||
label="Inbox"
|
||||
value="/email"
|
||||
color="secondary"
|
||||
component={NavLink}
|
||||
icon={<AllInboxIcon />}
|
||||
to="/email"
|
||||
/>
|
||||
<BottomNavigationAction
|
||||
className={classes.icon}
|
||||
label="New"
|
||||
value="/email/new"
|
||||
component={NavLink}
|
||||
icon={<DraftsIcon />}
|
||||
to="/email/new"
|
||||
/>
|
||||
<BottomNavigationAction
|
||||
className={classes.icon}
|
||||
label="Sent"
|
||||
value="/email/sent"
|
||||
component={NavLink}
|
||||
icon={<SentIcon />}
|
||||
to="/email/sent"
|
||||
/>
|
||||
</BottomNavigation>
|
||||
);
|
||||
};
|
||||
|
||||
export default EmailNavBar;
|
||||
@@ -0,0 +1,31 @@
|
||||
import React, { useState } from 'react';
|
||||
import { Box, makeStyles } from '@material-ui/core';
|
||||
import { SearchField } from '../../../ui/components/SearchField';
|
||||
import { useQueryParams } from '../../../common/hooks/useQueryParams';
|
||||
|
||||
const useStyles = makeStyles({
|
||||
search: {
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
margin: '0 auto',
|
||||
},
|
||||
});
|
||||
|
||||
export const InboxPage = () => {
|
||||
const classes = useStyles();
|
||||
const [search, setSearch] = useState<string>('');
|
||||
|
||||
const { autoSearch } = useQueryParams<{ autoSearch }>();
|
||||
|
||||
const handleSearch = (e) => {
|
||||
setSearch(e.target.value);
|
||||
};
|
||||
|
||||
return (
|
||||
<Box height="100%" pt="60px">
|
||||
<Box className={classes.search}>
|
||||
<SearchField autoFocus={!!autoSearch} onChange={handleSearch} value={search} />
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
import { red, common, grey } from '@material-ui/core/colors';
|
||||
|
||||
export const EMAIL_APP_DEFAULT_PRIMARY_COLOR = '#00695c';
|
||||
export const EMAIL_APP_DEFAULT_TEXT_COLOR = common.white;
|
||||
|
||||
const theme = {
|
||||
palette: {
|
||||
primary: {
|
||||
main: EMAIL_APP_DEFAULT_PRIMARY_COLOR,
|
||||
dark: '#004940',
|
||||
light: '#33877c',
|
||||
contrastText: EMAIL_APP_DEFAULT_TEXT_COLOR,
|
||||
},
|
||||
text: {
|
||||
primary: grey[900],
|
||||
},
|
||||
background: {
|
||||
default: grey[100],
|
||||
paper: grey[50],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default theme;
|
||||
@@ -0,0 +1,9 @@
|
||||
import { atom } from 'recoil';
|
||||
import { IEmail } from '../../../common/typings/email';
|
||||
|
||||
export const emailState = {
|
||||
emails: atom<IEmail[]>({
|
||||
default: null,
|
||||
key: 'EMAIL:emails',
|
||||
}),
|
||||
};
|
||||
@@ -0,0 +1,8 @@
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { emailState } from './state';
|
||||
|
||||
export const useEmail = () => {
|
||||
const emails = useRecoilValue(emailState.emails);
|
||||
|
||||
return { emails };
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
import { useSetRecoilState } from 'recoil';
|
||||
import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent';
|
||||
import { emailState } from './state';
|
||||
|
||||
export const useEmailService = () => {
|
||||
const setEmails = useSetRecoilState(emailState.emails);
|
||||
|
||||
useNuiEvent('EMAIL', 'phone:fetchAllEmailsSuccess', setEmails);
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
import { createAppThemeProvider } from '../../../os/apps/utils/createAppThemeProvider';
|
||||
import theme from '../email.theme';
|
||||
|
||||
export const EmailThemeProvider = createAppThemeProvider(theme);
|
||||
@@ -0,0 +1,20 @@
|
||||
export interface IEmailPhoneAction {
|
||||
path: string;
|
||||
}
|
||||
|
||||
export interface IEmailExternalAction {
|
||||
eventName: string;
|
||||
args: Array<string | number>;
|
||||
closePhone?: boolean;
|
||||
}
|
||||
|
||||
export interface IEmail {
|
||||
id: number;
|
||||
receivers: string[];
|
||||
sender: string;
|
||||
sendDate: number;
|
||||
subject: string;
|
||||
body: string;
|
||||
phoneActions: Array<IEmailPhoneAction>;
|
||||
externalActions: Array<IEmailExternalAction>;
|
||||
}
|
||||
@@ -48,6 +48,7 @@
|
||||
"APPS_TWITTER": "Twitter",
|
||||
"APPS_SELLOUT": "Market",
|
||||
"APPS_CAMERA": "Camera",
|
||||
"APPS_EMAIL": "E-mail",
|
||||
|
||||
"APPS_DIALER_INCOMING_CALL_TITLE": "Incoming Phone Call",
|
||||
"APPS_DIALER_CURRENT_CALL_TITLE": "Current Phone Call",
|
||||
|
||||
@@ -16,6 +16,7 @@ import MessageIcon from '@material-ui/icons/Message';
|
||||
import FireIcon from '@material-ui/icons/Whatshot';
|
||||
import { CalculatorIcon } from '../../../apps/calculator/components/CalculatorIcon';
|
||||
import CameraAltIcon from '@material-ui/icons/CameraAlt';
|
||||
import MailIcon from '@material-ui/icons/Mail';
|
||||
import { DialerApp } from '../../../apps/dialer/components/DialerApp';
|
||||
import { ContactsApp } from '../../../apps/contacts/components/ContactsApp';
|
||||
import { CalculatorApp } from '../../../apps/calculator/components/CalculatorApp';
|
||||
@@ -27,29 +28,39 @@ import { TwitterApp } from '../../../apps/twitter/components/TwitterApp';
|
||||
import { ExampleApp } from '../../../apps/example/components/ExampleApp';
|
||||
import { MarketplaceApp } from '../../../apps/marketplace/components/MarketplaceApp';
|
||||
import { NotesApp } from '../../../apps/notes/NotesApp';
|
||||
import { EmailApp } from '../../../apps/email/components/EmailApp';
|
||||
import CameraApp from '../../../apps/camera/components/CameraApp';
|
||||
import { AppRoute } from '../components/AppRoute';
|
||||
|
||||
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';
|
||||
|
||||
import {
|
||||
MESSAGES_APP_PRIMARY_COLOR,
|
||||
MESSAGES_APP_TEXT_COLOR,
|
||||
} from '../../../apps/messages/messages.theme';
|
||||
|
||||
import {
|
||||
CONTACTS_APP_PRIMARY_COLOR,
|
||||
CONTACTS_APP_TEXT_COLOR,
|
||||
} from '../../../apps/contacts/contacts.theme';
|
||||
|
||||
import {
|
||||
SELLOUT_APP_PRIMARY_COLOR,
|
||||
SELLOUT_APP_ICON_COLOR,
|
||||
} from '../../../apps/marketplace/marketplace.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';
|
||||
import {
|
||||
TWITTER_APP_PRIMARY_COLOR,
|
||||
TWITTER_APP_TEXT_COLOR,
|
||||
} from '../../../apps/twitter/twitter.theme';
|
||||
import { MATCH_APP_PRIMARY_COLOR, MATCH_APP_TEXT_COLOR } from '../../../apps/match/match.theme';
|
||||
|
||||
import {
|
||||
EMAIL_APP_DEFAULT_PRIMARY_COLOR,
|
||||
EMAIL_APP_DEFAULT_TEXT_COLOR,
|
||||
} from '../../../apps/email/email.theme';
|
||||
|
||||
export interface IAppConfig {
|
||||
id: string;
|
||||
nameLocale: string;
|
||||
@@ -172,6 +183,16 @@ export const APPS: IAppConfig[] = [
|
||||
path: '/camera',
|
||||
Route: () => <AppRoute id="CAMERA" path="/camera" component={CameraApp} />,
|
||||
},
|
||||
{
|
||||
id: 'EMAIL',
|
||||
nameLocale: 'APPS_EMAIL',
|
||||
icon: <MailIcon fontSize="large" />,
|
||||
notificationIcon: <MailIcon fontSize="small" />,
|
||||
backgroundColor: EMAIL_APP_DEFAULT_PRIMARY_COLOR,
|
||||
color: EMAIL_APP_DEFAULT_TEXT_COLOR,
|
||||
path: '/email',
|
||||
Route: () => <AppRoute id="EMAIL" path="/email" component={EmailApp} />,
|
||||
},
|
||||
];
|
||||
|
||||
// Example app only in dev
|
||||
|
||||
@@ -52,16 +52,23 @@ const useStyles = makeStyles((theme) => ({
|
||||
interface IProps {
|
||||
onChange: (event: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>) => void;
|
||||
value: string;
|
||||
autoFocus?: boolean;
|
||||
placeholder?: string;
|
||||
}
|
||||
|
||||
const DEFAULT_PROPS = {
|
||||
onChange: () => {},
|
||||
value: '',
|
||||
autoFocus: false,
|
||||
placeholder: 'Search...',
|
||||
};
|
||||
|
||||
export const SearchField = ({ value, onChange, placeholder }: IProps = DEFAULT_PROPS) => {
|
||||
export const SearchField = ({
|
||||
value,
|
||||
onChange,
|
||||
placeholder,
|
||||
autoFocus,
|
||||
}: IProps = DEFAULT_PROPS) => {
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<Paper elevation={24} variant="outlined" className={classes.bg}>
|
||||
@@ -72,6 +79,7 @@ export const SearchField = ({ value, onChange, placeholder }: IProps = DEFAULT_P
|
||||
<InputBase
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
autoFocus={autoFocus}
|
||||
placeholder={placeholder}
|
||||
classes={{
|
||||
root: classes.inputRoot,
|
||||
|
||||
Reference in new issue
Block a user