I really hope I didnt fuck anything up now

This commit is contained in:
chip committed 2020-08-23 20:08:08 +02:00
1 parent ad20755608
commit ec37fcde46
67 files changed

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
+2
View File
@@ -0,0 +1,2 @@
# New Phone Who Dis
A FiveM phone created with ReactJS, with the power from BTNGaming, kidz, ROCKY_shouthpaw and chip.
+55
View File
@@ -0,0 +1,55 @@
{
"name": "new-phone",
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.11.0",
"@material-ui/icons": "^4.9.1",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"husky": "^4.2.5",
"i18next": "^19.7.0",
"lint-staged": "^10.2.11",
"lodash": "^4.17.20",
"prettier": "^2.0.5",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-hotkeys": "^2.0.0",
"react-i18next": "^11.7.1",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.3",
"recoil": "^0.0.10"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"lint-staged": {
"src/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
"prettier --write"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

+45
View File
@@ -0,0 +1,45 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
+25
View File
@@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 381 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

+3
View File
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
+61
View File
@@ -0,0 +1,61 @@
.PhoneWrapper {
width: 100vw;
height: 100vh;
}
.Phone {
position: absolute;
bottom: 0vh;
right: 0vh;
width: 500px;
height: 1000px;
background-size: cover;
}
.PhoneFrame {
position: absolute;
z-index: 999;
width: 500px;
height: 1000px;
pointer-events: none;
}
.PhoneScreen {
overflow: hidden;
position: absolute;
background-color: black;
border-top: 2px solid black;
border-left: 4px solid black;
border-right: 4px solid black;
bottom: 100px;
left: 50px;
right: 50px;
top: 100px;
display: flex;
flex-direction: column;
}
.PhoneAppContainer {
height: 100%;
width: 100%;
display: flex;
flex-direction: column;
}
* {
box-sizing: border-box;
}
*::-webkit-scrollbar-track
{
box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
background-color: #F5F5F5;
}
*::-webkit-scrollbar
{
width: 3px;
background-color: transparent;
}
*::-webkit-scrollbar-thumb
{
background-color: #666;
}
+67
View File
@@ -0,0 +1,67 @@
import React from "react";
import "./Phone.css";
import "./i18n";
import { Route } from "react-router-dom";
import { useSettings } from "./apps/settings/hooks/useSettings";
import { NotificationBar } from "./os/components/NotificationBar";
import { NotificationIcon } from "./os/components/NotificationIcon";
import { Navigation } from "./os/components/Navigation";
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 { PhoneApp } from "./apps/phone/components/PhoneApp";
import { BankApp } from "./apps/bank/components/BankApp";
import { ThemeProvider } from "@material-ui/core";
import { CalculatorApp } from "./apps/calculator/components/CalculatorApp";
import { useInitKeyboard } from "./os/hooks/useKeyboard";
function Phone() {
useInitKeyboard();
const { settings, currentTheme } = useSettings();
return (
<ThemeProvider theme={currentTheme()}>
<div className="PhoneWrapper">
<div style={{ zoom: "80%" }}>
<div className="Phone">
<div
className="PhoneFrame"
style={{
backgroundImage: `${process.env.PUBLIC_URL}url(/media/frames/${settings.frame})`,
}}
></div>
<div
id="phone"
className="PhoneScreen"
style={{
backgroundImage: `${process.env.PUBLIC_URL}url(/media/backgrounds/${settings.wallpaper})`,
}}
>
<NotificationBar
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} />
<Route exact path="/phone" component={PhoneApp} />
<Route exact path="/bank" component={BankApp} />
<Route exact path="/calculator" component={CalculatorApp} />
</div>
<Navigation />
</div>
</div>
</div>
</div>
</ThemeProvider>
);
}
export default Phone;
+9
View File
@@ -0,0 +1,9 @@
import React from 'react';
import { render } from '@testing-library/react';
import App from './App';
test('renders learn react link', () => {
const { getByText } = render(<App />);
const linkElement = getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
+73
View File
@@ -0,0 +1,73 @@
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 };
};
@@ -0,0 +1 @@
@import url("https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap");
+59
View File
@@ -0,0 +1,59 @@
import React from "react";
import { makeStyles } from "@material-ui/core";
import { AppTitle } from "../../../ui/components/AppTitle";
import { AppWrapper } from "../../../ui/components";
import { AppContent } from "../../../ui/components/AppContent";
import { useTranslation } from "react-i18next";
import { Button } from "@material-ui/core";
import { useBank } from '../hooks/useBank';
import { TransactionList } from './transactionList';
import "./BankApp.css";
const useStyles = makeStyles((theme) => ({
root: {
height: "90px",
display: "flex",
justifyContent: "center",
backgroundColor: "#fb8c00",
alignItems: "center",
},
header: {
fontFamily: "'Bebas Neue', cursive",
textAlign: "center",
fontSize: 50,
},
bankOptions: {},
bankOptionsButton: {
display: "block",
textAlign: "center",
},
}));
export const BankApp = () => {
const { transactionList } = useBank();
const { t } = useTranslation();
const classes = useStyles();
return (
<AppWrapper>
<AppTitle className={classes.root}>
<h1 className={classes.header}>WhoDis Banking</h1>
</AppTitle>
<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>
<TransactionList
transactions={transactionList}
/>
</AppContent>
</AppWrapper>
);
};
@@ -0,0 +1,19 @@
import React from 'react';
import { List } from '../../../ui/components/List';
import { ListItem } from '../../../ui/components/ListItem';
import ListItemText from "@material-ui/core/ListItemText";
export const TransactionList = ({ transactions }) => {
return (
<List>
{transactions.map((transaction) => (
<ListItem key={transaction.id} divider>
<ListItemText
primary={transaction.amount}
secondary={transaction.type}
/>
</ListItem>
))}
</List>
)
}
+31
View File
@@ -0,0 +1,31 @@
import { useRecoilState, atom } from 'recoil';
const transactionListState = atom({
key: 'transactionList',
default: [
{
id: 0,
amount: 300,
type: 'withdraw',
date: '3'
},
{
id: 1,
amount: 1000,
type: 'withdraw',
date: '3'
},
{
id: 2,
amount: 50,
type: 'transfer',
date: '2'
},
],
});
export const useBank = () => {
const [transactionList, setTransactionList] = useRecoilState
(transactionListState);
return { transactionList, setTransactionList };
}
@@ -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,
};
};
@@ -0,0 +1,29 @@
import React from "react";
import ListItemText from "@material-ui/core/ListItemText";
import { Button } from "@material-ui/core";
import PhoneIcon from "@material-ui/icons/Phone";
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 }) => {
return (
<List>
{contacts.map((contact) => (
<ListItem key={contact.id} divider>
<ListItemText
primary={contact.display}
secondary={contact.phoneNumber}
/>
<Button onClick={() => onCall(contact.display)}>
<PhoneIcon />
</Button>
<Button onClick={onMessage}>
<ChatIcon />
</Button>
</ListItem>
))}
</List>
);
};
@@ -0,0 +1,28 @@
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 { useContacts } from "../hooks/useContacts";
import { ContactList } from "./ContactList";
import { useApps } from "../../appmarket/hooks/useApps";
export const ContactsApp = () => {
const { contactList } = useContacts();
const { getApp } = useApps();
const { t } = useTranslation();
return (
<AppWrapper>
<AppTitle color={getApp("contacts").backgroundColor}>
{t("APPS_CONTACTS")}
</AppTitle>
<AppContent>
<ContactList
contacts={contactList}
onCall={(contact => console.log(contact))}
onMessage={() => console.log("Opening messages")}
/>
</AppContent>
</AppWrapper>
);
};
@@ -0,0 +1,22 @@
import { useRecoilState, atom } from "recoil";
const contactListState = atom({
key: "contactList",
default: [
{
id: 0,
display: "Test Contact",
phoneNumber: "000-1111",
},
{
id: 1,
display: "Test Contact 2",
phoneNumber: "000-1112",
},
],
});
export const useContacts = () => {
const [contactList, setContactList] = useRecoilState(contactListState);
return { contactList, setContactList };
};
+14
View File
@@ -0,0 +1,14 @@
import React from "react";
import { AppWrapper } from "../../../ui/components";
import { Box } from "@material-ui/core";
import { useApps } from "../../appmarket/hooks/useApps";
import { GridMenu } from "../../../ui/components/GridMenu";
export const HomeApp = () => {
const { apps } = useApps();
return (
<AppWrapper>
<Box width="100%" mt={6} px={1}>{apps && <GridMenu items={apps.preinstalled} />}</Box>
</AppWrapper>
);
};
Whitespace-only changes.
Whitespace-only changes.
View File
Whitespace-only changes.
@@ -0,0 +1,26 @@
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>
)
}
@@ -0,0 +1,24 @@
import React from "react";
import ListItemText from "@material-ui/core/ListItemText";
import PhoneCallbackIcon from "@material-ui/icons/PhoneCallback";
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 }) => {
return (
<List>
{calls.map((call) => (
<ListItem key={call.id} divider>
<ListItemText primary={call.caller} secondary={call.phoneNumber} />
{CallTypeIcon[call.type]}
</ListItem>
))}
</List>
);
};
+25
View File
@@ -0,0 +1,25 @@
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,75 @@
import React from "react";
import { AppWrapper } from "../../../ui/components";
import { ListItemText, Divider } from "@material-ui/core";
import { AppTitle } from "../../../ui/components/AppTitle";
import { AppContent } from "../../../ui/components/AppContent";
import { useTranslation } from "react-i18next";
import {
useContextMenu,
MapStringOptions,
} from "../../../ui/hooks/useContextMenu";
import { useConfig } from "../../../config/hooks/useConfig";
import { useSettings } from "../hooks/useSettings";
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 }) => {
return (
<>
<ListItem onClick={() => onClick(options)} button>
<ListItemText primary={label} secondary={value} />
</ListItem>
<Divider />
</>
);
};
export const SettingsApp = () => {
const { t } = useTranslation();
const [config] = useConfig();
const { getApp } = useApps();
const { setSettings, settings } = useSettings();
const wallpapers = config.wallpapers.map(
MapStringOptions(settings.wallpaper, (val) => setSettings("wallpaper", val))
);
const frames = config.frames.map(
MapStringOptions(settings.frame, (val) => setSettings("frame", val))
);
const themes = Object.keys(config.themes).map(
MapStringOptions(settings.theme, (val) => setSettings("theme", val))
);
const [openMenu, closeMenu, ContextMenu, isMenuOpen] = useContextMenu();
return (
<AppWrapper>
<AppTitle color={getApp("settings").backgroundColor}>
{t("APPS_SETTINGS")}
</AppTitle>
<AppContent backdrop={isMenuOpen} onClickBackdrop={closeMenu}>
<List>
<SettingItem
label="Theme"
value={settings.theme}
options={themes}
onClick={openMenu}
/>
<SettingItem
label="Wallpaper"
value={settings.wallpaper}
options={wallpapers}
onClick={openMenu}
/>
<SettingItem
label="Frame"
value={settings.frame}
options={frames}
onClick={openMenu}
/>
</List>
</AppContent>
<ContextMenu />
</AppWrapper>
);
};
+5
View File
@@ -0,0 +1,5 @@
{
"wallpaper": "default.png",
"frame": "default.png",
"theme": "default-dark"
}
@@ -0,0 +1,16 @@
import Default from "../default.json";
import { useConfig } from "../../../config/hooks/useConfig";
import { atom } from "recoil";
import { createMuiTheme } from "@material-ui/core";
const settingsState = atom({
key: "settings",
default: Default,
});
export const useSettings = () => {
const [settings, setSettings] = useConfig(settingsState);
const [config] = useConfig();
const currentTheme = () => createMuiTheme(config.themes[settings.theme]);
return { settings, setSettings, currentTheme };
};
+18
View File
@@ -0,0 +1,18 @@
{
"4gNetowrk": "AT&T",
"language": "en_US",
"wallpapers": ["default.png", "dragon.jpg", "legacy.jpg"],
"frames": ["default.png", "s10.png"],
"themes": {
"default-dark": {
"palette": {
"type": "dark"
}
},
"default-light": {
"palette": {
"type": "light"
}
}
}
}
+20
View File
@@ -0,0 +1,20 @@
import Default from "../default.json";
import { atom, useRecoilState } from "recoil";
const configState = atom({
key: 'config',
default: Default
})
export const useConfig = (state = configState) => {
const [config, _setConfig] = useRecoilState(state)
const setConfig = (key, value) => {
_setConfig(oldConfig => ({
...oldConfig,
[key]: value
}));
};
return [config, setConfig];
};
+22
View File
@@ -0,0 +1,22 @@
import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import en from "./locale/en.json";
const resources = {
en
};
i18n
.use(initReactI18next) // passes i18n down to react-i18next
.init({
resources,
lng: "en",
keySeparator: false, // we do not use keys in form messages.welcome
interpolation: {
escapeValue: false, // react already safes from xss
},
});
export default i18n;
+21
View File
@@ -0,0 +1,21 @@
import React from "react";
import ReactDOM from "react-dom";
import "./main.css";
import Phone from "./Phone";
import * as serviceWorker from "./serviceWorker";
import { BrowserRouter } from "react-router-dom";
import { RecoilRoot } from "recoil";
ReactDOM.render(
<BrowserRouter>
<RecoilRoot>
<Phone />
</RecoilRoot>
</BrowserRouter>,
document.getElementById("root")
);
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
+16
View File
@@ -0,0 +1,16 @@
{
"translation": {
"COMING_SOON": "Coming soon...",
"APPS_PHONE": "Phone",
"APPS_CONTACTS": "Contacts",
"APPS_MESSAGES": "Messages",
"APPS_CALCULATOR": "Calculator",
"APPS_SETTINGS": "Settings",
"APPS_BANK": "WhoDis Banking",
"APPS_BANK_DEPOSIT": "Deposit",
"APPS_BANK_WITHDRAW": "Withdraw",
"APPS_BANK_TRANSFER": "Transfer",
"APPS_SETTINGS_OPTIONS_WALLPAPER": "Wallpaper",
"APPS_SETTINGS_OPTIONS_FRAME": "Frame"
}
}
+7
View File
@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3">
<g fill="#61DAFB">
<path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/>
<circle cx="420.9" cy="296.5" r="45.7"/>
<path d="M520.5 78.1z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

