mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 06:28:51 +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 { RecoilRoot } from 'recoil';
|
||||
import { shallow } from 'enzyme';
|
||||
import { PhoneContainer } from './PhoneContainer';
|
||||
import { PhoneProviders } from './PhoneProviders';
|
||||
|
||||
it('renders Phone', () => {
|
||||
shallow(
|
||||
<RecoilRoot>
|
||||
<PhoneContainer />
|
||||
<PhoneProviders />
|
||||
</RecoilRoot>,
|
||||
);
|
||||
});
|
||||
+35
-65
@@ -4,7 +4,7 @@ import './i18n';
|
||||
import { Route } from 'react-router-dom';
|
||||
import { CallModal } from './os/call/components/CallModal';
|
||||
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 { Navigation } from './os/navigation-bar/components/Navigation';
|
||||
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 { useDialService } from './apps/dialer/hooks/useDialService';
|
||||
import InjectDebugData from './os/debug/InjectDebugData';
|
||||
import { usePhoneVisibility } from './os/phone/hooks/usePhoneVisibility';
|
||||
import { PhoneSnackbar } from './ui/components/PhoneSnackbar';
|
||||
import { NotificationAlert } from './os/notifications/components/NotificationAlert';
|
||||
import { useCallModal } from './os/call/hooks/useCallModal';
|
||||
@@ -33,8 +32,8 @@ import { useTranslation } from 'react-i18next';
|
||||
import { useSnackbar } from './ui/hooks/useSnackbar';
|
||||
import { PhoneEvents } from '../../typings/phone';
|
||||
import dayjs from 'dayjs';
|
||||
import { isDefaultWallpaper } from './apps/settings/utils/isDefaultWallpaper';
|
||||
import { useKeyboardService } from './os/keyboard/hooks/useKeyboardService';
|
||||
import PhoneWrapper from './PhoneWrapper';
|
||||
|
||||
function Phone() {
|
||||
const { t, i18n } = useTranslation();
|
||||
@@ -78,74 +77,45 @@ function Phone() {
|
||||
useDialService();
|
||||
|
||||
const { modal: callModal } = useCallModal();
|
||||
const { bottom, visibility } = usePhoneVisibility();
|
||||
const { isPhoneReady } = usePhone();
|
||||
|
||||
return (
|
||||
<div>
|
||||
<WindowSnackbar />
|
||||
<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})`,
|
||||
}}
|
||||
>
|
||||
{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>
|
||||
)}
|
||||
<PhoneWrapper>
|
||||
{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>
|
||||
</div>
|
||||
</div>
|
||||
</Slide>
|
||||
<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>
|
||||
)}
|
||||
</PhoneWrapper>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import Phone from './Phone';
|
||||
import { NuiProvider } from 'fivem-nui-react-lib';
|
||||
import { SoundProvider } from './os/sound/providers/SoundProvider';
|
||||
|
||||
export const PhoneContainer = () => {
|
||||
export const PhoneProviders = () => {
|
||||
const currentTheme = usePhoneTheme();
|
||||
return (
|
||||
<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 { AppWrapper } from '../../ui/components/AppWrapper';
|
||||
import { AppWrapper } from '../../ui/components';
|
||||
import { AppContent } from '../../ui/components/AppContent';
|
||||
import { AppTitle } from '../../ui/components/AppTitle';
|
||||
import { useApp } from '../../os/apps/hooks/useApps';
|
||||
@@ -11,25 +11,23 @@ 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';
|
||||
import { Route } from 'react-router-dom';
|
||||
import { NotesEvents } from '../../../../typings/notes';
|
||||
|
||||
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} />
|
||||
<NoteModal />
|
||||
<AppContent>
|
||||
<Route path="/notes" component={NoteList} />
|
||||
<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 { useNoteDetail } from '../hooks/useNoteDetail';
|
||||
import { useNotes } from '../hooks/useNotes';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
// add search bar later
|
||||
// TODO: Add interface for note
|
||||
// TODO: add search bar later
|
||||
const NoteList = () => {
|
||||
const history = useHistory();
|
||||
const { notes } = useNotes();
|
||||
const { setDetail } = useNoteDetail();
|
||||
|
||||
const handleNoteModal = (note) => {
|
||||
setDetail(note);
|
||||
history.push('/notes/detail');
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -14,46 +14,38 @@ import { useNoteDetail } from '../hooks/useNoteDetail';
|
||||
import useStyles from './modal.styles';
|
||||
import { useNuiRequest } from 'fivem-nui-react-lib';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { StatusButton } from '../../../ui/components/StatusButton';
|
||||
import { NotesEvents } from '../../../../../typings/notes';
|
||||
|
||||
export const NoteModal = () => {
|
||||
const Nui = useNuiRequest();
|
||||
const classes = useStyles();
|
||||
const history = useHistory();
|
||||
const { t } = useTranslation();
|
||||
const { detail, setDetail } = useNoteDetail();
|
||||
|
||||
const onClose = () => history.goBack();
|
||||
|
||||
const _handleClose = () => {
|
||||
setDetail(null);
|
||||
onClose();
|
||||
};
|
||||
|
||||
const handleNoteSave = () => {
|
||||
Nui.send(NotesEvents.ADD_NOTE, detail);
|
||||
setDetail(null);
|
||||
onClose();
|
||||
};
|
||||
|
||||
const handleDeleteNote = () => {
|
||||
const id = detail.id;
|
||||
Nui.send(NotesEvents.DELETE_NOTE, id);
|
||||
setDetail(null);
|
||||
onClose();
|
||||
};
|
||||
|
||||
const handleUpdateNote = () => {
|
||||
Nui.send(NotesEvents.UPDATE_NOTE, detail);
|
||||
setDetail(null);
|
||||
onClose();
|
||||
};
|
||||
|
||||
return (
|
||||
<Slide direction="left" in={!!detail}>
|
||||
<Paper className={classes.modalRoot}>
|
||||
<Slide direction="left" in={!!detail} mountOnEnter unmountOnExit>
|
||||
<Paper className={classes.modalRoot} square>
|
||||
{!detail ? (
|
||||
<CircularProgress />
|
||||
) : (
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ import * as Sentry from '@sentry/react';
|
||||
import { Integrations } from '@sentry/tracing';
|
||||
import './main.css';
|
||||
import PhoneConfig from './config/default.json';
|
||||
import { PhoneContainer } from './PhoneContainer';
|
||||
import { PhoneProviders } from './PhoneProviders';
|
||||
import attachMockNuiEvent from './os/debug/AttachMockNuiEvent';
|
||||
import dayjs from 'dayjs';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
@@ -34,7 +34,7 @@ if (process.env.NODE_ENV === 'development') attachMockNuiEvent();
|
||||
ReactDOM.render(
|
||||
<HashRouter>
|
||||
<RecoilRoot>
|
||||
<PhoneContainer />
|
||||
<PhoneProviders />
|
||||
</RecoilRoot>
|
||||
</HashRouter>,
|
||||
document.getElementById('root'),
|
||||
|
||||
Reference in new issue
Block a user