Add phone service, rename phone app to dialer, etc improvements

This commit is contained in:
J Francisco Rader committed 2020-08-25 21:13:01 -03:00
1 parent bf2e7fa295
commit b2e0cba844
24 files changed
+311 -255

No files matched your search

+62 -25
View File
@@ -8,7 +8,7 @@ import MessageIcon from "@material-ui/icons/Email";
import { HomeApp } from "./apps/home/components/Home"; import { HomeApp } from "./apps/home/components/Home";
import { ContactsApp } from "./apps/contacts/components/ContactsApp"; import { ContactsApp } from "./apps/contacts/components/ContactsApp";
import { SettingsApp } from "./apps/settings/components/SettingsApp"; import { SettingsApp } from "./apps/settings/components/SettingsApp";
import { PhoneApp } from "./apps/phone/components/PhoneApp"; import { DialerApp } from "./apps/dialer/components/DialerApp";
import { BankApp } from "./apps/bank/components/BankApp"; import { BankApp } from "./apps/bank/components/BankApp";
import { ThemeProvider } from "@material-ui/core"; import { ThemeProvider } from "@material-ui/core";
import { CalculatorApp } from "./apps/calculator/components/CalculatorApp"; import { CalculatorApp } from "./apps/calculator/components/CalculatorApp";
@@ -18,8 +18,10 @@ 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";
import { useSimcardService } from "./os/simcard/hooks/useSimcardService"; import { useSimcardService } from "./os/simcard/hooks/useSimcardService";
import { usePhoneService } from "./os/phone/hooks/usePhoneService";
// @TODO: Remove this testing shit // @TODO: Remove this testing shit
// Used for testing NUI events while we work on clientside
setTimeout(() => { setTimeout(() => {
window.dispatchEvent( window.dispatchEvent(
new MessageEvent("message", { new MessageEvent("message", {
@@ -32,12 +34,49 @@ setTimeout(() => {
); );
}, 3000); }, 3000);
setTimeout(() => {
window.dispatchEvent(
new MessageEvent("message", {
data: {
app: "PHONE",
method: "setPowerOff",
data: false,
},
})
);
}, 4000);
setTimeout(() => {
window.dispatchEvent(
new MessageEvent("message", {
data: {
app: "PHONE",
method: "setVisibility",
data: true,
},
})
);
}, 3000);
function Phone() { function Phone() {
useNuiService(); useNuiService();
const { visibility, powerOff } = usePhoneService();
useSimcardService(); useSimcardService();
useInitKeyboard(); useInitKeyboard();
const { settings, currentTheme } = useSettings(); const { settings, currentTheme } = useSettings();
if (visibility === false) {
return null;
}
const screenStyle = powerOff
? {
backgroundColor: "black",
}
: {
backgroundImage: `url(${process.env.PUBLIC_URL}/media/backgrounds/${settings.wallpaper})`,
};
return ( return (
<ThemeProvider theme={currentTheme()}> <ThemeProvider theme={currentTheme()}>
<div className="PhoneWrapper"> <div className="PhoneWrapper">
@@ -49,30 +88,28 @@ function Phone() {
backgroundImage: `url(${process.env.PUBLIC_URL}/media/frames/${settings.frame})`, backgroundImage: `url(${process.env.PUBLIC_URL}/media/frames/${settings.frame})`,
}} }}
></div> ></div>
<div <div id="phone" className="PhoneScreen" style={screenStyle}>
id="phone" {!powerOff && (
className="PhoneScreen" <>
style={{ <NotificationBar
backgroundImage: `url(${process.env.PUBLIC_URL}/media/backgrounds/${settings.wallpaper})`, notifications={[
}} {
> key: "newMessage",
<NotificationBar icon: <NotificationIcon Icon={MessageIcon} />,
notifications={[ },
{ ]}
key: "newMessage", />
icon: <NotificationIcon Icon={MessageIcon} />, <div className="PhoneAppContainer">
}, <Route exact path="/" component={HomeApp} />
]} <Route exact path="/contacts" component={ContactsApp} />
/> <Route exact path="/settings" component={SettingsApp} />
<div className="PhoneAppContainer"> <Route exact path="/phone" component={DialerApp} />
<Route exact path="/" component={HomeApp} /> <Route exact path="/bank" component={BankApp} />
<Route exact path="/contacts" component={ContactsApp} /> <Route exact path="/calculator" component={CalculatorApp} />
<Route exact path="/settings" component={SettingsApp} /> </div>
<Route exact path="/phone" component={PhoneApp} /> <Navigation />
<Route exact path="/bank" component={BankApp} /> </>
<Route exact path="/calculator" component={CalculatorApp} /> )}
</div>
<Navigation />
</div> </div>
</div> </div>
</div> </div>
-73
View File
@@ -1,73 +0,0 @@
import React, { useEffect } from "react";
import { useConfig } from "../../../config/hooks/useConfig";
import { blue, grey, green, orange } from "@material-ui/core/colors";
import { useTranslation } from "react-i18next";
import ContactsIcon from "@material-ui/icons/Contacts";
import SettingsIcon from '@material-ui/icons/Settings'
import PhoneIcon from '@material-ui/icons/Phone';
import AccountBalanceIcon from '@material-ui/icons/AccountBalance';
import { atom } from "recoil";
import { useSettings } from "../../settings/hooks/useSettings";
import { CalculatorIcon } from "../../calculator/components/CalculatorIcon";
const appsState = atom({
key: "apps",
default: { preinstalled: [] },
});
export const useApps = () => {
const [apps, setApps] = useConfig(appsState);
const { currentTheme } = useSettings();
const { t } = useTranslation();
useEffect(() => {
setApps("preinstalled", [
{
id: "phone",
name: t("APPS_PHONE"),
icon: <PhoneIcon />,
backgroundColor: green[400],
color: green[50],
path: "/phone",
},
{
id: "contacts",
name: t("APPS_CONTACTS"),
icon: <ContactsIcon />,
backgroundColor: blue[500],
color: blue[50],
path: "/contacts",
},
{
id: "calculator",
name: t("APPS_CALCULATOR"),
icon: <CalculatorIcon />,
backgroundColor: currentTheme().palette.primary.light,
color: currentTheme().palette.primary.contrastText,
path: "/calculator",
},
{
id: "settings",
name: t("APPS_SETTINGS"),
icon: <SettingsIcon />,
backgroundColor: grey[700],
color: grey[50],
path: '/settings'
},
{
id: 'bank',
name: t('APPS_BANK'),
icon: <AccountBalanceIcon />,
backgroundColor: orange[600],
color: orange[50],
path: '/bank'
},
]);
// eslint-disable-next-line
}, []);
const allApps = [...apps.preinstalled];
const getApp = (id) => allApps.find((a) => a.id === id) || {};
return { apps, allApps, setApps, getApp };
};
+6 -8
View File
@@ -5,9 +5,10 @@ import { AppWrapper } from "../../../ui/components";
import { AppContent } from "../../../ui/components/AppContent"; import { AppContent } from "../../../ui/components/AppContent";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { Button } from "@material-ui/core"; import { Button } from "@material-ui/core";
import { useBank } from '../hooks/useBank'; import { useBank } from "../hooks/useBank";
import { TransactionList } from './transactionList'; import { TransactionList } from "./TransactionList";
import "./BankApp.css"; import "./BankApp.css";
import { useApp } from "../../../os/apps/hooks/useApps";
const useStyles = makeStyles((theme) => ({ const useStyles = makeStyles((theme) => ({
root: { root: {
@@ -33,11 +34,10 @@ export const BankApp = () => {
const { transactionList } = useBank(); const { transactionList } = useBank();
const { t } = useTranslation(); const { t } = useTranslation();
const classes = useStyles(); const classes = useStyles();
const bank = useApp("BANK");
return ( return (
<AppWrapper> <AppWrapper>
<AppTitle className={classes.root}> <AppTitle {...bank} className={classes.root} />
<h1 className={classes.header}>WhoDis Banking</h1>
</AppTitle>
<AppContent> <AppContent>
<div className={classes.bankOptions}> <div className={classes.bankOptions}>
<Button className={classes.bankOptionsButton}> <Button className={classes.bankOptionsButton}>
@@ -50,9 +50,7 @@ export const BankApp = () => {
{t("APPS_BANK_TRANSFER")} {t("APPS_BANK_TRANSFER")}
</Button> </Button>
</div> </div>
<TransactionList <TransactionList transactions={transactionList} />
transactions={transactionList}
/>
</AppContent> </AppContent>
</AppWrapper> </AppWrapper>
); );
@@ -1,19 +1,19 @@
import React from 'react'; import React from "react";
import { List } from '../../../ui/components/List'; import { List } from "../../../ui/components/List";
import { ListItem } from '../../../ui/components/ListItem'; import { ListItem } from "../../../ui/components/ListItem";
import ListItemText from "@material-ui/core/ListItemText"; import ListItemText from "@material-ui/core/ListItemText";
export const TransactionList = ({ transactions }) => { export const TransactionList = ({ transactions }) => {
return ( return (
<List> <List>
{transactions.map((transaction) => ( {transactions.map((transaction) => (
<ListItem key={transaction.id} divider> <ListItem key={transaction.id} divider>
<ListItemText <ListItemText
primary={transaction.amount} primary={transaction.amount}
secondary={transaction.type} secondary={transaction.type}
/> />
</ListItem> </ListItem>
))} ))}
</List> </List>
) );
} };
@@ -2,18 +2,14 @@ import React 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";
import { useTranslation } from "react-i18next";
import { useApps } from "../../appmarket/hooks/useApps";
import { Calculator } from "./Calculator"; import { Calculator } from "./Calculator";
import { useApp } from "../../../os/apps/hooks/useApps";
export const CalculatorApp = () => { export const CalculatorApp = () => {
const { t } = useTranslation(); const calculator = useApp("CALCULATOR");
const { getApp } = useApps();
return ( return (
<AppWrapper> <AppWrapper>
<AppTitle color={getApp("calculator").backgroundColor}> <AppTitle {...calculator} />
{t("APPS_CALCULATOR")}
</AppTitle>
<AppContent> <AppContent>
<Calculator /> <Calculator />
</AppContent> </AppContent>
@@ -2,24 +2,20 @@ import React 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";
import { useTranslation } from "react-i18next";
import { useContacts } from "../hooks/useContacts"; import { useContacts } from "../hooks/useContacts";
import { ContactList } from "./ContactList"; import { ContactList } from "./ContactList";
import { useApps } from "../../appmarket/hooks/useApps"; import { useApp } from "../../../os/apps/hooks/useApps";
export const ContactsApp = () => { export const ContactsApp = () => {
const { contactList } = useContacts(); const { contactList } = useContacts();
const { getApp } = useApps(); const contacts = useApp("CONTACTS");
const { t } = useTranslation();
return ( return (
<AppWrapper> <AppWrapper>
<AppTitle color={getApp("contacts").backgroundColor}> <AppTitle {...contacts} />
{t("APPS_CONTACTS")}
</AppTitle>
<AppContent> <AppContent>
<ContactList <ContactList
contacts={contactList} contacts={contactList}
onCall={(contact => console.log(contact))} onCall={(contact) => console.log(contact)}
onMessage={() => console.log("Opening messages")} onMessage={() => console.log("Opening messages")}
/> />
</AppContent> </AppContent>
@@ -0,0 +1,20 @@
import React from "react";
import { AppWrapper } from "../../../ui/components";
import { AppTitle } from "../../../ui/components/AppTitle";
import { AppContent } from "../../../ui/components/AppContent";
import { DialerHistory } from "./DialerHistory";
import { useDialerHistory } from "../hooks/useDialerHistory";
import { useApp } from "../../../os/apps/hooks/useApps";
export const DialerApp = () => {
const { history } = useDialerHistory();
const dialer = useApp("DIALER");
return (
<AppWrapper>
<AppTitle {...dialer} />
<AppContent>
<DialerHistory calls={history} />
</AppContent>
</AppWrapper>
);
};
@@ -10,7 +10,7 @@ const CallTypeIcon = {
outgoing: <PhoneForwardedIcon />, outgoing: <PhoneForwardedIcon />,
}; };
export const PhoneList = ({ calls }) => { export const DialerHistory = ({ calls }) => {
return ( return (
<List> <List>
{calls.map((call) => ( {calls.map((call) => (
@@ -0,0 +1,24 @@
import { useRecoilState, atom } from "recoil";
const dialerHistoryState = atom({
key: "dialerHistory",
default: [
{
id: 0,
caller: "Kidz",
phoneNumber: "000-1111",
type: "incoming",
},
{
id: 1,
caller: "ROCKY",
phoneNumber: "000-1112",
type: "outgoing",
},
],
});
export const useDialerHistory = () => {
const [history, setHistory] = useRecoilState(dialerHistoryState);
return { history, setHistory };
};
+4 -2
View File
@@ -1,14 +1,16 @@
import React from "react"; import React from "react";
import { AppWrapper } from "../../../ui/components"; import { AppWrapper } from "../../../ui/components";
import { Box } from "@material-ui/core"; import { Box } from "@material-ui/core";
import { useApps } from "../../appmarket/hooks/useApps";
import { GridMenu } from "../../../ui/components/GridMenu"; import { GridMenu } from "../../../ui/components/GridMenu";
import { useApps } from "../../../os/apps/hooks/useApps";
export const HomeApp = () => { export const HomeApp = () => {
const { apps } = useApps(); const { apps } = useApps();
return ( return (
<AppWrapper> <AppWrapper>
<Box width="100%" mt={6} px={1}>{apps && <GridMenu items={apps.preinstalled} />}</Box> <Box width="100%" mt={6} px={1}>
{apps && <GridMenu items={apps.preinstalled} />}
</Box>
</AppWrapper> </AppWrapper>
); );
}; };
@@ -1,26 +0,0 @@
import React from 'react'
import { AppWrapper } from "../../../ui/components";
import { AppTitle } from "../../../ui/components/AppTitle";
import { AppContent } from "../../../ui/components/AppContent";
import { useTranslation } from "react-i18next";
import { useApps } from "../../appmarket/hooks/useApps";
import { PhoneList } from './PhoneList';
import { useCalls } from '../hooks/useCalls';
export const PhoneApp = () => {
const { callList } = useCalls();
const { getApp } = useApps();
const { t } = useTranslation();
return (
<AppWrapper>
<AppTitle color={getApp("phone").backgroundColor}>
{t("APPS_PHONE")}
</AppTitle>
<AppContent>
<PhoneList
calls={callList}
/>
</AppContent>
</AppWrapper>
)
}
-25
View File
@@ -1,25 +0,0 @@
import { useRecoilState, atom } from 'recoil';
const callListState = atom({
key: 'callList',
default: [
{
id: 0,
caller: 'Kidz',
phoneNumber: "000-1111",
type: 'incoming'
},
{
id: 1,
caller: 'ROCKY',
phoneNumber: '000-1112',
type: 'outgoing'
},
],
});
export const useCalls = () => {
const [callList, setCallList] = useRecoilState
(callListState);
return { callList, setCallList };
}
@@ -0,0 +1,13 @@
import React from "react";
import { ListItem, ListItemText, Divider } from "@material-ui/core";
export const SettingItem = ({ options, label, value, onClick }) => {
return (
<>
<ListItem onClick={() => onClick(options)} button>
<ListItemText primary={label} secondary={value} />
</ListItem>
<Divider />
</>
);
};
@@ -1,37 +1,23 @@
import React from "react"; import React from "react";
import { AppWrapper } from "../../../ui/components"; import { AppWrapper } from "../../../ui/components";
import { ListItemText, Divider } from "@material-ui/core";
import { AppTitle } from "../../../ui/components/AppTitle"; import { AppTitle } from "../../../ui/components/AppTitle";
import { AppContent } from "../../../ui/components/AppContent"; import { AppContent } from "../../../ui/components/AppContent";
import { useTranslation } from "react-i18next";
import { import {
useContextMenu, useContextMenu,
MapStringOptions, MapStringOptions,
} from "../../../ui/hooks/useContextMenu"; } from "../../../ui/hooks/useContextMenu";
import { useConfig } from "../../../config/hooks/useConfig"; import { useConfig } from "../../../config/hooks/useConfig";
import { useSettings } from "../hooks/useSettings"; import { useSettings } from "../hooks/useSettings";
import { useApps } from "../../appmarket/hooks/useApps";
import { List } from "../../../ui/components/List"; import { List } from "../../../ui/components/List";
import { ListItem } from "../../../ui/components/ListItem";
import { useSimcard } from "../../../os/simcard/hooks/useSimcard"; import { useSimcard } from "../../../os/simcard/hooks/useSimcard";
import { useApp } from "../../../os/apps/hooks/useApps";
export const SettingItem = ({ options, label, value, onClick }) => { import { SettingItem } from "./SettingItem";
return (
<>
<ListItem onClick={() => onClick(options)} button>
<ListItemText primary={label} secondary={value} />
</ListItem>
<Divider />
</>
);
};
export const SettingsApp = () => { export const SettingsApp = () => {
const { t } = useTranslation(); const settingsApp = useApp("SETTINGS");
const [config] = useConfig(); const [config] = useConfig();
const { getApp } = useApps();
const { setSettings, settings } = useSettings(); const { setSettings, settings } = useSettings();
const simcard = useSimcard(); const simcard = useSimcard();
const wallpapers = config.wallpapers.map( const wallpapers = config.wallpapers.map(
MapStringOptions(settings.wallpaper, (val) => setSettings("wallpaper", val)) MapStringOptions(settings.wallpaper, (val) => setSettings("wallpaper", val))
@@ -46,9 +32,7 @@ export const SettingsApp = () => {
const [openMenu, closeMenu, ContextMenu, isMenuOpen] = useContextMenu(); const [openMenu, closeMenu, ContextMenu, isMenuOpen] = useContextMenu();
return ( return (
<AppWrapper> <AppWrapper>
<AppTitle color={getApp("settings").backgroundColor}> <AppTitle {...settingsApp} />
{t("APPS_SETTINGS")}
</AppTitle>
<AppContent backdrop={isMenuOpen} onClickBackdrop={closeMenu}> <AppContent backdrop={isMenuOpen} onClickBackdrop={closeMenu}>
<List> <List>
<SettingItem <SettingItem
@@ -69,10 +53,7 @@ export const SettingsApp = () => {
options={frames} options={frames}
onClick={openMenu} onClick={openMenu}
/> />
<SettingItem <SettingItem label="Phone Number" value={simcard.number} />
label="Phone Number"
value={simcard.number}
/>
</List> </List>
</AppContent> </AppContent>
<ContextMenu /> <ContextMenu />
+15 -15
View File
@@ -1,16 +1,16 @@
{ {
"translation": { "translation": {
"COMING_SOON": "Coming soon...", "COMING_SOON": "Coming soon...",
"APPS_PHONE": "Phone", "APPS_DIALER": "Phone",
"APPS_CONTACTS": "Contacts", "APPS_CONTACTS": "Contacts",
"APPS_MESSAGES": "Messages", "APPS_MESSAGES": "Messages",
"APPS_CALCULATOR": "Calculator", "APPS_CALCULATOR": "Calculator",
"APPS_SETTINGS": "Settings", "APPS_SETTINGS": "Settings",
"APPS_BANK": "WhoDis Banking", "APPS_BANK": "WhoDis Banking",
"APPS_BANK_DEPOSIT": "Deposit", "APPS_BANK_DEPOSIT": "Deposit",
"APPS_BANK_WITHDRAW": "Withdraw", "APPS_BANK_WITHDRAW": "Withdraw",
"APPS_BANK_TRANSFER": "Transfer", "APPS_BANK_TRANSFER": "Transfer",
"APPS_SETTINGS_OPTIONS_WALLPAPER": "Wallpaper", "APPS_SETTINGS_OPTIONS_WALLPAPER": "Wallpaper",
"APPS_SETTINGS_OPTIONS_FRAME": "Frame" "APPS_SETTINGS_OPTIONS_FRAME": "Frame"
} }
} }
+71
View File
@@ -0,0 +1,71 @@
import React from "react";
import { useConfig } from "../../../config/hooks/useConfig";
import { blue, grey, green, orange, purple } from "@material-ui/core/colors";
import ContactsIcon from "@material-ui/icons/Contacts";
import SettingsIcon from "@material-ui/icons/Settings";
import PhoneIcon from "@material-ui/icons/Phone";
import AccountBalanceIcon from "@material-ui/icons/AccountBalance";
import { atom } from "recoil";
import { CalculatorIcon } from "../../../apps/calculator/components/CalculatorIcon";
const appsState = atom({
key: "apps",
default: {
preinstalled: [
{
id: "DIALER",
nameLocale: "APPS_DIALER",
icon: <PhoneIcon />,
backgroundColor: green[400],
color: green[50],
path: "/phone",
},
{
id: "CONTACTS",
nameLocale: "APPS_CONTACTS",
icon: <ContactsIcon />,
backgroundColor: blue[500],
color: blue[50],
path: "/contacts",
},
{
id: "CALCULATOR",
nameLocale: "APPS_CALCULATOR",
icon: <CalculatorIcon />,
backgroundColor: purple[500],
color: grey[50],
path: "/calculator",
},
{
id: "SETTINGS",
nameLocale: "APPS_SETTINGS",
icon: <SettingsIcon />,
backgroundColor: grey[700],
color: grey[50],
path: "/settings",
},
{
id: "BANK",
nameLocale: "APPS_BANK",
icon: <AccountBalanceIcon />,
backgroundColor: orange[600],
color: orange[50],
path: "/bank",
},
],
},
});
export const useApps = () => {
const [apps, setApps] = useConfig(appsState);
const allApps = [...apps.preinstalled];
const getApp = (id) => allApps.find((a) => a.id === id) || null;
return { apps, allApps, setApps, getApp };
};
export const useApp = (id) => {
const { getApp } = useApps();
return getApp(id);
};
+7 -7
View File
@@ -6,16 +6,16 @@ export const useNuiEvent = (app, method, handler, options = {}) => {
const { capture, passive, once } = options; const { capture, passive, once } = options;
useEffect(() => { useEffect(() => {
savedHandler.current = event => { savedHandler.current = handler;
const { data } = event;
if (handler && handler.call) {
handler(data);
}
};
}, [handler]); }, [handler]);
useEffect(() => { useEffect(() => {
const eventListener = (event) => savedHandler.current(event); const eventListener = (event) => {
const { data } = event;
if (savedHandler.current && savedHandler.current.call) {
savedHandler.current(data);
}
};
const opts = { capture, passive, once }; const opts = { capture, passive, once };
const eventName = eventNameFactory(app, method); const eventName = eventNameFactory(app, method);
window.addEventListener(eventName, eventListener, opts); window.addEventListener(eventName, eventListener, opts);
@@ -4,9 +4,8 @@ import { eventNameFactory } from "../utils/nuiUtils";
export const useNuiService = (options = {}) => { export const useNuiService = (options = {}) => {
const { capture, passive, once } = options; const { capture, passive, once } = options;
const eventListener = (event) => { const eventListener = (event) => {
console.log(event);
const { app, method, data } = event.data; const { app, method, data } = event.data;
if (app && method && data) { if (app && method && data !== undefined) {
window.dispatchEvent( window.dispatchEvent(
new MessageEvent(eventNameFactory(app, method), { new MessageEvent(eventNameFactory(app, method), {
data, data,
+12
View File
@@ -0,0 +1,12 @@
import { atom } from "recoil";
export const phoneState = {
visibility: atom({
key: "phoneVisibility",
default: false,
}),
powerOff: atom({
key: "phonePowerOff",
default: true,
}),
};
+8
View File
@@ -0,0 +1,8 @@
import { useRecoilValue } from "recoil";
import { phoneState } from "./state";
export const usePhone = () => {
const visibility = useRecoilValue(phoneState.visibility);
const powerOff = useRecoilValue(phoneState.powerOff);
return { visibility, powerOff };
};
@@ -0,0 +1,13 @@
import { useSetRecoilState } from "recoil";
import { phoneState } from "./state";
import { useNuiEvent } from "../../nui-events/hooks/useNuiEvent";
import { usePhone } from "./usePhone";
export const usePhoneService = () => {
const setVisibility = useSetRecoilState(phoneState.visibility);
const setPowerOff = useSetRecoilState(phoneState.powerOff);
useNuiEvent("PHONE", "setPowerOff", setPowerOff);
useNuiEvent("PHONE", "setVisibility", setVisibility);
const { visibility, powerOff } = usePhone();
return { visibility, powerOff };
};
@@ -1,10 +1,10 @@
import { useNuiEvent } from "../../nui-events/hooks/useNuiEvent"; import { useNuiEvent } from "../../nui-events/hooks/useNuiEvent";
import { useSetRecoilState } from "recoil"; import { useSetRecoilState } from "recoil";
import { simcardState } from "./state"; import { simcardState } from "./state";
import { useSimcard } from "./useSimcard";
export const useSimcardService = () => { export const useSimcardService = () => {
const setNumber = useSetRecoilState(simcardState.number); const setNumber = useSetRecoilState(simcardState.number);
useNuiEvent("SIMCARD", "setNumber", (data) => { useNuiEvent("SIMCARD", "setNumber", setNumber);
setNumber(data); return useSimcard();
});
}; };
+21 -11
View File
@@ -1,22 +1,32 @@
import React from "react"; import React from "react";
import { Typography, Box, makeStyles } from "@material-ui/core"; import { Typography, Box, makeStyles } from "@material-ui/core";
import { useTranslation } from "react-i18next";
const useStyle = makeStyles(theme => ({ const useStyle = makeStyles((theme) => ({
root: ({ color }) => ({ root: ({ backgroundColor }) => ({
width: '100%', width: "100%",
textAlign: 'center', textAlign: "center",
backgroundColor: color || theme.palette.background.default backgroundColor: backgroundColor || theme.palette.background.default,
}),
text: ({ color }) => ({
color: color || theme.palette.text.primary,
}), }),
text: {
color: theme.palette.text.primary
}
})); }));
export const AppTitle = ({ children, color, ...props }) => { export const AppTitle = ({
const classes = useStyle({ color }); backgroundColor,
color,
nameLocale,
variant = "h4",
...props
}) => {
const classes = useStyle({ color, backgroundColor });
const { t } = useTranslation();
return ( return (
<Box px={2} pt={4} className={classes.root} {...props}> <Box px={2} pt={4} className={classes.root} {...props}>
<Typography className={classes.text} paragraph variant="h4">{children}</Typography> <Typography className={classes.text} paragraph variant={variant}>
{t(nameLocale)}
</Typography>
</Box> </Box>
); );
}; };
+1 -1
View File
@@ -32,9 +32,9 @@ export const GridMenu = ({ items, Component = AppIcon }) => {
items.length && items.length &&
items.map((item) => ( items.map((item) => (
<Grid <Grid
key={item.id}
item item
className={classes.item} className={classes.item}
key={item.name}
tabIndex="-1" tabIndex="-1"
component={Link} component={Link}
to={item.path} to={item.path}