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