mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
Tweak(Contacts): New layout and functions
This commit is contained in:
1 parent
2a399013f1
commit
a9f80130e0
4 files changed
+124
-95
No files matched your search
@@ -0,0 +1,10 @@
|
||||
.display-block {
|
||||
/*Sets modal to center*/
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.display-none {
|
||||
display: none;
|
||||
}
|
||||
@@ -1,25 +1,33 @@
|
||||
import React from "react";
|
||||
import React, { useState } 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 DeleteIcon from "@material-ui/icons/Delete";
|
||||
import { List } from "../../../ui/components/List";
|
||||
import { ListItem } from "../../../ui/components/ListItem";
|
||||
import { useContacts } from "../hooks/useContacts";
|
||||
|
||||
import Nui from "../../../os/nui-events/utils/Nui";
|
||||
|
||||
export const ContactList = () => {
|
||||
const contacts = useContacts();
|
||||
const [call, setCall] = useState("");
|
||||
|
||||
const startCall = (number) => {
|
||||
console.log(number);
|
||||
Nui.send("phone:startCall", {
|
||||
number,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<List>
|
||||
{contacts.contacts.map((contact) => (
|
||||
<ListItem key={contact.id} divider>
|
||||
<ListItemText primary={contact.display} secondary={contact.number} />
|
||||
<Button
|
||||
onClick={() =>
|
||||
console.log("Call: " + contact.display, contact.number)
|
||||
}
|
||||
>
|
||||
<Button onClick={() => startCall(contact.number)}>
|
||||
<PhoneIcon />
|
||||
</Button>
|
||||
<Button
|
||||
@@ -29,6 +37,9 @@ export const ContactList = () => {
|
||||
>
|
||||
<ChatIcon />
|
||||
</Button>
|
||||
<Button>
|
||||
<DeleteIcon />
|
||||
</Button>
|
||||
</ListItem>
|
||||
))}
|
||||
</List>
|
||||
|
||||
@@ -1,103 +1,79 @@
|
||||
import React, { useState } from "react";
|
||||
import { makeStyles } from "@material-ui/core/styles";
|
||||
import AddCircleIcon from "@material-ui/icons/AddCircle";
|
||||
import { AppContent } from "../../../ui/components/AppContent";
|
||||
import { Container, Button } from "@material-ui/core";
|
||||
import { Button, TextField, Paper } from "@material-ui/core";
|
||||
import Nui from "../../../os/nui-events/utils/Nui";
|
||||
import { TextInput } from "../../../ui/components/Input";
|
||||
import List from "@material-ui/core/List";
|
||||
import ListItem from "@material-ui/core/ListItem";
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
modal: {
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
},
|
||||
paper: {
|
||||
backgroundColor: theme.palette.background.paper,
|
||||
boxShadow: theme.shadows[5],
|
||||
padding: theme.spacing(2, 4, 3),
|
||||
},
|
||||
modalContainer: {
|
||||
backgroundColor: "#232323",
|
||||
width: "80%",
|
||||
height: "30vh",
|
||||
},
|
||||
button: {
|
||||
margin: 5,
|
||||
marginTop: 20,
|
||||
},
|
||||
root: {
|
||||
position: "fixed",
|
||||
bottom: 380,
|
||||
zIndex: 2,
|
||||
background: "#232323",
|
||||
marginLeft: "-4em",
|
||||
height: "20%",
|
||||
},
|
||||
|
||||
displayBlock: {
|
||||
/*Sets modal to center*/
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
},
|
||||
displayNone: {
|
||||
display: "none",
|
||||
},
|
||||
}));
|
||||
|
||||
export const AddContactModal = () => {
|
||||
const [modal, setModal] = useState(false);
|
||||
export const AddContactModal = ({ handleClose, show, children }) => {
|
||||
const [name, setName] = useState("");
|
||||
const [number, setNumber] = useState("");
|
||||
const classes = useStyles();
|
||||
const showHideClassName = show ? classes.displayBlock : classes.displayNone;
|
||||
|
||||
const Modal = (props) => {
|
||||
const [name, setName] = useState("");
|
||||
const [number, setNumber] = useState("");
|
||||
|
||||
const addContact = () => {
|
||||
if (name === "" || number === "") {
|
||||
console.log("You need to pass in values");
|
||||
} else {
|
||||
Nui.send("contacts:add", {
|
||||
name,
|
||||
number,
|
||||
});
|
||||
console.log(name, number);
|
||||
}
|
||||
};
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<Container
|
||||
fixed
|
||||
className={classes.modalContainer}
|
||||
style={{
|
||||
visibility: props.show ? "visible" : "hidden",
|
||||
}}
|
||||
>
|
||||
<h2 style={{ textAlign: "center" }}>New contact:</h2>
|
||||
<TextInput
|
||||
style={{ display: "flex" }}
|
||||
placeholder="Name"
|
||||
value={name}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
/>
|
||||
<TextInput
|
||||
style={{ display: "flex" }}
|
||||
placeholder="Phone number"
|
||||
value={number}
|
||||
onChange={(e) => setNumber(e.target.value)}
|
||||
id="number-basic"
|
||||
type="number"
|
||||
label="Phone Number"
|
||||
color="primary"
|
||||
/>
|
||||
<Button
|
||||
onClick={addContact}
|
||||
variant="contained"
|
||||
style={{ backgroundColor: "#fff", color: "#000" }}
|
||||
className={classes.button}
|
||||
>
|
||||
Add
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => setModal(false)}
|
||||
variant="contained"
|
||||
style={{ backgroundColor: "#c0392b", color: "#fff" }}
|
||||
className={classes.button}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
</Container>
|
||||
);
|
||||
const addContact = () => {
|
||||
if (name === "" || number === "") {
|
||||
console.log("You need to pass in values");
|
||||
} else {
|
||||
Nui.send("contacts:add", {
|
||||
name,
|
||||
number,
|
||||
});
|
||||
console.log(name, number);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<AppContent>
|
||||
<Button fullWidth onClick={() => setModal(true)}>
|
||||
<AddCircleIcon />
|
||||
</Button>
|
||||
<Modal show={modal} />
|
||||
</AppContent>
|
||||
<div className={showHideClassName}>
|
||||
<Paper className={classes.root}>
|
||||
<List>
|
||||
<ListItem>
|
||||
<TextField
|
||||
value={name}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
style={{ fontSize: "18px" }}
|
||||
fullWidth
|
||||
placeholder="Name"
|
||||
/>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<TextField
|
||||
value={number}
|
||||
onChange={(e) => setNumber(e.target.value)}
|
||||
fullWidth
|
||||
placeholder="Number"
|
||||
type="number"
|
||||
/>
|
||||
</ListItem>
|
||||
</List>
|
||||
<Button onClick={addContact}>Add</Button>
|
||||
<Button onClick={handleClose}>Close</Button>
|
||||
</Paper>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,19 +1,51 @@
|
||||
import React from "react";
|
||||
import React, { useState } from "react";
|
||||
import { makeStyles } from "@material-ui/core/styles";
|
||||
import { AppWrapper } from "../../../ui/components";
|
||||
import { AppTitle } from "../../../ui/components/AppTitle";
|
||||
import { AppContent } from "../../../ui/components/AppContent";
|
||||
import { ContactList } from "./ContactList";
|
||||
import { useApp } from "../../../os/apps/hooks/useApps";
|
||||
import AddCircleIcon from "@material-ui/icons/AddCircle";
|
||||
import { AddContactModal } from "./ContactModal";
|
||||
import { Button } from "@material-ui/core";
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
modalOpener: {
|
||||
backgroundColor: "red",
|
||||
height: 50,
|
||||
position: "fixed",
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
},
|
||||
}));
|
||||
|
||||
export const ContactsApp = () => {
|
||||
const [modal, setModal] = useState(false);
|
||||
const classes = useStyles();
|
||||
const contacts = useApp("CONTACTS");
|
||||
|
||||
const openModal = () => {
|
||||
setModal(true);
|
||||
};
|
||||
|
||||
const closeModal = () => {
|
||||
setModal(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<AppWrapper>
|
||||
<AppTitle app={contacts} />
|
||||
<AppTitle app={contacts}></AppTitle>
|
||||
<Button
|
||||
onClick={openModal}
|
||||
variant="contained"
|
||||
style={{ backgroundColor: "#232323" }}
|
||||
>
|
||||
<AddCircleIcon color="action" />
|
||||
</Button>
|
||||
<AppContent>
|
||||
<AddContactModal show={modal} handleClose={closeModal} />
|
||||
<ContactList />
|
||||
<AddContactModal />
|
||||
</AppContent>
|
||||
</AppWrapper>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user