mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 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);
|
||||
Reference in new issue
Block a user