From f81a1fa667bb2d6177317a18a471cdf78fe37f2b Mon Sep 17 00:00:00 2001 From: chip Date: Fri, 16 Oct 2020 18:30:59 +0200 Subject: [PATCH] Feat(Contacts): Added MuiAvatar for list - in new directoryt --- .../contacts/components/List/ContactList.tsx | 64 ++++++++++++++ .../components/List/SearchContacts.tsx | 83 +++++++++++++++++++ 2 files changed, 147 insertions(+) create mode 100644 phone/src/apps/contacts/components/List/ContactList.tsx create mode 100644 phone/src/apps/contacts/components/List/SearchContacts.tsx diff --git a/phone/src/apps/contacts/components/List/ContactList.tsx b/phone/src/apps/contacts/components/List/ContactList.tsx new file mode 100644 index 0000000..b968b86 --- /dev/null +++ b/phone/src/apps/contacts/components/List/ContactList.tsx @@ -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 ( + + {contacts.contacts.filter(contact => contact.display.includes(filteredContacts) || contact.number.includes(filteredContacts)).map((contact) => ( + + + {contact.img ? ( + + ): ( + {contact.display.slice(0, 1)} + )} + + + + + + + ))} + + ); +}; diff --git a/phone/src/apps/contacts/components/List/SearchContacts.tsx b/phone/src/apps/contacts/components/List/SearchContacts.tsx new file mode 100644 index 0000000..316c9e5 --- /dev/null +++ b/phone/src/apps/contacts/components/List/SearchContacts.tsx @@ -0,0 +1,83 @@ +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, 2, 1, 2), + // 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', + }, + }, + }) +); + +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 ( +
+
+ +
+
+ ) +}