mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
Add theme provider for notes
This commit is contained in:
13 files changed
+205
-198
No files matched your search
@@ -1,41 +1,38 @@
|
||||
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';
|
||||
|
||||
// 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 +41,99 @@ 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 && (
|
||||
<Button
|
||||
color='primary'
|
||||
variant='contained'
|
||||
disabled={detail.title.length > 0 ? false : true}
|
||||
className={classes.saveButton}
|
||||
onClick={handleNoteSave}
|
||||
>
|
||||
{t('GENERIC_SAVE')}
|
||||
</Button>
|
||||
)}
|
||||
{!!detail.id && (
|
||||
<>
|
||||
<Button
|
||||
color='primary'
|
||||
variant='contained'
|
||||
className={classes.updateButton}
|
||||
onClick={handleUpdateNote}
|
||||
>
|
||||
{t('GENERIC_UPDATE')}
|
||||
</Button>
|
||||
<Button
|
||||
color='secondary'
|
||||
variant='contained'
|
||||
className={classes.deleteButton}
|
||||
onClick={handleDeleteNote}
|
||||
>
|
||||
{t('GENERIC_DELETE')}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</Box>
|
||||
</Container>
|
||||
)}
|
||||
</Paper>
|
||||
</Slide>
|
||||
);
|
||||
};
|
||||
@@ -6,21 +6,7 @@ const useStyles = makeStyles((theme) => ({
|
||||
position: 'absolute',
|
||||
height: '100%',
|
||||
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,18 +16,16 @@ const useStyles = makeStyles((theme) => ({
|
||||
},
|
||||
inputPropsContent: {
|
||||
fontSize: 20,
|
||||
lineHeight: 1.2
|
||||
},
|
||||
saveButton: {
|
||||
background: '#f9a825',
|
||||
padding: '10px 30px',
|
||||
},
|
||||
updateButton: {
|
||||
background: '#f9a825',
|
||||
padding: '10px 30px',
|
||||
marginRight: '8px',
|
||||
},
|
||||
deleteButton: {
|
||||
background: '#c62828',
|
||||
padding: '10px 30px',
|
||||
},
|
||||
}));
|
||||
|
||||
Reference in new issue
Block a user