mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 06:28:51 +00:00
* Remove client phoneConfig event * Remove unused debug * Remove unused import * Remove unused import * Remove duplicated functions | fix useEffect dependency | etc * Fix warnings * Update phone/src/apps/twitter/components/TwitterApp.tsx Co-authored-by: Taso <[email protected]> Co-authored-by: Taso <[email protected]>
82 lines
2.1 KiB
TypeScript
82 lines
2.1 KiB
TypeScript
import React from 'react';
|
|
import { Box, Button } from '@material-ui/core';
|
|
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 { useHistory } from 'react-router-dom';
|
|
import { useQueryParams } from '../../../../common/hooks/useQueryParams';
|
|
import { addQueryToLocation } from '../../../../common/utils/addQueryToLocation';
|
|
import { getLocationFromUrl } from '../../../../common/utils/getLocationFromUrl';
|
|
|
|
export const GalleryGrid = () => {
|
|
const classes = useStyles();
|
|
const history = useHistory();
|
|
const query = useQueryParams();
|
|
|
|
const referal = query.referal
|
|
? decodeURIComponent(query.referal)
|
|
: '/camera/image';
|
|
|
|
const photos = usePhotos();
|
|
|
|
const handleCamera = () => {
|
|
Nui.send('phone:TakePhoto', {});
|
|
};
|
|
|
|
const handlePhotoOpen = (photo) => {
|
|
history.push(
|
|
addQueryToLocation(getLocationFromUrl(referal), 'image', photo.image)
|
|
);
|
|
};
|
|
|
|
if (!photos)
|
|
return (
|
|
<Box
|
|
display='flex'
|
|
flexWrap='wrap'
|
|
alignContent='flex-start'
|
|
className={classes.root}
|
|
>
|
|
<Box>
|
|
<Button
|
|
onClick={handleCamera}
|
|
style={{ borderRadius: 0 }}
|
|
className={classes.photo}
|
|
>
|
|
<AddIcon fontSize='large' />
|
|
</Button>
|
|
</Box>
|
|
</Box>
|
|
);
|
|
|
|
return (
|
|
<div>
|
|
<Box
|
|
display='flex'
|
|
flexWrap='wrap'
|
|
alignContent='flex-start'
|
|
className={classes.root}
|
|
>
|
|
<Box>
|
|
<Button
|
|
onClick={handleCamera}
|
|
style={{ borderRadius: 0 }}
|
|
className={classes.photo}
|
|
>
|
|
<AddIcon fontSize='large' />
|
|
</Button>
|
|
</Box>
|
|
{photos.map((photo) => (
|
|
<Box key={photo.id} onClick={() => handlePhotoOpen(photo)}>
|
|
<div
|
|
style={{ backgroundImage: `url(${photo.image})` }}
|
|
className={classes.photo}
|
|
/>
|
|
</Box>
|
|
))}
|
|
</Box>
|
|
</div>
|
|
);
|
|
};
|