mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-05 06:28:51 +00:00
Merge pull request #36 from Re-Ignited-Development/feature/camera-gallery
Feature/camera gallery
This commit is contained in:
24 files changed
+626
-54
No files matched your search
+25
-31
@@ -22,9 +22,31 @@ import { useSelloutService } from "./apps/sellout/hooks/useSelloutService";
|
|||||||
import { useBankService } from './apps/bank/hooks/useBankService';
|
import { useBankService } from './apps/bank/hooks/useBankService';
|
||||||
import { useMessagesService } from "./apps/messages/hooks/useMessageService";
|
import { useMessagesService } from "./apps/messages/hooks/useMessageService";
|
||||||
import { useNotesService } from "./apps/notes/hooks/useNotesService";
|
import { useNotesService } from "./apps/notes/hooks/useNotesService";
|
||||||
|
import { usePhotoService } from "./apps/camera/hooks/usePhotoService";
|
||||||
import Nui from "./os/nui-events/utils/Nui";
|
import Nui from "./os/nui-events/utils/Nui";
|
||||||
|
|
||||||
//These events are just for testing. Comment it out before building.
|
//These events are just for testing. Comment it out before building.
|
||||||
|
setTimeout(() => {
|
||||||
|
window.dispatchEvent(
|
||||||
|
new MessageEvent("message", {
|
||||||
|
data: {
|
||||||
|
app: "CAMERA",
|
||||||
|
method: "setPhotos",
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
image: 'https://i.imgur.com/OO8wx6Z.jpg',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
image: 'https://i.imgur.com/pqGBiST.jpg'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.dispatchEvent(
|
window.dispatchEvent(
|
||||||
new MessageEvent("message", {
|
new MessageEvent("message", {
|
||||||
@@ -37,6 +59,8 @@ setTimeout(() => {
|
|||||||
);
|
);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.dispatchEvent(
|
window.dispatchEvent(
|
||||||
new MessageEvent("message", {
|
new MessageEvent("message", {
|
||||||
@@ -162,37 +186,6 @@ setTimeout(() => {
|
|||||||
)
|
)
|
||||||
}, 1000)
|
}, 1000)
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
window.dispatchEvent(
|
|
||||||
new MessageEvent("message", {
|
|
||||||
data: {
|
|
||||||
app: "CONTACTS",
|
|
||||||
method: "setContacts",
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: 1,
|
|
||||||
number: "345-4366",
|
|
||||||
display: "chip",
|
|
||||||
avatar: 'https://upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Rotating_earth_%28large%29.gif/200px-Rotating_earth_%28large%29.gif'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 2,
|
|
||||||
number: "456-4366",
|
|
||||||
display: "shit",
|
|
||||||
avatar: ''
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 3,
|
|
||||||
number: "123-4366",
|
|
||||||
display: "rocky",
|
|
||||||
avatar: 'https://i.imgur.com/B8ta5Aa.jpeg'
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.dispatchEvent(
|
window.dispatchEvent(
|
||||||
new MessageEvent("message", {
|
new MessageEvent("message", {
|
||||||
@@ -236,6 +229,7 @@ function Phone() {
|
|||||||
useBankService();
|
useBankService();
|
||||||
useMessagesService()
|
useMessagesService()
|
||||||
useNotesService();
|
useNotesService();
|
||||||
|
usePhotoService();
|
||||||
|
|
||||||
if (visibility === false) {
|
if (visibility === false) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -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 (
|
||||||
|
<AppWrapper id='camera-app'>
|
||||||
|
<AppContent>
|
||||||
|
<GalleryModal />
|
||||||
|
{/*<Router>
|
||||||
|
<Switch>
|
||||||
|
<Route path="/camera/image" component={GalleryModal} />
|
||||||
|
<Route path="/" exact component={GalleryGrid} />
|
||||||
|
</Switch>
|
||||||
|
</Router>*/}
|
||||||
|
{!modal ? <GalleryGrid /> : null}
|
||||||
|
</AppContent>
|
||||||
|
</AppWrapper>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CameraApp;
|
||||||
@@ -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 (
|
||||||
|
<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 onClick={() => handlePhotoOpen(photo)}>
|
||||||
|
<div style={{ backgroundImage: `url(${photo.image})` }} className={classes.photo} />
|
||||||
|
</Box>
|
||||||
|
))}
|
||||||
|
</Box>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
@@ -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 (
|
||||||
|
<Paper className={modal ? classes.modal : classes.modalHide}>
|
||||||
|
<ShareModal />
|
||||||
|
<div className={shareModal ? classes.backgroundModal : undefined} />
|
||||||
|
<Button onClick={_handleClose}><ArrowBackIcon /></Button>
|
||||||
|
<div className={classes.image} style={{ backgroundImage: `url(${meta.image})`}} />
|
||||||
|
<div className={classes.actionDiv}>
|
||||||
|
<Button onClick={handleDeletePhoto}>
|
||||||
|
<DeleteIcon fontSize="large" />
|
||||||
|
</Button>
|
||||||
|
<Button onClick={handleSharePhoto}>
|
||||||
|
<ShareIcon fontSize="large" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Paper>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -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 (
|
||||||
|
<Modal visible={shareModal} handleClose={_handleClose}>
|
||||||
|
<div style={{ marginBottom: 50 }}>
|
||||||
|
<Button style={{ position: 'absolute', right: 0, width: '10%' }} onClick={_handleClose}><CloseIcon /></Button>
|
||||||
|
<div style={{ marginTop: 40 }}>
|
||||||
|
<h4 style={{ textAlign: 'center', marginTop: 20 }}>Where do you want to share the photo?</h4>
|
||||||
|
<Button>
|
||||||
|
{<TwitterIcon />} Twitter
|
||||||
|
</Button>
|
||||||
|
<Button>
|
||||||
|
{<FontAwesomeIcon icon={faAd} fixedWidth size="2x"/>} Advert
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
@@ -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
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import { useRecoilState } from 'recoil';
|
||||||
|
import { photoState } from './state';
|
||||||
|
|
||||||
|
export const usePhotoMeta = () => {
|
||||||
|
const [meta, setMeta] = useRecoilState(photoState.photoMeta);
|
||||||
|
return { meta, setMeta};
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import { useRecoilState } from 'recoil';
|
||||||
|
import { photoState } from './state';
|
||||||
|
|
||||||
|
export const usePhotoModal = () => {
|
||||||
|
const [modal, setModal] = useRecoilState(photoState.modal);
|
||||||
|
return { modal, setModal}
|
||||||
|
}
|
||||||
@@ -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();
|
||||||
|
}
|
||||||
@@ -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<IPhotos | null>(photoState.photos);
|
||||||
|
return photos;
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import { useRecoilState } from 'recoil';
|
||||||
|
import { photoState } from './state';
|
||||||
|
|
||||||
|
export const useShareLink = () => {
|
||||||
|
const [ shareLink, setShareLink ] = useRecoilState(photoState.shareLink);
|
||||||
|
return { shareLink, setShareLink }
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import { useRecoilState } from 'recoil';
|
||||||
|
import { photoState } from './state';
|
||||||
|
|
||||||
|
export const useShareModal = () => {
|
||||||
|
const [ shareModal, setShareModal ] = useRecoilState(photoState.shareModal);
|
||||||
|
return { shareModal, setShareModal }
|
||||||
|
}
|
||||||
@@ -4,5 +4,5 @@ export const selloutState = {
|
|||||||
listing: atom({
|
listing: atom({
|
||||||
key: "listing",
|
key: "listing",
|
||||||
default: [],
|
default: [],
|
||||||
}),
|
})
|
||||||
};
|
};
|
||||||
@@ -40,5 +40,5 @@ export const twitterState = {
|
|||||||
notification: atom({
|
notification: atom({
|
||||||
key: "notification",
|
key: "notification",
|
||||||
default: null,
|
default: null,
|
||||||
}),
|
})
|
||||||
};
|
};
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
export interface IPhoto {
|
||||||
|
image: string;
|
||||||
|
id: number
|
||||||
|
}
|
||||||
@@ -16,7 +16,7 @@ import {
|
|||||||
faPlaneArrival,
|
faPlaneArrival,
|
||||||
faPhoneAlt,
|
faPhoneAlt,
|
||||||
faWonSign,
|
faWonSign,
|
||||||
faStickyNote
|
faStickyNote,
|
||||||
} from "@fortawesome/free-solid-svg-icons";
|
} from "@fortawesome/free-solid-svg-icons";
|
||||||
import { faTwitter } from "@fortawesome/free-brands-svg-icons";
|
import { faTwitter } from "@fortawesome/free-brands-svg-icons";
|
||||||
|
|
||||||
@@ -25,6 +25,7 @@ import SettingsIcon from "@material-ui/icons/Settings";
|
|||||||
import MessageIcon from "@material-ui/icons/Message";
|
import MessageIcon from "@material-ui/icons/Message";
|
||||||
import { atom } from "recoil";
|
import { atom } from "recoil";
|
||||||
import { CalculatorIcon } from "../../../apps/calculator/components/CalculatorIcon";
|
import { CalculatorIcon } from "../../../apps/calculator/components/CalculatorIcon";
|
||||||
|
import CameraAltIcon from '@material-ui/icons/CameraAlt';
|
||||||
import { Route } from "react-router-dom";
|
import { Route } from "react-router-dom";
|
||||||
import { DialerApp } from "../../../apps/dialer/components/DialerApp";
|
import { DialerApp } from "../../../apps/dialer/components/DialerApp";
|
||||||
import { ContactsApp } from "../../../apps/contacts/components/ContactsApp";
|
import { ContactsApp } from "../../../apps/contacts/components/ContactsApp";
|
||||||
@@ -36,6 +37,7 @@ import { TwitterApp } from "../../../apps/twitter/components/TwitterApp";
|
|||||||
import { ExampleApp } from "../../../apps/example/components/ExampleApp";
|
import { ExampleApp } from "../../../apps/example/components/ExampleApp";
|
||||||
import { SelloutApp } from "../../../apps/sellout/components/SelloutApp";
|
import { SelloutApp } from "../../../apps/sellout/components/SelloutApp";
|
||||||
import { NotesApp } from "../../../apps/notes/NotesApp";
|
import { NotesApp } from "../../../apps/notes/NotesApp";
|
||||||
|
import CameraApp from "../../../apps/camera/components/CameraApp";
|
||||||
|
|
||||||
const appsState = atom({
|
const appsState = atom({
|
||||||
key: "apps",
|
key: "apps",
|
||||||
@@ -122,6 +124,15 @@ const appsState = atom({
|
|||||||
path: "/notes",
|
path: "/notes",
|
||||||
Route: () => <Route path="/notes" component={NotesApp}/>
|
Route: () => <Route path="/notes" component={NotesApp}/>
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: "CAMERA",
|
||||||
|
name: 'APPS_CAMERA',
|
||||||
|
icon: <CameraAltIcon fontSize="large"/>,
|
||||||
|
backgroundColor: grey['A400'],
|
||||||
|
color: common.white,
|
||||||
|
path: "/camera",
|
||||||
|
Route: () => <Route path="/camera" component={CameraApp} />
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: "EXAMPLE",
|
id: "EXAMPLE",
|
||||||
nameLocale: "APPS_EXAMPLE",
|
nameLocale: "APPS_EXAMPLE",
|
||||||
|
|||||||
+51
-19
@@ -226,6 +226,25 @@ setTick(() => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// setTick(() => {
|
||||||
|
// if (isPhoneOpen) {
|
||||||
|
// DisableControlAction(0, 1, true)
|
||||||
|
// DisableControlAction(0, 2, true)
|
||||||
|
// DisableControlAction(0, 24, true)
|
||||||
|
// DisableControlAction(0, 257, true)
|
||||||
|
// DisableControlAction(0, 25, true)
|
||||||
|
// DisableControlAction(0, 263, true)
|
||||||
|
// } else {
|
||||||
|
// EnableControlAction(0, 1, true)
|
||||||
|
// EnableControlAction(0, 2, true)
|
||||||
|
// EnableControlAction(0, 24, true)
|
||||||
|
// EnableControlAction(0, 257, true)
|
||||||
|
// EnableControlAction(0, 25, true)
|
||||||
|
// EnableControlAction(0, 263, true)
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
|
||||||
async function Phone() {
|
async function Phone() {
|
||||||
if (config.PhoneAsItem) {
|
if (config.PhoneAsItem) {
|
||||||
console.log("CONFIG ON");
|
console.log("CONFIG ON");
|
||||||
@@ -247,6 +266,8 @@ async function Phone() {
|
|||||||
);
|
);
|
||||||
sendPhoneConfig();
|
sendPhoneConfig();
|
||||||
SetNuiFocus(true, true);
|
SetNuiFocus(true, true);
|
||||||
|
//SetNuiFocusKeepInput(true)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
isPhoneOpen = false;
|
isPhoneOpen = false;
|
||||||
SendNuiMessage(
|
SendNuiMessage(
|
||||||
@@ -258,6 +279,8 @@ async function Phone() {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
SetNuiFocus(false, false);
|
SetNuiFocus(false, false);
|
||||||
|
//SetNuiFocusKeepInput(false)
|
||||||
|
|
||||||
await phoneCloseAnim(); // Animation starts after the UI is closed.
|
await phoneCloseAnim(); // Animation starts after the UI is closed.
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -282,6 +305,8 @@ async function Phone() {
|
|||||||
);
|
);
|
||||||
sendPhoneConfig();
|
sendPhoneConfig();
|
||||||
SetNuiFocus(true, true);
|
SetNuiFocus(true, true);
|
||||||
|
//SetNuiFocusKeepInput(true)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
isPhoneOpen = false;
|
isPhoneOpen = false;
|
||||||
SendNuiMessage(
|
SendNuiMessage(
|
||||||
@@ -293,6 +318,8 @@ async function Phone() {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
SetNuiFocus(false, false);
|
SetNuiFocus(false, false);
|
||||||
|
//SetNuiFocusKeepInput(false)
|
||||||
|
|
||||||
await phoneCloseAnim(); // Animation starts after the UI is closed.
|
await phoneCloseAnim(); // Animation starts after the UI is closed.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -322,6 +349,11 @@ on(`__cfx_nui:${events.OPEN_APP_BANK}`, () => {
|
|||||||
emitNet(events.BANK_GET_CREDENTIALS);
|
emitNet(events.BANK_GET_CREDENTIALS);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
RegisterNuiCallbackType(events.OPEN_APP_CAMERA);
|
||||||
|
on(`__cfx_nui:${events.OPEN_APP_CAMERA}`, () => {
|
||||||
|
emitNet(events.CAMERA_FETCH_PHOTOS);
|
||||||
|
})
|
||||||
|
|
||||||
RegisterCommand(
|
RegisterCommand(
|
||||||
"phone",
|
"phone",
|
||||||
() => {
|
() => {
|
||||||
@@ -367,25 +399,25 @@ function countPhone(cb: any) {
|
|||||||
|
|
||||||
let destroyedPhone = false;
|
let destroyedPhone = false;
|
||||||
|
|
||||||
setTick(async () => {
|
// setTick(async () => {
|
||||||
while (config.SwimDestroy) {
|
// while (config.SwimDestroy) {
|
||||||
await Delay(config.RunRate * 1000);
|
// await Delay(config.RunRate * 1000);
|
||||||
if (IsPedSwimming(PlayerPedId())) {
|
// if (IsPedSwimming(PlayerPedId())) {
|
||||||
let chance = Math.floor(Math.random() * 100 + 1);
|
// let chance = Math.floor(Math.random() * 100 + 1);
|
||||||
if (chance <= config.DestoryChance) {
|
// if (chance <= config.DestoryChance) {
|
||||||
countPhone((countPhone: boolean) => {
|
// countPhone((countPhone: boolean) => {
|
||||||
if (countPhone) {
|
// if (countPhone) {
|
||||||
ESX.ShowNotification("Your phone is ruined from the water!");
|
// ESX.ShowNotification("Your phone is ruined from the water!");
|
||||||
destroyedPhone = true;
|
// destroyedPhone = true;
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
if (destroyedPhone) {
|
// if (destroyedPhone) {
|
||||||
await Delay(config.DestroyPhoneReCheck * 60000);
|
// await Delay(config.DestroyPhoneReCheck * 60000);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
onNet("phone:sendCredentials", (number: string) => {
|
onNet("phone:sendCredentials", (number: string) => {
|
||||||
SendNuiMessage(
|
SendNuiMessage(
|
||||||
|
|||||||
@@ -0,0 +1,143 @@
|
|||||||
|
import events from "../utils/events";
|
||||||
|
import { Delay } from "../utils/fivem";
|
||||||
|
import { tokenData } from '../utils/token';
|
||||||
|
|
||||||
|
const exp = (global as any).exports
|
||||||
|
|
||||||
|
function closePhoneTemp() {
|
||||||
|
SendNuiMessage(
|
||||||
|
//Hides phone
|
||||||
|
JSON.stringify({
|
||||||
|
app: "PHONE",
|
||||||
|
method: "setVisibility",
|
||||||
|
data: false,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function openPhoneTemp() {
|
||||||
|
SendNuiMessage(
|
||||||
|
//Opens phone
|
||||||
|
JSON.stringify({
|
||||||
|
app: "PHONE",
|
||||||
|
method: "setVisibility",
|
||||||
|
data: true,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let takingPhoto = false
|
||||||
|
|
||||||
|
function CellFrontCamActivate(activate: any) {
|
||||||
|
return Citizen.invokeNative('0x2491A93618B7D838', activate)
|
||||||
|
}
|
||||||
|
|
||||||
|
RegisterNuiCallbackType(events.CAMERA_TAKE_PHOTO);
|
||||||
|
on(`__cfx_nui:${events.CAMERA_TAKE_PHOTO}`, async () => {
|
||||||
|
CreateMobilePhone(1);
|
||||||
|
CellCamActivate(true, true);
|
||||||
|
|
||||||
|
closePhoneTemp()
|
||||||
|
SetNuiFocus(false, false);
|
||||||
|
|
||||||
|
takingPhoto = true;
|
||||||
|
|
||||||
|
while (takingPhoto) {
|
||||||
|
await Delay(0);
|
||||||
|
let frontCam = false;
|
||||||
|
|
||||||
|
if (IsControlJustPressed(1, 27)) {
|
||||||
|
if (!frontCam) {
|
||||||
|
frontCam = true;
|
||||||
|
CellFrontCamActivate(true);
|
||||||
|
} else {
|
||||||
|
frontCam = false;
|
||||||
|
CellFrontCamActivate(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (IsControlJustPressed(1, 176)) {
|
||||||
|
takePhoto()
|
||||||
|
await Delay(200)
|
||||||
|
console.log("phone closing")
|
||||||
|
DestroyMobilePhone();
|
||||||
|
CellCamActivate(false, false);
|
||||||
|
|
||||||
|
openPhoneTemp()
|
||||||
|
SetNuiFocus(true, true);
|
||||||
|
|
||||||
|
takingPhoto = false;
|
||||||
|
|
||||||
|
} else if (IsControlJustPressed(1, 177)) {
|
||||||
|
DestroyMobilePhone();
|
||||||
|
CellCamActivate(false, false);
|
||||||
|
|
||||||
|
openPhoneTemp()
|
||||||
|
SetNuiFocus(true, true);
|
||||||
|
|
||||||
|
takingPhoto = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//setTick(async () => {
|
||||||
|
// while (takingPhoto) {
|
||||||
|
// await Delay(0);
|
||||||
|
//
|
||||||
|
// if (IsControlReleased(1, 177)) {
|
||||||
|
// DestroyMobilePhone();
|
||||||
|
// CellCamActivate(false, false);
|
||||||
|
// takingPhoto = false;
|
||||||
|
// SetNuiFocus(true, true);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
onNet(events.CAMERA_SEND_PHOTOS, (photos: string[]) => {
|
||||||
|
console.log(photos)
|
||||||
|
SendNuiMessage(
|
||||||
|
JSON.stringify({
|
||||||
|
app: "CAMERA",
|
||||||
|
method: "setPhotos",
|
||||||
|
data: photos
|
||||||
|
})
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
function takePhoto() {
|
||||||
|
const [width, height] = GetActiveScreenResolution();
|
||||||
|
console.log("photo taken")
|
||||||
|
exp["screenshot-basic"].requestScreenshotUpload(
|
||||||
|
"https://api.imgur.com/3/image",
|
||||||
|
"imgur",
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
'authorization': `Client-ID ${ tokenData.token }`,
|
||||||
|
'content-type': 'multipart/form-data'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
(data: string) => {
|
||||||
|
console.log("herrrrroooooooo")
|
||||||
|
const imageLink = JSON.parse(data).data.link;
|
||||||
|
emitNet(events.CAMERA_UPLOAD_PHOTO, imageLink)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// delete photo
|
||||||
|
|
||||||
|
RegisterNuiCallbackType(events.CAMERA_DELETE_PHOTO);
|
||||||
|
on(`__cfx_nui:${events.CAMERA_DELETE_PHOTO}`, (data: any) => {
|
||||||
|
emitNet(events.CAMERA_DELETE_PHOTO, data)
|
||||||
|
})
|
||||||
|
|
||||||
|
onNet(events.CAMERA_DELETE_PHOTO_SUCCESS, () => {
|
||||||
|
emitNet(events.CAMERA_FETCH_PHOTOS)
|
||||||
|
})
|
||||||
|
|
||||||
@@ -5,6 +5,7 @@ import './cl_contacts';
|
|||||||
import './cl_sellout';
|
import './cl_sellout';
|
||||||
import './cl_bank';
|
import './cl_bank';
|
||||||
import './cl_notes';
|
import './cl_notes';
|
||||||
|
import './cl_photo';
|
||||||
import './cl_messages';
|
import './cl_messages';
|
||||||
|
|
||||||
export let ESX: ESXClient = null;
|
export let ESX: ESXClient = null;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import './sv_contacts';
|
|||||||
import './sv_sellout';
|
import './sv_sellout';
|
||||||
import './sv_bank';
|
import './sv_bank';
|
||||||
import './sv_notes';
|
import './sv_notes';
|
||||||
|
import './sv_photo';
|
||||||
import './sv_messages';
|
import './sv_messages';
|
||||||
|
|
||||||
export let ESX: ESXServer = null;
|
export let ESX: ESXServer = null;
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import events from '../utils/events';
|
||||||
|
import { ESX, getSource } from './server';
|
||||||
|
import { pool } from './db';
|
||||||
|
import { useIdentifier } from './functions';
|
||||||
|
import { IPhoto } from '../../phone/src/common/interfaces/photo';
|
||||||
|
|
||||||
|
async function uploadPhoto(identifier: string, image: string) {
|
||||||
|
const query = 'INSERT INTO npwd_phone_gallery (identifier, image) VALUES (?, ?)';
|
||||||
|
await pool.query(query, [identifier, image])
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getPhotosByIdentifier(identifier: string): Promise<IPhoto[]> {
|
||||||
|
const query = "SELECT id, image FROM npwd_phone_gallery WHERE identifier = ? ORDER BY id DESC";
|
||||||
|
const [ results ] = await pool.query(query, [identifier]);
|
||||||
|
const photos = <IPhoto[]>results;
|
||||||
|
return photos;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deletePhoto(photo: IPhoto, identifier: string) {
|
||||||
|
const query = "DELETE FROM npwd_phone_gallery WHERE id = ? AND identifier = ?";
|
||||||
|
await pool.query(query, [photo.id, identifier])
|
||||||
|
console.log(photo.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
onNet(events.CAMERA_UPLOAD_PHOTO, async (image: string) => {
|
||||||
|
const identifier = await useIdentifier()
|
||||||
|
await uploadPhoto(identifier, image)
|
||||||
|
})
|
||||||
|
|
||||||
|
onNet(events.CAMERA_FETCH_PHOTOS, async () => {
|
||||||
|
const identifier = await useIdentifier();
|
||||||
|
const photos = await getPhotosByIdentifier(identifier)
|
||||||
|
emitNet(events.CAMERA_SEND_PHOTOS, getSource(), photos)
|
||||||
|
})
|
||||||
|
|
||||||
|
onNet(events.CAMERA_DELETE_PHOTO, async (photo: IPhoto) => {
|
||||||
|
try {
|
||||||
|
const identifier = await useIdentifier()
|
||||||
|
await deletePhoto(photo, identifier)
|
||||||
|
emitNet(events.CAMERA_DELETE_PHOTO_SUCCESS, getSource())
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -81,6 +81,14 @@ export default {
|
|||||||
OPEN_APP_CONTACTS: 'phone:app:CONTACTS',
|
OPEN_APP_CONTACTS: 'phone:app:CONTACTS',
|
||||||
OPEN_APP_BANK: 'phone:app:BANK',
|
OPEN_APP_BANK: 'phone:app:BANK',
|
||||||
OPEN_APP_NOTES: 'phone:app:NOTES',
|
OPEN_APP_NOTES: 'phone:app:NOTES',
|
||||||
OPEN_APP_LISTINGS: 'phone:app:SELLOUT'
|
OPEN_APP_LISTINGS: 'phone:app:SELLOUT',
|
||||||
|
OPEN_APP_CAMERA: 'phone:app:CAMERA',
|
||||||
|
|
||||||
|
// camera
|
||||||
|
CAMERA_TAKE_PHOTO: 'phone:TakePhoto',
|
||||||
|
CAMERA_UPLOAD_PHOTO: 'phone:UploadPhoto',
|
||||||
|
CAMERA_FETCH_PHOTOS: 'phone:FetchPhotos',
|
||||||
|
CAMERA_SEND_PHOTOS: 'phone:SendPhotos',
|
||||||
|
CAMERA_DELETE_PHOTO: 'photo:deletePhoto',
|
||||||
|
CAMERA_DELETE_PHOTO_SUCCESS: 'phone:deletePhotoSuccess'
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user