mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
Improve code
This commit is contained in:
1 parent
b2e0cba844
commit
c65108b360
9 files changed
+45
-51
No files matched your search
+20
-25
@@ -6,12 +6,7 @@ import { useSettings } from "./apps/settings/hooks/useSettings";
|
|||||||
import MessageIcon from "@material-ui/icons/Email";
|
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 { SettingsApp } from "./apps/settings/components/SettingsApp";
|
|
||||||
import { DialerApp } from "./apps/dialer/components/DialerApp";
|
|
||||||
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 { useInitKeyboard } from "./os/keyboard/hooks/useKeyboard";
|
import { useInitKeyboard } from "./os/keyboard/hooks/useKeyboard";
|
||||||
import { NotificationIcon } from "./os/notifications/components/NotificationIcon";
|
import { NotificationIcon } from "./os/notifications/components/NotificationIcon";
|
||||||
import { NotificationBar } from "./os/notifications/components/NotificationBar";
|
import { NotificationBar } from "./os/notifications/components/NotificationBar";
|
||||||
@@ -19,6 +14,7 @@ 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";
|
import { usePhoneService } from "./os/phone/hooks/usePhoneService";
|
||||||
|
import { useApps } from "./os/apps/hooks/useApps";
|
||||||
|
|
||||||
// @TODO: Remove this testing shit
|
// @TODO: Remove this testing shit
|
||||||
// Used for testing NUI events while we work on clientside
|
// Used for testing NUI events while we work on clientside
|
||||||
@@ -32,19 +28,7 @@ setTimeout(() => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}, 3000);
|
}, 1000);
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
window.dispatchEvent(
|
|
||||||
new MessageEvent("message", {
|
|
||||||
data: {
|
|
||||||
app: "PHONE",
|
|
||||||
method: "setPowerOff",
|
|
||||||
data: false,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}, 4000);
|
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.dispatchEvent(
|
window.dispatchEvent(
|
||||||
@@ -56,14 +40,27 @@ setTimeout(() => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}, 3000);
|
}, 1000);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
window.dispatchEvent(
|
||||||
|
new MessageEvent("message", {
|
||||||
|
data: {
|
||||||
|
app: "PHONE",
|
||||||
|
method: "setPowerOff",
|
||||||
|
data: false,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}, 2300);
|
||||||
|
|
||||||
function Phone() {
|
function Phone() {
|
||||||
useNuiService();
|
useNuiService();
|
||||||
const { visibility, powerOff } = usePhoneService();
|
const { visibility, powerOff } = usePhoneService();
|
||||||
|
const { settings, currentTheme } = useSettings();
|
||||||
|
const { allApps } = useApps();
|
||||||
useSimcardService();
|
useSimcardService();
|
||||||
useInitKeyboard();
|
useInitKeyboard();
|
||||||
const { settings, currentTheme } = useSettings();
|
|
||||||
|
|
||||||
if (visibility === false) {
|
if (visibility === false) {
|
||||||
return null;
|
return null;
|
||||||
@@ -101,11 +98,9 @@ function Phone() {
|
|||||||
/>
|
/>
|
||||||
<div className="PhoneAppContainer">
|
<div className="PhoneAppContainer">
|
||||||
<Route exact path="/" component={HomeApp} />
|
<Route exact path="/" component={HomeApp} />
|
||||||
<Route exact path="/contacts" component={ContactsApp} />
|
{allApps.map((App) => (
|
||||||
<Route exact path="/settings" component={SettingsApp} />
|
<App.Route key={App.id} />
|
||||||
<Route exact path="/phone" component={DialerApp} />
|
))}
|
||||||
<Route exact path="/bank" component={BankApp} />
|
|
||||||
<Route exact path="/calculator" component={CalculatorApp} />
|
|
||||||
</div>
|
</div>
|
||||||
<Navigation />
|
<Navigation />
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import { makeStyles } from "@material-ui/core";
|
|||||||
import { AppTitle } from "../../../ui/components/AppTitle";
|
import { AppTitle } from "../../../ui/components/AppTitle";
|
||||||
import { AppWrapper } from "../../../ui/components";
|
import { AppWrapper } from "../../../ui/components";
|
||||||
import { AppContent } from "../../../ui/components/AppContent";
|
import { AppContent } from "../../../ui/components/AppContent";
|
||||||
|
import { Button } from "../../../ui/components/Button";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
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";
|
||||||
@@ -23,11 +23,6 @@ const useStyles = makeStyles((theme) => ({
|
|||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
fontSize: 50,
|
fontSize: 50,
|
||||||
},
|
},
|
||||||
bankOptions: {},
|
|
||||||
bankOptionsButton: {
|
|
||||||
display: "block",
|
|
||||||
textAlign: "center",
|
|
||||||
},
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const BankApp = () => {
|
export const BankApp = () => {
|
||||||
@@ -37,18 +32,12 @@ export const BankApp = () => {
|
|||||||
const bank = useApp("BANK");
|
const bank = useApp("BANK");
|
||||||
return (
|
return (
|
||||||
<AppWrapper>
|
<AppWrapper>
|
||||||
<AppTitle {...bank} className={classes.root} />
|
<AppTitle app={bank} className={classes.root} />
|
||||||
<AppContent>
|
<AppContent>
|
||||||
<div className={classes.bankOptions}>
|
<div>
|
||||||
<Button className={classes.bankOptionsButton}>
|
<Button fullWidth>{t("APPS_BANK_DEPOSIT")}</Button>
|
||||||
{t("APPS_BANK_DEPOSIT")}
|
<Button fullWidth>{t("APPS_BANK_WITHDRAW")}</Button>
|
||||||
</Button>
|
<Button fullWidth>{t("APPS_BANK_TRANSFER")}</Button>
|
||||||
<Button className={classes.bankOptionsButton}>
|
|
||||||
{t("APPS_BANK_WITHDRAW")}
|
|
||||||
</Button>
|
|
||||||
<Button className={classes.bankOptionsButton}>
|
|
||||||
{t("APPS_BANK_TRANSFER")}
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
<TransactionList transactions={transactionList} />
|
<TransactionList transactions={transactionList} />
|
||||||
</AppContent>
|
</AppContent>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export const CalculatorApp = () => {
|
|||||||
const calculator = useApp("CALCULATOR");
|
const calculator = useApp("CALCULATOR");
|
||||||
return (
|
return (
|
||||||
<AppWrapper>
|
<AppWrapper>
|
||||||
<AppTitle {...calculator} />
|
<AppTitle app={calculator} />
|
||||||
<AppContent>
|
<AppContent>
|
||||||
<Calculator />
|
<Calculator />
|
||||||
</AppContent>
|
</AppContent>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export const ContactsApp = () => {
|
|||||||
const contacts = useApp("CONTACTS");
|
const contacts = useApp("CONTACTS");
|
||||||
return (
|
return (
|
||||||
<AppWrapper>
|
<AppWrapper>
|
||||||
<AppTitle {...contacts} />
|
<AppTitle app={contacts} />
|
||||||
<AppContent>
|
<AppContent>
|
||||||
<ContactList
|
<ContactList
|
||||||
contacts={contactList}
|
contacts={contactList}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export const DialerApp = () => {
|
|||||||
const dialer = useApp("DIALER");
|
const dialer = useApp("DIALER");
|
||||||
return (
|
return (
|
||||||
<AppWrapper>
|
<AppWrapper>
|
||||||
<AppTitle {...dialer} />
|
<AppTitle app={dialer} />
|
||||||
<AppContent>
|
<AppContent>
|
||||||
<DialerHistory calls={history} />
|
<DialerHistory calls={history} />
|
||||||
</AppContent>
|
</AppContent>
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export const SettingsApp = () => {
|
|||||||
const [openMenu, closeMenu, ContextMenu, isMenuOpen] = useContextMenu();
|
const [openMenu, closeMenu, ContextMenu, isMenuOpen] = useContextMenu();
|
||||||
return (
|
return (
|
||||||
<AppWrapper>
|
<AppWrapper>
|
||||||
<AppTitle {...settingsApp} />
|
<AppTitle app={settingsApp} />
|
||||||
<AppContent backdrop={isMenuOpen} onClickBackdrop={closeMenu}>
|
<AppContent backdrop={isMenuOpen} onClickBackdrop={closeMenu}>
|
||||||
<List>
|
<List>
|
||||||
<SettingItem
|
<SettingItem
|
||||||
|
|||||||
@@ -7,6 +7,12 @@ import PhoneIcon from "@material-ui/icons/Phone";
|
|||||||
import AccountBalanceIcon from "@material-ui/icons/AccountBalance";
|
import AccountBalanceIcon from "@material-ui/icons/AccountBalance";
|
||||||
import { atom } from "recoil";
|
import { atom } from "recoil";
|
||||||
import { CalculatorIcon } from "../../../apps/calculator/components/CalculatorIcon";
|
import { CalculatorIcon } from "../../../apps/calculator/components/CalculatorIcon";
|
||||||
|
import { Route } from "react-router-dom";
|
||||||
|
import { DialerApp } from "../../../apps/dialer/components/DialerApp";
|
||||||
|
import { ContactsApp } from "../../../apps/contacts/components/ContactsApp";
|
||||||
|
import { CalculatorApp } from "../../../apps/calculator/components/CalculatorApp";
|
||||||
|
import { SettingsApp } from "../../../apps/settings/components/SettingsApp";
|
||||||
|
import { BankApp } from "../../../apps/bank/components/BankApp";
|
||||||
|
|
||||||
const appsState = atom({
|
const appsState = atom({
|
||||||
key: "apps",
|
key: "apps",
|
||||||
@@ -19,6 +25,7 @@ const appsState = atom({
|
|||||||
backgroundColor: green[400],
|
backgroundColor: green[400],
|
||||||
color: green[50],
|
color: green[50],
|
||||||
path: "/phone",
|
path: "/phone",
|
||||||
|
Route: () => <Route exact path="/phone" component={DialerApp} />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "CONTACTS",
|
id: "CONTACTS",
|
||||||
@@ -27,6 +34,7 @@ const appsState = atom({
|
|||||||
backgroundColor: blue[500],
|
backgroundColor: blue[500],
|
||||||
color: blue[50],
|
color: blue[50],
|
||||||
path: "/contacts",
|
path: "/contacts",
|
||||||
|
Route: () => <Route exact path="/contacts" component={ContactsApp} />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "CALCULATOR",
|
id: "CALCULATOR",
|
||||||
@@ -35,6 +43,9 @@ const appsState = atom({
|
|||||||
backgroundColor: purple[500],
|
backgroundColor: purple[500],
|
||||||
color: grey[50],
|
color: grey[50],
|
||||||
path: "/calculator",
|
path: "/calculator",
|
||||||
|
Route: () => (
|
||||||
|
<Route exact path="/calculator" component={CalculatorApp} />
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "SETTINGS",
|
id: "SETTINGS",
|
||||||
@@ -43,6 +54,7 @@ const appsState = atom({
|
|||||||
backgroundColor: grey[700],
|
backgroundColor: grey[700],
|
||||||
color: grey[50],
|
color: grey[50],
|
||||||
path: "/settings",
|
path: "/settings",
|
||||||
|
Route: () => <Route exact path="/settings" component={SettingsApp} />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "BANK",
|
id: "BANK",
|
||||||
@@ -51,6 +63,7 @@ const appsState = atom({
|
|||||||
backgroundColor: orange[600],
|
backgroundColor: orange[600],
|
||||||
color: orange[50],
|
color: orange[50],
|
||||||
path: "/bank",
|
path: "/bank",
|
||||||
|
Route: () => <Route exact path="/bank" component={BankApp} />,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -8,6 +8,5 @@ export const usePhoneService = () => {
|
|||||||
const setPowerOff = useSetRecoilState(phoneState.powerOff);
|
const setPowerOff = useSetRecoilState(phoneState.powerOff);
|
||||||
useNuiEvent("PHONE", "setPowerOff", setPowerOff);
|
useNuiEvent("PHONE", "setPowerOff", setPowerOff);
|
||||||
useNuiEvent("PHONE", "setVisibility", setVisibility);
|
useNuiEvent("PHONE", "setVisibility", setVisibility);
|
||||||
const { visibility, powerOff } = usePhone();
|
return usePhone();
|
||||||
return { visibility, powerOff };
|
|
||||||
};
|
};
|
||||||
@@ -14,9 +14,7 @@ const useStyle = makeStyles((theme) => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
export const AppTitle = ({
|
export const AppTitle = ({
|
||||||
backgroundColor,
|
app: { backgroundColor, color, nameLocale },
|
||||||
color,
|
|
||||||
nameLocale,
|
|
||||||
variant = "h4",
|
variant = "h4",
|
||||||
...props
|
...props
|
||||||
}) => {
|
}) => {
|
||||||
|
|||||||
Reference in new issue
Block a user