diff --git a/phone/package.json b/phone/package.json index 1e7ba82..1e6e99a 100644 --- a/phone/package.json +++ b/phone/package.json @@ -25,7 +25,9 @@ "enzyme": "^3.11.0", "enzyme-adapter-react-16": "^1.15.5", "i18next": "^19.7.0", + "parse-url": "^5.0.2", "prettier": "^2.0.5", + "qs": "^6.9.6", "react": "^16.13.1", "react-dom": "^16.13.1", "react-hotkeys": "^2.0.0", @@ -45,8 +47,10 @@ "@babel/preset-react": "^7.0.0", "@types/enzyme": "^3.10.7", "@types/node": "^14.11.5", + "@types/qs": "^6.9.5", "@types/react": "^16.9.51", "@types/react-dom": "^16.9.8", + "@types/react-router-dom": "^5.1.7", "babel-eslint": "^10.0.1", "babel-loader": "^8.1.0", "babel-plugin-styled-components": "^1.10.0", diff --git a/phone/src/apps/bank/components/transfers/TransferModal.tsx b/phone/src/apps/bank/components/transfers/TransferModal.tsx index 39d430c..c23185a 100644 --- a/phone/src/apps/bank/components/transfers/TransferModal.tsx +++ b/phone/src/apps/bank/components/transfers/TransferModal.tsx @@ -7,7 +7,6 @@ import { TextField, makeStyles, } from '@material-ui/core'; -import CloseIcon from '@material-ui/icons/Close'; import Nui from '../../../../os/nui-events/utils/Nui'; @@ -33,11 +32,6 @@ const useStyles = makeStyles((theme) => ({ fontSize: 16, marginBottom: 30, }, - closeButton: { - position: 'absolute', - right: 0, - width: '10%', - }, })); export const TransferModal = () => { @@ -65,9 +59,6 @@ export const TransferModal = () => { return ( - { - const { modal } = usePhotoModal(); - return ( - - {/* - - - - - */} - {!modal ? : null} + + + + ); diff --git a/phone/src/apps/camera/components/grid/GalleryGrid.tsx b/phone/src/apps/camera/components/grid/GalleryGrid.tsx index 1a97bcd..b18d049 100644 --- a/phone/src/apps/camera/components/grid/GalleryGrid.tsx +++ b/phone/src/apps/camera/components/grid/GalleryGrid.tsx @@ -4,28 +4,30 @@ import useStyles from './grid.styles'; import { usePhotos } from '../../hooks/usePhotos'; import AddIcon from '@material-ui/icons/Add'; import Nui from '../../../../os/nui-events/utils/Nui'; -import { usePhotoModal } from '../../hooks/usePhotoModal'; -import { usePhotoMeta } from '../../hooks/usePhotoMeta'; +import { useHistory } from 'react-router-dom'; +import { useQueryParams } from '../../../../common/hooks/useQueryParams'; +import { addQueryToLocation } from '../../../../common/utils/addQueryToLocation'; +import { getLocationFromUrl } from '../../../../common/utils/getLocationFromUrl'; -// isMessage will work as a style handler kinda. If the gallery is rendered in the messages, -// it will have the value true, which basically means a tweak on the design to fit in a modal -export const GalleryGrid = (isMessags) => { +export const GalleryGrid = () => { const classes = useStyles(); + const history = useHistory(); + const query = useQueryParams(); - const { setMeta } = usePhotoMeta(); - const { setModal } = usePhotoModal(); + const referal = query.referal + ? decodeURIComponent(query.referal) + : '/camera/image'; const photos = usePhotos(); - console.log(photos); - const handleCamera = () => { Nui.send('phone:TakePhoto', {}); }; const handlePhotoOpen = (photo) => { - setModal(true); - setMeta(photo); + history.push( + addQueryToLocation(getLocationFromUrl(referal), 'image', photo.image) + ); }; if (!photos) @@ -66,7 +68,7 @@ export const GalleryGrid = (isMessags) => { {photos.map((photo) => ( - handlePhotoOpen(photo)}> + handlePhotoOpen(photo)}>
{ - const { meta, setMeta } = usePhotoMeta(); - const { modal, setModal } = usePhotoModal(); const classes = useStyles(); + const history = useHistory(); + const query = useQueryParams(); + const referal = query.referal || '/camera'; - const { shareModal, setShareModal } = useShareModal(); - const { setShareLink } = useShareLink(); + const [shareOpen, setShareOpen] = useState(null); + + const meta: ICameraPhoto = useMemo( + () => ({ id: query.id as string, image: query.image as string }), + [query] + ); const _handleClose = () => { - setModal(false); - setMeta(null); + history.push(referal); }; - const handleDeletePhoto = () => { - console.log(meta.id); + const handleDeletePhoto = useCallback(() => { Nui.send('photo:deletePhoto', { id: meta.id, }); - setModal(false); - }; + history.push(referal); + }, [history, meta.id, referal]); - const handleSharePhoto = () => { - setShareModal(true); - setShareLink(meta.image); - }; + const handleSharePhoto = useCallback(() => { + setShareOpen(meta); + }, [meta]); if (!meta) return null; return ( - - -
- -
-
- - -
- +
+
+ + +
+ + ); }; diff --git a/phone/src/apps/camera/components/modal/ShareModal.tsx b/phone/src/apps/camera/components/modal/ShareModal.tsx index e631e83..63493e2 100644 --- a/phone/src/apps/camera/components/modal/ShareModal.tsx +++ b/phone/src/apps/camera/components/modal/ShareModal.tsx @@ -1,46 +1,42 @@ import React from 'react'; import Modal from '../../../../ui/components/Modal'; -import { useShareLink } from '../../hooks/useShareLink'; -import { useShareModal } from '../../hooks/useShareModal'; import { Button } from '@material-ui/core'; import MessageIcon from '@material-ui/icons/Message'; import { setClipboard } from '../../../../os/phone/hooks/useClipboard'; -import CloseIcon from '@material-ui/icons/Close'; import useStyles from './modal.styles'; +import { ICameraPhoto } from '../../hooks/usePhotos'; +import { useHistory } from 'react-router-dom'; -export const ShareModal = (meta) => { +interface IShareModalProps { + meta: ICameraPhoto; + referal: string; + onClose(): void; +} + +export const ShareModal = ({ meta, onClose, referal }: IShareModalProps) => { const classes = useStyles(); - const { shareModal, setShareModal } = useShareModal(); - const { setShareLink } = useShareLink(); - - const _handleClose = () => { - setShareModal(false); - setShareLink(null); - }; + const history = useHistory(); const handleCopyImage = () => { setClipboard(meta.image); + history.push(referal); }; return ( - +
-
-

- Where do you want to share the photo? -

- -

Or just copy the image here:

- + <> +

+ Where do you want to share the photo? +

+ +

Or just copy the image here:

+ +
diff --git a/phone/src/apps/camera/hooks/state.ts b/phone/src/apps/camera/hooks/state.ts index 9305ab0..aa6495e 100644 --- a/phone/src/apps/camera/hooks/state.ts +++ b/phone/src/apps/camera/hooks/state.ts @@ -5,20 +5,4 @@ export const photoState = { key: 'galleryPhotos', default: null, }), - modal: atom({ - key: 'photoModal', - default: false, - }), - photoMeta: atom({ - key: 'photoMeta', - default: null, - }), - shareModal: atom({ - key: 'phoneShareModal', - default: false, - }), - shareLink: atom({ - key: 'photoShareLink', - default: null, - }), }; diff --git a/phone/src/apps/camera/hooks/usePhotoMeta.ts b/phone/src/apps/camera/hooks/usePhotoMeta.ts deleted file mode 100644 index ffc8dd5..0000000 --- a/phone/src/apps/camera/hooks/usePhotoMeta.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { useRecoilState } from 'recoil'; -import { photoState } from './state'; - -export const usePhotoMeta = () => { - const [meta, setMeta] = useRecoilState(photoState.photoMeta); - return { meta, setMeta }; -}; diff --git a/phone/src/apps/camera/hooks/usePhotoModal.ts b/phone/src/apps/camera/hooks/usePhotoModal.ts deleted file mode 100644 index df44ef0..0000000 --- a/phone/src/apps/camera/hooks/usePhotoModal.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { useRecoilState } from 'recoil'; -import { photoState } from './state'; - -export const usePhotoModal = () => { - const [modal, setModal] = useRecoilState(photoState.modal); - return { modal, setModal }; -}; diff --git a/phone/src/apps/camera/hooks/usePhotos.ts b/phone/src/apps/camera/hooks/usePhotos.ts index c38c047..1bee938 100644 --- a/phone/src/apps/camera/hooks/usePhotos.ts +++ b/phone/src/apps/camera/hooks/usePhotos.ts @@ -1,13 +1,11 @@ import { useRecoilValue } from 'recoil'; import { photoState } from './state'; -interface IPhotos { - image: string[]; - - map?: any; +export interface ICameraPhoto { + id: string; + image: string; } -export const usePhotos = (): IPhotos | null => { - const photos = useRecoilValue(photoState.photos); - return photos; +export const usePhotos = (): ICameraPhoto[] | null => { + return useRecoilValue(photoState.photos); }; diff --git a/phone/src/apps/camera/hooks/useShareLink.ts b/phone/src/apps/camera/hooks/useShareLink.ts deleted file mode 100644 index 9d79d13..0000000 --- a/phone/src/apps/camera/hooks/useShareLink.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { useRecoilState } from 'recoil'; -import { photoState } from './state'; - -export const useShareLink = () => { - const [shareLink, setShareLink] = useRecoilState(photoState.shareLink); - return { shareLink, setShareLink }; -}; diff --git a/phone/src/apps/camera/hooks/useShareModal.ts b/phone/src/apps/camera/hooks/useShareModal.ts deleted file mode 100644 index 09a95f8..0000000 --- a/phone/src/apps/camera/hooks/useShareModal.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { useRecoilState } from 'recoil'; -import { photoState } from './state'; - -interface ShareModalProps { - shareModal: boolean; - setShareModal: (show: boolean) => void; -} - -export const useShareModal = (): ShareModalProps => { - const [ shareModal, setShareModal ] = useRecoilState(photoState.shareModal); - return { shareModal, setShareModal } -} diff --git a/phone/src/apps/contacts/components/ContactModal.tsx b/phone/src/apps/contacts/components/ContactModal.tsx index ce8b8f3..994c4da 100644 --- a/phone/src/apps/contacts/components/ContactModal.tsx +++ b/phone/src/apps/contacts/components/ContactModal.tsx @@ -5,7 +5,6 @@ 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'; @@ -41,9 +40,6 @@ export const AddContactModal = () => { return ( - diff --git a/phone/src/apps/messages/components/MessagesApp.tsx b/phone/src/apps/messages/components/MessagesApp.tsx index 56e19fc..8b1b67f 100644 --- a/phone/src/apps/messages/components/MessagesApp.tsx +++ b/phone/src/apps/messages/components/MessagesApp.tsx @@ -1,25 +1,67 @@ +import './messages.css'; import React from 'react'; import { AppWrapper } from '../../../ui/components'; import { AppTitle } from '../../../ui/components/AppTitle'; import { AppContent } from '../../../ui/components/AppContent'; import { useApp } from '../../../os/apps/hooks/useApps'; import AlertBar from './AlertBar'; -import { MessageModal } from './modal/MessageModal'; import MessageGroupModal from './modal/MessageGroupModal'; -import NewMessageGroupButton from './buttons/NewMessageGroupButton'; import MessagesList from './list/MessagesList'; -import './messages.css'; +import { Route, Switch } from 'react-router-dom'; +import { MessageModal } from './modal/MessageModal'; +import InjectDebugData from '../../../os/debug/InjectDebugData'; + +InjectDebugData([ + { + app: 'MESSAGES', + method: 'phone:fetchMessagesSuccess', + data: [ + { + id: 1, + message: 'sup!', + user_identifier: '1234', + phone_number: '444-4444', + display: 'kidz', + avatar: null, + isRead: true, + isMine: false, + updatedAt: Date.now(), + }, + ], + }, + { + app: 'MESSAGES', + method: 'phone:fetchMessageGroupsSuccess', + data: [ + { + groupId: '2', + groupDisplay: 'dev-chat', + isGroupChat: true, + avatar: null, + label: null, + updatedAt: Date.now(), + }, + ], + }, +]); export const MessagesApp = () => { const messages = useApp('MESSAGES'); return ( - - - - + + + + + + + diff --git a/phone/src/apps/messages/components/buttons/NewMessageGroupButton.tsx b/phone/src/apps/messages/components/buttons/NewMessageGroupButton.tsx index 2504a3d..5e09974 100644 --- a/phone/src/apps/messages/components/buttons/NewMessageGroupButton.tsx +++ b/phone/src/apps/messages/components/buttons/NewMessageGroupButton.tsx @@ -2,7 +2,6 @@ import React from 'react'; import { makeStyles } from '@material-ui/core/styles'; import { Fab } from '@material-ui/core'; import AddIcon from '@material-ui/icons/Add'; -import useModals from '../../hooks/useModals'; const useStyles = makeStyles(() => ({ root: { @@ -12,15 +11,18 @@ const useStyles = makeStyles(() => ({ }, })); -export function NewMessageGroupButton() { - const classes = useStyles(); - const { setShowNewMessageGroup } = useModals(); +interface INewMessageGroupButtonProps { + onClick(): void; +} - const handleClick = () => setShowNewMessageGroup(true); +export function NewMessageGroupButton({ + onClick, +}: INewMessageGroupButtonProps) { + const classes = useStyles(); return (
- +
diff --git a/phone/src/apps/messages/components/form/MessageInput.tsx b/phone/src/apps/messages/components/form/MessageInput.tsx index b83c5de..60af078 100644 --- a/phone/src/apps/messages/components/form/MessageInput.tsx +++ b/phone/src/apps/messages/components/form/MessageInput.tsx @@ -5,14 +5,13 @@ import useStyles from './form.styles'; import SendIcon from '@material-ui/icons/Send'; import ImageIcon from '@material-ui/icons/Image'; import Nui from '../../../../os/nui-events/utils/Nui'; -import { useImageModal } from '../../hooks/useImageModal'; interface IProps { + onAddImageClick(): void; messageGroupId: string | undefined; } -const MessageInput = ({ messageGroupId }: IProps) => { - const { setImageModal } = useImageModal(); +const MessageInput = ({ messageGroupId, onAddImageClick }: IProps) => { const classes = useStyles(); const { t } = useTranslation(); const [message, setMessage] = useState(''); @@ -29,10 +28,6 @@ const MessageInput = ({ messageGroupId }: IProps) => { } }; - const openImageModal = () => { - setImageModal(true); - }; - if (!messageGroupId) return null; return ( @@ -48,7 +43,7 @@ const MessageInput = ({ messageGroupId }: IProps) => { className: classes.messagesInput, }} /> - diff --git a/phone/src/apps/messages/components/modal/MessageImageModal.tsx b/phone/src/apps/messages/components/modal/MessageImageModal.tsx index 881a3c6..e5ecefb 100644 --- a/phone/src/apps/messages/components/modal/MessageImageModal.tsx +++ b/phone/src/apps/messages/components/modal/MessageImageModal.tsx @@ -1,55 +1,128 @@ -import { TextField, Button } from '@material-ui/core'; -import React, { useState } from 'react'; +import React, { useCallback, useEffect, useMemo, useState } from 'react'; +import qs from 'qs'; import Nui from '../../../../os/nui-events/utils/Nui'; import Modal from '../../../../ui/components/Modal'; -import { useImageModal } from '../../hooks/useImageModal'; -import CloseIcon from '@material-ui/icons/Close'; +import PhotoLibraryIcon from '@material-ui/icons/PhotoLibrary'; +import { Box, Button, TextField, Typography } from '@material-ui/core'; +import FileCopyIcon from '@material-ui/icons/FileCopy'; import useStyles from './modal.styles'; +import { useHistory, useLocation } from 'react-router-dom'; +import { ContextMenu } from '../../../../ui/components/ContextMenu'; +import { deleteQueryFromLocation } from '../../../../common/utils/deleteQueryFromLocation'; +import { PictureResponsive } from '../../../../ui/components/PictureResponsive'; interface IProps { + isOpen: boolean; messageGroupId: string | undefined; + onClose(): void; + image?: string; } -export const MessageImageModal = ({ messageGroupId }: IProps) => { +export const MessageImageModal = ({ + isOpen, + messageGroupId, + onClose, + image, +}: IProps) => { const classes = useStyles(); - const { imageModal, setImageModal } = useImageModal(); + const history = useHistory(); + const { pathname, search } = useLocation(); + const [message, setMessage] = useState(''); + const [pasteVisible, setPasteVisible] = useState(false); + const [queryParamImagePreview, setQueryParamImagePreview] = useState(null); - const _handleClose = () => { - setImageModal(false); - }; - - const sendImageMessage = (event) => { - if (event.key === 'Enter') { + const sendImageMessage = useCallback( + (m) => { Nui.send('phone:sendMessage', { groupId: messageGroupId, - message, + message: m, }); - setImageModal(false); + onClose(); + }, + [messageGroupId, onClose] + ); + + const sendFromQueryParam = useCallback( + (image) => { + setQueryParamImagePreview(null); + sendImageMessage(image); + + console.log('++++', { pathname, search }); + history.replace(deleteQueryFromLocation({ pathname, search }, 'image')); + }, + [history, pathname, search, sendImageMessage] + ); + + useEffect(() => { + if (!image) return; + setQueryParamImagePreview(image); + }, [image, sendFromQueryParam]); + + const sendFromClipboard = (event) => { + if (event.key === 'Enter') { + sendImageMessage(message); } }; + const menuOptions = useMemo( + () => [ + { + label: 'Paste from clipboard', + icon: , + onClick: () => setPasteVisible(true), + }, + { + label: 'Camera / Gallery', + icon: , + onClick: () => + history.push( + `/camera?${qs.stringify({ + referal: encodeURIComponent(pathname + search), + })}` + ), + }, + ], + [history, pathname, search] + ); + return ( - -
- - setMessage(e.target.value)} - value={message} - className={classes.input} - inputProps={{ - className: classes.messagesInput, - }} - inputRef={(input) => input && input.focus()} - onKeyPress={sendImageMessage} - /> -
-
+ <> + + setQueryParamImagePreview(null)} + > + + Do you want to share this image? + + + + + setPasteVisible(false)}> +
+ setMessage(e.target.value)} + value={message} + className={classes.input} + inputProps={{ + className: classes.messagesInput, + }} + inputRef={(input) => input && input.focus()} + onKeyPress={sendFromClipboard} + /> +
+
+ ); }; diff --git a/phone/src/apps/messages/components/modal/MessageModal.tsx b/phone/src/apps/messages/components/modal/MessageModal.tsx index 40bdfca..d979b01 100644 --- a/phone/src/apps/messages/components/modal/MessageModal.tsx +++ b/phone/src/apps/messages/components/modal/MessageModal.tsx @@ -4,10 +4,12 @@ import ArrowBackIcon from '@material-ui/icons/ArrowBack'; import useStyles from './modal.styles'; import useMessages from '../../hooks/useMessages'; -import useModals from '../../hooks/useModals'; import Conversation, { CONVERSATION_ELEMENT_ID } from './Conversation'; import MessageSkeletonList from './MessageSkeletonList'; import Nui from '../../../../os/nui-events/utils/Nui'; +import { useQueryParams } from '../../../../common/hooks/useQueryParams'; +import { MessageGroup } from '../../../../common/typings/messages'; +import { useHistory, useParams } from 'react-router-dom'; const LARGE_HEADER_CHARS = 30; const MAX_HEADER_CHARS = 80; @@ -16,27 +18,29 @@ const MESSAGES_REFRESH_RATE = 5000; export const MessageModal = () => { const classes = useStyles(); + const history = useHistory(); + const activeMessageGroup = useQueryParams(); + const { groupId } = useParams<{ groupId: string }>(); const { messages, setMessages } = useMessages(); const [minimumLoadPassed, setMimimumLoadPassed] = useState(false); - const { activeMessageGroup, setActiveMessageGroup } = useModals(); const closeModal = () => { - setActiveMessageGroup(null); + history.push('/messages'); setMessages(null); setMimimumLoadPassed(false); }; useEffect(() => { - if (!activeMessageGroup?.groupId) return; + if (!groupId) return; const timeout = window.setTimeout(() => { setMimimumLoadPassed(true); }, MINIMUM_LOAD_TIME); const interval = window.setInterval(() => { - if (!activeMessageGroup) return; + if (!groupId) return; Nui.send('phone:fetchMessages', { - groupId: activeMessageGroup.groupId, + groupId, }); }, MESSAGES_REFRESH_RATE); @@ -44,7 +48,7 @@ export const MessageModal = () => { window.clearInterval(interval); window.clearTimeout(timeout); }; - }, [activeMessageGroup]); + }, [groupId]); useEffect(() => { // when we get a new message group we should scroll to the @@ -61,7 +65,6 @@ export const MessageModal = () => { // there isn't a quick flash of loading and immediately // another flash to the tweets screen. const hasLoaded = messages && minimumLoadPassed; - const isOpen = activeMessageGroup !== null; // don't allow too many characters, it takes too much room let header = activeMessageGroup ? activeMessageGroup.groupDisplay : ''; @@ -77,8 +80,8 @@ export const MessageModal = () => { : classes.groupdisplay; return ( - - + + (); + */ +export function useQueryParams>() { + return qs.parse(useLocation().search, { ignoreQueryPrefix: true }) as T & + Partial; +} diff --git a/phone/src/common/utils/addQueryToLocation.ts b/phone/src/common/utils/addQueryToLocation.ts new file mode 100644 index 0000000..3fdb312 --- /dev/null +++ b/phone/src/common/utils/addQueryToLocation.ts @@ -0,0 +1,19 @@ +import qs from 'qs'; +import url from 'parse-url'; + +interface IRouterLocation { + pathname: string; + search: string; +} + +export const addQueryToLocation = ( + { pathname = '', search = '' }: Record & IRouterLocation, + key = '', + value = '' +) => { + const { query } = url(pathname + search); + return `${pathname}?${qs.stringify({ + ...query, + [key]: value, + })}`; +}; diff --git a/phone/src/common/utils/deleteQueryFromLocation.ts b/phone/src/common/utils/deleteQueryFromLocation.ts new file mode 100644 index 0000000..bc27156 --- /dev/null +++ b/phone/src/common/utils/deleteQueryFromLocation.ts @@ -0,0 +1,18 @@ +import qs from 'qs'; +import url from 'parse-url'; + +interface IRouterLocation { + pathname: string; + search: any; +} + +export const deleteQueryFromLocation = ( + location: Record & IRouterLocation, + key = '' +) => { + const { query } = url(location.pathname + location.search); + return `${location.pathname}/?${qs.stringify({ + ...query, + [key]: undefined, + })}`; +}; diff --git a/phone/src/common/utils/getLocationFromUrl.ts b/phone/src/common/utils/getLocationFromUrl.ts new file mode 100644 index 0000000..476d5f6 --- /dev/null +++ b/phone/src/common/utils/getLocationFromUrl.ts @@ -0,0 +1,7 @@ +import parseUrl from 'parse-url'; + +export const getLocationFromUrl = (url: String) => { + const { pathname, search } = parseUrl(url); + const searchStr = '?' + (search || ''); + return { pathname, search: searchStr }; +}; diff --git a/phone/src/os/apps/hooks/useApps.tsx b/phone/src/os/apps/hooks/useApps.tsx index f79001e..76da56c 100644 --- a/phone/src/os/apps/hooks/useApps.tsx +++ b/phone/src/os/apps/hooks/useApps.tsx @@ -59,6 +59,7 @@ const appsState = atom({ backgroundColor: amber[700], color: common.white, path: '/messages', + sharePath: '/messages/new', Route: () => , }, { diff --git a/phone/src/ui/components/ContextMenu.tsx b/phone/src/ui/components/ContextMenu.tsx index a148c72..9a26a31 100644 --- a/phone/src/ui/components/ContextMenu.tsx +++ b/phone/src/ui/components/ContextMenu.tsx @@ -18,7 +18,19 @@ const useStyles = makeStyles((theme) => ({ }, })); -export const ContextMenu = ({ open, onClose, options }) => { +interface IContextMenuProps { + open: boolean; + onClose(): void; + options: Array<{ + onClick(e, option): void; + label: string; + selected?: boolean; + icon?: React.ReactNode; + key?: string; + }>; +} + +export const ContextMenu = ({ open, onClose, options }: IContextMenuProps) => { const classes = useStyles(); return ( diff --git a/phone/src/ui/components/Modal.tsx b/phone/src/ui/components/Modal.tsx index 1b977d3..aeb92c9 100644 --- a/phone/src/ui/components/Modal.tsx +++ b/phone/src/ui/components/Modal.tsx @@ -1,9 +1,11 @@ import React, { useEffect } from 'react'; +import CloseIcon from '@material-ui/icons/Close'; import { makeStyles } from '@material-ui/core/styles'; -import { Paper } from '@material-ui/core'; +import { Button, Paper } from '@material-ui/core'; const useStyles = makeStyles(() => ({ root: { + padding: '24px', zIndex: 10, background: '#424242', marginTop: '15px', @@ -24,6 +26,12 @@ const useStyles = makeStyles(() => ({ displayNone: { display: 'none', }, + imageModalCloseButton: { + position: 'absolute', + right: 0, + top: 0, + width: '10%', + }, })); export const Modal = ({ children, visible, handleClose }) => { @@ -48,7 +56,12 @@ export const Modal = ({ children, visible, handleClose }) => { return (
- {children} + + + {children} +
); }; diff --git a/phone/yarn.lock b/phone/yarn.lock index b8f6449..1598c19 100644 --- a/phone/yarn.lock +++ b/phone/yarn.lock @@ -1893,6 +1893,11 @@ "@types/minimatch" "*" "@types/node" "*" +"@types/history@*": + version "4.7.8" + resolved "https://registry.yarnpkg.com/@types/history/-/history-4.7.8.tgz#49348387983075705fe8f4e02fb67f7daaec4934" + integrity sha512-S78QIYirQcUoo6UJZx9CSP0O2ix9IaeAXwQi26Rhr/+mg7qqPy8TzaxHSUut7eGjL8WmLccT7/MXf304WjqHcA== + "@types/html-minifier-terser@^5.0.0": version "5.1.1" resolved "https://registry.yarnpkg.com/@types/html-minifier-terser/-/html-minifier-terser-5.1.1.tgz#3c9ee980f1a10d6021ae6632ca3e79ca2ec4fb50" @@ -1973,6 +1978,11 @@ resolved "https://registry.yarnpkg.com/@types/q/-/q-1.5.4.tgz#15925414e0ad2cd765bfef58842f7e26a7accb24" integrity sha512-1HcDas8SEj4z1Wc696tH56G8OlRaH/sqZOynNNB+HF0WOeXPaxTtbYzJY2oEfiUxjSKjhCKr+MvR7dCHcEelug== +"@types/qs@^6.9.5": + version "6.9.5" + resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.5.tgz#434711bdd49eb5ee69d90c1d67c354a9a8ecb18b" + integrity sha512-/JHkVHtx/REVG0VVToGRGH2+23hsYLHdyG+GrvoUGlGAd0ErauXDyvHtRI/7H7mzLm+tBCKA7pfcpkQ1lf58iQ== + "@types/react-dom@*", "@types/react-dom@^16.9.8": version "16.9.8" resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.9.8.tgz#fe4c1e11dfc67155733dfa6aa65108b4971cb423" @@ -1980,6 +1990,23 @@ dependencies: "@types/react" "*" +"@types/react-router-dom@^5.1.7": + version "5.1.7" + resolved "https://registry.yarnpkg.com/@types/react-router-dom/-/react-router-dom-5.1.7.tgz#a126d9ea76079ffbbdb0d9225073eb5797ab7271" + integrity sha512-D5mHD6TbdV/DNHYsnwBTv+y73ei+mMjrkGrla86HthE4/PVvL1J94Bu3qABU+COXzpL23T1EZapVVpwHuBXiUg== + dependencies: + "@types/history" "*" + "@types/react" "*" + "@types/react-router" "*" + +"@types/react-router@*": + version "5.1.11" + resolved "https://registry.yarnpkg.com/@types/react-router/-/react-router-5.1.11.tgz#b01ce4cb21bf7d6b32edc862fc1e2c0088044b5b" + integrity sha512-ofHbZMlp0Y2baOHgsWBQ4K3AttxY61bDMkwTiBOkPg7U6C/3UwwB5WaIx28JmSVi/eX3uFEMRo61BV22fDQIvg== + dependencies: + "@types/history" "*" + "@types/react" "*" + "@types/react-transition-group@^4.2.0": version "4.4.0" resolved "https://registry.yarnpkg.com/@types/react-transition-group/-/react-transition-group-4.4.0.tgz#882839db465df1320e4753e6e9f70ca7e9b4d46d" @@ -6876,6 +6903,13 @@ is-root@2.1.0: resolved "https://registry.yarnpkg.com/is-root/-/is-root-2.1.0.tgz#809e18129cf1129644302a4f8544035d51984a9c" integrity sha512-AGOriNp96vNBd3HtU+RzFEc75FfR5ymiYv8E553I71SCeXBiMsVDUtdio1OEFvrPyLIQ9tVR5RxXIFe5PUFjMg== +is-ssh@^1.3.0: + version "1.3.2" + resolved "https://registry.yarnpkg.com/is-ssh/-/is-ssh-1.3.2.tgz#a4b82ab63d73976fd8263cceee27f99a88bdae2b" + integrity sha512-elEw0/0c2UscLrNG+OAorbP539E3rhliKPg+hDMWN9VwrDXfYK+4PBEykDPfxlYYtQvl84TascnQyobfQLHEhQ== + dependencies: + protocols "^1.1.0" + is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" @@ -8564,7 +8598,7 @@ normalize-url@1.9.1: query-string "^4.1.0" sort-keys "^1.0.0" -normalize-url@^3.0.0: +normalize-url@^3.0.0, normalize-url@^3.3.0: version "3.3.0" resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-3.3.0.tgz#b2e1c4dc4f7c6d57743df733a4f5978d18650559" integrity sha512-U+JJi7duF1o+u2pynbp2zXDW2/PADgC30f0GsHZtRh+HOcXHnw137TrNlyxxRvWW5fjKd3bcLHPxofWuCjaeZg== @@ -8977,6 +9011,26 @@ parse-passwd@^1.0.0: resolved "https://registry.yarnpkg.com/parse-passwd/-/parse-passwd-1.0.0.tgz#6d5b934a456993b23d37f40a382d6f1666a8e5c6" integrity sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY= +parse-path@^4.0.0: + version "4.0.3" + resolved "https://registry.yarnpkg.com/parse-path/-/parse-path-4.0.3.tgz#82d81ec3e071dcc4ab49aa9f2c9c0b8966bb22bf" + integrity sha512-9Cepbp2asKnWTJ9x2kpw6Fe8y9JDbqwahGCTvklzd/cEq5C5JC59x2Xb0Kx+x0QZ8bvNquGO8/BWP0cwBHzSAA== + dependencies: + is-ssh "^1.3.0" + protocols "^1.4.0" + qs "^6.9.4" + query-string "^6.13.8" + +parse-url@^5.0.2: + version "5.0.2" + resolved "https://registry.yarnpkg.com/parse-url/-/parse-url-5.0.2.tgz#856a3be1fcdf78dc93fc8b3791f169072d898b59" + integrity sha512-Czj+GIit4cdWtxo3ISZCvLiUjErSo0iI3wJ+q9Oi3QuMYTI6OZu+7cewMWZ+C1YAnKhYTk6/TLuhIgCypLthPA== + dependencies: + is-ssh "^1.3.0" + normalize-url "^3.3.0" + parse-path "^4.0.0" + protocols "^1.4.0" + parse5@4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/parse5/-/parse5-4.0.0.tgz#6d78656e3da8d78b4ec0b906f7c08ef1dfe3f608" @@ -10018,6 +10072,11 @@ prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2, prop-types@^15.7.2: object-assign "^4.1.1" react-is "^16.8.1" +protocols@^1.1.0, protocols@^1.4.0: + version "1.4.8" + resolved "https://registry.yarnpkg.com/protocols/-/protocols-1.4.8.tgz#48eea2d8f58d9644a4a32caae5d5db290a075ce8" + integrity sha512-IgjKyaUSjsROSO8/D49Ab7hP8mJgTYcqApOqdPhLoPxAplXmkp+zRvsrSQjFn5by0rhm4VH0GAUELIPpx7B1yg== + proxy-addr@~2.0.5: version "2.0.6" resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.6.tgz#fdc2336505447d3f2f2c638ed272caf614bbb2bf" @@ -10098,6 +10157,11 @@ qs@6.7.0: resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc" integrity sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ== +qs@^6.9.4, qs@^6.9.6: + version "6.9.6" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.9.6.tgz#26ed3c8243a431b2924aca84cc90471f35d5a0ee" + integrity sha512-TIRk4aqYLNoJUbd+g2lEdz5kLWIuTMRagAXxl78Q0RiVjAOugHmeKNGdd3cwo/ktpf9aL9epCfFqWDEKysUlLQ== + qs@~6.5.2: version "6.5.2" resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" @@ -10111,6 +10175,15 @@ query-string@^4.1.0: object-assign "^4.1.0" strict-uri-encode "^1.0.0" +query-string@^6.13.8: + version "6.13.8" + resolved "https://registry.yarnpkg.com/query-string/-/query-string-6.13.8.tgz#8cf231759c85484da3cf05a851810d8e825c1159" + integrity sha512-jxJzQI2edQPE/NPUOusNjO/ZOGqr1o2OBa/3M00fU76FsLXDVbJDv/p7ng5OdQyorKrkRz1oqfwmbe5MAMePQg== + dependencies: + decode-uri-component "^0.2.0" + split-on-first "^1.0.0" + strict-uri-encode "^2.0.0" + querystring-es3@^0.2.0: version "0.2.1" resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73" @@ -11386,6 +11459,11 @@ spdy@^4.0.2: select-hose "^2.0.0" spdy-transport "^3.0.0" +split-on-first@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/split-on-first/-/split-on-first-1.1.0.tgz#f610afeee3b12bce1d0c30425e76398b78249a5f" + integrity sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw== + split-string@^3.0.1, split-string@^3.0.2: version "3.1.0" resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2" @@ -11500,6 +11578,11 @@ strict-uri-encode@^1.0.0: resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713" integrity sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM= +strict-uri-encode@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546" + integrity sha1-ucczDHBChi9rFC3CdLvMWGbONUY= + string-argv@0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/string-argv/-/string-argv-0.3.1.tgz#95e2fbec0427ae19184935f816d74aaa4c5c19da"