mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 22:16:54 +00:00
Merge branch 'master' into feat/alerts-for-apps
This commit is contained in:
79 files changed
+1716
-970
No files matched your search
@@ -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 { useApp } from '../../os/apps/hooks/useApps';
|
||||
import NoteList from './list/NoteList';
|
||||
|
||||
import { useNotes } from './hooks/useNotes';
|
||||
import { NoteModal } from './modal/NoteModal';
|
||||
import { Fab } from '@material-ui/core';
|
||||
import AddIcon from '@material-ui/icons/Add';
|
||||
|
||||
import { useNoteModal } from './hooks/useNoteModal';
|
||||
import { useNoteDetail } from './hooks/useNoteDetail';
|
||||
|
||||
import useStyles from './notes.styles';
|
||||
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([
|
||||
{
|
||||
@@ -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 { yellow } from '@material-ui/core/colors';
|
||||
|
||||
import useStyles from './notes.styles';
|
||||
|
||||
import { Paper } from '@material-ui/core';
|
||||
import { makeStyles, Paper } from '@material-ui/core';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
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 classes = useStyles();
|
||||
return (
|
||||
<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>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -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 { useNoteModal } from '../hooks/useNoteModal';
|
||||
import { List, ListItem, ListItemText } from '@material-ui/core';
|
||||
import { useNoteDetail } from '../hooks/useNoteDetail';
|
||||
import { useNotes } from '../hooks/useNotes';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
// add search bar later
|
||||
// TODO: Add interface for note
|
||||
const NoteList = ({ notes }) => {
|
||||
const { setNoteModal } = useNoteModal();
|
||||
const NoteList = () => {
|
||||
const history = useHistory();
|
||||
const { notes } = useNotes();
|
||||
const { setDetail } = useNoteDetail();
|
||||
|
||||
const handleNoteModal = (note) => {
|
||||
setNoteModal(true);
|
||||
setDetail(note);
|
||||
history.push('/notes/detail');
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,41 +1,39 @@
|
||||
import { Button, TextField, Slide } from '@material-ui/core';
|
||||
import React, { useState } from 'react';
|
||||
import {
|
||||
Button,
|
||||
TextField,
|
||||
Slide,
|
||||
Paper,
|
||||
Typography,
|
||||
Container,
|
||||
CircularProgress,
|
||||
Box,
|
||||
} from '@material-ui/core';
|
||||
import React from 'react';
|
||||
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
|
||||
|
||||
import { useNoteModal } from '../hooks/useNoteModal';
|
||||
import { useNoteDetail } from '../hooks/useNoteDetail';
|
||||
|
||||
import useStyles from './modal.styles';
|
||||
|
||||
import '../NotesApp.css';
|
||||
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 = () => {
|
||||
const { noteModal, setNoteModal } = useNoteModal();
|
||||
const classes = useStyles();
|
||||
const history = useHistory();
|
||||
const { t } = useTranslation();
|
||||
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 = () => {
|
||||
setDetail(null);
|
||||
setNoteModal(false);
|
||||
onClose();
|
||||
};
|
||||
|
||||
const handleNoteSave = () => {
|
||||
Nui.send('phone:addNote', {
|
||||
title,
|
||||
content,
|
||||
});
|
||||
Nui.send('phone:addNote', detail);
|
||||
setDetail(null);
|
||||
setNoteModal(false);
|
||||
|
||||
setTitle('')
|
||||
setContent('')
|
||||
onClose();
|
||||
};
|
||||
|
||||
const handleDeleteNote = () => {
|
||||
@@ -44,78 +42,112 @@ export const NoteModal = () => {
|
||||
id,
|
||||
});
|
||||
setDetail(null);
|
||||
setNoteModal(false);
|
||||
onClose();
|
||||
};
|
||||
|
||||
const handleUpdateNote = () => {
|
||||
Nui.send('phone:updateNote', {
|
||||
id: detail.id,
|
||||
title,
|
||||
content,
|
||||
});
|
||||
Nui.send('phone:updateNote', detail);
|
||||
setDetail(null);
|
||||
setNoteModal(false);
|
||||
onClose();
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={noteModal ? classes.modalRoot : classes.modalHide}>
|
||||
<Slide direction='left' in={noteModal} mountOnEnter unmountOnExit>
|
||||
<div>
|
||||
<Button className={classes.closeButton} onClick={_handleClose}>
|
||||
<ArrowBackIcon fontSize='large' />
|
||||
</Button>
|
||||
<div id='notes-modal' className={classes.noteContainer}>
|
||||
<TextField
|
||||
className={classes.input}
|
||||
rowsMax={1}
|
||||
placeholder='Title'
|
||||
inputProps={{
|
||||
className: classes.inputPropsTitle,
|
||||
maxLength: 25
|
||||
}}
|
||||
fullWidth
|
||||
value={title}
|
||||
onChange={(e) => setTitle(e.target.value)}
|
||||
/>
|
||||
<TextField
|
||||
className={classes.input}
|
||||
inputProps={{
|
||||
className: classes.inputPropsContent,
|
||||
maxLength: 250,
|
||||
}}
|
||||
placeholder='Content'
|
||||
multiline
|
||||
fullWidth
|
||||
rows={19}
|
||||
variant='outlined'
|
||||
value={content}
|
||||
onChange={(e) => setContent(e.target.value)}
|
||||
/>
|
||||
<p style={{ color: "#fff" }}>{content.length}/250</p>
|
||||
{!detail &&(
|
||||
<Button disabled={title.length > 0 ? false : true} className={classes.saveButton} onClick={handleNoteSave}>
|
||||
Save
|
||||
</Button>
|
||||
)}
|
||||
{detail && (
|
||||
<Button
|
||||
className={classes.updateButton}
|
||||
onClick={handleUpdateNote}
|
||||
>
|
||||
Update
|
||||
</Button>
|
||||
)}
|
||||
{detail && (
|
||||
<Button
|
||||
className={classes.deleteButton}
|
||||
onClick={handleDeleteNote}
|
||||
>
|
||||
Delete
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</Slide>
|
||||
</div>
|
||||
<Slide direction='left' in={!!detail}>
|
||||
<Paper className={classes.modalRoot}>
|
||||
{!detail ? (
|
||||
<CircularProgress />
|
||||
) : (
|
||||
<Container>
|
||||
<Box>
|
||||
<Box py={2}>
|
||||
<Button
|
||||
color='primary'
|
||||
size='large'
|
||||
startIcon={<ArrowBackIcon fontSize='large' />}
|
||||
onClick={_handleClose}
|
||||
>
|
||||
{t('APPS_NOTES')}
|
||||
</Button>
|
||||
</Box>
|
||||
<TextField
|
||||
className={classes.input}
|
||||
rowsMax={1}
|
||||
label={t('GENERIC_TITLE')}
|
||||
inputProps={{
|
||||
className: classes.inputPropsTitle,
|
||||
maxLength: 25,
|
||||
}}
|
||||
fullWidth
|
||||
value={detail.title}
|
||||
onChange={(e) =>
|
||||
setDetail((d) => ({ ...d, title: e.target.value }))
|
||||
}
|
||||
/>
|
||||
<TextField
|
||||
className={classes.input}
|
||||
inputProps={{
|
||||
className: classes.inputPropsContent,
|
||||
maxLength: 250,
|
||||
}}
|
||||
label={t('GENERIC_CONTENT')}
|
||||
multiline
|
||||
fullWidth
|
||||
rows={16}
|
||||
variant='outlined'
|
||||
value={detail.content}
|
||||
onChange={(e) =>
|
||||
setDetail((d) => ({ ...d, content: e.target.value }))
|
||||
}
|
||||
/>
|
||||
<Typography paragraph>{detail.content.length}/250</Typography>
|
||||
{!detail.id ? (
|
||||
<>
|
||||
<Box display="inline" p={1}>
|
||||
<Button
|
||||
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}
|
||||
>
|
||||
{t('GENERIC_UPDATE')}
|
||||
</Button>
|
||||
</Box>
|
||||
<Box display="inline" p={1}>
|
||||
<StatusButton
|
||||
color='error'
|
||||
variant='contained'
|
||||
onClick={handleDeleteNote}
|
||||
>
|
||||
{t('GENERIC_DELETE')}
|
||||
</StatusButton>
|
||||
</Box>
|
||||
</>
|
||||
)}
|
||||
</Box>
|
||||
</Container>
|
||||
)}
|
||||
</Paper>
|
||||
</Slide>
|
||||
);
|
||||
};
|
||||
@@ -4,23 +4,9 @@ const useStyles = makeStyles((theme) => ({
|
||||
modalRoot: {
|
||||
zIndex: 20,
|
||||
position: 'absolute',
|
||||
height: '100%',
|
||||
height: '99%',
|
||||
width: '100%',
|
||||
background: '#232323',
|
||||
},
|
||||
modalHide: {
|
||||
display: 'none',
|
||||
},
|
||||
closeButton: {
|
||||
width: '10%',
|
||||
position: 'absolute',
|
||||
top: 10,
|
||||
left: 0,
|
||||
},
|
||||
noteContainer: {
|
||||
width: '90%',
|
||||
marginTop: 80,
|
||||
margin: '0 auto',
|
||||
background: theme.palette.background.default,
|
||||
},
|
||||
input: {
|
||||
marginBottom: 20,
|
||||
@@ -30,19 +16,7 @@ const useStyles = makeStyles((theme) => ({
|
||||
},
|
||||
inputPropsContent: {
|
||||
fontSize: 20,
|
||||
},
|
||||
saveButton: {
|
||||
background: '#f9a825',
|
||||
padding: '10px 30px',
|
||||
},
|
||||
updateButton: {
|
||||
background: '#f9a825',
|
||||
padding: '10px 30px',
|
||||
marginRight: '8px',
|
||||
},
|
||||
deleteButton: {
|
||||
background: '#c62828',
|
||||
padding: '10px 30px',
|
||||
lineHeight: 1.2,
|
||||
},
|
||||
}));
|
||||
|
||||
|
||||
@@ -1,15 +1,6 @@
|
||||
import { makeStyles } from '@material-ui/core';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
header: {
|
||||
width: '100%',
|
||||
display: 'flex',
|
||||
flexFlow: 'row nowrap',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
textAlign: 'center',
|
||||
height: '60px',
|
||||
},
|
||||
backgroundModal: {
|
||||
background: 'black',
|
||||
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);
|
||||
Reference in new issue
Block a user