+19
View File
@@ -0,0 +1,19 @@
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-size: 20px;
margin: 0;
padding: 0;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
a, a:visited, a:hover, a:active {
text-decoration: none;
}
+44
View File
@@ -0,0 +1,44 @@
import React from "react";
import {
makeStyles,
BottomNavigation,
BottomNavigationAction,
} from "@material-ui/core";
import KeyboardArrowLeftIcon from "@material-ui/icons/KeyboardArrowLeft";
import AppsIcon from "@material-ui/icons/Apps";
import PhoneIcon from "@material-ui/icons/Phone";
import { useHistory } from "react-router-dom";
const useStyles = makeStyles((theme) => ({
root: {
zIndex: 2,
backgroundColor: theme.palette.background.default,
},
}));
export const Navigation = () => {
const classes = useStyles();
const history = useHistory();
return (
<BottomNavigation
className={classes.root}
onChange={(_e, value) => value()}
>
<BottomNavigationAction
label="Phone"
value={() => history.push("/phone")}
icon={<PhoneIcon className={classes.icon} />}
/>
<BottomNavigationAction
label="Home"
value={() => history.push("/")}
icon={<AppsIcon className={classes.icon} />}
/>
<BottomNavigationAction
label="Back"
value={() => history.goBack()}
icon={<KeyboardArrowLeftIcon />}
/>
</BottomNavigation>
);
};
@@ -0,0 +1,57 @@
import React from "react";
import { makeStyles, Typography, Grid, IconButton } from "@material-ui/core";
import { fade } from "@material-ui/core/styles/colorManipulator";
import SignalIcon from "@material-ui/icons/SignalCellular3Bar";
const useStyles = makeStyles((theme) => ({
root: {
backgroundColor: fade(theme.palette.background.paper, 0.7),
height: "25px",
width: "100%",
color: theme.palette.text.primary,
zIndex: 2,
},
item: {
margin: "0 6px",
},
text: {
position: "relative",
bottom: "2px",
color: theme.palette.text.primary,
},
icon: {
padding: '4px',
color: theme.palette.text.primary,
},
}));
export const NotificationBar = ({ notifications = [] }) => {
const classes = useStyles();
return (
<Grid
className={classes.root}
container
justify="space-between"
wrap="nowrap"
>
<Grid container item wrap="nowrap">
{notifications.map((notification) => (
<Grid item key={notification.key} component={IconButton} className={classes.icon}>
{notification.icon}
</Grid>
))}
</Grid>
<Grid container item wrap="nowrap" justify="flex-end">
<Grid item>
<SignalIcon fontSize="small" />
</Grid>
<Grid item className={classes.item}>
<Typography
className={classes.text}
variant="button"
>{`AT&T`}</Typography>
</Grid>
</Grid>
</Grid>
);
};
@@ -0,0 +1,5 @@
import React from "react";
export const NotificationIcon = ({ Icon }) => {
return <Icon fontSize="small" />;
};
+99
View File
@@ -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 });
};
};
Whitespace-only changes.
+141
View File
@@ -0,0 +1,141 @@
// This optional code is used to register a service worker.
// register() is not called by default.
// This lets the app load faster on subsequent visits in production, and gives
// it offline capabilities. However, it also means that developers (and users)
// will only see deployed updates on subsequent visits to a page, after all the
// existing tabs open on the page have been closed, since previously cached
// resources are updated in the background.
// To learn more about the benefits of this model and instructions on how to
// opt-in, read https://bit.ly/CRA-PWA
const isLocalhost = Boolean(
window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.0/8 are considered localhost for IPv4.
window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
)
);
export function register(config) {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin
// from what our page is served on. This might happen if a CDN is used to
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
return;
}
window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
if (isLocalhost) {
// This is running on localhost. Let's check if a service worker still exists or not.
checkValidServiceWorker(swUrl, config);
// Add some additional logging to localhost, pointing developers to the
// service worker/PWA documentation.
navigator.serviceWorker.ready.then(() => {
console.log(
'This web app is being served cache-first by a service ' +
'worker. To learn more, visit https://bit.ly/CRA-PWA'
);
});
} else {
// Is not localhost. Just register service worker
registerValidSW(swUrl, config);
}
});
}
}
function registerValidSW(swUrl, config) {
navigator.serviceWorker
.register(swUrl)
.then(registration => {
registration.onupdatefound = () => {
const installingWorker = registration.installing;
if (installingWorker == null) {
return;
}
installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
// At this point, the updated precached content has been fetched,
// but the previous service worker will still serve the older
// content until all client tabs are closed.
console.log(
'New content is available and will be used when all ' +
'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
);
// Execute callback
if (config && config.onUpdate) {
config.onUpdate(registration);
}
} else {
// At this point, everything has been precached.
// It's the perfect time to display a
// "Content is cached for offline use." message.
console.log('Content is cached for offline use.');
// Execute callback
if (config && config.onSuccess) {
config.onSuccess(registration);
}
}
}
};
};
})
.catch(error => {
console.error('Error during service worker registration:', error);
});
}
function checkValidServiceWorker(swUrl, config) {
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl, {
headers: { 'Service-Worker': 'script' },
})
.then(response => {
// Ensure service worker exists, and that we really are getting a JS file.
const contentType = response.headers.get('content-type');
if (
response.status === 404 ||
(contentType != null && contentType.indexOf('javascript') === -1)
) {
// No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then(registration => {
registration.unregister().then(() => {
window.location.reload();
});
});
} else {
// Service worker found. Proceed as normal.
registerValidSW(swUrl, config);
}
})
.catch(() => {
console.log(
'No internet connection found. App is running in offline mode.'
);
});
}
export function unregister() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready
.then(registration => {
registration.unregister();
})
.catch(error => {
console.error(error.message);
});
}
}
+5
View File
@@ -0,0 +1,5 @@
// jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom/extend-expect';
+39
View File
@@ -0,0 +1,39 @@
import React from "react";
import { Box, makeStyles, Backdrop, Paper } from "@material-ui/core";
const useStyles = makeStyles((theme) => ({
box: {
width: "100%",
position: "relative",
},
backdrop: {
position: "absolute",
zIndex: 1,
},
paper: {
width: "100%",
height: "100%",
},
}));
export const AppContent = ({
children,
style,
backdrop,
onClickBackdrop,
...props
}) => {
const classes = useStyles();
return (
<Box flexGrow={1} className={classes.box} {...props}>
<Paper square px={2} pt={1} elevation={0} className={classes.paper}>
<Backdrop
className={classes.backdrop}
open={backdrop || false}
onClick={onClickBackdrop}
></Backdrop>
{children}
</Paper>
</Box>
);
};
+33
View File
@@ -0,0 +1,33 @@
import React from "react";
import { makeStyles } from "@material-ui/core/styles";
import Avatar from "@material-ui/core/Avatar";
import { green } from "@material-ui/core/colors";
import { Button } from "@material-ui/core";
const useStyles = makeStyles((theme) => ({
root: {
display: "flex",
"& > *": {
margin: theme.spacing(1),
},
padding: 0
},
avatar: {
backgroundColor: ({ backgroundColor }) => backgroundColor,
color: ({ color }) => color,
width: theme.spacing(7),
height: theme.spacing(7),
fontSize: theme.typography.h4.fontSize,
}
}));
export const AppIcon = ({ name, icon, backgroundColor, color }) => {
const classes = useStyles({ backgroundColor: backgroundColor || green[50], color: color || green[400] });
return (
<Button className={classes.root}>
<Avatar className={classes.avatar}>
{icon || name[0].toUpperCase()}
</Avatar>
</Button>
);
};
+22
View File
@@ -0,0 +1,22 @@
import React from "react";
import { Typography, Box, makeStyles } from "@material-ui/core";
const useStyle = makeStyles(theme => ({
root: ({ color }) => ({
width: '100%',
textAlign: 'center',
backgroundColor: color || theme.palette.background.default
}),
text: {
color: theme.palette.text.primary
}
}));
export const AppTitle = ({ children, color, ...props }) => {
const classes = useStyle({ color });
return (
<Box px={2} pt={4} className={classes.root} {...props}>
<Typography className={classes.text} paragraph variant="h4">{children}</Typography>
</Box>
);
};
+21
View File
@@ -0,0 +1,21 @@
import React from "react";
export const AppWrapper = ({ children, style, handleClickAway, ...props }) => {
return (
<div
{...props}
style={{
padding: 0,
margin: 0,
width: "100%",
height: "100%",
display: "flex",
position: 'relative',
flexDirection: "column",
...style,
}}
>
{children}
</div>
);
};
+10
View File
@@ -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>
);
};
+45
View File
@@ -0,0 +1,45 @@
import React from "react";
import {
ListItemIcon,
ListItemText,
Slide,
makeStyles,
Paper,
} from "@material-ui/core";
import { List } from "./List";
import { ListItem } from "./ListItem";
const useStyles = makeStyles((theme) => ({
root: {
width: "100%",
position: "absolute",
bottom: 0,
zIndex: 2,
},
}));
export const ContextMenu = ({ open, onClose, options }) => {
const classes = useStyles();
return (
<Slide direction="up" in={open} mountOnEnter unmountOnExit>
<Paper square className={classes.root}>
<List>
{options.map((option) => (
<ListItem
selected={option.selected}
key={option.key || option.label}
button
onClick={(e) => {
option.onClick(e, option);
onClose();
}}
>
{option.icon && <ListItemIcon>{option.icon}</ListItemIcon>}
<ListItemText primary={option.label} />
</ListItem>
))}
</List>
</Paper>
</Slide>
);
};
+48
View File
@@ -0,0 +1,48 @@
import React, { useEffect } from "react";
import { AppIcon } from "./AppIcon";
import { Grid, makeStyles } from "@material-ui/core";
import { Link } from "react-router-dom";
import { useKeyboard } from "../../os/hooks/useKeyboard";
const useStyles = makeStyles((theme) => ({
root: {
marginTop: theme.spacing(3),
},
item: {
marginTop: theme.spacing(3),
width: "20%",
},
}));
export const GridMenu = ({ items, Component = AppIcon }) => {
const setKey = useKeyboard();
const classes = useStyles();
useEffect(function registerKeyHandlers() {
setKey("ArrowLeft", () => {
console.log(":v");
});
// eslint-disable-next-line
}, []);
return (
<Grid container justify="center">
<Grid container item>
{items &&
items.length &&
items.map((item) => (
<Grid
item
className={classes.item}
key={item.name}
tabIndex="-1"
component={Link}
to={item.path}
>
<Component {...item} />
</Grid>
))}
</Grid>
</Grid>
);
};
+10
View File
@@ -0,0 +1,10 @@
import React from "react";
import MaterialList from "@material-ui/core/List";
export const List = ({ ...props }) => {
return (
<MaterialList aria-label="list" {...props}>
{props.children}
</MaterialList>
);
};
+10
View File
@@ -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>
);
};
View File
Whitespace-only changes.
+1
View File
@@ -0,0 +1 @@
export * from './AppWrapper';
+30
View File
@@ -0,0 +1,30 @@
import React, { useState } from "react";
import { ContextMenu } from "../components/ContextMenu";
export const MapStringOptions = (current, onClick) => (string) => {
return {
selected: current === string,
label: string,
key: string,
onClick: () => onClick(string)
};
};
export const useContextMenu = (_options = []) => {
const [open, setOpen] = useState();
const [options, setOptions] = useState(_options);
const onClose = () => setOpen(false);
const onOpen = (opts) => {
setOptions(opts);
setOpen(true);
};
return [
onOpen,
onClose,
() => <ContextMenu open={open} onClose={onClose} options={options} />,
open,
];
};
View File
Whitespace-only changes.
+11456
View File
File diff suppressed because it is too large. Load diff