mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
Feat(Contacts | Components): Contact modal | Input compoent | New dependency
This commit is contained in:
1 parent
0312d2c4a6
commit
dde1bd6931
8 files changed
+245
-72
No files matched your search
+1
-40
@@ -18,6 +18,7 @@ import { useApps } from "./os/apps/hooks/useApps";
|
||||
|
||||
import { useContactsService } from "./apps/contacts/hooks/useContactsService";
|
||||
|
||||
// These events are just for testing. Comment it out before building.
|
||||
setTimeout(() => {
|
||||
window.dispatchEvent(
|
||||
new MessageEvent("message", {
|
||||
@@ -47,46 +48,6 @@ setTimeout(() => {
|
||||
number: "345-4366",
|
||||
display: "Kevin",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
number: "345-4366",
|
||||
display: "Kevin",
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
number: "345-4366",
|
||||
display: "Kevin",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
number: "345-4366",
|
||||
display: "Kevin",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
number: "345-4366",
|
||||
display: "Kevin",
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
number: "345-4366",
|
||||
display: "Kevin",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
number: "345-4366",
|
||||
display: "Kevin",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
number: "345-4366",
|
||||
display: "Kevin",
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
number: "345-4366",
|
||||
display: "Kevin",
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
|
||||
@@ -15,10 +15,18 @@ export const ContactList = () => {
|
||||
{contacts.contacts.map((contact) => (
|
||||
<ListItem key={contact.id} divider>
|
||||
<ListItemText primary={contact.display} secondary={contact.number} />
|
||||
<Button>
|
||||
<Button
|
||||
onClick={() =>
|
||||
console.log("Call: " + contact.display, contact.number)
|
||||
}
|
||||
>
|
||||
<PhoneIcon />
|
||||
</Button>
|
||||
<Button>
|
||||
<Button
|
||||
onClick={() =>
|
||||
console.log("Message: " + contact.display, contact.number)
|
||||
}
|
||||
>
|
||||
<ChatIcon />
|
||||
</Button>
|
||||
</ListItem>
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
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 Nui from "../../../os/nui-events/utils/Nui";
|
||||
import { TextInput } from "../../../ui/components/Input";
|
||||
|
||||
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,
|
||||
},
|
||||
}));
|
||||
|
||||
export const AddContactModal = () => {
|
||||
const [modal, setModal] = useState(false);
|
||||
|
||||
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>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<AppContent>
|
||||
<Button fullWidth onClick={() => setModal(true)}>
|
||||
<AddCircleIcon />
|
||||
</Button>
|
||||
<Modal show={modal} />
|
||||
</AppContent>
|
||||
);
|
||||
};
|
||||
@@ -4,8 +4,7 @@ import { AppTitle } from "../../../ui/components/AppTitle";
|
||||
import { AppContent } from "../../../ui/components/AppContent";
|
||||
import { ContactList } from "./ContactList";
|
||||
import { useApp } from "../../../os/apps/hooks/useApps";
|
||||
import { Button } from "../../../ui/components/Button";
|
||||
import AddCircleIcon from "@material-ui/icons/AddCircle";
|
||||
import { AddContactModal } from "./ContactModal";
|
||||
|
||||
export const ContactsApp = () => {
|
||||
const contacts = useApp("CONTACTS");
|
||||
@@ -14,9 +13,7 @@ export const ContactsApp = () => {
|
||||
<AppTitle app={contacts} />
|
||||
<AppContent>
|
||||
<ContactList />
|
||||
<Button fullWidth>
|
||||
<AddCircleIcon />
|
||||
</Button>
|
||||
<AddContactModal />
|
||||
</AppContent>
|
||||
</AppWrapper>
|
||||
);
|
||||
|
||||
@@ -5,24 +5,3 @@ export const useContacts = () => {
|
||||
const contacts = useRecoilValue(contactsState.contacts);
|
||||
return { contacts };
|
||||
};
|
||||
|
||||
//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 };
|
||||
//};
|
||||
@@ -0,0 +1,24 @@
|
||||
import React from "react";
|
||||
|
||||
import styled from "styled-components";
|
||||
|
||||
const Input = styled("input")`
|
||||
text-align: center;
|
||||
padding: 10px;
|
||||
border: none;
|
||||
font-size: 20px;
|
||||
outline: none;
|
||||
background: transparent;
|
||||
color: #fff;
|
||||
margin-bottom: 1em;
|
||||
border-bottom: 1px solid #fff;
|
||||
`;
|
||||
|
||||
export const TextInput = (props) => (
|
||||
<Input
|
||||
placeholder={props.placeholder}
|
||||
type={props.type}
|
||||
defaultValue={props.value}
|
||||
onChange={props.onChange}
|
||||
/>
|
||||
);
|
||||
Reference in new issue
Block a user