diff --git a/phone/src/apps/camera/components/CameraApp.tsx b/phone/src/apps/camera/components/CameraApp.tsx new file mode 100644 index 0000000..404313c --- /dev/null +++ b/phone/src/apps/camera/components/CameraApp.tsx @@ -0,0 +1,30 @@ +import { Fab } from '@material-ui/core'; +import React from 'react' +import { AppWrapper } from "../../../ui/components"; +import { AppContent } from "../../../ui/components/AppContent"; +import { usePhotoModal } from '../hooks/usePhotoModal'; +import { GalleryGrid } from './grid/GalleryGrid'; +import { GalleryModal } from './modal/GalleryModal'; + + +const CameraApp = () => { + + const {modal} = usePhotoModal(); + + return ( + + + + {/* + + + + + */} + {!modal ? : null} + + + ) +} + +export default CameraApp; diff --git a/phone/src/apps/camera/components/grid/GalleryGrid.tsx b/phone/src/apps/camera/components/grid/GalleryGrid.tsx new file mode 100644 index 0000000..9a3ead6 --- /dev/null +++ b/phone/src/apps/camera/components/grid/GalleryGrid.tsx @@ -0,0 +1,62 @@ +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 { usePhotoModal } from '../../hooks/usePhotoModal'; +import { usePhotoMeta } from '../../hooks/usePhotoMeta'; +import { useModal } from '../../../contacts/hooks/useModal'; +//import { useHistory } from 'react-router-dom'; + +// 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) => { + const classes = useStyles() + + const { setMeta } = usePhotoMeta(); + const { setModal } = usePhotoModal(); + + //let history = useHistory(); + + const photos = usePhotos(); + + console.log(photos) + + const handleCamera = () => { + Nui.send('phone:TakePhoto', {}) + } + + const handlePhotoOpen = (photo) => { + setModal(true) + setMeta(photo) + //history.push('/camera/image') + } + + if(!photos) return ( + + + + + + ) + + return ( +
+ + + + + {photos.map(photo => ( + handlePhotoOpen(photo)}> +
+ + ))} + +
+ ) +} diff --git a/phone/src/apps/camera/components/grid/grid.styles.ts b/phone/src/apps/camera/components/grid/grid.styles.ts new file mode 100644 index 0000000..5e7008b --- /dev/null +++ b/phone/src/apps/camera/components/grid/grid.styles.ts @@ -0,0 +1,19 @@ +import { makeStyles, Theme } from '@material-ui/core/styles'; + +const useStyles = makeStyles((theme: Theme) => ({ + root: { + flexGrow: 1 + }, + photo: { + border: '1px inset #fff', + height: 129, + width: 129, + maxWidth: 150, + maxHeight: 150, + backgroundPosition: 'center', + backgroundRepeat: 'no-repeat', + backgroundSize: 'cover', + } +})) + +export default useStyles; \ No newline at end of file diff --git a/phone/src/apps/camera/components/modal/GalleryModal.tsx b/phone/src/apps/camera/components/modal/GalleryModal.tsx new file mode 100644 index 0000000..10ea82d --- /dev/null +++ b/phone/src/apps/camera/components/modal/GalleryModal.tsx @@ -0,0 +1,65 @@ +import React from 'react' +import Modal from '../../../../ui/components/Modal'; +import { usePhotoMeta } from '../../hooks/usePhotoMeta'; +import { usePhotoModal } from '../../hooks/usePhotoModal'; +import useStyles from './modal.styles'; +import { useHistory } from 'react-router-dom'; +import { Button, Paper } from '@material-ui/core'; +import ArrowBackIcon from '@material-ui/icons/ArrowBack'; +import DeleteIcon from '@material-ui/icons/Delete'; +import ShareIcon from '@material-ui/icons/Share'; +import Nui from '../../../../os/nui-events/utils/Nui'; +import { useImagePrompt } from '../../../twitter/hooks/useImagePrompt'; +import { useShareModal } from '../../hooks/useShareModal'; +import { ShareModal } from './ShareModal'; +import { useShareLink } from '../../hooks/useShareLink'; + +export const GalleryModal = () => { + + const { meta, setMeta } = usePhotoMeta(); + const { modal, setModal } = usePhotoModal(); + const classes = useStyles(); + + const { shareModal ,setShareModal } = useShareModal(); + const { setShareLink } = useShareLink(); + + let history = useHistory(); + + const _handleClose = () => { + setModal(false) + setMeta(null); + //history.goBack(); + } + + const handleDeletePhoto = () => { + console.log(meta.id) + Nui.send('photo:deletePhoto', { + id: meta.id + }) + setModal(false) + } + + const handleSharePhoto = () => { + setShareModal(true) + setShareLink(meta.image) + } + + 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 new file mode 100644 index 0000000..1d7d024 --- /dev/null +++ b/phone/src/apps/camera/components/modal/ShareModal.tsx @@ -0,0 +1,43 @@ +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 TwitterIcon from '@material-ui/icons/Twitter'; +import { useHistory } from 'react-router-dom'; +import { useModal } from '../../../twitter/hooks/useModal'; +import CloseIcon from '@material-ui/icons/Close'; + +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { faAd } from "@fortawesome/free-solid-svg-icons"; + +export const ShareModal = () => { + const { shareModal, setShareModal } = useShareModal(); + const { shareLink, setShareLink } = useShareLink(); + const { setModalVisible } = useModal(); + + + let history = useHistory(); + + const _handleClose = () => { + setShareModal(false) + setShareLink(null) + } + + return ( + +
+ +
+

Where do you want to share the photo?

+ + +
+
+
+ ) +} diff --git a/phone/src/apps/camera/components/modal/modal.styles.ts b/phone/src/apps/camera/components/modal/modal.styles.ts new file mode 100644 index 0000000..c16478e --- /dev/null +++ b/phone/src/apps/camera/components/modal/modal.styles.ts @@ -0,0 +1,39 @@ +import { makeStyles, Theme } from '@material-ui/core/styles'; + +const useStyles = makeStyles((theme: Theme) => ({ + backgroundModal: { + background: "black", + opacity: "0.6", + position: "absolute", + top: 0, + left: 0, + right: 0, + bottom: 0, + zIndex: 5, + }, + modal: { + position: 'absolute', + height: '100%', + width: '100%', + }, + modalHide: { + display: 'none' + }, + image: { + width: 'auto', + height: 380, + maxWidth: 'auto', + maxHeight: 380, + backgroundPosition: 'center', + backgroundSize: 'cover', + backgroundRepeat: 'no-repeat', + marginTop: '4em' + }, + actionDiv: { + marginTop: 15, + display: 'flex', + justifyContent: 'space-evenly' + } +})) + +export default useStyles; \ No newline at end of file diff --git a/phone/src/apps/camera/hooks/state.ts b/phone/src/apps/camera/hooks/state.ts new file mode 100644 index 0000000..d098ba4 --- /dev/null +++ b/phone/src/apps/camera/hooks/state.ts @@ -0,0 +1,24 @@ +import { atom } from 'recoil'; + +export const photoState = { + photos: atom({ + 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 + }) +} \ No newline at end of file diff --git a/phone/src/apps/camera/hooks/usePhotoMeta.ts b/phone/src/apps/camera/hooks/usePhotoMeta.ts new file mode 100644 index 0000000..5c31a5c --- /dev/null +++ b/phone/src/apps/camera/hooks/usePhotoMeta.ts @@ -0,0 +1,7 @@ +import { useRecoilState } from 'recoil'; +import { photoState } from './state'; + +export const usePhotoMeta = () => { + const [meta, setMeta] = useRecoilState(photoState.photoMeta); + return { meta, setMeta}; +} \ No newline at end of file diff --git a/phone/src/apps/camera/hooks/usePhotoModal.ts b/phone/src/apps/camera/hooks/usePhotoModal.ts new file mode 100644 index 0000000..39aafe2 --- /dev/null +++ b/phone/src/apps/camera/hooks/usePhotoModal.ts @@ -0,0 +1,7 @@ +import { useRecoilState } from 'recoil'; +import { photoState } from './state'; + +export const usePhotoModal = () => { + const [modal, setModal] = useRecoilState(photoState.modal); + return { modal, setModal} +} \ No newline at end of file diff --git a/phone/src/apps/camera/hooks/usePhotoService.ts b/phone/src/apps/camera/hooks/usePhotoService.ts new file mode 100644 index 0000000..b080ff2 --- /dev/null +++ b/phone/src/apps/camera/hooks/usePhotoService.ts @@ -0,0 +1,10 @@ +import { useSetRecoilState } from 'recoil'; +import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent'; +import { photoState } from './state'; +import { usePhotos } from './usePhotos'; + +export const usePhotoService = () => { + const setPhotos = useSetRecoilState(photoState.photos); + useNuiEvent('CAMERA', 'setPhotos', setPhotos); + return usePhotos(); +} \ No newline at end of file diff --git a/phone/src/apps/camera/hooks/usePhotos.ts b/phone/src/apps/camera/hooks/usePhotos.ts new file mode 100644 index 0000000..1c4d781 --- /dev/null +++ b/phone/src/apps/camera/hooks/usePhotos.ts @@ -0,0 +1,14 @@ +import { useRecoilValue } from 'recoil'; +import { photoState } from './state'; + +interface IPhotos { + image: string[]; + + map?: any; +} + + +export const usePhotos = (): IPhotos | null => { + const photos = useRecoilValue(photoState.photos); + return photos; +} \ No newline at end of file diff --git a/phone/src/apps/camera/hooks/useShareLink.ts b/phone/src/apps/camera/hooks/useShareLink.ts new file mode 100644 index 0000000..ecb1b9b --- /dev/null +++ b/phone/src/apps/camera/hooks/useShareLink.ts @@ -0,0 +1,7 @@ +import { useRecoilState } from 'recoil'; +import { photoState } from './state'; + +export const useShareLink = () => { + const [ shareLink, setShareLink ] = useRecoilState(photoState.shareLink); + return { shareLink, setShareLink } +} \ No newline at end of file diff --git a/phone/src/apps/camera/hooks/useShareModal.ts b/phone/src/apps/camera/hooks/useShareModal.ts new file mode 100644 index 0000000..66dfec1 --- /dev/null +++ b/phone/src/apps/camera/hooks/useShareModal.ts @@ -0,0 +1,7 @@ +import { useRecoilState } from 'recoil'; +import { photoState } from './state'; + +export const useShareModal = () => { + const [ shareModal, setShareModal ] = useRecoilState(photoState.shareModal); + return { shareModal, setShareModal } +} \ No newline at end of file