mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
Merge branch 'feat/public-api' of https://github.com/project-error/new-phone-who-dis into feat/public-api
This commit is contained in:
commit
ed05ebd6a8
8 files changed
+92
-90
No files matched your search
@@ -1,12 +1,12 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { RecoilRoot } from 'recoil';
|
import { RecoilRoot } from 'recoil';
|
||||||
import { shallow } from 'enzyme';
|
import { shallow } from 'enzyme';
|
||||||
import { PhoneContainer } from './PhoneContainer';
|
import { PhoneProviders } from './PhoneProviders';
|
||||||
|
|
||||||
it('renders Phone', () => {
|
it('renders Phone', () => {
|
||||||
shallow(
|
shallow(
|
||||||
<RecoilRoot>
|
<RecoilRoot>
|
||||||
<PhoneContainer />
|
<PhoneProviders />
|
||||||
</RecoilRoot>,
|
</RecoilRoot>,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
+35
-65
@@ -4,7 +4,7 @@ import './i18n';
|
|||||||
import { Route } from 'react-router-dom';
|
import { Route } from 'react-router-dom';
|
||||||
import { CallModal } from './os/call/components/CallModal';
|
import { CallModal } from './os/call/components/CallModal';
|
||||||
import { HomeApp } from './apps/home/components/Home';
|
import { HomeApp } from './apps/home/components/Home';
|
||||||
import { Box, Paper, Slide, Typography } from '@material-ui/core';
|
import { Box, Paper, Typography } from '@material-ui/core';
|
||||||
import { NotificationBar } from './os/notifications/components/NotificationBar';
|
import { NotificationBar } from './os/notifications/components/NotificationBar';
|
||||||
import { Navigation } from './os/navigation-bar/components/Navigation';
|
import { Navigation } from './os/navigation-bar/components/Navigation';
|
||||||
import { useSimcardService } from './os/simcard/hooks/useSimcardService';
|
import { useSimcardService } from './os/simcard/hooks/useSimcardService';
|
||||||
@@ -23,7 +23,6 @@ import { isSettingsSchemaValid, useSettings } from './apps/settings/hooks/useSet
|
|||||||
import { useCallService } from './os/call/hooks/useCallService';
|
import { useCallService } from './os/call/hooks/useCallService';
|
||||||
import { useDialService } from './apps/dialer/hooks/useDialService';
|
import { useDialService } from './apps/dialer/hooks/useDialService';
|
||||||
import InjectDebugData from './os/debug/InjectDebugData';
|
import InjectDebugData from './os/debug/InjectDebugData';
|
||||||
import { usePhoneVisibility } from './os/phone/hooks/usePhoneVisibility';
|
|
||||||
import { PhoneSnackbar } from './ui/components/PhoneSnackbar';
|
import { PhoneSnackbar } from './ui/components/PhoneSnackbar';
|
||||||
import { NotificationAlert } from './os/notifications/components/NotificationAlert';
|
import { NotificationAlert } from './os/notifications/components/NotificationAlert';
|
||||||
import { useCallModal } from './os/call/hooks/useCallModal';
|
import { useCallModal } from './os/call/hooks/useCallModal';
|
||||||
@@ -33,8 +32,8 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { useSnackbar } from './ui/hooks/useSnackbar';
|
import { useSnackbar } from './ui/hooks/useSnackbar';
|
||||||
import { PhoneEvents } from '../../typings/phone';
|
import { PhoneEvents } from '../../typings/phone';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { isDefaultWallpaper } from './apps/settings/utils/isDefaultWallpaper';
|
|
||||||
import { useKeyboardService } from './os/keyboard/hooks/useKeyboardService';
|
import { useKeyboardService } from './os/keyboard/hooks/useKeyboardService';
|
||||||
|
import PhoneWrapper from './PhoneWrapper';
|
||||||
|
|
||||||
function Phone() {
|
function Phone() {
|
||||||
const { t, i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
@@ -78,74 +77,45 @@ function Phone() {
|
|||||||
useDialService();
|
useDialService();
|
||||||
|
|
||||||
const { modal: callModal } = useCallModal();
|
const { modal: callModal } = useCallModal();
|
||||||
const { bottom, visibility } = usePhoneVisibility();
|
|
||||||
const { isPhoneReady } = usePhone();
|
const { isPhoneReady } = usePhone();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<WindowSnackbar />
|
<WindowSnackbar />
|
||||||
<Slide direction="up" timeout={{ enter: 500, exit: 500 }} in={visibility}>
|
<PhoneWrapper>
|
||||||
<div className="PhoneWrapper">
|
{isPhoneReady ? (
|
||||||
<div
|
<>
|
||||||
className="Phone"
|
<NotificationBar />
|
||||||
style={{
|
<div className="PhoneAppContainer">
|
||||||
position: 'fixed',
|
<>
|
||||||
transformOrigin: 'right bottom',
|
<Route exact path="/" component={HomeApp} />
|
||||||
transform: `scale(${settings.zoom.value}`,
|
{callModal && <Route exact path="/call" component={CallModal} />}
|
||||||
bottom,
|
{apps.map((App) => (
|
||||||
}}
|
<App.Route key={App.id} />
|
||||||
>
|
))}
|
||||||
<div
|
</>
|
||||||
className="PhoneFrame"
|
<NotificationAlert />
|
||||||
style={{
|
<PhoneSnackbar />
|
||||||
backgroundImage: `url(media/frames/${settings.frame.value})`,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<div
|
|
||||||
id="phone"
|
|
||||||
className="PhoneScreen"
|
|
||||||
style={{
|
|
||||||
backgroundImage: !isDefaultWallpaper(settings.wallpaper.value)
|
|
||||||
? `url(${settings.wallpaper.value})`
|
|
||||||
: `url(media/backgrounds/${settings.wallpaper.value})`,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{isPhoneReady ? (
|
|
||||||
<>
|
|
||||||
<NotificationBar />
|
|
||||||
<div className="PhoneAppContainer">
|
|
||||||
<>
|
|
||||||
<Route exact path="/" component={HomeApp} />
|
|
||||||
{callModal && <Route exact path="/call" component={CallModal} />}
|
|
||||||
{apps.map((App) => (
|
|
||||||
<App.Route key={App.id} />
|
|
||||||
))}
|
|
||||||
</>
|
|
||||||
<NotificationAlert />
|
|
||||||
<PhoneSnackbar />
|
|
||||||
</div>
|
|
||||||
<Navigation />
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<Box
|
|
||||||
component={Paper}
|
|
||||||
height="100%"
|
|
||||||
width="100%"
|
|
||||||
display="flex"
|
|
||||||
flexDirection="column"
|
|
||||||
alignItems="center"
|
|
||||||
justifyContent="center"
|
|
||||||
>
|
|
||||||
<Typography paragraph variant="h6">
|
|
||||||
NPWD {t('INITIALIZING')}
|
|
||||||
</Typography>
|
|
||||||
<Typography paragraph>{t('GENERIC_WAIT')}</Typography>
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<Navigation />
|
||||||
</div>
|
</>
|
||||||
</Slide>
|
) : (
|
||||||
|
<Box
|
||||||
|
component={Paper}
|
||||||
|
height="100%"
|
||||||
|
width="100%"
|
||||||
|
display="flex"
|
||||||
|
flexDirection="column"
|
||||||
|
alignItems="center"
|
||||||
|
justifyContent="center"
|
||||||
|
>
|
||||||
|
<Typography paragraph variant="h6">
|
||||||
|
NPWD {t('INITIALIZING')}
|
||||||
|
</Typography>
|
||||||
|
<Typography paragraph>{t('GENERIC_WAIT')}</Typography>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
</PhoneWrapper>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import Phone from './Phone';
|
|||||||
import { NuiProvider } from 'fivem-nui-react-lib';
|
import { NuiProvider } from 'fivem-nui-react-lib';
|
||||||
import { SoundProvider } from './os/sound/providers/SoundProvider';
|
import { SoundProvider } from './os/sound/providers/SoundProvider';
|
||||||
|
|
||||||
export const PhoneContainer = () => {
|
export const PhoneProviders = () => {
|
||||||
const currentTheme = usePhoneTheme();
|
const currentTheme = usePhoneTheme();
|
||||||
return (
|
return (
|
||||||
<NuiProvider resource="new-phone-who-dis">
|
<NuiProvider resource="new-phone-who-dis">
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { isDefaultWallpaper } from './apps/settings/utils/isDefaultWallpaper';
|
||||||
|
import { useSettings } from './apps/settings/hooks/useSettings';
|
||||||
|
import { usePhoneVisibility } from './os/phone/hooks/usePhoneVisibility';
|
||||||
|
import { Slide } from '@material-ui/core';
|
||||||
|
|
||||||
|
const PhoneWrapper: React.FC = ({ children }) => {
|
||||||
|
const [settings] = useSettings();
|
||||||
|
const { bottom, visibility } = usePhoneVisibility();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Slide direction="up" timeout={{ enter: 500, exit: 500 }} in={visibility}>
|
||||||
|
<div className="PhoneWrapper">
|
||||||
|
<div
|
||||||
|
className="Phone"
|
||||||
|
style={{
|
||||||
|
position: 'fixed',
|
||||||
|
transformOrigin: 'right bottom',
|
||||||
|
transform: `scale(${settings.zoom.value}`,
|
||||||
|
bottom,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="PhoneFrame"
|
||||||
|
style={{
|
||||||
|
backgroundImage: `url(media/frames/${settings.frame.value})`,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
id="phone"
|
||||||
|
className="PhoneScreen"
|
||||||
|
style={{
|
||||||
|
backgroundImage: !isDefaultWallpaper(settings.wallpaper.value)
|
||||||
|
? `url(${settings.wallpaper.value})`
|
||||||
|
: `url(media/backgrounds/${settings.wallpaper.value})`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Slide>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PhoneWrapper;
|
||||||
@@ -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,46 +14,38 @@ 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 = () => {
|
||||||
const id = detail.id;
|
const id = detail.id;
|
||||||
Nui.send(NotesEvents.DELETE_NOTE, id);
|
Nui.send(NotesEvents.DELETE_NOTE, 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 />
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
+2
-2
@@ -7,7 +7,7 @@ import * as Sentry from '@sentry/react';
|
|||||||
import { Integrations } from '@sentry/tracing';
|
import { Integrations } from '@sentry/tracing';
|
||||||
import './main.css';
|
import './main.css';
|
||||||
import PhoneConfig from './config/default.json';
|
import PhoneConfig from './config/default.json';
|
||||||
import { PhoneContainer } from './PhoneContainer';
|
import { PhoneProviders } from './PhoneProviders';
|
||||||
import attachMockNuiEvent from './os/debug/AttachMockNuiEvent';
|
import attachMockNuiEvent from './os/debug/AttachMockNuiEvent';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||||
@@ -34,7 +34,7 @@ if (process.env.NODE_ENV === 'development') attachMockNuiEvent();
|
|||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<HashRouter>
|
<HashRouter>
|
||||||
<RecoilRoot>
|
<RecoilRoot>
|
||||||
<PhoneContainer />
|
<PhoneProviders />
|
||||||
</RecoilRoot>
|
</RecoilRoot>
|
||||||
</HashRouter>,
|
</HashRouter>,
|
||||||
document.getElementById('root'),
|
document.getElementById('root'),
|
||||||
|
|||||||
Reference in new issue
Block a user