mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +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 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 DeleteIcon from "@material-ui/icons/Delete";
|
||||||
import { List } from "../../../ui/components/List";
|
import { List } from "../../../ui/components/List";
|
||||||
import { ListItem } from "../../../ui/components/ListItem";
|
import { ListItem } from "../../../ui/components/ListItem";
|
||||||
import { useContacts } from "../hooks/useContacts";
|
import { useContacts } from "../hooks/useContacts";
|
||||||
|
|
||||||
|
import Nui from "../../../os/nui-events/utils/Nui";
|
||||||
|
|
||||||
export const ContactList = () => {
|
export const ContactList = () => {
|
||||||
const contacts = useContacts();
|
const contacts = useContacts();
|
||||||
|
const [call, setCall] = useState("");
|
||||||
|
|
||||||
|
const startCall = (number) => {
|
||||||
|
console.log(number);
|
||||||
|
Nui.send("phone:startCall", {
|
||||||
|
number,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<List>
|
<List>
|
||||||
{contacts.contacts.map((contact) => (
|
{contacts.contacts.map((contact) => (
|
||||||
<ListItem key={contact.id} divider>
|
<ListItem key={contact.id} divider>
|
||||||
<ListItemText primary={contact.display} secondary={contact.number} />
|
<ListItemText primary={contact.display} secondary={contact.number} />
|
||||||
<Button
|
<Button onClick={() => startCall(contact.number)}>
|
||||||
onClick={() =>
|
|
||||||
console.log("Call: " + contact.display, contact.number)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<PhoneIcon />
|
<PhoneIcon />
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
@@ -29,6 +37,9 @@ export const ContactList = () => {
|
|||||||
>
|
>
|
||||||
<ChatIcon />
|
<ChatIcon />
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button>
|
||||||
|
<DeleteIcon />
|
||||||
|
</Button>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
))}
|
))}
|
||||||
</List>
|
</List>
|
||||||
|
|||||||
@@ -1,103 +1,79 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { makeStyles } from "@material-ui/core/styles";
|
import { makeStyles } from "@material-ui/core/styles";
|
||||||
import AddCircleIcon from "@material-ui/icons/AddCircle";
|
import { Button, TextField, Paper } from "@material-ui/core";
|
||||||
import { AppContent } from "../../../ui/components/AppContent";
|
|
||||||
import { Container, Button } from "@material-ui/core";
|
|
||||||
import Nui from "../../../os/nui-events/utils/Nui";
|
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) => ({
|
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: {
|
button: {
|
||||||
margin: 5,
|
margin: 5,
|
||||||
marginTop: 20,
|
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 = () => {
|
export const AddContactModal = ({ handleClose, show, children }) => {
|
||||||
const [modal, setModal] = useState(false);
|
const [name, setName] = useState("");
|
||||||
|
const [number, setNumber] = useState("");
|
||||||
|
const classes = useStyles();
|
||||||
|
const showHideClassName = show ? classes.displayBlock : classes.displayNone;
|
||||||
|
|
||||||
const Modal = (props) => {
|
const addContact = () => {
|
||||||
const [name, setName] = useState("");
|
if (name === "" || number === "") {
|
||||||
const [number, setNumber] = useState("");
|
console.log("You need to pass in values");
|
||||||
|
} else {
|
||||||
const addContact = () => {
|
Nui.send("contacts:add", {
|
||||||
if (name === "" || number === "") {
|
name,
|
||||||
console.log("You need to pass in values");
|
number,
|
||||||
} else {
|
});
|
||||||
Nui.send("contacts:add", {
|
console.log(name, number);
|
||||||
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>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppContent>
|
<div className={showHideClassName}>
|
||||||
<Button fullWidth onClick={() => setModal(true)}>
|
<Paper className={classes.root}>
|
||||||
<AddCircleIcon />
|
<List>
|
||||||
</Button>
|
<ListItem>
|
||||||
<Modal show={modal} />
|
<TextField
|
||||||
</AppContent>
|
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 { AppWrapper } from "../../../ui/components";
|
||||||
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 { ContactList } from "./ContactList";
|
import { ContactList } from "./ContactList";
|
||||||
import { useApp } from "../../../os/apps/hooks/useApps";
|
import { useApp } from "../../../os/apps/hooks/useApps";
|
||||||
|
import AddCircleIcon from "@material-ui/icons/AddCircle";
|
||||||
import { AddContactModal } from "./ContactModal";
|
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 = () => {
|
export const ContactsApp = () => {
|
||||||
|
const [modal, setModal] = useState(false);
|
||||||
|
const classes = useStyles();
|
||||||
const contacts = useApp("CONTACTS");
|
const contacts = useApp("CONTACTS");
|
||||||
|
|
||||||
|
const openModal = () => {
|
||||||
|
setModal(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const closeModal = () => {
|
||||||
|
setModal(false);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppWrapper>
|
<AppWrapper>
|
||||||
<AppTitle app={contacts} />
|
<AppTitle app={contacts}></AppTitle>
|
||||||
|
<Button
|
||||||
|
onClick={openModal}
|
||||||
|
variant="contained"
|
||||||
|
style={{ backgroundColor: "#232323" }}
|
||||||
|
>
|
||||||
|
<AddCircleIcon color="action" />
|
||||||
|
</Button>
|
||||||
<AppContent>
|
<AppContent>
|
||||||
|
<AddContactModal show={modal} handleClose={closeModal} />
|
||||||
<ContactList />
|
<ContactList />
|
||||||
<AddContactModal />
|
|
||||||
</AppContent>
|
</AppContent>
|
||||||
</AppWrapper>
|
</AppWrapper>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user