mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
fix(phone/notes): Fixed slide transition with notes modal
This commit is contained in:
1 parent
ec4ebdc54d
commit
4b7a6280fd
3 files changed
+6
-20
No files matched your search
@@ -1,5 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { AppWrapper } from '../../ui/components/AppWrapper';
|
import { AppWrapper } from '../../ui/components';
|
||||||
import { AppContent } from '../../ui/components/AppContent';
|
import { AppContent } from '../../ui/components/AppContent';
|
||||||
import { AppTitle } from '../../ui/components/AppTitle';
|
import { AppTitle } from '../../ui/components/AppTitle';
|
||||||
import { useApp } from '../../os/apps/hooks/useApps';
|
import { useApp } from '../../os/apps/hooks/useApps';
|
||||||
@@ -11,25 +11,23 @@ import { useNoteDetail } from './hooks/useNoteDetail';
|
|||||||
import useStyles from './notes.styles';
|
import useStyles from './notes.styles';
|
||||||
import InjectDebugData from '../../os/debug/InjectDebugData';
|
import InjectDebugData from '../../os/debug/InjectDebugData';
|
||||||
import { NotesThemeProvider } from './providers/NotesThemeProvider';
|
import { NotesThemeProvider } from './providers/NotesThemeProvider';
|
||||||
import { Route, useHistory } from 'react-router-dom';
|
import { Route } from 'react-router-dom';
|
||||||
import { NotesEvents } from '../../../../typings/notes';
|
import { NotesEvents } from '../../../../typings/notes';
|
||||||
|
|
||||||
export const NotesApp = () => {
|
export const NotesApp = () => {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const history = useHistory();
|
|
||||||
const notesApp = useApp('NOTES');
|
const notesApp = useApp('NOTES');
|
||||||
const { setDetail } = useNoteDetail();
|
const { setDetail } = useNoteDetail();
|
||||||
|
|
||||||
const onClickCreate = () => {
|
const onClickCreate = () => {
|
||||||
setDetail({ title: '', content: '' });
|
setDetail({ title: '', content: '' });
|
||||||
history.push('/notes/detail');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NotesThemeProvider>
|
<NotesThemeProvider>
|
||||||
<AppWrapper id="notes-app">
|
<AppWrapper id="notes-app">
|
||||||
<AppTitle app={notesApp} />
|
<AppTitle app={notesApp} />
|
||||||
<Route path="/notes/detail" component={NoteModal} />
|
<NoteModal />
|
||||||
<AppContent>
|
<AppContent>
|
||||||
<Route path="/notes" component={NoteList} />
|
<Route path="/notes" component={NoteList} />
|
||||||
<Fab className={classes.absolute} onClick={onClickCreate} color="primary">
|
<Fab className={classes.absolute} onClick={onClickCreate} color="primary">
|
||||||
|
|||||||
@@ -2,18 +2,14 @@ import React from 'react';
|
|||||||
import { List, ListItem, ListItemText } from '@material-ui/core';
|
import { List, ListItem, ListItemText } from '@material-ui/core';
|
||||||
import { useNoteDetail } from '../hooks/useNoteDetail';
|
import { useNoteDetail } from '../hooks/useNoteDetail';
|
||||||
import { useNotes } from '../hooks/useNotes';
|
import { useNotes } from '../hooks/useNotes';
|
||||||
import { useHistory } from 'react-router-dom';
|
|
||||||
|
|
||||||
// add search bar later
|
// TODO: add search bar later
|
||||||
// TODO: Add interface for note
|
|
||||||
const NoteList = () => {
|
const NoteList = () => {
|
||||||
const history = useHistory();
|
|
||||||
const { notes } = useNotes();
|
const { notes } = useNotes();
|
||||||
const { setDetail } = useNoteDetail();
|
const { setDetail } = useNoteDetail();
|
||||||
|
|
||||||
const handleNoteModal = (note) => {
|
const handleNoteModal = (note) => {
|
||||||
setDetail(note);
|
setDetail(note);
|
||||||
history.push('/notes/detail');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -14,28 +14,22 @@ import { useNoteDetail } from '../hooks/useNoteDetail';
|
|||||||
import useStyles from './modal.styles';
|
import useStyles from './modal.styles';
|
||||||
import { useNuiRequest } from 'fivem-nui-react-lib';
|
import { useNuiRequest } from 'fivem-nui-react-lib';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useHistory } from 'react-router-dom';
|
|
||||||
import { StatusButton } from '../../../ui/components/StatusButton';
|
import { StatusButton } from '../../../ui/components/StatusButton';
|
||||||
import { NotesEvents } from '../../../../../typings/notes';
|
import { NotesEvents } from '../../../../../typings/notes';
|
||||||
|
|
||||||
export const NoteModal = () => {
|
export const NoteModal = () => {
|
||||||
const Nui = useNuiRequest();
|
const Nui = useNuiRequest();
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const history = useHistory();
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { detail, setDetail } = useNoteDetail();
|
const { detail, setDetail } = useNoteDetail();
|
||||||
|
|
||||||
const onClose = () => history.goBack();
|
|
||||||
|
|
||||||
const _handleClose = () => {
|
const _handleClose = () => {
|
||||||
setDetail(null);
|
setDetail(null);
|
||||||
onClose();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleNoteSave = () => {
|
const handleNoteSave = () => {
|
||||||
Nui.send(NotesEvents.ADD_NOTE, detail);
|
Nui.send(NotesEvents.ADD_NOTE, detail);
|
||||||
setDetail(null);
|
setDetail(null);
|
||||||
onClose();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDeleteNote = () => {
|
const handleDeleteNote = () => {
|
||||||
@@ -44,18 +38,16 @@ export const NoteModal = () => {
|
|||||||
id,
|
id,
|
||||||
});
|
});
|
||||||
setDetail(null);
|
setDetail(null);
|
||||||
onClose();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleUpdateNote = () => {
|
const handleUpdateNote = () => {
|
||||||
Nui.send(NotesEvents.UPDATE_NOTE, detail);
|
Nui.send(NotesEvents.UPDATE_NOTE, detail);
|
||||||
setDetail(null);
|
setDetail(null);
|
||||||
onClose();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Slide direction="left" in={!!detail}>
|
<Slide direction="left" in={!!detail} mountOnEnter unmountOnExit>
|
||||||
<Paper className={classes.modalRoot}>
|
<Paper className={classes.modalRoot} square>
|
||||||
{!detail ? (
|
{!detail ? (
|
||||||
<CircularProgress />
|
<CircularProgress />
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
Reference in new issue
Block a user