diff --git a/phone/src/apps/contacts/components/List/SearchContacts.tsx b/phone/src/apps/contacts/components/List/SearchContacts.tsx index 672fd7f..dc6be54 100644 --- a/phone/src/apps/contacts/components/List/SearchContacts.tsx +++ b/phone/src/apps/contacts/components/List/SearchContacts.tsx @@ -1,83 +1,22 @@ import React from 'react'; -import { InputBase } from '@material-ui/core'; -import SearchIcon from '@material-ui/icons/Search'; -import { createStyles, Theme, makeStyles } from '@material-ui/core/styles'; +import { Box } from '@material-ui/core'; import { useTranslation } from 'react-i18next'; import { useFilteredContacts } from '../../hooks/useFilteredContacts'; - -const useStyles = makeStyles((theme: Theme) => - createStyles({ - bg: { - backgroundColor: theme.palette.background.paper, - display: 'flex', - height: 60, - justifyContent: 'center', - alignItems: 'center', - }, - textFieldInput: { - fontSize: 20, - }, - inputRoot: { - fontSize: 18, - border: '1px solid', - borderColor: theme.palette.divider, - }, - inputInput: { - padding: theme.spacing(1, 4, 1, 4), - transition: theme.transitions.create('width'), - [theme.breakpoints.up('sm')]: { - width: '13ch', - '&:focus': { - width: '20ch', - }, - }, - }, - search: { - position: 'relative', - borderRadius: theme.shape.borderRadius, - 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', - }, - }), -); +import { SearchField } from '../../../../ui/components/SearchField'; export const SearchContacts = () => { - const { setFilteredContacts } = useFilteredContacts(); - const classes = useStyles(); + const { setFilteredContacts, filteredContacts } = useFilteredContacts(); const { t } = useTranslation(); return ( -
-
-
- -
- setFilteredContacts(e.target.value)} - placeholder={t('APPS_CONTACT_PLACEHOLDER_SEARCH_CONTACTS')} - classes={{ - root: classes.inputRoot, - input: classes.inputInput, - }} - inputProps={{ 'aria-label': 'search', autoFocus: true }} - /> -
-
+ + setFilteredContacts(e.target.value)} + placeholder={t('APPS_CONTACT_PLACEHOLDER_SEARCH_CONTACTS')} + value={filteredContacts} + /> + ); }; diff --git a/phone/src/apps/messages/components/MessagesApp.tsx b/phone/src/apps/messages/components/MessagesApp.tsx index 827e706..b32a49f 100644 --- a/phone/src/apps/messages/components/MessagesApp.tsx +++ b/phone/src/apps/messages/components/MessagesApp.tsx @@ -32,10 +32,7 @@ export const MessagesApp = () => { - <> - - history.push('/messages/new')} /> - + @@ -44,6 +41,9 @@ export const MessagesApp = () => { + + history.push('/messages/new')} /> + ); diff --git a/phone/src/apps/messages/components/form/MessageInput.tsx b/phone/src/apps/messages/components/form/MessageInput.tsx index 961ab3b..d0620f7 100644 --- a/phone/src/apps/messages/components/form/MessageInput.tsx +++ b/phone/src/apps/messages/components/form/MessageInput.tsx @@ -12,7 +12,7 @@ interface IProps { } const useStyles = makeStyles({ - root: { position: 'absolute', bottom: 0, width: '100%' }, + root: { width: '100%' }, }); const MessageInput = ({ messageGroupId, onAddImageClick }: IProps) => { diff --git a/phone/src/apps/messages/components/form/NewMessageGroupButton.tsx b/phone/src/apps/messages/components/form/NewMessageGroupButton.tsx index ca18c6b..38efde1 100644 --- a/phone/src/apps/messages/components/form/NewMessageGroupButton.tsx +++ b/phone/src/apps/messages/components/form/NewMessageGroupButton.tsx @@ -6,7 +6,7 @@ import { Fab } from '@material-ui/core'; const useStyles = makeStyles((theme) => ({ root: { position: 'absolute', - bottom: theme.spacing(2), + bottom: theme.spacing(5), right: theme.spacing(3), }, })); diff --git a/phone/src/apps/messages/components/list/MessageSearch.tsx b/phone/src/apps/messages/components/list/MessageSearch.tsx deleted file mode 100644 index a565854..0000000 --- a/phone/src/apps/messages/components/list/MessageSearch.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import React from 'react'; -import { useTranslation } from 'react-i18next'; -import { InputBase, Paper } from '@material-ui/core'; -import SearchIcon from '@material-ui/icons/Search'; - -import useStyles from './list.styles'; - -interface IProps { - value: string; - handleChange: (event: React.ChangeEvent) => void; -} - -const MessageSearch = ({ value, handleChange }: IProps) => { - const { t } = useTranslation(); - const classes = useStyles(); - return ( - -
-
- -
- -
-
- ); -}; - -export default MessageSearch; diff --git a/phone/src/apps/messages/components/list/MessagesList.tsx b/phone/src/apps/messages/components/list/MessagesList.tsx index dc6a380..7cbc401 100644 --- a/phone/src/apps/messages/components/list/MessagesList.tsx +++ b/phone/src/apps/messages/components/list/MessagesList.tsx @@ -1,17 +1,19 @@ import React, { useEffect, useState } from 'react'; -import { List } from '@material-ui/core'; +import { Box, List } from '@material-ui/core'; import { MessageGroup } from '../../../../common/typings/messages'; import Nui from '../../../../os/nui-events/utils/Nui'; import useMessages from '../../hooks/useMessages'; -import MessageSearch from './MessageSearch'; import MessageGroupItem from './MessageGroupItem'; import useStyles from './list.styles'; import { useHistory } from 'react-router-dom'; import { goToConversation } from '../../utils/goToConversation'; +import { SearchField } from '../../../../ui/components/SearchField'; +import { useTranslation } from 'react-i18next'; const MessagesList = (): any => { const classes = useStyles(); const history = useHistory(); + const { t } = useTranslation(); const { messageGroups, createMessageGroupResult, clearMessageGroupResult } = useMessages(); @@ -46,18 +48,28 @@ const MessagesList = (): any => { }; return ( - <> - setSearchValue(e.target.value)} /> - - {filteredGroups.map((messageGroup) => ( - - ))} - - + + + setSearchValue(e.target.value)} + placeholder={t('APPS_MESSAGES_SEARCH_PLACEHOLDER')} + /> + + + + + {filteredGroups.map((messageGroup) => ( + + ))} + + + + ); }; diff --git a/phone/src/apps/messages/components/list/list.styles.ts b/phone/src/apps/messages/components/list/list.styles.ts index fce8868..f960794 100644 --- a/phone/src/apps/messages/components/list/list.styles.ts +++ b/phone/src/apps/messages/components/list/list.styles.ts @@ -1,61 +1,10 @@ -import { makeStyles, fade } from '@material-ui/core'; +import { makeStyles } from '@material-ui/core'; const useStyles = makeStyles((theme) => ({ root: { - height: '100%', + height: '580px', overflowY: 'auto', }, - bg: { - display: 'flex', - height: 60, - justifyContent: 'center', - alignItems: 'center', - }, - textFieldInput: { - fontSize: 20, - }, - inputRoot: { - fontWeight: 400, - fontSize: 18, - border: '1px solid', - borderColor: theme.palette.divider, - }, - 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: '24ch', - }, - }, - }, - search: { - position: 'relative', - borderRadius: theme.shape.borderRadius, - backgroundColor: fade(theme.palette.common.white, 0.25), - '&: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 default useStyles; diff --git a/phone/src/apps/messages/components/modal/Conversation.tsx b/phone/src/apps/messages/components/modal/Conversation.tsx index a83e534..be661a4 100644 --- a/phone/src/apps/messages/components/modal/Conversation.tsx +++ b/phone/src/apps/messages/components/modal/Conversation.tsx @@ -30,15 +30,29 @@ const Conversation = ({ activeMessageGroup, messages, onClickDisplay }: IProps) isOpen={imageModalOpen} messageGroupId={activeMessageGroup.groupId} /> - - {messages.map((message) => ( - - ))} + + + {messages.map((message) => ( + + ))} + ({ + root: { + '&:first-child': { + marginTop: 'auto', + }, + }, imageMessage: { width: '80%', maxWidth: '80%', @@ -55,7 +60,7 @@ export const MessageBubble = ({ }) => { const classes = useStyles(); return ( -
+
{isImage(message.message) ? ( diff --git a/phone/src/apps/messages/components/modal/MessageModal.tsx b/phone/src/apps/messages/components/modal/MessageModal.tsx index 55ad6e2..07a4f16 100644 --- a/phone/src/apps/messages/components/modal/MessageModal.tsx +++ b/phone/src/apps/messages/components/modal/MessageModal.tsx @@ -82,13 +82,13 @@ export const MessageModal = () => { }, [groupId, setActiveMessageGroup]); useEffect(() => { - if (messages) { + if (isLoaded && messages) { const element = document.getElementById(CONVERSATION_ELEMENT_ID); if (element) { element.scrollTop = element.scrollHeight; } } - }, [messages]); + }, [isLoaded, messages]); // sends all unread messages useEffect(() => { diff --git a/phone/src/apps/messages/components/modal/modal.styles.ts b/phone/src/apps/messages/components/modal/modal.styles.ts index 364e4a1..c35ee8b 100644 --- a/phone/src/apps/messages/components/modal/modal.styles.ts +++ b/phone/src/apps/messages/components/modal/modal.styles.ts @@ -26,10 +26,9 @@ const useStyles = makeStyles({ bottom: '0', }, overflowAutoY: { - flex: 6, + height: '550px', overflowY: 'auto', overflowX: 'hidden', - justifyContent: 'end', }, groupdisplay: { width: '300px', diff --git a/phone/src/locale/en.json b/phone/src/locale/en.json index 666afb0..599974f 100644 --- a/phone/src/locale/en.json +++ b/phone/src/locale/en.json @@ -91,7 +91,7 @@ "APPS_CONTACT_UPDATE_FAILED": "Failed to update contact!", "APPS_CONTACT_DELETE_SUCCESS": "Successfully deleted contact!", "APPS_CONTACT_DELETE_FAILED": "Failed to delete contact!", - "APPS_CONTACT_PLACEHOLDER_SEARCH_CONTACTS": "Search contacts", + "APPS_CONTACT_PLACEHOLDER_SEARCH_CONTACTS": "Search contacts...", "APPS_CONTACT_MODAL_PLACEHOLDER_NAME": "Name", "APPS_CONTACT_MODAL_PLACEHOLDER_NUMBER": "Number", "APPS_CONTACT_MODAL_PLACEHOLDER_AVATAR": "Avatar", diff --git a/phone/src/ui/components/SearchField.tsx b/phone/src/ui/components/SearchField.tsx new file mode 100644 index 0000000..8d83097 --- /dev/null +++ b/phone/src/ui/components/SearchField.tsx @@ -0,0 +1,85 @@ +import React from 'react'; +import { emphasize, InputBase, makeStyles, Paper } from '@material-ui/core'; +import SearchIcon from '@material-ui/icons/Search'; + +const useStyles = makeStyles((theme) => ({ + bg: { + display: 'flex', + height: '60px', + justifyContent: 'center', + alignItems: 'center', + }, + textFieldInput: { + fontSize: 20, + }, + inputRoot: { + fontWeight: 400, + fontSize: 18, + border: '1px solid', + borderColor: theme.palette.divider, + }, + inputInput: { + padding: theme.spacing(1, 4, 1, 4), + // vertical padding + font size from searchIcon + transition: theme.transitions.create(['width', 'border']), + width: '16ch', + '&:focus': { + width: '24ch', + borderLeft: `2px solid ${theme.palette.primary.main} `, + }, + }, + search: { + position: 'relative', + borderRadius: theme.shape.borderRadius, + backgroundColor: emphasize(theme.palette.background.paper, 0.21), + '&:hover': { + backgroundColor: emphasize(theme.palette.background.paper, 0.28), + }, + marginLeft: theme.spacing(1), + width: 'auto', + }, + searchIcon: { + padding: theme.spacing(0, 0.7), + height: '100%', + position: 'absolute', + pointerEvents: 'none', + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + }, +})); + +interface IProps { + onChange: (event: React.ChangeEvent) => void; + value: string; + placeholder?: string; +} + +const DEFAULT_PROPS = { + onChange: () => {}, + value: '', + placeholder: 'Search...', +}; + +export const SearchField = ({ value, onChange, placeholder }: IProps = DEFAULT_PROPS) => { + const classes = useStyles(); + return ( + +
+
+ +
+ +
+
+ ); +};