Feat(Contacts): Added MuiAvatar for list - in new directoryt

This commit is contained in:
chip committed 2020-10-16 18:30:59 +02:00
1 parent 0f6b8ba0dc
commit f81a1fa667
2 files changed
+147

No files matched your search

@@ -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,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 (
<div className={classes.bg}>
<div className={classes.search}>
<InputBase
onChange={handleChange}
placeholder="Search contacts..."
classes={{
root: classes.inputRoot,
input: classes.inputInput
}}
inputProps={{ 'aria-label': 'search' }}
/>
</div>
</div>
)
}