|
@@ -1,9 +1,15 @@
|
|
|
|
|
|
import { makeStyles } from '@material-ui/core'
|
|
import { makeStyles } from '@material-ui/core'
|
|
-import { useState } from 'react';
|
|
|
|
|
|
+import { useState,useRef } from 'react';
|
|
import ImageListItem from '@mui/material/ImageListItem';
|
|
import ImageListItem from '@mui/material/ImageListItem';
|
|
import DownloadForOfflineIcon from '@mui/icons-material/DownloadForOffline';
|
|
import DownloadForOfflineIcon from '@mui/icons-material/DownloadForOffline';
|
|
-import { handleDownload,timeStampEU,prodAwsS3 } from '../../../../../../helpers'
|
|
|
|
|
|
+import ListItemText from '@mui/material/ListItemText';
|
|
|
|
+import ListItemIcon from '@mui/material/ListItemIcon';
|
|
|
|
+import Avatar from '@mui/material/Avatar';
|
|
|
|
+import ZoomOutIcon from '@mui/icons-material/ZoomOut';
|
|
|
|
+import ZoomInIcon from '@mui/icons-material/ZoomIn';
|
|
|
|
+import CloseIcon from '@mui/icons-material/Close';
|
|
|
|
+import { handleDownload, timeStampEU, prodAwsS3,firstLetter, slicedWord } from '../../../../../../helpers'
|
|
|
|
|
|
const useStyles = makeStyles({
|
|
const useStyles = makeStyles({
|
|
overlay: {
|
|
overlay: {
|
|
@@ -14,24 +20,49 @@ const useStyles = makeStyles({
|
|
height: '100vh',
|
|
height: '100vh',
|
|
zIndex: 100,
|
|
zIndex: 100,
|
|
backgroundColor: 'rgba(104, 105, 104, 0.6)',
|
|
backgroundColor: 'rgba(104, 105, 104, 0.6)',
|
|
- overflowY: 'hidden',
|
|
|
|
|
|
+ overflow: 'auto',
|
|
boxSizing: 'border-box',
|
|
boxSizing: 'border-box',
|
|
display: 'flex',
|
|
display: 'flex',
|
|
justifyContent: 'center',
|
|
justifyContent: 'center',
|
|
alignContent: 'center',
|
|
alignContent: 'center',
|
|
alignItems: 'center'
|
|
alignItems: 'center'
|
|
},
|
|
},
|
|
- wrapper: {
|
|
|
|
- width: '30%',
|
|
|
|
- maxHeight: '80%',
|
|
|
|
- position: 'relative',
|
|
|
|
|
|
+ topBar: {
|
|
|
|
+ position: 'fixed',
|
|
|
|
+ top: 0,
|
|
|
|
+ left: 0,
|
|
|
|
+ height: '7vh',
|
|
|
|
+ width: '100vw',
|
|
display: 'flex',
|
|
display: 'flex',
|
|
|
|
+ alignContent: 'center',
|
|
|
|
+ alignItems: 'center',
|
|
|
|
+ justifyContent: 'space-between',
|
|
|
|
+ backgroundColor: 'rgba(65, 65, 65, 0.9)',
|
|
|
|
+ zIndex: 10,
|
|
|
|
+ padding: '0px 20px'
|
|
},
|
|
},
|
|
|
|
+ wrapperCredentials: {
|
|
|
|
+ display: 'flex',
|
|
|
|
+ alignContent: 'center',
|
|
|
|
+ alignItems: 'center',
|
|
|
|
+ },
|
|
|
|
+ wrapperIcons: {
|
|
|
|
+ display: 'flex',
|
|
|
|
+ alignContent: 'center',
|
|
|
|
+ alignItems: 'center',
|
|
|
|
+ },
|
|
|
|
+ magnifying : {
|
|
|
|
+ marginLeft:5,
|
|
|
|
+ cursor: 'pointer',
|
|
|
|
+ color: '#e9e7e7',
|
|
|
|
+ padding: 0,
|
|
|
|
+ '&:hover': {
|
|
|
|
+ color: '#ffffff',
|
|
|
|
+ transform: 'scale(1.1)'
|
|
|
|
+ }
|
|
|
|
+ },
|
|
downloadIcon: {
|
|
downloadIcon: {
|
|
- position: 'absolute',
|
|
|
|
- content: '',
|
|
|
|
- right: 0,
|
|
|
|
- top: -40,
|
|
|
|
|
|
+ marginLeft:5,
|
|
cursor: 'pointer',
|
|
cursor: 'pointer',
|
|
color: '#e9e7e7',
|
|
color: '#e9e7e7',
|
|
padding: 0,
|
|
padding: 0,
|
|
@@ -41,22 +72,33 @@ const useStyles = makeStyles({
|
|
color: '#b8b7b7',
|
|
color: '#b8b7b7',
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ iconCloseOverlay: {
|
|
|
|
+ marginLeft:5,
|
|
|
|
+ cursor: 'pointer',
|
|
|
|
+ color: '#e9e7e7',
|
|
|
|
+ padding: 0,
|
|
|
|
+ '&:hover': {
|
|
|
|
+ color: '#ffffff',
|
|
|
|
+ transform: 'rotate(180deg)',
|
|
|
|
+ transition: 'all 250ms ease-out ',
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ wrapperImage: {
|
|
|
|
+ borderRadius: 5,
|
|
|
|
+ maxWidth:500,
|
|
|
|
+ maxHeight: 750,
|
|
|
|
+ display: 'flex',
|
|
|
|
+ overflow: 'auto'
|
|
|
|
+ },
|
|
|
|
+ innerImage: {
|
|
|
|
+ objectFit: 'cover',
|
|
|
|
+ },
|
|
img: {
|
|
img: {
|
|
cursor:'pointer',
|
|
cursor:'pointer',
|
|
'&:hover': {
|
|
'&:hover': {
|
|
scale:0.98
|
|
scale:0.98
|
|
}
|
|
}
|
|
- },
|
|
|
|
- time: {
|
|
|
|
- position: 'absolute',
|
|
|
|
- content: '',
|
|
|
|
- color: '#ffffff',
|
|
|
|
- top: -30,
|
|
|
|
- left: 0,
|
|
|
|
- borderRadius: 10,
|
|
|
|
- padding:'2px 6px 2px 6px',
|
|
|
|
- backgroundColor:'#707070'
|
|
|
|
- }
|
|
|
|
|
|
+ },
|
|
});
|
|
});
|
|
|
|
|
|
interface IMediaListItem {
|
|
interface IMediaListItem {
|
|
@@ -65,15 +107,40 @@ interface IMediaListItem {
|
|
updatedAt: string,
|
|
updatedAt: string,
|
|
handleScrollToTheMessage: (_id: string,companionId:string) => void,
|
|
handleScrollToTheMessage: (_id: string,companionId:string) => void,
|
|
id: string,
|
|
id: string,
|
|
- companionId: string
|
|
|
|
|
|
+ companionId: string,
|
|
|
|
+ name: string,
|
|
|
|
+ lastName: string,
|
|
|
|
+ color: string
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-const MediaListItem = ({ message,fullType,updatedAt,handleScrollToTheMessage,id,companionId }: IMediaListItem) => {
|
|
|
|
|
|
+const MediaListItem = ({ message,fullType,updatedAt,handleScrollToTheMessage,id,companionId,name,lastName,color }: IMediaListItem) => {
|
|
const classes = useStyles();
|
|
const classes = useStyles();
|
|
const [watch, setWatch] = useState<boolean>(false)
|
|
const [watch, setWatch] = useState<boolean>(false)
|
|
|
|
+ const [scale, setScale] = useState<number>(1)
|
|
|
|
+ const refView = useRef<null | any>(null)
|
|
|
|
+ const handleIncreaseScale = () => {
|
|
|
|
+ if (scale < 5) {
|
|
|
|
+ refView.current.style.transform = `scale(${scale+0.25},${scale+0.25})`
|
|
|
|
+ refView.current.style.transformOrigin = `${50 / scale + 0.25}px ${50 / scale + 0.25}px`
|
|
|
|
+ setScale(scale+0.25)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ const handleDecreaseScale = () => {
|
|
|
|
+ if (scale >= 0.5) {
|
|
|
|
+ refView.current.style.transform = `scale(${scale-0.25},${scale-0.25})`
|
|
|
|
+ refView.current.style.transformOrigin = `${50/scale-0.25}px ${50/scale-0.25}px`
|
|
|
|
+ setScale(scale-0.25)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
const handleOpenWatch = () => !watch && setWatch(true)
|
|
const handleOpenWatch = () => !watch && setWatch(true)
|
|
- const handleCloseWatch = (e:any) => e.target.id === 'overlay'&&watch&&setWatch(false)
|
|
|
|
|
|
+ const handleCloseWatch = (e:any) => {
|
|
|
|
+ const id = e.target.id
|
|
|
|
+ if (id === 'overlay' || id === 'close') {
|
|
|
|
+ setWatch(false)
|
|
|
|
+ setScale(1)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
const url = `${prodAwsS3}/${message}`
|
|
const url = `${prodAwsS3}/${message}`
|
|
|
|
|
|
@@ -82,12 +149,34 @@ const MediaListItem = ({ message,fullType,updatedAt,handleScrollToTheMessage,id,
|
|
handleCloseWatch(e)
|
|
handleCloseWatch(e)
|
|
handleScrollToTheMessage(id,companionId)
|
|
handleScrollToTheMessage(id,companionId)
|
|
}} id='overlay' className={classes.overlay}>
|
|
}} id='overlay' className={classes.overlay}>
|
|
- <div className={classes.wrapper}>
|
|
|
|
- <span className={classes.time}>{timeStampEU(updatedAt)}</span>
|
|
|
|
- <DownloadForOfflineIcon className={classes.downloadIcon} fontSize='large'
|
|
|
|
- onClick={() => handleDownload(url, fullType)}/>
|
|
|
|
- <img width='100%' height='auto' alt='imageItem' src={url} />
|
|
|
|
- </div>
|
|
|
|
|
|
+ <div className={classes.topBar}>
|
|
|
|
+ <div className={classes.wrapperCredentials}>
|
|
|
|
+ <ListItemIcon >
|
|
|
|
+ <Avatar alt={name} src={url?url:undefined}
|
|
|
|
+ sx={{ background: color, width: 44, height: 44 }}>
|
|
|
|
+ {!url&&`${firstLetter(name)}${firstLetter(lastName)}`}
|
|
|
|
+ </Avatar>
|
|
|
|
+ </ListItemIcon>
|
|
|
|
+ <ListItemText primary={`${firstLetter(name)}${slicedWord(name, 15, 1)}
|
|
|
|
+ ${firstLetter(lastName)}${slicedWord(lastName, 15, 1)}`}
|
|
|
|
+ primaryTypographyProps={{ color: '#ffffff' }}
|
|
|
|
+ secondary={timeStampEU(updatedAt)} secondaryTypographyProps={{ color: '#ffffff' }} />
|
|
|
|
+ </div>
|
|
|
|
+ <div className={classes.wrapperIcons}>
|
|
|
|
+ <ZoomOutIcon onClick={handleDecreaseScale}
|
|
|
|
+ className={classes.magnifying} fontSize='large' />
|
|
|
|
+ <ZoomInIcon onClick={handleIncreaseScale}
|
|
|
|
+ className={classes.magnifying} fontSize='large' />
|
|
|
|
+ <DownloadForOfflineIcon onClick={() => handleDownload(url, fullType)}
|
|
|
|
+ className={classes.downloadIcon} fontSize='large' />
|
|
|
|
+ <CloseIcon id='close' onClick={handleCloseWatch}
|
|
|
|
+ className={classes.iconCloseOverlay} fontSize='large' />
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ <div ref={refView} className={classes.wrapperImage}>
|
|
|
|
+ <img className={classes.innerImage}
|
|
|
|
+ width='100%' height='auto' alt='imageItem' src={url} />
|
|
|
|
+ </div>
|
|
</div> :
|
|
</div> :
|
|
<ImageListItem>
|
|
<ImageListItem>
|
|
<img onClick={handleOpenWatch} className={classes.img}
|
|
<img onClick={handleOpenWatch} className={classes.img}
|