mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
Feat(useApps): Merge fix
This commit is contained in:
commit
5dd9be3fa0
20 files changed
+537
-76
No files matched your search
+15
-1
@@ -11,12 +11,20 @@ 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";
|
||||||
|
<<<<<<< HEAD
|
||||||
import { PhoneApp } from './apps/phone/components/PhoneApp';
|
import { PhoneApp } from './apps/phone/components/PhoneApp';
|
||||||
import { BankApp } from './apps/bank/component/BankApp';
|
import { BankApp } from './apps/bank/component/BankApp';
|
||||||
|
=======
|
||||||
|
import { PhoneApp } from "./apps/phone/components/PhoneApp";
|
||||||
|
>>>>>>> 6ce38f2746e21d5096169f5d1f0f2a40c0cd9a9d
|
||||||
import { ThemeProvider } from "@material-ui/core";
|
import { ThemeProvider } from "@material-ui/core";
|
||||||
|
import { CalculatorApp } from "./apps/calculator/components/CalculatorApp";
|
||||||
|
import { useInitKeyboard } from "./os/hooks/useKeyboard";
|
||||||
|
|
||||||
function Phone() {
|
function Phone() {
|
||||||
|
useInitKeyboard();
|
||||||
const { settings, currentTheme } = useSettings();
|
const { settings, currentTheme } = useSettings();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ThemeProvider theme={currentTheme()}>
|
<ThemeProvider theme={currentTheme()}>
|
||||||
<div className="PhoneWrapper">
|
<div className="PhoneWrapper">
|
||||||
@@ -36,14 +44,20 @@ function Phone() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<NotificationBar
|
<NotificationBar
|
||||||
notifications={[{ icon: <NotificationIcon Icon={MessageIcon} /> }, { icon: <NotificationIcon Icon={MessageIcon} /> }]}
|
notifications={[
|
||||||
|
{ key: 'newMessage', icon: <NotificationIcon Icon={MessageIcon} /> },
|
||||||
|
]}
|
||||||
/>
|
/>
|
||||||
<div className="PhoneAppContainer">
|
<div className="PhoneAppContainer">
|
||||||
<Route exact path="/" component={HomeApp} />
|
<Route exact path="/" component={HomeApp} />
|
||||||
<Route exact path="/contacts" component={ContactsApp} />
|
<Route exact path="/contacts" component={ContactsApp} />
|
||||||
<Route exact path="/settings" component={SettingsApp} />
|
<Route exact path="/settings" component={SettingsApp} />
|
||||||
<Route exact path="/phone" component={PhoneApp} />
|
<Route exact path="/phone" component={PhoneApp} />
|
||||||
|
<<<<<<< HEAD
|
||||||
<Route exact path="/bank" component={BankApp} />
|
<Route exact path="/bank" component={BankApp} />
|
||||||
|
=======
|
||||||
|
<Route exact path="/calculator" component={CalculatorApp} />
|
||||||
|
>>>>>>> 6ce38f2746e21d5096169f5d1f0f2a40c0cd9a9d
|
||||||
</div>
|
</div>
|
||||||
<Navigation />
|
<Navigation />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,40 +3,56 @@ import { useConfig } from "../../../config/hooks/useConfig";
|
|||||||
import { blue, grey, green, orange } from "@material-ui/core/colors";
|
import { blue, grey, green, orange } from "@material-ui/core/colors";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import ContactsIcon from "@material-ui/icons/Contacts";
|
import ContactsIcon from "@material-ui/icons/Contacts";
|
||||||
|
<<<<<<< HEAD
|
||||||
import SettingsIcon from '@material-ui/icons/Settings'
|
import SettingsIcon from '@material-ui/icons/Settings'
|
||||||
import PhoneIcon from '@material-ui/icons/Phone';
|
import PhoneIcon from '@material-ui/icons/Phone';
|
||||||
import AccountBalanceIcon from '@material-ui/icons/AccountBalance';
|
import AccountBalanceIcon from '@material-ui/icons/AccountBalance';
|
||||||
|
=======
|
||||||
|
import SettingsIcon from "@material-ui/icons/Settings";
|
||||||
|
import PhoneIcon from "@material-ui/icons/Phone";
|
||||||
|
>>>>>>> 6ce38f2746e21d5096169f5d1f0f2a40c0cd9a9d
|
||||||
import { atom } from "recoil";
|
import { atom } from "recoil";
|
||||||
|
import { useSettings } from "../../settings/hooks/useSettings";
|
||||||
|
import { CalculatorIcon } from "../../calculator/components/CalculatorIcon";
|
||||||
|
|
||||||
const appsState = atom({
|
const appsState = atom({
|
||||||
key: 'apps',
|
key: "apps",
|
||||||
default: { preinstalled: [] }
|
default: { preinstalled: [] },
|
||||||
});
|
});
|
||||||
|
|
||||||
export const useApps = () => {
|
export const useApps = () => {
|
||||||
const [apps, setApps] = useConfig(appsState);
|
const [apps, setApps] = useConfig(appsState);
|
||||||
|
const { currentTheme } = useSettings();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setApps("preinstalled", [
|
setApps("preinstalled", [
|
||||||
{
|
{
|
||||||
id: 'phone',
|
id: "phone",
|
||||||
name: t('APPS_PHONE'),
|
name: t("APPS_PHONE"),
|
||||||
icon: <PhoneIcon />,
|
icon: <PhoneIcon />,
|
||||||
backgroundColor: green[400],
|
backgroundColor: green[400],
|
||||||
color: green[50],
|
color: green[50],
|
||||||
path: '/phone'
|
path: "/phone",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'contacts',
|
id: "contacts",
|
||||||
name: t('APPS_CONTACTS'),
|
name: t("APPS_CONTACTS"),
|
||||||
icon: <ContactsIcon />,
|
icon: <ContactsIcon />,
|
||||||
backgroundColor: blue[500],
|
backgroundColor: blue[500],
|
||||||
color: blue[50],
|
color: blue[50],
|
||||||
path: '/contacts'
|
path: "/contacts",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'settings',
|
id: "calculator",
|
||||||
name: t('APPS_SETTINGS'),
|
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 />,
|
icon: <SettingsIcon />,
|
||||||
backgroundColor: grey[700],
|
backgroundColor: grey[700],
|
||||||
color: grey[50],
|
color: grey[50],
|
||||||
@@ -49,14 +65,14 @@ export const useApps = () => {
|
|||||||
backgroundColor: orange[600],
|
backgroundColor: orange[600],
|
||||||
color: orange[50],
|
color: orange[50],
|
||||||
path: '/bank'
|
path: '/bank'
|
||||||
}
|
},
|
||||||
]);
|
]);
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const allApps = [...apps.preinstalled];
|
const allApps = [...apps.preinstalled];
|
||||||
|
|
||||||
const getApp = id => allApps.find(a => a.id === id) || {};
|
const getApp = (id) => allApps.find((a) => a.id === id) || {};
|
||||||
|
|
||||||
return { apps, allApps, setApps, getApp };
|
return { apps, allApps, setApps, getApp };
|
||||||
};
|
};
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { useCalculator, CalcButton } from "../hooks/useCalculator";
|
||||||
|
import { Grid, makeStyles, Box, Paper } from "@material-ui/core";
|
||||||
|
|
||||||
|
const useStyles = makeStyles((theme) => ({
|
||||||
|
button: {
|
||||||
|
fontSize: theme.typography.h5.fontSize,
|
||||||
|
padding: theme.spacing(2),
|
||||||
|
},
|
||||||
|
result: {
|
||||||
|
fontSize: theme.typography.h2.fontSize,
|
||||||
|
textAlign: "right",
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const Calculator = ({ ...props }) => {
|
||||||
|
const {
|
||||||
|
result,
|
||||||
|
equals,
|
||||||
|
clear,
|
||||||
|
clearAll,
|
||||||
|
divider,
|
||||||
|
multiplier,
|
||||||
|
substractor,
|
||||||
|
adder,
|
||||||
|
dot,
|
||||||
|
zero,
|
||||||
|
one,
|
||||||
|
two,
|
||||||
|
three,
|
||||||
|
four,
|
||||||
|
five,
|
||||||
|
six,
|
||||||
|
seven,
|
||||||
|
eight,
|
||||||
|
nine,
|
||||||
|
} = useCalculator();
|
||||||
|
const classes = useStyles();
|
||||||
|
return (
|
||||||
|
<Box display="flex" flexDirection="column">
|
||||||
|
<Box flexGrow={1} component={Paper} p={4} className={classes.result}>
|
||||||
|
{result()}
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Grid container justify="space-around">
|
||||||
|
<CalcButton button={clear} className={classes.button} />
|
||||||
|
<CalcButton button={clearAll} className={classes.button} />
|
||||||
|
<CalcButton button={divider} className={classes.button} />
|
||||||
|
<CalcButton button={multiplier} className={classes.button} />
|
||||||
|
<CalcButton button={seven} className={classes.button} />
|
||||||
|
<CalcButton button={eight} className={classes.button} />
|
||||||
|
<CalcButton button={nine} className={classes.button} />
|
||||||
|
<CalcButton button={substractor} className={classes.button} />
|
||||||
|
<CalcButton button={four} className={classes.button} />
|
||||||
|
<CalcButton button={five} className={classes.button} />
|
||||||
|
<CalcButton button={six} className={classes.button} />
|
||||||
|
<CalcButton button={adder} className={classes.button} />
|
||||||
|
<CalcButton button={one} className={classes.button} />
|
||||||
|
<CalcButton button={two} className={classes.button} />
|
||||||
|
<CalcButton button={three} className={classes.button} />
|
||||||
|
<CalcButton button={equals} className={classes.button} />
|
||||||
|
<CalcButton button={dot} className={classes.button} />
|
||||||
|
<CalcButton button={zero} className={classes.button} xs={9} />
|
||||||
|
</Grid>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
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 { Calculator } from "./Calculator";
|
||||||
|
|
||||||
|
export const CalculatorApp = () => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { getApp } = useApps();
|
||||||
|
return (
|
||||||
|
<AppWrapper>
|
||||||
|
<AppTitle color={getApp("calculator").backgroundColor}>
|
||||||
|
{t("APPS_CALCULATOR")}
|
||||||
|
</AppTitle>
|
||||||
|
<AppContent>
|
||||||
|
<Calculator />
|
||||||
|
</AppContent>
|
||||||
|
</AppWrapper>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { SvgIcon } from "@material-ui/core";
|
||||||
|
|
||||||
|
export const CalculatorIcon = ({ ...props }) => {
|
||||||
|
return (
|
||||||
|
<SvgIcon {...props}>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
x="0"
|
||||||
|
y="0"
|
||||||
|
enableBackground="new 0 0 56 56"
|
||||||
|
version="1.1"
|
||||||
|
viewBox="0 0 56 56"
|
||||||
|
xmlSpace="preserve"
|
||||||
|
>
|
||||||
|
<path fill="#EBBA16" d="M0 0H28V28H0z"></path>
|
||||||
|
<path fill="#ED8A19" d="M28 0H56V28H28z"></path>
|
||||||
|
<path fill="#ED8A19" d="M0 28H28V56H0z"></path>
|
||||||
|
<path fill="#556080" d="M28 28H56V56H28z"></path>
|
||||||
|
<path
|
||||||
|
fill="#FFF"
|
||||||
|
d="M48 46H36a1 1 0 110-2h12a1 1 0 110 2zM48 40H36a1 1 0 110-2h12a1 1 0 110 2zM14 43a.999.999 0 01-.707-1.707l5-5a.999.999 0 111.414 1.414l-5 5A.997.997 0 0114 43z"
|
||||||
|
></path>
|
||||||
|
<path
|
||||||
|
fill="#FFF"
|
||||||
|
d="M9 48a.999.999 0 01-.707-1.707l5-5a.999.999 0 111.414 1.414l-5 5A.997.997 0 019 48z"
|
||||||
|
></path>
|
||||||
|
<path
|
||||||
|
fill="#FFF"
|
||||||
|
d="M19 48a.997.997 0 01-.707-.293l-5-5a.999.999 0 111.414-1.414l5 5A.999.999 0 0119 48z"
|
||||||
|
></path>
|
||||||
|
<path
|
||||||
|
fill="#FFF"
|
||||||
|
d="M14 43a.997.997 0 01-.707-.293l-5-5a.999.999 0 111.414-1.414l5 5A.999.999 0 0114 43zM20 15H8a1 1 0 110-2h12a1 1 0 110 2z"
|
||||||
|
></path>
|
||||||
|
<path
|
||||||
|
fill="#FFF"
|
||||||
|
d="M14 21a1 1 0 01-1-1V8a1 1 0 112 0v12a1 1 0 01-1 1zM48 15H36a1 1 0 110-2h12a1 1 0 110 2z"
|
||||||
|
></path>
|
||||||
|
</svg>
|
||||||
|
</SvgIcon>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,168 @@
|
|||||||
|
import React, { useReducer } from "react";
|
||||||
|
import { Grid, Button } from "@material-ui/core";
|
||||||
|
|
||||||
|
const initialState = {
|
||||||
|
value: 0,
|
||||||
|
op: "",
|
||||||
|
num1: 0,
|
||||||
|
num2: "",
|
||||||
|
num3: "",
|
||||||
|
};
|
||||||
|
|
||||||
|
const Reducer = (state, action) => {
|
||||||
|
switch (action.type) {
|
||||||
|
case "2":
|
||||||
|
if (!state.num1) {
|
||||||
|
return { ...state, num1: state.num2, op: action.payload, num2: "" };
|
||||||
|
}
|
||||||
|
if (!state.num2) {
|
||||||
|
return { ...state, op: action.payload };
|
||||||
|
}
|
||||||
|
if (state.num1 && state.op) {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
value: state.op(state.value, state.num2),
|
||||||
|
op: action.payload,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
value: state.op(state.num1, state.num2),
|
||||||
|
num2: "",
|
||||||
|
op: action.payload,
|
||||||
|
num1: state.op(state.num1, state.num2),
|
||||||
|
};
|
||||||
|
|
||||||
|
case "1":
|
||||||
|
if (state.num2 === "" && action.payload === ".") {
|
||||||
|
return { ...state, num2: "0" + action.payload };
|
||||||
|
}
|
||||||
|
if (state.num2 === "") {
|
||||||
|
return { ...state, num2: action.payload };
|
||||||
|
}
|
||||||
|
if (action.payload === "." && state.num2.includes(".")) {
|
||||||
|
return state;
|
||||||
|
} else {
|
||||||
|
return { ...state, num2: state.num2 + action.payload };
|
||||||
|
}
|
||||||
|
|
||||||
|
case "3":
|
||||||
|
if (state.op && state.num2) {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
value: state.op(state.num1, state.num2),
|
||||||
|
num2: "",
|
||||||
|
num1: state.op(state.num1, state.num2),
|
||||||
|
num3: state.num2,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (state.op && state.value) {
|
||||||
|
return { ...state, value: state.op(state.value, state.num3) };
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
|
||||||
|
case "c":
|
||||||
|
if (state.num2.length === 2 && state.num2.includes("0.")) {
|
||||||
|
return { ...state, num2: "" };
|
||||||
|
}
|
||||||
|
if (state.num2.length > 1) {
|
||||||
|
return { ...state, num2: state.num2.slice(0, -1) };
|
||||||
|
}
|
||||||
|
return { ...state, num2: "" };
|
||||||
|
|
||||||
|
case "ac":
|
||||||
|
return {
|
||||||
|
value: 0,
|
||||||
|
op: "",
|
||||||
|
num1: 0,
|
||||||
|
num2: "",
|
||||||
|
num3: "",
|
||||||
|
};
|
||||||
|
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const CalcButton = ({ button, className, ...props }) => (
|
||||||
|
<Grid key={button.label} item xs={3} {...props}>
|
||||||
|
<Button fullWidth className={className} onClick={button.onClick}>
|
||||||
|
{button.label}
|
||||||
|
</Button>
|
||||||
|
</Grid>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const useCalculator = () => {
|
||||||
|
const [state, dispatch] = useReducer(Reducer, initialState);
|
||||||
|
|
||||||
|
const getPayload = (label, type) => {
|
||||||
|
if (type !== "2") {
|
||||||
|
return `${label}`;
|
||||||
|
}
|
||||||
|
switch (label) {
|
||||||
|
case "/":
|
||||||
|
return (a, b) => Number(a) / Number(b);
|
||||||
|
case "*":
|
||||||
|
return (a, b) => Number(a) * Number(b);
|
||||||
|
case "+":
|
||||||
|
return (a, b) => Number(a) + Number(b);
|
||||||
|
case "-":
|
||||||
|
return (a, b) => Number(a) - Number(b);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const buttonProps = (label, type) => ({
|
||||||
|
label,
|
||||||
|
onClick: () =>
|
||||||
|
dispatch({
|
||||||
|
type,
|
||||||
|
payload: getPayload(label, type),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
const number = (n) => buttonProps(n, "1");
|
||||||
|
const operator = (sym) => buttonProps(sym, "2");
|
||||||
|
const clear = buttonProps("C", "c");
|
||||||
|
const clearAll = buttonProps("AC", "ac");
|
||||||
|
const equals = buttonProps("=", "3");
|
||||||
|
const zero = number(0);
|
||||||
|
const dot = number(".");
|
||||||
|
const divider = operator("/");
|
||||||
|
const multiplier = operator("*");
|
||||||
|
const adder = operator("+");
|
||||||
|
const substractor = operator("-");
|
||||||
|
const one = number(1);
|
||||||
|
const two = number(2);
|
||||||
|
const three = number(3);
|
||||||
|
const four = number(4);
|
||||||
|
const five = number(5);
|
||||||
|
const six = number(6);
|
||||||
|
const seven = number(7);
|
||||||
|
const eight = number(8);
|
||||||
|
const nine = number(9);
|
||||||
|
const result = () => (!state.num2 ? state.value : state.num2);
|
||||||
|
|
||||||
|
return {
|
||||||
|
result,
|
||||||
|
equals,
|
||||||
|
clear,
|
||||||
|
clearAll,
|
||||||
|
divider,
|
||||||
|
multiplier,
|
||||||
|
substractor,
|
||||||
|
adder,
|
||||||
|
dot,
|
||||||
|
zero,
|
||||||
|
one,
|
||||||
|
two,
|
||||||
|
three,
|
||||||
|
four,
|
||||||
|
five,
|
||||||
|
six,
|
||||||
|
seven,
|
||||||
|
eight,
|
||||||
|
nine,
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import List from "@material-ui/core/List";
|
|
||||||
import ListItem from "@material-ui/core/ListItem";
|
|
||||||
import ListItemText from "@material-ui/core/ListItemText";
|
import ListItemText from "@material-ui/core/ListItemText";
|
||||||
import { Button } from "@material-ui/core";
|
import { Button } from "@material-ui/core";
|
||||||
|
|
||||||
import PhoneIcon from "@material-ui/icons/Phone";
|
import PhoneIcon from "@material-ui/icons/Phone";
|
||||||
import ChatIcon from "@material-ui/icons/Chat";
|
import ChatIcon from "@material-ui/icons/Chat";
|
||||||
|
import { List } from "../../../ui/components/List";
|
||||||
|
import { ListItem } from "../../../ui/components/ListItem";
|
||||||
|
|
||||||
export const ContactList = ({ contacts, onCall, onMessage }) => {
|
export const ContactList = ({ contacts, onCall, onMessage }) => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
import React from 'react';
|
import React from "react";
|
||||||
import List from "@material-ui/core/List";
|
|
||||||
import ListItem from "@material-ui/core/ListItem";
|
|
||||||
import ListItemText from "@material-ui/core/ListItemText";
|
import ListItemText from "@material-ui/core/ListItemText";
|
||||||
import PhoneCallbackIcon from '@material-ui/icons/PhoneCallback';
|
import PhoneCallbackIcon from "@material-ui/icons/PhoneCallback";
|
||||||
import PhoneForwardedIcon from '@material-ui/icons/PhoneForwarded';
|
import PhoneForwardedIcon from "@material-ui/icons/PhoneForwarded";
|
||||||
|
import { List } from "../../../ui/components/List";
|
||||||
|
import { ListItem } from "../../../ui/components/ListItem";
|
||||||
|
|
||||||
|
const CallTypeIcon = {
|
||||||
|
incoming: <PhoneCallbackIcon />,
|
||||||
|
outgoing: <PhoneForwardedIcon />,
|
||||||
|
};
|
||||||
|
|
||||||
export const PhoneList = ({ calls }) => {
|
export const PhoneList = ({ calls }) => {
|
||||||
const CallTypeIcon = {'incoming': <PhoneCallbackIcon />, 'outgoing': <PhoneForwardedIcon />}
|
return (
|
||||||
|
<List>
|
||||||
return (
|
{calls.map((call) => (
|
||||||
<List>
|
<ListItem key={call.id} divider>
|
||||||
{calls.map((call) => (
|
<ListItemText primary={call.caller} secondary={call.phoneNumber} />
|
||||||
<ListItem key={call.id} divider>
|
{CallTypeIcon[call.type]}
|
||||||
<ListItemText
|
</ListItem>
|
||||||
primary={call.caller}
|
))}
|
||||||
secondary={call.phoneNumber}
|
</List>
|
||||||
/>
|
);
|
||||||
{CallTypeIcon[call.type]}
|
};
|
||||||
</ListItem>
|
|
||||||
))}
|
|
||||||
</List>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { AppWrapper } from "../../../ui/components";
|
import { AppWrapper } from "../../../ui/components";
|
||||||
import { List, ListItem, ListItemText, Divider } from "@material-ui/core";
|
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 { useTranslation } from "react-i18next";
|
||||||
@@ -11,6 +11,8 @@ import {
|
|||||||
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 { useApps } from "../../appmarket/hooks/useApps";
|
||||||
|
import { List } from "../../../ui/components/List";
|
||||||
|
import { ListItem } from "../../../ui/components/ListItem";
|
||||||
|
|
||||||
export const SettingItem = ({ options, label, value, onClick }) => {
|
export const SettingItem = ({ options, label, value, onClick }) => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ const configState = atom({
|
|||||||
default: Default
|
default: Default
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(Default)
|
|
||||||
|
|
||||||
export const useConfig = (state = configState) => {
|
export const useConfig = (state = configState) => {
|
||||||
const [config, _setConfig] = useRecoilState(state)
|
const [config, _setConfig] = useRecoilState(state)
|
||||||
|
|
||||||
|
|||||||
+5
-7
@@ -7,13 +7,11 @@ import { BrowserRouter } from "react-router-dom";
|
|||||||
import { RecoilRoot } from "recoil";
|
import { RecoilRoot } from "recoil";
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<React.StrictMode>
|
<BrowserRouter>
|
||||||
<BrowserRouter>
|
<RecoilRoot>
|
||||||
<RecoilRoot>
|
<Phone />
|
||||||
<Phone />
|
</RecoilRoot>
|
||||||
</RecoilRoot>
|
</BrowserRouter>,
|
||||||
</BrowserRouter>
|
|
||||||
</React.StrictMode>,
|
|
||||||
document.getElementById("root")
|
document.getElementById("root")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
"APPS_PHONE": "Phone",
|
"APPS_PHONE": "Phone",
|
||||||
"APPS_CONTACTS": "Contacts",
|
"APPS_CONTACTS": "Contacts",
|
||||||
"APPS_MESSAGES": "Messages",
|
"APPS_MESSAGES": "Messages",
|
||||||
|
"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",
|
||||||
|
|||||||
@@ -2,10 +2,11 @@ import React from "react";
|
|||||||
import {
|
import {
|
||||||
makeStyles,
|
makeStyles,
|
||||||
BottomNavigation,
|
BottomNavigation,
|
||||||
BottomNavigationAction
|
BottomNavigationAction,
|
||||||
} from "@material-ui/core";
|
} from "@material-ui/core";
|
||||||
import KeyboardArrowLeftIcon from "@material-ui/icons/KeyboardArrowLeft";
|
import KeyboardArrowLeftIcon from "@material-ui/icons/KeyboardArrowLeft";
|
||||||
import AppsIcon from "@material-ui/icons/Apps";
|
import AppsIcon from "@material-ui/icons/Apps";
|
||||||
|
import PhoneIcon from "@material-ui/icons/Phone";
|
||||||
import { useHistory } from "react-router-dom";
|
import { useHistory } from "react-router-dom";
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
const useStyles = makeStyles((theme) => ({
|
||||||
@@ -18,24 +19,26 @@ const useStyles = makeStyles((theme) => ({
|
|||||||
export const Navigation = () => {
|
export const Navigation = () => {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BottomNavigation
|
<BottomNavigation
|
||||||
className={classes.root}
|
className={classes.root}
|
||||||
onChange={(_e, value) =>
|
onChange={(_e, value) => value()}
|
||||||
value === "back" ? history.goBack() : history.push("/")
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<BottomNavigationAction
|
<BottomNavigationAction
|
||||||
label="Back"
|
label="Phone"
|
||||||
value="back"
|
value={() => history.push("/phone")}
|
||||||
icon={<KeyboardArrowLeftIcon />}
|
icon={<PhoneIcon className={classes.icon} />}
|
||||||
/>
|
/>
|
||||||
<BottomNavigationAction
|
<BottomNavigationAction
|
||||||
label="Home"
|
label="Home"
|
||||||
value="home"
|
value={() => history.push("/")}
|
||||||
icon={<AppsIcon className={classes.icon} />}
|
icon={<AppsIcon className={classes.icon} />}
|
||||||
/>
|
/>
|
||||||
|
<BottomNavigationAction
|
||||||
|
label="Back"
|
||||||
|
value={() => history.goBack()}
|
||||||
|
icon={<KeyboardArrowLeftIcon />}
|
||||||
|
/>
|
||||||
</BottomNavigation>
|
</BottomNavigation>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -36,7 +36,7 @@ export const NotificationBar = ({ notifications = [] }) => {
|
|||||||
>
|
>
|
||||||
<Grid container item wrap="nowrap">
|
<Grid container item wrap="nowrap">
|
||||||
{notifications.map((notification) => (
|
{notifications.map((notification) => (
|
||||||
<Grid item component={IconButton} className={classes.icon}>
|
<Grid item key={notification.key} component={IconButton} className={classes.icon}>
|
||||||
{notification.icon}
|
{notification.icon}
|
||||||
</Grid>
|
</Grid>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
import { useEffect } from "react";
|
||||||
|
import { atom, useSetRecoilState, useRecoilValue } from "recoil";
|
||||||
|
|
||||||
|
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 useInitKeyboard = () => {
|
||||||
|
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 setEscape = useSetRecoilState(keyboardState.Escape);
|
||||||
|
|
||||||
|
useEffect(
|
||||||
|
function handleNUIKeyboardMessage() {
|
||||||
|
function onKeyUp(event) {
|
||||||
|
const { key } = event;
|
||||||
|
const callback = getters[key];
|
||||||
|
if (
|
||||||
|
isKeyValid(key) &&
|
||||||
|
callback &&
|
||||||
|
callback.handler &&
|
||||||
|
callback.handler.call
|
||||||
|
) {
|
||||||
|
return callback.handler();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener("keyup", onKeyUp);
|
||||||
|
return () => window.removeEventListener("keyup", onKeyUp);
|
||||||
|
},
|
||||||
|
[getters]
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(function registerEscapeHandler() {
|
||||||
|
setEscape({ handler: () => console.log("close phone") });
|
||||||
|
}, [setEscape]);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useKeyboard = () => {
|
||||||
|
const setters = {
|
||||||
|
ArrowRight: useSetRecoilState(keyboardState.ArrowRight),
|
||||||
|
ArrowLeft: useSetRecoilState(keyboardState.ArrowLeft),
|
||||||
|
ArrowUp: useSetRecoilState(keyboardState.ArrowUp),
|
||||||
|
ArrowDown: useSetRecoilState(keyboardState.ArrowDown),
|
||||||
|
Backspace: useSetRecoilState(keyboardState.Backspace),
|
||||||
|
Enter: useSetRecoilState(keyboardState.Enter),
|
||||||
|
};
|
||||||
|
|
||||||
|
return (key, handler) => {
|
||||||
|
setters[key]({ handler });
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import React from "react";
|
||||||
|
import MaterialButton from "@material-ui/core/Button";
|
||||||
|
|
||||||
|
export const Button = ({ ...props }) => {
|
||||||
|
return (
|
||||||
|
<MaterialButton aria-label="button" {...props}>
|
||||||
|
{props.children}
|
||||||
|
</MaterialButton>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import {
|
import {
|
||||||
ListItem,
|
|
||||||
List,
|
|
||||||
ListItemIcon,
|
ListItemIcon,
|
||||||
ListItemText,
|
ListItemText,
|
||||||
Slide,
|
Slide,
|
||||||
makeStyles,
|
makeStyles,
|
||||||
Paper,
|
Paper,
|
||||||
} from "@material-ui/core";
|
} from "@material-ui/core";
|
||||||
|
import { List } from "./List";
|
||||||
|
import { ListItem } from "./ListItem";
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
const useStyles = makeStyles((theme) => ({
|
||||||
root: {
|
root: {
|
||||||
@@ -23,7 +23,7 @@ export const ContextMenu = ({ open, onClose, options }) => {
|
|||||||
return (
|
return (
|
||||||
<Slide direction="up" in={open} mountOnEnter unmountOnExit>
|
<Slide direction="up" in={open} mountOnEnter unmountOnExit>
|
||||||
<Paper square className={classes.root}>
|
<Paper square className={classes.root}>
|
||||||
<List aria-label="context menu">
|
<List>
|
||||||
{options.map((option) => (
|
{options.map((option) => (
|
||||||
<ListItem
|
<ListItem
|
||||||
selected={option.selected}
|
selected={option.selected}
|
||||||
@@ -34,7 +34,7 @@ export const ContextMenu = ({ open, onClose, options }) => {
|
|||||||
onClose();
|
onClose();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ListItemIcon>{option.icon}</ListItemIcon>
|
{option.icon && <ListItemIcon>{option.icon}</ListItemIcon>}
|
||||||
<ListItemText primary={option.label} />
|
<ListItemText primary={option.label} />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -1,20 +1,30 @@
|
|||||||
import React from "react";
|
import React, { useEffect } from "react";
|
||||||
import { AppIcon } from "./AppIcon";
|
import { AppIcon } from "./AppIcon";
|
||||||
import { Grid, makeStyles } from "@material-ui/core";
|
import { Grid, makeStyles } from "@material-ui/core";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
|
import { useKeyboard } from "../../os/hooks/useKeyboard";
|
||||||
|
|
||||||
const useStyles = makeStyles(theme => ({
|
const useStyles = makeStyles((theme) => ({
|
||||||
root: {
|
root: {
|
||||||
marginTop: theme.spacing(3)
|
marginTop: theme.spacing(3),
|
||||||
},
|
},
|
||||||
item: {
|
item: {
|
||||||
marginTop: theme.spacing(3),
|
marginTop: theme.spacing(3),
|
||||||
width: '20%'
|
width: "20%",
|
||||||
}
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const GridMenu = ({ items, Component = AppIcon }) => {
|
export const GridMenu = ({ items, Component = AppIcon }) => {
|
||||||
|
const setKey = useKeyboard();
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
|
||||||
|
useEffect(function registerKeyHandlers() {
|
||||||
|
setKey("ArrowLeft", () => {
|
||||||
|
console.log(":v");
|
||||||
|
});
|
||||||
|
// eslint-disable-next-line
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid container justify="center">
|
<Grid container justify="center">
|
||||||
<Grid container item>
|
<Grid container item>
|
||||||
@@ -25,7 +35,7 @@ export const GridMenu = ({ items, Component = AppIcon }) => {
|
|||||||
item
|
item
|
||||||
className={classes.item}
|
className={classes.item}
|
||||||
key={item.name}
|
key={item.name}
|
||||||
tabindex="-1"
|
tabIndex="-1"
|
||||||
component={Link}
|
component={Link}
|
||||||
to={item.path}
|
to={item.path}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import React from 'react'
|
import React from "react";
|
||||||
import List from '@material-ui/core/List';
|
import MaterialList from "@material-ui/core/List";
|
||||||
|
|
||||||
export const PhoneList = (props) => {
|
export const List = ({ ...props }) => {
|
||||||
|
return (
|
||||||
return (
|
<MaterialList aria-label="list" {...props}>
|
||||||
<List component='nav' className={props.className} aria-label='mailbox folders'>
|
{props.children}
|
||||||
{props.children}
|
</MaterialList>
|
||||||
</List>
|
);
|
||||||
)
|
};
|
||||||
}
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import React from "react";
|
||||||
|
import MaterialListItem from "@material-ui/core/ListItem";
|
||||||
|
|
||||||
|
export const ListItem = ({ ...props }) => {
|
||||||
|
return (
|
||||||
|
<MaterialListItem aria-label="list item" {...props}>
|
||||||
|
{props.children}
|
||||||
|
</MaterialListItem>
|
||||||
|
);
|
||||||
|
};
|
||||||
Reference in new issue
Block a user