mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 06:28:51 +00:00
Merge pull request #11 from Re-Ignited-Development/tweak/contacts-app
Tweak/contacts app
This commit is contained in:
15 files changed
+399
-134
No files matched your search
+11
-3
@@ -43,12 +43,20 @@ setTimeout(() => {
|
||||
{
|
||||
id: 1,
|
||||
number: "345-4366",
|
||||
display: "Kevin",
|
||||
display: "Gjelten",
|
||||
img: 'https://i.imgur.com/Qpw6j8D.png'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
number: "345-4366",
|
||||
display: "Kevin",
|
||||
number: "456-4366",
|
||||
display: "Loyd",
|
||||
img: ''
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
number: "123-4366",
|
||||
display: "Fabian",
|
||||
img: 'https://i.imgur.com/B8ta5Aa.jpeg'
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
.display-block {
|
||||
/*Sets modal to center*/
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.display-none {
|
||||
display: none;
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
import React 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 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={() => startCall(contact.number)}>
|
||||
<PhoneIcon />
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() =>
|
||||
console.log("Message: " + contact.display, contact.number)
|
||||
}
|
||||
>
|
||||
<ChatIcon />
|
||||
</Button>
|
||||
<Button>
|
||||
<DeleteIcon />
|
||||
</Button>
|
||||
</ListItem>
|
||||
))}
|
||||
</List>
|
||||
);
|
||||
};
|
||||
@@ -1,11 +1,18 @@
|
||||
import React, { useState } from "react";
|
||||
import { makeStyles } from "@material-ui/core/styles";
|
||||
import { Button, TextField, Paper } from "@material-ui/core";
|
||||
import { makeStyles, Theme } from "@material-ui/core/styles";
|
||||
import { Button, TextField } from "@material-ui/core";
|
||||
import Nui from "../../../os/nui-events/utils/Nui";
|
||||
import List from "@material-ui/core/List";
|
||||
import ListItem from "@material-ui/core/ListItem";
|
||||
import Modal from '../../../ui/components/Modal';
|
||||
import { useModal } from '../hooks/useModal';
|
||||
import ClearIcon from '@material-ui/icons/Clear';
|
||||
import PersonIcon from '@material-ui/icons/Person';
|
||||
import PhoneIcon from '@material-ui/icons/Phone';
|
||||
import AccountCircleIcon from '@material-ui/icons/AccountCircle';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) => ({
|
||||
button: {
|
||||
margin: 5,
|
||||
marginTop: 20,
|
||||
@@ -18,23 +25,42 @@ const useStyles = makeStyles((theme) => ({
|
||||
marginLeft: "-4em",
|
||||
height: "20%",
|
||||
},
|
||||
|
||||
displayBlock: {
|
||||
/*Sets modal to center*/
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
clearButton: {
|
||||
width: '10%',
|
||||
position: 'absolute',
|
||||
right: 0
|
||||
},
|
||||
displayNone: {
|
||||
display: "none",
|
||||
textInputField: {
|
||||
fontSize: 20,
|
||||
borderBottomColor: 'red'
|
||||
},
|
||||
addBtn: {
|
||||
margin: 'auto',
|
||||
fontSize: 16,
|
||||
width: 150,
|
||||
background: "#2196f3",
|
||||
marginBottom: 10,
|
||||
padding: 8
|
||||
},
|
||||
cancelBtn: {
|
||||
margin: 'auto',
|
||||
width: 150,
|
||||
background: "#232323",
|
||||
marginBottom: 20,
|
||||
padding: 8
|
||||
},
|
||||
icons: {
|
||||
marginRight: 5
|
||||
}
|
||||
}));
|
||||
|
||||
export const AddContactModal = ({ handleClose, show }) => {
|
||||
export const AddContactModal = () => {
|
||||
const [name, setName] = useState("");
|
||||
const [number, setNumber] = useState("");
|
||||
const [avatar, setAvatar] = useState("");
|
||||
const classes = useStyles();
|
||||
const showHideClassName = show ? classes.displayBlock : classes.displayNone;
|
||||
|
||||
const { showModal, setShowModal } = useModal();
|
||||
|
||||
const addContact = () => {
|
||||
if (name === "" || number === "") {
|
||||
@@ -43,37 +69,57 @@ export const AddContactModal = ({ handleClose, show }) => {
|
||||
Nui.send("contacts:add", {
|
||||
name,
|
||||
number,
|
||||
avatar
|
||||
});
|
||||
console.log(name, number);
|
||||
console.log(name, number, avatar);
|
||||
}
|
||||
};
|
||||
|
||||
const _handleClose = () => {
|
||||
setShowModal(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<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>
|
||||
<Modal visible={showModal} handleClose={_handleClose}>
|
||||
<Button onClick={_handleClose} className={classes.clearButton}><ClearIcon /></Button>
|
||||
<List style={{ marginTop: 30 }}>
|
||||
<ListItem>
|
||||
<PersonIcon className={classes.icons} />
|
||||
<TextField
|
||||
value={name}
|
||||
inputProps={{ className: classes.textInputField}}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
fullWidth
|
||||
variant="standard"
|
||||
placeholder="Name"
|
||||
/>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<PhoneIcon className={classes.icons} />
|
||||
<TextField
|
||||
value={number}
|
||||
inputProps={{ className: classes.textInputField}}
|
||||
onChange={(e) => setNumber(e.target.value)}
|
||||
fullWidth
|
||||
placeholder="Number"
|
||||
variant="standard"
|
||||
type="number"
|
||||
/>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<AccountCircleIcon className={classes.icons} />
|
||||
<TextField
|
||||
value={avatar}
|
||||
inputProps={{ className: classes.textInputField}}
|
||||
onChange={(e) => setAvatar(e.target.value)}
|
||||
fullWidth
|
||||
placeholder="Avatar URL"
|
||||
variant="standard"
|
||||
type="text"
|
||||
/>
|
||||
</ListItem>
|
||||
</List>
|
||||
<Button onClick={addContact}>Add</Button>
|
||||
<Button onClick={handleClose}>Close</Button>
|
||||
</Paper>
|
||||
</div>
|
||||
<Button className={classes.addBtn} onClick={addContact}>Add Contact</Button>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
import React from 'react'
|
||||
import { makeStyles, createStyles, Theme } from "@material-ui/core/styles";
|
||||
import Paper from "@material-ui/core/Paper";
|
||||
import ContactsIcon from "@material-ui/icons/Contacts";
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) =>
|
||||
createStyles({
|
||||
root: {
|
||||
height: "60px",
|
||||
width: "100%",
|
||||
display: "flex",
|
||||
flexFlow: "row nowrap",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
background: "#424242",
|
||||
},
|
||||
icon: {
|
||||
color: "#fff",
|
||||
fontSize: 30,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
export const ContactTitle = () => {
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<Paper className={classes.root} square variant="outlined" elevation={24}>
|
||||
<ContactsIcon className={classes.icon} />
|
||||
</Paper>
|
||||
)
|
||||
}
|
||||
@@ -1,38 +1,60 @@
|
||||
import React, { useState } from "react";
|
||||
import React from "react";
|
||||
import { AppWrapper } from "../../../ui/components";
|
||||
import { makeStyles, createStyles, Theme } from "@material-ui/core/styles";
|
||||
import { AppTitle } from "../../../ui/components/AppTitle";
|
||||
import { AppContent } from "../../../ui/components/AppContent";
|
||||
import { ContactList } from "./ContactList";
|
||||
import { ContactList } from "./List/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";
|
||||
import { useModal } from '../hooks/useModal';
|
||||
import { SearchContacts } from "./List/SearchContacts";
|
||||
import PersonAddIcon from '@material-ui/icons/PersonAdd'
|
||||
|
||||
import Fab from '@material-ui/core/Fab';
|
||||
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) =>
|
||||
createStyles({
|
||||
backgroundModal: {
|
||||
background: "black",
|
||||
opacity: "0.6",
|
||||
position: "absolute",
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
zIndex: 5,
|
||||
},
|
||||
absolute: {
|
||||
position: 'sticky',
|
||||
bottom: theme.spacing(2),
|
||||
left: theme.spacing(3),
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
export const ContactsApp = () => {
|
||||
const [modal, setModal] = useState(false);
|
||||
|
||||
const classes = useStyles();
|
||||
const { showModal, setShowModal } = useModal();
|
||||
const contacts = useApp("CONTACTS");
|
||||
|
||||
const openModal = () => {
|
||||
setModal(true);
|
||||
setShowModal(true);
|
||||
};
|
||||
|
||||
const closeModal = () => {
|
||||
setModal(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<AppWrapper>
|
||||
<AppWrapper id="contact-app">
|
||||
<AppTitle app={contacts}></AppTitle>
|
||||
<Button
|
||||
onClick={openModal}
|
||||
variant="contained"
|
||||
style={{ backgroundColor: "#232323" }}
|
||||
>
|
||||
<AddCircleIcon color="action" />
|
||||
</Button>
|
||||
<SearchContacts />
|
||||
<AddContactModal/>
|
||||
<div className={showModal ? classes.backgroundModal : undefined} />
|
||||
<AppContent>
|
||||
<AddContactModal show={modal} handleClose={closeModal} />
|
||||
<ContactList />
|
||||
<Fab onClick={openModal} style={{backgroundColor: '#2196f3', color: '#fff'}} className={classes.absolute}>
|
||||
<PersonAddIcon />
|
||||
</Fab>
|
||||
</AppContent>
|
||||
</AppWrapper>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
import React from "react";
|
||||
import ListItemText from "@material-ui/core/ListItemText";
|
||||
import {
|
||||
Button,
|
||||
ListItemAvatar,
|
||||
Avatar as MuiAvatar
|
||||
} from "@material-ui/core";
|
||||
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { faPen } from "@fortawesome/free-solid-svg-icons";
|
||||
|
||||
import { useFilteredContacts } from '../../hooks/useFilteredContacts';
|
||||
|
||||
import PhoneIcon from "@material-ui/icons/Phone";
|
||||
import ChatIcon from "@material-ui/icons/Chat";
|
||||
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 { filteredContacts } = useFilteredContacts();
|
||||
|
||||
const contacts = useContacts();
|
||||
|
||||
const startCall = (number) => {
|
||||
console.log(number);
|
||||
Nui.send("phone:startCall", {
|
||||
number,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<List>
|
||||
{contacts.contacts.filter(contact => contact.display.includes(filteredContacts) || contact.number.includes(filteredContacts)).map((contact) => (
|
||||
<ListItem key={contact.id} divider>
|
||||
<ListItemAvatar>
|
||||
{contact.img ? (
|
||||
<MuiAvatar src={contact.img} />
|
||||
): (
|
||||
<MuiAvatar>{contact.display.slice(0, 1)}</MuiAvatar>
|
||||
)}
|
||||
</ListItemAvatar>
|
||||
<ListItemText primary={contact.display} secondary={contact.number} />
|
||||
<Button onClick={() => startCall(contact.number)}>
|
||||
<PhoneIcon />
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() =>
|
||||
console.log("Message: " + contact.display, contact.number)
|
||||
}
|
||||
>
|
||||
<ChatIcon />
|
||||
</Button>
|
||||
<Button>
|
||||
<FontAwesomeIcon icon={faPen} size="lg"/>
|
||||
</Button>
|
||||
</ListItem>
|
||||
))}
|
||||
</List>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,95 @@
|
||||
import React, { useState } from 'react'
|
||||
import { InputBase } from "@material-ui/core";
|
||||
import SearchIcon from '@material-ui/icons/Search';
|
||||
import { createStyles, fade, Theme, makeStyles } from '@material-ui/core/styles';
|
||||
|
||||
import { useFilteredContacts } from '../../hooks/useFilteredContacts';
|
||||
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) =>
|
||||
createStyles({
|
||||
bg: {
|
||||
backgroundColor: "#232323",
|
||||
display: 'flex',
|
||||
height: 60,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center'
|
||||
},
|
||||
textFieldInput: {
|
||||
fontSize: 20
|
||||
},
|
||||
inputRoot: {
|
||||
color: '#fff',
|
||||
fontSize: 18
|
||||
},
|
||||
inputInput: {
|
||||
padding: theme.spacing(1, 4, 1, 4),
|
||||
// vertical padding + font size from searchIcon
|
||||
transition: theme.transitions.create('width'),
|
||||
width: '100%',
|
||||
|
||||
[theme.breakpoints.up('sm')]: {
|
||||
width: '13ch',
|
||||
'&:focus': {
|
||||
width: '20ch',
|
||||
},
|
||||
},
|
||||
},
|
||||
search: {
|
||||
position: 'relative',
|
||||
borderRadius: theme.shape.borderRadius,
|
||||
backgroundColor: fade(theme.palette.common.white, 0.15),
|
||||
'&:hover': {
|
||||
backgroundColor: fade(theme.palette.common.white, 0.25),
|
||||
},
|
||||
marginLeft: 0,
|
||||
width: '100%',
|
||||
[theme.breakpoints.up('sm')]: {
|
||||
marginLeft: theme.spacing(1),
|
||||
width: 'auto',
|
||||
},
|
||||
},
|
||||
searchIcon: {
|
||||
padding: theme.spacing(0, 0.5),
|
||||
height: '100%',
|
||||
position: 'absolute',
|
||||
pointerEvents: 'none',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
export const SearchContacts = () => {
|
||||
|
||||
const { setFilteredContacts } = useFilteredContacts();
|
||||
|
||||
const classes = useStyles();
|
||||
const [ searchValue, setSearchValue ] = useState('')
|
||||
|
||||
|
||||
const handleChange = (e) => {
|
||||
setSearchValue(e.target.value)
|
||||
setFilteredContacts(e.target.value)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={classes.bg}>
|
||||
<div className={classes.search}>
|
||||
<div className={classes.searchIcon}>
|
||||
<SearchIcon style={{ color: '#fff' }} />
|
||||
</div>
|
||||
<InputBase
|
||||
onChange={handleChange}
|
||||
placeholder="Search contacts..."
|
||||
classes={{
|
||||
root: classes.inputRoot,
|
||||
input: classes.inputInput
|
||||
}}
|
||||
inputProps={{ 'aria-label': 'search' }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -5,4 +5,12 @@ export const contactsState = {
|
||||
key: "contactsList",
|
||||
default: [],
|
||||
}),
|
||||
showModal: atom({
|
||||
key: 'showModal',
|
||||
default: false
|
||||
}),
|
||||
filterContacts: atom({
|
||||
key: 'filterContacts',
|
||||
default: ""
|
||||
})
|
||||
};
|
||||
@@ -5,6 +5,7 @@ interface Contact {
|
||||
id: string;
|
||||
display: string;
|
||||
number: string;
|
||||
img?: string
|
||||
}
|
||||
|
||||
interface IUseContacts {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import { useRecoilState } from 'recoil';
|
||||
import { contactsState } from './state';
|
||||
|
||||
export const useFilteredContacts = () => {
|
||||
const [ filteredContacts, setFilteredContacts ] = useRecoilState(contactsState.filterContacts);
|
||||
return { filteredContacts, setFilteredContacts };
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { useRecoilState } from 'recoil';
|
||||
import { contactsState } from './state';
|
||||
|
||||
export const useModal = () => {
|
||||
const [ showModal, setShowModal ] = useRecoilState(contactsState.showModal);
|
||||
return { showModal, setShowModal };
|
||||
}
|
||||
@@ -5,21 +5,17 @@ import {
|
||||
common,
|
||||
grey,
|
||||
green,
|
||||
orange,
|
||||
purple,
|
||||
red,
|
||||
amber,
|
||||
} from "@material-ui/core/colors";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { faAd } from "@fortawesome/free-solid-svg-icons";
|
||||
import { faAd, faPlaneArrival, faPhoneAlt, faLandmark } from "@fortawesome/free-solid-svg-icons";
|
||||
import { faTwitter } from '@fortawesome/free-brands-svg-icons'
|
||||
|
||||
import ContactsIcon from "@material-ui/icons/Contacts";
|
||||
import SettingsIcon from "@material-ui/icons/Settings";
|
||||
import PhoneIcon from "@material-ui/icons/Phone";
|
||||
import CalendarTodayIcon from "@material-ui/icons/CalendarToday";
|
||||
import AccountBalanceIcon from "@material-ui/icons/AccountBalance";
|
||||
import MessageIcon from "@material-ui/icons/Message";
|
||||
import TwitterIcon from "@material-ui/icons/Twitter";
|
||||
import { atom } from "recoil";
|
||||
import { CalculatorIcon } from "../../../apps/calculator/components/CalculatorIcon";
|
||||
import { Route } from "react-router-dom";
|
||||
@@ -40,18 +36,18 @@ const appsState = atom({
|
||||
{
|
||||
id: "DIALER",
|
||||
nameLocale: "APPS_DIALER",
|
||||
icon: <PhoneIcon />,
|
||||
backgroundColor: green[400],
|
||||
color: green[50],
|
||||
icon: <FontAwesomeIcon icon={faPhoneAlt} size="xs" />,
|
||||
backgroundColor: green[600],
|
||||
color: common.white,
|
||||
path: "/phone",
|
||||
Route: () => <Route path="/phone" component={DialerApp} />,
|
||||
},
|
||||
{
|
||||
id: "MESSAGES",
|
||||
nameLocale: "APPS_MESSAGES",
|
||||
icon: <MessageIcon />,
|
||||
backgroundColor: amber[400],
|
||||
color: amber[50],
|
||||
icon: <MessageIcon fontSize="default" />,
|
||||
backgroundColor: amber[700],
|
||||
color: common.white,
|
||||
path: "/messages",
|
||||
Route: () => <Route path="/messages" component={MessagesApp} />,
|
||||
},
|
||||
@@ -60,7 +56,7 @@ const appsState = atom({
|
||||
nameLocale: "APPS_CONTACTS",
|
||||
icon: <ContactsIcon />,
|
||||
backgroundColor: blue[500],
|
||||
color: blue[50],
|
||||
color: common.white,
|
||||
path: "/contacts",
|
||||
Route: () => <Route path="/contacts" component={ContactsApp} />,
|
||||
},
|
||||
@@ -85,16 +81,16 @@ const appsState = atom({
|
||||
{
|
||||
id: "BANK",
|
||||
nameLocale: "APPS_BANK",
|
||||
icon: <AccountBalanceIcon />,
|
||||
backgroundColor: orange[600],
|
||||
color: orange[50],
|
||||
icon: <FontAwesomeIcon icon={faLandmark} size="xs" />,
|
||||
backgroundColor: blue[900],
|
||||
color: common.white,
|
||||
path: "/bank",
|
||||
Route: () => <Route path="/bank" component={BankApp} />,
|
||||
},
|
||||
{
|
||||
id: "TWITTER",
|
||||
nameLocale: "APPS_TWITTER",
|
||||
icon: <TwitterIcon />,
|
||||
icon: <FontAwesomeIcon icon={faTwitter} fixedWidth size="xs"/>,
|
||||
backgroundColor: blue[600],
|
||||
color: common.white,
|
||||
path: "/twitter",
|
||||
@@ -112,7 +108,7 @@ const appsState = atom({
|
||||
{
|
||||
id: "EXAMPLE",
|
||||
nameLocale: "APPS_EXAMPLE",
|
||||
icon: <CalendarTodayIcon />,
|
||||
icon: <FontAwesomeIcon icon={faPlaneArrival} size="sm" />,
|
||||
backgroundColor: blue[500],
|
||||
color: blue[50],
|
||||
path: "/example",
|
||||
|
||||
Reference in new issue
Block a user