Feat(Nui): Nui send event | Close button

This commit is contained in:
chip committed 2020-08-28 00:22:25 +02:00
1 parent 3a213ea308
commit 5ae9f99f42
3 files changed
+31 -1

No files matched your search

+1 -1
View File
@@ -56,7 +56,7 @@ import { useContactsService } from "./apps/contacts/hooks/useContactsService";
// data: {
// app: "PHONE",
// method: "setVisibility",
// data: false,
// data: true,
// },
// })
// );
@@ -7,8 +7,11 @@ import {
import KeyboardArrowLeftIcon from "@material-ui/icons/KeyboardArrowLeft";
import AppsIcon from "@material-ui/icons/Apps";
import PhoneIcon from "@material-ui/icons/Phone";
import RadioButtonUncheckedIcon from "@material-ui/icons/RadioButtonUnchecked";
import { useHistory } from "react-router-dom";
import Nui from "../../nui-events/utils/Nui";
const useStyles = makeStyles((theme) => ({
root: {
zIndex: 2,
@@ -17,6 +20,11 @@ const useStyles = makeStyles((theme) => ({
}));
export const Navigation = () => {
const closePhone = () => {
console.log("Phone closed");
Nui.send("phone:close");
};
const classes = useStyles();
const history = useHistory();
return (
@@ -34,6 +42,11 @@ export const Navigation = () => {
value={() => history.push("/")}
icon={<AppsIcon className={classes.icon} />}
/>
<BottomNavigationAction
label="Close"
value={() => closePhone()}
icon={<RadioButtonUncheckedIcon className={classes.icon} />}
/>
<BottomNavigationAction
label="Back"
value={() => history.goBack()}
+17
View File
@@ -0,0 +1,17 @@
export default {
async send(event, data = {}) {
// /// #if DEBUG
//return new Promise(resolve => setTimeout(resolve, 100));
// /// #endif
/* eslint-disable no-unreachable */
return fetch(`http://new-phone-who-dis/${event}`, {
method: "post",
headers: {
"Content-type": "application/json; charset=UTF-8",
},
body: JSON.stringify(data),
});
/* eslint-enable no-unreachable */
},
};