mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
I really hope I didnt fuck anything up now
This commit is contained in:
1 parent
ad20755608
commit
ec37fcde46
67 files changed
No files matched your search
@@ -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" />;
|
||||
};
|
||||
@@ -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.
Reference in new issue
Block a user