mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c05ef39c7 |
No files matched your search
+5
-10
@@ -5,6 +5,7 @@ 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, Slide, Typography } from '@material-ui/core';
|
||||||
|
import { useKeyboardService } from './os/keyboard/hooks/useKeyboardService';
|
||||||
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 { useNuiService } from './os/nui-events/hooks/useNuiService';
|
import { useNuiService } from './os/nui-events/hooks/useNuiService';
|
||||||
@@ -32,8 +33,6 @@ import WindowSnackbar from './ui/components/WindowSnackbar';
|
|||||||
import { usePhone } from './os/phone/hooks/usePhone';
|
import { usePhone } from './os/phone/hooks/usePhone';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useSnackbar } from './ui/hooks/useSnackbar';
|
import { useSnackbar } from './ui/hooks/useSnackbar';
|
||||||
import { PhoneEvents } from '../../typings/phone';
|
|
||||||
import dayjs from 'dayjs';
|
|
||||||
|
|
||||||
function Phone() {
|
function Phone() {
|
||||||
const { t, i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
@@ -63,6 +62,7 @@ function Phone() {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useNuiService();
|
useNuiService();
|
||||||
|
useKeyboardService();
|
||||||
usePhoneService();
|
usePhoneService();
|
||||||
useSimcardService();
|
useSimcardService();
|
||||||
useContactsService();
|
useContactsService();
|
||||||
@@ -151,20 +151,15 @@ function Phone() {
|
|||||||
|
|
||||||
export default Phone;
|
export default Phone;
|
||||||
|
|
||||||
InjectDebugData<any>([
|
InjectDebugData([
|
||||||
{
|
{
|
||||||
app: 'PHONE',
|
app: 'PHONE',
|
||||||
method: PhoneEvents.SET_VISIBILITY,
|
method: 'setVisibility',
|
||||||
data: true,
|
data: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
app: 'PHONE',
|
app: 'PHONE',
|
||||||
method: PhoneEvents.SET_PHONE_READY,
|
method: 'setPhoneReady',
|
||||||
data: true,
|
data: true,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
app: 'PHONE',
|
|
||||||
method: PhoneEvents.SET_TIME,
|
|
||||||
data: dayjs().format('hh:mm'),
|
|
||||||
},
|
|
||||||
]);
|
]);
|
||||||
@@ -7,6 +7,7 @@ import { useBankNotification } from './useBankNotification';
|
|||||||
import { IAlert, useSnackbar } from '../../../ui/hooks/useSnackbar';
|
import { IAlert, useSnackbar } from '../../../ui/hooks/useSnackbar';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { BankEvents } from '../../../../../typings/bank';
|
import { BankEvents } from '../../../../../typings/bank';
|
||||||
|
import { PhoneEvents } from '../../../../../typings/phone';
|
||||||
|
|
||||||
export const useBankService = () => {
|
export const useBankService = () => {
|
||||||
const setTransaction = useSetRecoilState(bankState.transactions);
|
const setTransaction = useSetRecoilState(bankState.transactions);
|
||||||
|
|||||||
@@ -7,8 +7,9 @@ import ShareIcon from '@material-ui/icons/Share';
|
|||||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import { useQueryParams } from '../../../../common/hooks/useQueryParams';
|
import { useQueryParams } from '../../../../common/hooks/useQueryParams';
|
||||||
|
import { ICameraPhoto } from '../../hooks/usePhotos';
|
||||||
import { ShareModal } from './ShareModal';
|
import { ShareModal } from './ShareModal';
|
||||||
import { IPhoto, PhotoEvents } from '../../../../../../typings/photo';
|
import { PhotoEvents } from '../../../../../../typings/photo';
|
||||||
|
|
||||||
export const GalleryModal = () => {
|
export const GalleryModal = () => {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
@@ -18,9 +19,10 @@ export const GalleryModal = () => {
|
|||||||
|
|
||||||
const [shareOpen, setShareOpen] = useState(null);
|
const [shareOpen, setShareOpen] = useState(null);
|
||||||
|
|
||||||
const meta: IPhoto = useMemo(() => ({ id: parseInt(query.id), image: query.image as string }), [
|
const meta: ICameraPhoto = useMemo(
|
||||||
query,
|
() => ({ id: query.id as string, image: query.image as string }),
|
||||||
]);
|
[query],
|
||||||
|
);
|
||||||
|
|
||||||
const _handleClose = () => {
|
const _handleClose = () => {
|
||||||
history.push(referal);
|
history.push(referal);
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ import MessageIcon from '@material-ui/icons/Message';
|
|||||||
import { setClipboard } from '../../../../os/phone/hooks/useClipboard';
|
import { setClipboard } from '../../../../os/phone/hooks/useClipboard';
|
||||||
|
|
||||||
import useStyles from './modal.styles';
|
import useStyles from './modal.styles';
|
||||||
|
import { ICameraPhoto } from '../../hooks/usePhotos';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import { IPhoto } from '../../../../../../typings/photo';
|
|
||||||
|
|
||||||
interface IShareModalProps {
|
interface IShareModalProps {
|
||||||
meta: IPhoto;
|
meta: ICameraPhoto;
|
||||||
referal: string;
|
referal: string;
|
||||||
onClose(): void;
|
onClose(): void;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import { atom } from 'recoil';
|
import { atom } from 'recoil';
|
||||||
import { IPhoto } from '../../../../../typings/photo';
|
|
||||||
|
|
||||||
export const photoState = {
|
export const photoState = {
|
||||||
photos: atom<IPhoto[]>({
|
photos: atom({
|
||||||
key: 'galleryPhotos',
|
key: 'galleryPhotos',
|
||||||
default: [],
|
default: null,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
@@ -1,6 +1,11 @@
|
|||||||
import { useRecoilValue } from 'recoil';
|
import { useRecoilValue } from 'recoil';
|
||||||
import { photoState } from './state';
|
import { photoState } from './state';
|
||||||
|
|
||||||
export const usePhotos = () => {
|
export interface ICameraPhoto {
|
||||||
return useRecoilValue(photoState.photos);
|
id: string;
|
||||||
|
image: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const usePhotos = (): ICameraPhoto[] | null => {
|
||||||
|
return useRecoilValue<ICameraPhoto[] | null>(photoState.photos);
|
||||||
};
|
};
|
||||||
@@ -1,17 +1,24 @@
|
|||||||
import { atom } from 'recoil';
|
import { atom } from 'recoil';
|
||||||
import { Contact } from '../../../../../typings/contact';
|
|
||||||
|
|
||||||
export const contactsState = {
|
export const contactsState = {
|
||||||
contacts: atom<Contact[]>({
|
contacts: atom({
|
||||||
key: 'contactsList',
|
key: 'contactsList',
|
||||||
default: [],
|
default: [],
|
||||||
}),
|
}),
|
||||||
showModal: atom<boolean>({
|
showModal: atom({
|
||||||
key: 'showModal',
|
key: 'showModal',
|
||||||
default: false,
|
default: false,
|
||||||
}),
|
}),
|
||||||
filterContacts: atom<string>({
|
filterContacts: atom({
|
||||||
key: 'filterContacts',
|
key: 'filterContacts',
|
||||||
default: '',
|
default: '',
|
||||||
}),
|
}),
|
||||||
|
showContactsModal: atom({
|
||||||
|
key: 'showContactModal',
|
||||||
|
default: false,
|
||||||
|
}),
|
||||||
|
contactDetail: atom({
|
||||||
|
key: 'contactDetail',
|
||||||
|
default: null,
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
@@ -3,7 +3,7 @@ import { contactsState } from './state';
|
|||||||
|
|
||||||
interface FilterdContactsProps {
|
interface FilterdContactsProps {
|
||||||
filteredContacts: string;
|
filteredContacts: string;
|
||||||
setFilteredContacts: (searchTerm: string) => void;
|
setFilteredContacts: (contact: any) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useFilteredContacts = (): FilterdContactsProps => {
|
export const useFilteredContacts = (): FilterdContactsProps => {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { ListItem } from '../../../../ui/components/ListItem';
|
|||||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||||
import { useSimcard } from '../../../../os/simcard/hooks/useSimcard';
|
import { useSimcard } from '../../../../os/simcard/hooks/useSimcard';
|
||||||
import { useContacts } from '../../../contacts/hooks/useContacts';
|
import { useContacts } from '../../../contacts/hooks/useContacts';
|
||||||
import { CallEvents, CallHistoryItem } from '../../../../../../typings/call';
|
import { CallEvents, ICall } from '../../../../../../typings/call';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Box, IconButton, ListItemIcon, ListItemText } from '@material-ui/core';
|
import { Box, IconButton, ListItemIcon, ListItemText } from '@material-ui/core';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
@@ -55,7 +55,7 @@ export const DialerHistory = ({ calls }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<List disablePadding>
|
<List disablePadding>
|
||||||
{calls.map((call: CallHistoryItem) =>
|
{calls.map((call: ICall) =>
|
||||||
call.transmitter === myNumber ? (
|
call.transmitter === myNumber ? (
|
||||||
<ListItem key={call.id} divider>
|
<ListItem key={call.id} divider>
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import { atom } from 'recoil';
|
import { atom } from 'recoil';
|
||||||
import { CallHistoryItem } from '../../../../../typings/call';
|
|
||||||
|
|
||||||
export const dialState = {
|
export const dialState = {
|
||||||
history: atom<CallHistoryItem[]>({
|
history: atom({
|
||||||
key: 'dialHistory',
|
key: 'dialHistory',
|
||||||
default: [],
|
default: [],
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useRecoilValue } from 'recoil';
|
import { useRecoilValue } from 'recoil';
|
||||||
|
import { ICall } from '../../../../../typings/call';
|
||||||
import { dialState } from './state';
|
import { dialState } from './state';
|
||||||
|
|
||||||
export const useDialHistory = () => {
|
export const useDialHistory = () => {
|
||||||
return useRecoilValue(dialState.history);
|
return useRecoilValue<ICall[]>(dialState.history);
|
||||||
};
|
};
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { makeStyles, Button, TextField } from '@material-ui/core';
|
import { makeStyles, Button, TextField, Typography } from '@material-ui/core';
|
||||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||||
import { MarketplaceEvents } from '../../../../../../typings/marketplace';
|
import { MarketplaceEvents } from '../../../../../../typings/marketplace';
|
||||||
import { useSnackbar } from '../../../../ui/hooks/useSnackbar';
|
import { useSnackbar } from '../../../../ui/hooks/useSnackbar';
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import { atom } from 'recoil';
|
import { atom } from 'recoil';
|
||||||
import { MarketplaceListing } from '../../../../../typings/marketplace';
|
|
||||||
|
|
||||||
export const selloutState = {
|
export const selloutState = {
|
||||||
listing: atom<MarketplaceListing[]>({
|
listing: atom({
|
||||||
key: 'listing',
|
key: 'listing',
|
||||||
default: [],
|
default: [],
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ const useStyles = makeStyles({
|
|||||||
export function MatchBottomNavigation({ activePage, handleChange }) {
|
export function MatchBottomNavigation({ activePage, handleChange }) {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
|
||||||
|
console.log(activePage);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BottomNavigation value={activePage} onChange={handleChange} className={classes.root}>
|
<BottomNavigation value={activePage} onChange={handleChange} className={classes.root}>
|
||||||
<BottomNavigationAction component={Link} to="/match" icon={<HomeIcon />} />
|
<BottomNavigationAction component={Link} to="/match" icon={<HomeIcon />} />
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import { atom } from 'recoil';
|
import { atom } from 'recoil';
|
||||||
import { FormattedMatch, FormattedProfile } from '../../../../../typings/match';
|
|
||||||
|
|
||||||
export const matchState = {
|
export const matchState = {
|
||||||
profiles: atom<FormattedProfile[]>({
|
profiles: atom({
|
||||||
key: 'profiles',
|
key: 'profiles',
|
||||||
default: null,
|
default: null,
|
||||||
}),
|
}),
|
||||||
@@ -10,19 +9,19 @@ export const matchState = {
|
|||||||
key: 'errorLoadingProfiles',
|
key: 'errorLoadingProfiles',
|
||||||
default: false,
|
default: false,
|
||||||
}),
|
}),
|
||||||
matches: atom<FormattedMatch[]>({
|
matches: atom({
|
||||||
key: 'matches',
|
key: 'matches',
|
||||||
default: null,
|
default: null,
|
||||||
}),
|
}),
|
||||||
errorLoadingMatches: atom<boolean>({
|
errorLoadingMatches: atom({
|
||||||
key: 'errorLoadingMatches',
|
key: 'errorLoadingMatches',
|
||||||
default: false,
|
default: false,
|
||||||
}),
|
}),
|
||||||
myProfile: atom<FormattedProfile | null>({
|
myProfile: atom({
|
||||||
key: 'myProfile',
|
key: 'myProfile',
|
||||||
default: null,
|
default: null,
|
||||||
}),
|
}),
|
||||||
noProfileExists: atom<boolean>({
|
noProfileExists: atom({
|
||||||
key: 'noProfileExists',
|
key: 'noProfileExists',
|
||||||
default: false,
|
default: false,
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { Box, List } from '@material-ui/core';
|
import { Box, List } from '@material-ui/core';
|
||||||
import { MessageGroup } from '../../../../../../typings/messages';
|
import { MessageEvents, MessageGroup } from '../../../../../../typings/messages';
|
||||||
|
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||||
import useMessages from '../../hooks/useMessages';
|
import useMessages from '../../hooks/useMessages';
|
||||||
import MessageGroupItem from './MessageGroupItem';
|
import MessageGroupItem from './MessageGroupItem';
|
||||||
import useStyles from './list.styles';
|
import useStyles from './list.styles';
|
||||||
|
|||||||
@@ -1,33 +1,32 @@
|
|||||||
import { atom } from 'recoil';
|
import { atom } from 'recoil';
|
||||||
import { CreateMessageGroupResult, Message, MessageGroup } from '../../../../../typings/messages';
|
|
||||||
|
|
||||||
export const messageState = {
|
export const messageState = {
|
||||||
messageGroups: atom<MessageGroup[]>({
|
messageGroups: atom({
|
||||||
key: 'messageGroups',
|
key: 'messageGroups',
|
||||||
default: [],
|
default: null,
|
||||||
}),
|
}),
|
||||||
messages: atom<Message[]>({
|
messages: atom({
|
||||||
key: 'messages',
|
key: 'messages',
|
||||||
default: null,
|
default: null,
|
||||||
}),
|
}),
|
||||||
activeMessageGroup: atom<MessageGroup>({
|
activeMessageGroup: atom({
|
||||||
key: 'activeMessageGroup',
|
key: 'activeMessageGroup',
|
||||||
default: null,
|
default: null,
|
||||||
}),
|
}),
|
||||||
showNewMessageGroup: atom<boolean>({
|
showNewMessageGroup: atom({
|
||||||
key: 'showNewMessageGroup',
|
key: 'showNewMessageGroup',
|
||||||
default: false,
|
default: false,
|
||||||
}),
|
}),
|
||||||
createMessageGroupResult: atom<CreateMessageGroupResult>({
|
createMessageGroupResult: atom({
|
||||||
key: 'createMessageGroupResult',
|
key: 'createMessageGroupResult',
|
||||||
default: null,
|
default: null,
|
||||||
}),
|
}),
|
||||||
imageModal: atom<boolean>({
|
imageModal: atom({
|
||||||
key: 'useImageModal',
|
key: 'useImageModal',
|
||||||
default: false,
|
default: false,
|
||||||
}),
|
}),
|
||||||
unreadMessagesCount: atom<number>({
|
unreadMessagesCount: atom({
|
||||||
key: 'unreadMessagesCount',
|
key: 'unreadMessagesCount',
|
||||||
default: 0,
|
default: 0,
|
||||||
}),
|
})
|
||||||
};
|
};
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { useCallback } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { matchPath, useHistory } from 'react-router-dom';
|
import { matchPath, useHistory } from 'react-router-dom';
|
||||||
import { useApp } from '../../../os/apps/hooks/useApps';
|
import { useApp } from '../../../os/apps/hooks/useApps';
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ interface IUseMessages {
|
|||||||
activeMessageGroup: MessageGroup | null;
|
activeMessageGroup: MessageGroup | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function useMessages(): IUseMessages {
|
export default (): IUseMessages => {
|
||||||
const [messages, setMessages] = useRecoilState<Message[] | null>(messageState.messages);
|
const [messages, setMessages] = useRecoilState<Message[] | null>(messageState.messages);
|
||||||
const messageGroups = useRecoilValue<MessageGroup[] | null>(messageState.messageGroups);
|
const messageGroups = useRecoilValue<MessageGroup[] | null>(messageState.messageGroups);
|
||||||
const [activeMessageGroup, _setActiveMessageGroup] = useRecoilState<MessageGroup | null>(
|
const [activeMessageGroup, _setActiveMessageGroup] = useRecoilState<MessageGroup | null>(
|
||||||
@@ -54,4 +54,4 @@ export default function useMessages(): IUseMessages {
|
|||||||
activeMessageGroup,
|
activeMessageGroup,
|
||||||
setActiveMessageGroup,
|
setActiveMessageGroup,
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
@@ -10,8 +10,10 @@ import {
|
|||||||
Tooltip,
|
Tooltip,
|
||||||
Typography,
|
Typography,
|
||||||
Switch,
|
Switch,
|
||||||
|
TextField,
|
||||||
} from '@material-ui/core';
|
} from '@material-ui/core';
|
||||||
import CreateIcon from '@material-ui/icons/Create';
|
import CreateIcon from '@material-ui/icons/Create';
|
||||||
|
import { PictureThumbnail } from '../../../ui/components/PictureThumbnail';
|
||||||
|
|
||||||
interface ISettingItem {
|
interface ISettingItem {
|
||||||
options?: any;
|
options?: any;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { useState } from 'react';
|
||||||
import { AppWrapper } from '../../../ui/components';
|
import { AppWrapper } from '../../../ui/components';
|
||||||
import { AppTitle } from '../../../ui/components/AppTitle';
|
import { AppTitle } from '../../../ui/components/AppTitle';
|
||||||
import { AppContent } from '../../../ui/components/AppContent';
|
import { AppContent } from '../../../ui/components/AppContent';
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ const localStorageEffect = (key) => ({ setSelf, onSet }) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const settingsState = atom<IPhoneSettings>({
|
export const settingsState = atom({
|
||||||
key: 'settings',
|
key: 'settings',
|
||||||
default: config.defaultSettings,
|
default: config.defaultSettings,
|
||||||
effects_UNSTABLE: [localStorageEffect(NPWD_STORAGE_KEY)],
|
effects_UNSTABLE: [localStorageEffect(NPWD_STORAGE_KEY)],
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { blue, common, grey, purple } from '@material-ui/core/colors';
|
import { blue, common, grey, purple } from '@material-ui/core/colors';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import { faAd, faPlaneArrival, faPhoneAlt, faStickyNote } from '@fortawesome/free-solid-svg-icons';
|
import {
|
||||||
|
faAd,
|
||||||
|
faPlaneArrival,
|
||||||
|
faPhoneAlt,
|
||||||
|
faWonSign,
|
||||||
|
faStickyNote,
|
||||||
|
} from '@fortawesome/free-solid-svg-icons';
|
||||||
import { faTwitter } from '@fortawesome/free-brands-svg-icons';
|
import { faTwitter } from '@fortawesome/free-brands-svg-icons';
|
||||||
|
|
||||||
import ContactsIcon from '@material-ui/icons/Contacts';
|
import ContactsIcon from '@material-ui/icons/Contacts';
|
||||||
@@ -14,6 +20,7 @@ import { DialerApp } from '../../../apps/dialer/components/DialerApp';
|
|||||||
import { ContactsApp } from '../../../apps/contacts/components/ContactsApp';
|
import { ContactsApp } from '../../../apps/contacts/components/ContactsApp';
|
||||||
import { CalculatorApp } from '../../../apps/calculator/components/CalculatorApp';
|
import { CalculatorApp } from '../../../apps/calculator/components/CalculatorApp';
|
||||||
import { SettingsApp } from '../../../apps/settings/components/SettingsApp';
|
import { SettingsApp } from '../../../apps/settings/components/SettingsApp';
|
||||||
|
import { BankApp } from '../../../apps/bank/components/BankApp';
|
||||||
import { MessagesApp } from '../../../apps/messages/components/MessagesApp';
|
import { MessagesApp } from '../../../apps/messages/components/MessagesApp';
|
||||||
import { MatchApp } from '../../../apps/match/components/MatchApp';
|
import { MatchApp } from '../../../apps/match/components/MatchApp';
|
||||||
import { TwitterApp } from '../../../apps/twitter/components/TwitterApp';
|
import { TwitterApp } from '../../../apps/twitter/components/TwitterApp';
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ import React from 'react';
|
|||||||
import { Box, makeStyles } from '@material-ui/core';
|
import { Box, makeStyles } from '@material-ui/core';
|
||||||
import { CallControls } from './CallControls';
|
import { CallControls } from './CallControls';
|
||||||
|
|
||||||
// interface ICallNotificationProps {
|
interface ICallNotificationProps {
|
||||||
// onAccept(): void;
|
onAccept(): void;
|
||||||
// onReject(): void;
|
onReject(): void;
|
||||||
// }
|
}
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
const useStyles = makeStyles((theme) => ({
|
||||||
root: {
|
root: {
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import { atom } from 'recoil';
|
import { atom } from 'recoil';
|
||||||
import { ActiveCall } from '../../../../../typings/call';
|
|
||||||
|
|
||||||
export const callerState = {
|
export const callerState = {
|
||||||
currentCall: atom<ActiveCall>({
|
currentCall: atom({
|
||||||
key: 'currentCall',
|
key: 'currentCall',
|
||||||
default: null,
|
default: null,
|
||||||
}),
|
}),
|
||||||
callModal: atom<boolean>({
|
callModal: atom({
|
||||||
key: 'callingModal',
|
key: 'callingModal',
|
||||||
default: false,
|
default: false,
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { useRecoilState } from 'recoil';
|
import { useRecoilState } from 'recoil';
|
||||||
import { ActiveCall } from '../../../../../typings/call';
|
import { CallProps } from '../../../../../typings/call';
|
||||||
import Nui from '../../nui-events/utils/Nui';
|
import Nui from '../../nui-events/utils/Nui';
|
||||||
import { callerState } from './state';
|
import { callerState } from './state';
|
||||||
import { CallEvents } from '../../../../../typings/call';
|
import { CallEvents } from '../../../../../typings/call';
|
||||||
|
|
||||||
interface CallHook {
|
interface CallHook {
|
||||||
call: ActiveCall;
|
call: CallProps;
|
||||||
setCall: (details: any) => void;
|
setCall: (details: any) => void;
|
||||||
acceptCall(): void;
|
acceptCall(): void;
|
||||||
rejectCall(): void;
|
rejectCall(): void;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import { ActiveCall } from '../../../../../typings/call';
|
import { CallProps } from '../../../../../typings/call';
|
||||||
import { useApp } from '../../apps/hooks/useApps';
|
import { useApp } from '../../apps/hooks/useApps';
|
||||||
import { useNotifications } from '../../notifications/hooks/useNotifications';
|
import { useNotifications } from '../../notifications/hooks/useNotifications';
|
||||||
import { useRingtoneSound } from '../../sound/hooks/useRingtoneSound';
|
import { useRingtoneSound } from '../../sound/hooks/useRingtoneSound';
|
||||||
@@ -27,7 +27,7 @@ export const useCallNotifications = () => {
|
|||||||
notificationIcon,
|
notificationIcon,
|
||||||
};
|
};
|
||||||
|
|
||||||
const setNotification = (call: ActiveCall) => {
|
const setNotification = (call: CallProps) => {
|
||||||
stop();
|
stop();
|
||||||
if (!call || !call.active) {
|
if (!call || !call.active) {
|
||||||
removeId(NOTIFICATION_ID);
|
removeId(NOTIFICATION_ID);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
|
|||||||
import { useNuiEvent } from '../../nui-events/hooks/useNuiEvent';
|
import { useNuiEvent } from '../../nui-events/hooks/useNuiEvent';
|
||||||
import { useSetRecoilState } from 'recoil';
|
import { useSetRecoilState } from 'recoil';
|
||||||
import { useCall } from './useCall';
|
import { useCall } from './useCall';
|
||||||
import { CallEvents, ActiveCall } from '../../../../../typings/call';
|
import { CallEvents, CallProps } from '../../../../../typings/call';
|
||||||
import InjectDebugData from '../../debug/InjectDebugData';
|
import InjectDebugData from '../../debug/InjectDebugData';
|
||||||
import { useCallModal } from './useCallModal';
|
import { useCallModal } from './useCallModal';
|
||||||
import { useHistory, useLocation } from 'react-router-dom';
|
import { useHistory, useLocation } from 'react-router-dom';
|
||||||
@@ -10,7 +10,7 @@ import { callerState } from './state';
|
|||||||
import { useCallNotifications } from './useCallNotifications';
|
import { useCallNotifications } from './useCallNotifications';
|
||||||
import { useDuration } from './useDuration';
|
import { useDuration } from './useDuration';
|
||||||
|
|
||||||
InjectDebugData<ActiveCall | boolean>([
|
InjectDebugData<CallProps | boolean>([
|
||||||
/* {
|
/* {
|
||||||
app: 'CALL',
|
app: 'CALL',
|
||||||
method: 'setCaller',
|
method: 'setCaller',
|
||||||
@@ -56,11 +56,11 @@ export const useCallService = () => {
|
|||||||
}
|
}
|
||||||
}, [history, modal, pathname, modalHasBeenOpenedThisCall]);
|
}, [history, modal, pathname, modalHasBeenOpenedThisCall]);
|
||||||
|
|
||||||
const _setCall = (_call: ActiveCall) => {
|
const _setCall = (_call: CallProps) => {
|
||||||
resetDuration();
|
resetDuration();
|
||||||
setCall(_call);
|
setCall(_call);
|
||||||
setNotification(_call);
|
setNotification(_call);
|
||||||
};
|
};
|
||||||
useNuiEvent<ActiveCall>('CALL', CallEvents.SET_CALLER, _setCall, call);
|
useNuiEvent<CallProps>('CALL', CallEvents.SET_CALLER, _setCall, call);
|
||||||
useNuiEvent<boolean>('CALL', CallEvents.SET_CALL_MODAL, setModal);
|
useNuiEvent<boolean>('CALL', CallEvents.SET_CALL_MODAL, setModal);
|
||||||
};
|
};
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
import { useCallback, useEffect, useRef } from 'react';
|
||||||
|
import { useHistory } from 'react-router-dom';
|
||||||
|
import { atom, useSetRecoilState, useRecoilValue } from 'recoil';
|
||||||
|
import { usePhone } from '../../phone/hooks/usePhone';
|
||||||
|
|
||||||
|
const keyboardState = {
|
||||||
|
ArrowRight: atom({
|
||||||
|
key: 'ArrowRight',
|
||||||
|
default: null,
|
||||||
|
}),
|
||||||
|
ArrowLeft: atom({
|
||||||
|
key: 'ArrowLeft',
|
||||||
|
default: null,
|
||||||
|
}),
|
||||||
|
ArrowUp: atom({
|
||||||
|
key: 'ArrowUp',
|
||||||
|
default: null,
|
||||||
|
}),
|
||||||
|
ArrowDown: atom({
|
||||||
|
key: 'ArrowDown',
|
||||||
|
default: null,
|
||||||
|
}),
|
||||||
|
Backspace: atom({
|
||||||
|
key: 'Backspace',
|
||||||
|
default: null,
|
||||||
|
}),
|
||||||
|
Enter: atom({
|
||||||
|
key: 'Enter',
|
||||||
|
default: null,
|
||||||
|
}),
|
||||||
|
Escape: atom({
|
||||||
|
key: 'Escape',
|
||||||
|
default: null,
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
const validKeys = [
|
||||||
|
'ArrowRight',
|
||||||
|
'ArrowLeft',
|
||||||
|
'ArrowUp',
|
||||||
|
'ArrowDown',
|
||||||
|
'Backspace',
|
||||||
|
'Enter',
|
||||||
|
'Escape',
|
||||||
|
];
|
||||||
|
|
||||||
|
const isKeyValid = (key) => validKeys.indexOf(key) !== -1;
|
||||||
|
|
||||||
|
export const useKeyboardService = () => {
|
||||||
|
const history = useHistory();
|
||||||
|
const { closePhone } = usePhone();
|
||||||
|
const getters = {
|
||||||
|
ArrowRight: useRecoilValue(keyboardState.ArrowRight),
|
||||||
|
ArrowLeft: useRecoilValue(keyboardState.ArrowLeft),
|
||||||
|
ArrowUp: useRecoilValue(keyboardState.ArrowUp),
|
||||||
|
ArrowDown: useRecoilValue(keyboardState.ArrowDown),
|
||||||
|
Backspace: useRecoilValue(keyboardState.Backspace),
|
||||||
|
Enter: useRecoilValue(keyboardState.Enter),
|
||||||
|
Escape: useRecoilValue(keyboardState.Escape),
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlers = useRef(new Map());
|
||||||
|
const setEscape = useSetRecoilState<any>(keyboardState.Escape);
|
||||||
|
const setBackspace = useSetRecoilState(keyboardState.Backspace);
|
||||||
|
|
||||||
|
useEffect(
|
||||||
|
function registerCustomKeys() {
|
||||||
|
Object.keys(getters).forEach((g) => {
|
||||||
|
handlers.current.set(g, getters[g]);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[getters],
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(
|
||||||
|
function handleNUIKeyboardMessage() {
|
||||||
|
function onKeyUp(event) {
|
||||||
|
const { key } = event;
|
||||||
|
const callback = handlers.current.get(key);
|
||||||
|
if (isKeyValid(key) && callback && callback.call) {
|
||||||
|
return callback(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('keyup', onKeyUp);
|
||||||
|
return () => window.removeEventListener('keyup', onKeyUp);
|
||||||
|
},
|
||||||
|
[getters],
|
||||||
|
);
|
||||||
|
|
||||||
|
const backspaceHandler = useCallback(
|
||||||
|
(event) => {
|
||||||
|
if (['input', 'textarea'].includes(event.target.nodeName.toLowerCase())) {
|
||||||
|
// Dont anything if we are typing something :)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
history.goBack();
|
||||||
|
},
|
||||||
|
[history],
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(
|
||||||
|
function registerDefaultHandlers() {
|
||||||
|
handlers.current.set('Escape', () => closePhone());
|
||||||
|
handlers.current.set('Backspace', backspaceHandler);
|
||||||
|
},
|
||||||
|
[setEscape, setBackspace, history, backspaceHandler, closePhone],
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -26,7 +26,7 @@ function getParams(event, data): [RequestInfo, RequestInit] {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
const NuiUtils = {
|
export default {
|
||||||
async send(event: any, data = {}) {
|
async send(event: any, data = {}) {
|
||||||
return fetch(...getParams(event, data));
|
return fetch(...getParams(event, data));
|
||||||
},
|
},
|
||||||
@@ -34,5 +34,3 @@ const NuiUtils = {
|
|||||||
return abortableFetch(...getParams(event, data));
|
return abortableFetch(...getParams(event, data));
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default NuiUtils;
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import { atom } from 'recoil';
|
||||||
|
|
||||||
|
export const phoneSettings = {
|
||||||
|
theme: atom({
|
||||||
|
key: 'settingTheme',
|
||||||
|
default: 'default-dark',
|
||||||
|
}),
|
||||||
|
zoom: atom({
|
||||||
|
key: 'settingZoom',
|
||||||
|
default: '100%',
|
||||||
|
}),
|
||||||
|
};
|
||||||
@@ -1,20 +1,19 @@
|
|||||||
import { atom } from 'recoil';
|
import { atom } from 'recoil';
|
||||||
import { IServerConfig } from '../../../../../typings/config';
|
|
||||||
|
|
||||||
export const phoneState = {
|
export const phoneState = {
|
||||||
visibility: atom<boolean>({
|
visibility: atom({
|
||||||
key: 'phoneVisibility',
|
key: 'phoneVisibility',
|
||||||
default: false,
|
default: false,
|
||||||
}),
|
}),
|
||||||
phoneConfig: atom<IServerConfig>({
|
phoneConfig: atom({
|
||||||
key: 'phoneConfig',
|
key: 'phoneConfig',
|
||||||
default: null,
|
default: undefined,
|
||||||
}),
|
}),
|
||||||
phoneReady: atom<boolean>({
|
phoneReady: atom({
|
||||||
key: 'phoneReady',
|
key: 'phoneReady',
|
||||||
default: false,
|
default: false,
|
||||||
}),
|
}),
|
||||||
phoneTime: atom<string>({
|
phoneTime: atom({
|
||||||
key: 'phoneTime',
|
key: 'phoneTime',
|
||||||
default: null,
|
default: null,
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
import { useSetRecoilState } from 'recoil';
|
import { useSetRecoilState } from 'recoil';
|
||||||
import { phoneState } from './state';
|
import { phoneState } from './state';
|
||||||
import { useNuiEvent } from '../../nui-events/hooks/useNuiEvent';
|
import { useNuiEvent } from '../../nui-events/hooks/useNuiEvent';
|
||||||
import { PhoneEvents } from '../../../../../typings/phone';
|
|
||||||
|
|
||||||
export const usePhoneService = () => {
|
export const usePhoneService = () => {
|
||||||
const setVisibility = useSetRecoilState(phoneState.visibility);
|
const setVisibility = useSetRecoilState(phoneState.visibility);
|
||||||
const setPhoneConfig = useSetRecoilState(phoneState.phoneConfig);
|
const setPhoneConfig = useSetRecoilState(phoneState.phoneConfig);
|
||||||
const setPhoneReady = useSetRecoilState(phoneState.phoneReady);
|
const setPhoneReady = useSetRecoilState(phoneState.phoneReady);
|
||||||
const setPhoneTime = useSetRecoilState(phoneState.phoneTime);
|
const setPhoneTime = useSetRecoilState(phoneState.phoneTime);
|
||||||
useNuiEvent('PHONE', PhoneEvents.SET_VISIBILITY, setVisibility);
|
useNuiEvent('PHONE', 'setVisibility', setVisibility);
|
||||||
useNuiEvent('PHONE', PhoneEvents.SET_PHONE_READY, setPhoneReady);
|
useNuiEvent('PHONE', 'setPhoneReady', setPhoneReady);
|
||||||
useNuiEvent('PHONE', PhoneEvents.SET_CONFIG, setPhoneConfig);
|
useNuiEvent('PHONE', 'phoneConfig', setPhoneConfig);
|
||||||
useNuiEvent('PHONE', PhoneEvents.SET_TIME, setPhoneTime);
|
useNuiEvent('PHONE', 'setTime', setPhoneTime);
|
||||||
};
|
};
|
||||||
@@ -3,7 +3,6 @@ import { useSetRecoilState } from 'recoil';
|
|||||||
import { simcardState } from './state';
|
import { simcardState } from './state';
|
||||||
import { useSimcard } from './useSimcard';
|
import { useSimcard } from './useSimcard';
|
||||||
import InjectDebugData from '../../debug/InjectDebugData';
|
import InjectDebugData from '../../debug/InjectDebugData';
|
||||||
import { PhoneEvents } from '../../../../../typings/phone';
|
|
||||||
|
|
||||||
InjectDebugData([
|
InjectDebugData([
|
||||||
{
|
{
|
||||||
@@ -15,6 +14,6 @@ InjectDebugData([
|
|||||||
|
|
||||||
export const useSimcardService = () => {
|
export const useSimcardService = () => {
|
||||||
const setNumber = useSetRecoilState(simcardState.number);
|
const setNumber = useSetRecoilState(simcardState.number);
|
||||||
useNuiEvent('SIMCARD', PhoneEvents.SET_NUMBER, setNumber);
|
useNuiEvent('SIMCARD', 'setNumber', setNumber);
|
||||||
return useSimcard();
|
return useSimcard();
|
||||||
};
|
};
|
||||||
@@ -1,9 +1,46 @@
|
|||||||
import React from 'react';
|
import React, { createContext, useRef, useState } from 'react';
|
||||||
import { AppWrapperTypes } from '../interface/InterfaceUI';
|
import { AppWrapperTypes } from '../interface/InterfaceUI';
|
||||||
|
import { Computer } from '@material-ui/icons';
|
||||||
|
import PhoneDrawer from './PhoneDrawer';
|
||||||
|
|
||||||
|
const items = [
|
||||||
|
{
|
||||||
|
onClick: () => console.log(),
|
||||||
|
icon: <Computer color="inherit" />,
|
||||||
|
text: 'Item Thing',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
onClick: () => console.log(),
|
||||||
|
icon: <Computer color="inherit" />,
|
||||||
|
text: 'Item Thing',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
onClick: () => console.log(),
|
||||||
|
icon: <Computer color="inherit" />,
|
||||||
|
text: 'Item Thing',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
onClick: () => console.log(),
|
||||||
|
icon: <Computer color="inherit" />,
|
||||||
|
text: 'Item Thing',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const AppWrapper = ({
|
||||||
|
children,
|
||||||
|
style,
|
||||||
|
handleClickAway,
|
||||||
|
sideMenu,
|
||||||
|
appName,
|
||||||
|
...props
|
||||||
|
}: AppWrapperTypes) => {
|
||||||
|
const ref = useRef();
|
||||||
|
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
export const AppWrapper = ({ children, style, handleClickAway, ...props }: AppWrapperTypes) => {
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
ref={ref}
|
||||||
{...props}
|
{...props}
|
||||||
style={{
|
style={{
|
||||||
padding: 0,
|
padding: 0,
|
||||||
@@ -17,6 +54,13 @@ export const AppWrapper = ({ children, style, handleClickAway, ...props }: AppWr
|
|||||||
...style,
|
...style,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<PhoneDrawer
|
||||||
|
open={open}
|
||||||
|
handleClose={() => setOpen(false)}
|
||||||
|
appTitle={'Side Menu Thing'}
|
||||||
|
containerEl={ref.current}
|
||||||
|
items={items}
|
||||||
|
/>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,11 +2,13 @@ import React from 'react';
|
|||||||
import Paper from '@material-ui/core/Paper';
|
import Paper from '@material-ui/core/Paper';
|
||||||
import Snackbar from '@material-ui/core/Snackbar';
|
import Snackbar from '@material-ui/core/Snackbar';
|
||||||
import Fade from '@material-ui/core/Fade';
|
import Fade from '@material-ui/core/Fade';
|
||||||
import { ThemeProvider } from '@material-ui/core';
|
import { createMuiTheme, ThemeProvider } from '@material-ui/core';
|
||||||
import { makeStyles } from '@material-ui/core/styles';
|
import { makeStyles } from '@material-ui/core/styles';
|
||||||
import { usePhone } from '../../os/phone/hooks/usePhone';
|
import { usePhone } from '../../os/phone/hooks/usePhone';
|
||||||
|
|
||||||
import { usePhoneTheme } from '../../os/phone/hooks/usePhoneTheme';
|
import { useRecoilState } from 'recoil';
|
||||||
|
import { settingsState } from '../../apps/settings/hooks/useSettings';
|
||||||
|
import themeConfig from '../../config/default.json';
|
||||||
|
|
||||||
const useStyles = makeStyles({
|
const useStyles = makeStyles({
|
||||||
paper: {
|
paper: {
|
||||||
@@ -23,14 +25,15 @@ function Notification({ children, handleClose, open }) {
|
|||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const { config } = usePhone();
|
const { config } = usePhone();
|
||||||
|
|
||||||
const currentTheme = usePhoneTheme();
|
const [settings] = useRecoilState(settingsState);
|
||||||
|
|
||||||
if (!config) return null;
|
if (!config) return null;
|
||||||
|
|
||||||
const { horizontal, vertical } = config.notificationPosition;
|
const { horizontal, vertical } = config.notificationPosition;
|
||||||
|
const currentTheme = () => createMuiTheme(themeConfig.themes[settings.theme.value]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ThemeProvider theme={currentTheme}>
|
<ThemeProvider theme={currentTheme()}>
|
||||||
<Snackbar
|
<Snackbar
|
||||||
className={classes.snackBar}
|
className={classes.snackBar}
|
||||||
anchorOrigin={{ horizontal, vertical }}
|
anchorOrigin={{ horizontal, vertical }}
|
||||||
|
|||||||
@@ -0,0 +1,115 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import {
|
||||||
|
ListItem,
|
||||||
|
List,
|
||||||
|
ListItemText,
|
||||||
|
ListItemIcon,
|
||||||
|
Drawer,
|
||||||
|
Typography,
|
||||||
|
Box,
|
||||||
|
Divider,
|
||||||
|
Button,
|
||||||
|
useTheme,
|
||||||
|
} from '@material-ui/core';
|
||||||
|
import { ChevronLeft, Settings } from '@material-ui/icons';
|
||||||
|
import { makeStyles, Theme } from '@material-ui/core/styles';
|
||||||
|
|
||||||
|
interface DrawerItem {
|
||||||
|
onClick: () => void;
|
||||||
|
text: string;
|
||||||
|
icon?: JSX.Element;
|
||||||
|
}
|
||||||
|
|
||||||
|
const BackAction = ({ handleClose }) => (
|
||||||
|
<Button
|
||||||
|
component={Box}
|
||||||
|
display="flex"
|
||||||
|
flexDirection="row"
|
||||||
|
alignItems="center"
|
||||||
|
left="16px"
|
||||||
|
position="absolute"
|
||||||
|
bottom="16px"
|
||||||
|
onClick={handleClose}
|
||||||
|
>
|
||||||
|
<ChevronLeft color="secondary" />
|
||||||
|
<Typography variant="body1" color="textSecondary">
|
||||||
|
Close
|
||||||
|
</Typography>
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
|
||||||
|
interface PhoneDrawer {
|
||||||
|
open: boolean;
|
||||||
|
handleClose: () => void;
|
||||||
|
containerEl: Element;
|
||||||
|
items: DrawerItem[];
|
||||||
|
appTitle?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const useStyles = makeStyles((theme: Theme) => ({
|
||||||
|
sidebarTitle: {
|
||||||
|
marginLeft: 20,
|
||||||
|
color: theme.palette.secondary.contrastText,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const PhoneDrawer: React.FC<PhoneDrawer> = ({
|
||||||
|
items,
|
||||||
|
open,
|
||||||
|
containerEl,
|
||||||
|
handleClose,
|
||||||
|
appTitle,
|
||||||
|
}) => {
|
||||||
|
const theme = useTheme();
|
||||||
|
|
||||||
|
const classes = useStyles();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Drawer
|
||||||
|
open={open}
|
||||||
|
onClose={() => {}}
|
||||||
|
PaperProps={{ style: { position: 'absolute', width: '70%' } }}
|
||||||
|
BackdropProps={{ style: { position: 'absolute' } }}
|
||||||
|
ModalProps={{
|
||||||
|
container: containerEl,
|
||||||
|
style: { position: 'absolute' },
|
||||||
|
}}
|
||||||
|
variant="temporary"
|
||||||
|
>
|
||||||
|
<Box height="100%">
|
||||||
|
<Box
|
||||||
|
display="flex"
|
||||||
|
flexDirection="row"
|
||||||
|
alignItems="center"
|
||||||
|
p={2}
|
||||||
|
bgcolor={theme.palette.secondary.main}
|
||||||
|
>
|
||||||
|
<Settings htmlColor={theme.palette.secondary.contrastText} />
|
||||||
|
{appTitle && (
|
||||||
|
<Typography variant="h6" className={classes.sidebarTitle}>
|
||||||
|
{appTitle}
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
<List disablePadding>
|
||||||
|
{items.map((item) => (
|
||||||
|
<>
|
||||||
|
<ListItem
|
||||||
|
button
|
||||||
|
onClick={item.onClick}
|
||||||
|
style={{ color: theme.palette.text.secondary }}
|
||||||
|
>
|
||||||
|
{item?.icon && <ListItemIcon>{item.icon}</ListItemIcon>}
|
||||||
|
<ListItemText primary={item.text} />
|
||||||
|
</ListItem>
|
||||||
|
<Divider />
|
||||||
|
</>
|
||||||
|
))}
|
||||||
|
</List>
|
||||||
|
<BackAction handleClose={handleClose} />
|
||||||
|
</Box>
|
||||||
|
</Drawer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PhoneDrawer;
|
||||||
@@ -9,7 +9,9 @@ export interface AppContentTypes {
|
|||||||
|
|
||||||
export interface AppWrapperTypes {
|
export interface AppWrapperTypes {
|
||||||
id?: string;
|
id?: string;
|
||||||
|
appName?: string;
|
||||||
children?: JSX.Element | JSX.Element[];
|
children?: JSX.Element | JSX.Element[];
|
||||||
style?: CSSProperties;
|
style?: CSSProperties;
|
||||||
handleClickAway?: (...args: any[]) => void;
|
handleClickAway?: (...args: any[]) => void;
|
||||||
|
sideMenu?: string[];
|
||||||
}
|
}
|
||||||
+19
-22
@@ -1,5 +1,5 @@
|
|||||||
import { CallEvents } from '../../typings/call';
|
import { CallEvents } from '../../typings/call';
|
||||||
import { CallHistoryItem } from '../../typings/call';
|
import { ICall } from '../../typings/call';
|
||||||
import { phoneCallStartAnim, phoneCallEndAnim } from './functions';
|
import { phoneCallStartAnim, phoneCallEndAnim } from './functions';
|
||||||
|
|
||||||
const exp = (global as any).exports;
|
const exp = (global as any).exports;
|
||||||
@@ -34,26 +34,23 @@ on(`__cfx_nui:${CallEvents.ACCEPT_CALL}`, (data: any, cb: Function) => {
|
|||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
|
|
||||||
onNet(
|
onNet(CallEvents.WAS_ACCEPTED, (channelId: number, currentCall: ICall, isTransmitter: boolean) => {
|
||||||
CallEvents.WAS_ACCEPTED,
|
exp['mumble-voip'].SetCallChannel(channelId);
|
||||||
(channelId: number, currentCall: CallHistoryItem, isTransmitter: boolean) => {
|
phoneCallStartAnim(); // Trigger call animation only if the call was accepted.
|
||||||
exp['mumble-voip'].SetCallChannel(channelId);
|
SendNuiMessage(
|
||||||
phoneCallStartAnim(); // Trigger call animation only if the call was accepted.
|
JSON.stringify({
|
||||||
SendNuiMessage(
|
app: 'CALL',
|
||||||
JSON.stringify({
|
method: CallEvents.SET_CALLER,
|
||||||
app: 'CALL',
|
data: {
|
||||||
method: CallEvents.SET_CALLER,
|
active: true,
|
||||||
data: {
|
transmitter: currentCall.transmitter,
|
||||||
active: true,
|
receiver: currentCall.receiver,
|
||||||
transmitter: currentCall.transmitter,
|
isTransmitter: isTransmitter,
|
||||||
receiver: currentCall.receiver,
|
accepted: true,
|
||||||
isTransmitter: isTransmitter,
|
},
|
||||||
accepted: true,
|
}),
|
||||||
},
|
);
|
||||||
}),
|
});
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
RegisterNuiCallbackType(CallEvents.REJECTED); // Fires when cancelling and rejecting a call.
|
RegisterNuiCallbackType(CallEvents.REJECTED); // Fires when cancelling and rejecting a call.
|
||||||
on(`__cfx_nui:${CallEvents.REJECTED}`, (data: any, cb: Function) => {
|
on(`__cfx_nui:${CallEvents.REJECTED}`, (data: any, cb: Function) => {
|
||||||
@@ -118,7 +115,7 @@ function openCallModal(show: boolean) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onNet(CallEvents.SEND_HISTORY, (calls: CallHistoryItem[]) => {
|
onNet(CallEvents.SEND_HISTORY, (calls: ICall) => {
|
||||||
SendNuiMessage(
|
SendNuiMessage(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
app: 'DIALER',
|
app: 'DIALER',
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ function fetchOnInitialize() {
|
|||||||
emitNet(ContactEvents.GET_CONTACTS);
|
emitNet(ContactEvents.GET_CONTACTS);
|
||||||
emitNet(MessageEvents.FETCH_MESSAGE_GROUPS);
|
emitNet(MessageEvents.FETCH_MESSAGE_GROUPS);
|
||||||
emitNet(TwitterEvents.GET_OR_CREATE_PROFILE);
|
emitNet(TwitterEvents.GET_OR_CREATE_PROFILE);
|
||||||
sendMessage('PHONE', PhoneEvents.SET_PHONE_READY, isPhoneReady);
|
sendMessage('PHONE', 'setPhoneReady', isPhoneReady);
|
||||||
sendMessage('PHONE', PhoneEvents.SET_CONFIG, config);
|
sendMessage('PHONE', 'phoneConfig', config);
|
||||||
}
|
}
|
||||||
|
|
||||||
RegisterKeyMapping('phone', 'Open Phone', 'keyboard', 'f1');
|
RegisterKeyMapping('phone', 'Open Phone', 'keyboard', 'f1');
|
||||||
@@ -55,14 +55,14 @@ const showPhone = async (): Promise<void> => {
|
|||||||
await phoneOpenAnim(); // Animation starts before the phone is open
|
await phoneOpenAnim(); // Animation starts before the phone is open
|
||||||
emitNet('phone:getCredentials');
|
emitNet('phone:getCredentials');
|
||||||
SetCursorLocation(0.9, 0.922); //Experimental
|
SetCursorLocation(0.9, 0.922); //Experimental
|
||||||
sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, true);
|
sendMessage('PHONE', 'setVisibility', true);
|
||||||
sendMessage('PHONE', PhoneEvents.SET_TIME, time);
|
sendMessage('PHONE', 'setTime', time);
|
||||||
SetNuiFocus(true, true);
|
SetNuiFocus(true, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const hidePhone = async (): Promise<void> => {
|
const hidePhone = async (): Promise<void> => {
|
||||||
isPhoneOpen = false;
|
isPhoneOpen = false;
|
||||||
sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, false);
|
sendMessage('PHONE', 'setVisibility', false);
|
||||||
await phoneCloseAnim();
|
await phoneCloseAnim();
|
||||||
SetNuiFocus(false, false);
|
SetNuiFocus(false, false);
|
||||||
};
|
};
|
||||||
@@ -115,15 +115,15 @@ onNet(PhoneEvents.PLAYER_IS_READY, fetchOnInitialize);
|
|||||||
|
|
||||||
AddEventHandler('onResourceStop', function (resource: string) {
|
AddEventHandler('onResourceStop', function (resource: string) {
|
||||||
if (resource === GetCurrentResourceName()) {
|
if (resource === GetCurrentResourceName()) {
|
||||||
sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, false);
|
sendMessage('PHONE', 'setVisibility', false);
|
||||||
SetNuiFocus(false, false);
|
SetNuiFocus(false, false);
|
||||||
removePhoneProp(); //Deletes the phone incase it was attached.
|
removePhoneProp(); //Deletes the phone incase it was attached.
|
||||||
ClearPedTasks(PlayerPedId()); //Leave here until launch as it'll fix any stuck animations.
|
ClearPedTasks(PlayerPedId()); //Leave here until launch as it'll fix any stuck animations.
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onNet(PhoneEvents.SEND_CREDENTIALS, (number: string) => {
|
onNet('phone:sendCredentials', (number: string) => {
|
||||||
sendMessage('SIMCARD', PhoneEvents.SET_NUMBER, number);
|
sendMessage('SIMCARD', 'setNumber', number);
|
||||||
});
|
});
|
||||||
|
|
||||||
// DO NOT CHANGE THIS EITHER, PLEASE - CHIP
|
// DO NOT CHANGE THIS EITHER, PLEASE - CHIP
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { PhotoEvents } from '../../typings/photo';
|
import { PhotoEvents } from '../../typings/photo';
|
||||||
import { Delay } from '../utils/fivem';
|
import { Delay } from '../utils/fivem';
|
||||||
import { sendMessage, sendCameraEvent } from '../utils/messages';
|
import { sendMessage, sendCameraEvent } from '../utils/messages';
|
||||||
import { PhoneEvents } from '../../typings/phone';
|
|
||||||
const SCREENSHOT_BASIC_TOKEN = GetConvar('SCREENSHOT_BASIC_TOKEN', 'none');
|
const SCREENSHOT_BASIC_TOKEN = GetConvar('SCREENSHOT_BASIC_TOKEN', 'none');
|
||||||
|
|
||||||
const exp = (global as any).exports;
|
const exp = (global as any).exports;
|
||||||
@@ -10,12 +9,12 @@ let inCameraMode = false;
|
|||||||
|
|
||||||
function closePhoneTemp() {
|
function closePhoneTemp() {
|
||||||
SetNuiFocus(false, false);
|
SetNuiFocus(false, false);
|
||||||
sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, false);
|
sendMessage('PHONE', 'setVisibility', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function openPhoneTemp() {
|
function openPhoneTemp() {
|
||||||
SetNuiFocus(true, true);
|
SetNuiFocus(true, true);
|
||||||
sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, true);
|
sendMessage('PHONE', 'setVisibility', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function CellFrontCamActivate(activate: boolean) {
|
function CellFrontCamActivate(activate: boolean) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { CallEvents } from '../../typings/call';
|
import { CallEvents } from '../../typings/call';
|
||||||
import { getIdentifierByPhoneNumber, getPlayer, getSource } from './functions';
|
import { getIdentifierByPhoneNumber, getPlayer, getSource } from './functions';
|
||||||
import { getPlayerFromIdentifier } from './functions';
|
import { getPlayerFromIdentifier } from './functions';
|
||||||
import { CallHistoryItem } from '../../typings/call';
|
import { ICall } from '../../typings/call';
|
||||||
|
|
||||||
import { pool } from './db';
|
import { pool } from './db';
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
@@ -9,25 +9,25 @@ import { mainLogger } from './sv_logger';
|
|||||||
|
|
||||||
const callLogger = mainLogger.child({ module: 'calls' });
|
const callLogger = mainLogger.child({ module: 'calls' });
|
||||||
|
|
||||||
async function saveCall(call: CallHistoryItem) {
|
async function saveCall(call: ICall) {
|
||||||
const query =
|
const query =
|
||||||
'INSERT INTO npwd_calls (identifier, transmitter, receiver, start) VALUES (?, ?, ?, ?)';
|
'INSERT INTO npwd_calls (identifier, transmitter, receiver, start) VALUES (?, ?, ?, ?)';
|
||||||
await pool.query(query, [call.identifier, call.transmitter, call.receiver, call.start]);
|
await pool.query(query, [call.identifier, call.transmitter, call.receiver, call.start]);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateCall(call: CallHistoryItem, isAccepted: boolean, end: number) {
|
async function updateCall(call: ICall, isAccepted: boolean, end: number) {
|
||||||
const query = 'UPDATE npwd_calls SET is_accepted=?, end=? WHERE identifier = ?';
|
const query = 'UPDATE npwd_calls SET is_accepted=?, end=? WHERE identifier = ?';
|
||||||
await pool.query(query, [isAccepted, end, call.identifier]);
|
await pool.query(query, [isAccepted, end, call.identifier]);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchCalls(phoneNumber: string): Promise<CallHistoryItem[]> {
|
async function fetchCalls(phoneNumber: string): Promise<ICall[]> {
|
||||||
const query = 'SELECT * FROM npwd_calls WHERE receiver = ? OR transmitter = ? ORDER BY id DESC';
|
const query = 'SELECT * FROM npwd_calls WHERE receiver = ? OR transmitter = ? ORDER BY id DESC';
|
||||||
const [result] = await pool.query(query, [phoneNumber, phoneNumber]);
|
const [result] = await pool.query(query, [phoneNumber, phoneNumber]);
|
||||||
const calls = <CallHistoryItem[]>result;
|
const calls = <ICall[]>result;
|
||||||
return calls;
|
return calls;
|
||||||
}
|
}
|
||||||
|
|
||||||
let calls: Map<string, CallHistoryItem> = new Map();
|
let calls: Map<string, ICall> = new Map();
|
||||||
|
|
||||||
onNet(CallEvents.INITIALIZE_CALL, async (phoneNumber: string) => {
|
onNet(CallEvents.INITIALIZE_CALL, async (phoneNumber: string) => {
|
||||||
const _source = getSource();
|
const _source = getSource();
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { pool } from './db';
|
import { pool } from './db';
|
||||||
import { getIdentifier, getSource } from './functions';
|
import { getIdentifier, getSource } from './functions';
|
||||||
import { mainLogger } from './sv_logger';
|
import { mainLogger } from './sv_logger';
|
||||||
import { PhoneEvents } from '../../typings/phone';
|
|
||||||
|
|
||||||
interface Credentials {
|
interface Credentials {
|
||||||
phone_number: string;
|
phone_number: string;
|
||||||
@@ -20,7 +19,7 @@ onNet('phone:getCredentials', async () => {
|
|||||||
try {
|
try {
|
||||||
const identifier = getIdentifier(_source);
|
const identifier = getIdentifier(_source);
|
||||||
const number = await getCredentials(identifier);
|
const number = await getCredentials(identifier);
|
||||||
emitNet(PhoneEvents.SEND_CREDENTIALS, _source, number);
|
emitNet('phone:sendCredentials', _source, number);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
mainLogger.error(`Failed to get a number, ${e.message}`, {
|
mainLogger.error(`Failed to get a number, ${e.message}`, {
|
||||||
source: _source,
|
source: _source,
|
||||||
|
|||||||
+9
-2
@@ -1,4 +1,4 @@
|
|||||||
export interface ActiveCall {
|
export interface CallProps {
|
||||||
active: boolean;
|
active: boolean;
|
||||||
accepted: boolean;
|
accepted: boolean;
|
||||||
isTransmitter: boolean;
|
isTransmitter: boolean;
|
||||||
@@ -6,7 +6,7 @@ export interface ActiveCall {
|
|||||||
receiver: string;
|
receiver: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CallHistoryItem {
|
export interface ICall {
|
||||||
id?: number;
|
id?: number;
|
||||||
identifier: string;
|
identifier: string;
|
||||||
transmitter: string;
|
transmitter: string;
|
||||||
@@ -18,6 +18,13 @@ export interface CallHistoryItem {
|
|||||||
accepted: boolean;
|
accepted: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ICallDuration {
|
||||||
|
ms: number;
|
||||||
|
s: number;
|
||||||
|
m: number;
|
||||||
|
h: number;
|
||||||
|
}
|
||||||
|
|
||||||
export enum CallEvents {
|
export enum CallEvents {
|
||||||
INITIALIZE_CALL = 'npwd:beginCall',
|
INITIALIZE_CALL = 'npwd:beginCall',
|
||||||
START_CALL = 'npwd:startCall',
|
START_CALL = 'npwd:startCall',
|
||||||
|
|||||||
@@ -11,11 +11,5 @@ export enum PhoneEvents {
|
|||||||
OPEN_PHONE = 'npwd:open',
|
OPEN_PHONE = 'npwd:open',
|
||||||
CLOSE_PHONE = 'npwd:close',
|
CLOSE_PHONE = 'npwd:close',
|
||||||
SET_ALERT = 'npwd:setAlert',
|
SET_ALERT = 'npwd:setAlert',
|
||||||
SET_VISIBILITY = 'npwd:setVisibility',
|
|
||||||
SET_NOTIFICATION = 'npwd:setNotification',
|
SET_NOTIFICATION = 'npwd:setNotification',
|
||||||
SET_NUMBER = 'npwd:setNumber',
|
|
||||||
SET_PHONE_READY = 'npwd:phoneReady',
|
|
||||||
SET_CONFIG = 'npwd:setPhoneConfig',
|
|
||||||
SET_TIME = 'npwd:setGameTime',
|
|
||||||
SEND_CREDENTIALS = 'npwd:sendCredentials',
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user