diff --git a/phone/src/apps/camera/components/modal/ShareModal.tsx b/phone/src/apps/camera/components/modal/ShareModal.tsx index 3e56671..c666578 100644 --- a/phone/src/apps/camera/components/modal/ShareModal.tsx +++ b/phone/src/apps/camera/components/modal/ShareModal.tsx @@ -1,43 +1,49 @@ -import React from 'react' -import Modal from '../../../../ui/components/Modal' +import React, { useRef, useState } from 'react'; +import Modal from '../../../../ui/components/Modal'; import { useShareLink } from '../../hooks/useShareLink'; -import { useShareModal } from '../../hooks/useShareModal' +import { useShareModal } from '../../hooks/useShareModal'; import { Button } from '@material-ui/core'; import MessageIcon from '@material-ui/icons/Message'; -import { useHistory } from 'react-router-dom'; -import { useModal } from '../../../twitter/hooks/useModal'; +import { setClipboard } from '../../../../os/phone/hooks/useClipboard'; import CloseIcon from '@material-ui/icons/Close'; import useStyles from './modal.styles'; - +import Nui from '../../../../os/nui-events/utils/Nui'; export const ShareModal = (meta) => { const classes = useStyles(); const { shareModal, setShareModal } = useShareModal(); - const { shareLink, setShareLink } = useShareLink(); - const { setModalVisible } = useModal(); + const { setShareLink } = useShareLink(); - - let history = useHistory(); - const _handleClose = () => { - setShareModal(false) - setShareLink(null) - } + setShareModal(false); + setShareLink(null); + }; + + const handleCopyImage = () => { + setClipboard(meta.image); + }; return (
- +
-

Where do you want to share the photo?

- +

+ Where do you want to share the photo? +

+

Or just copy the image here:

-

{meta.image}

+
- ) -} + ); +}; diff --git a/phone/src/os/phone/hooks/state.ts b/phone/src/os/phone/hooks/state.ts index 8af0dc6..5c37fb6 100644 --- a/phone/src/os/phone/hooks/state.ts +++ b/phone/src/os/phone/hooks/state.ts @@ -1,12 +1,12 @@ -import { atom } from "recoil"; +import { atom } from 'recoil'; export const phoneState = { visibility: atom({ - key: "phoneVisibility", + key: 'phoneVisibility', default: false, }), phoneConfig: atom({ - key: "phoneConfig", + key: 'phoneConfig', default: undefined, }), }; diff --git a/phone/src/os/phone/hooks/useClipboard.ts b/phone/src/os/phone/hooks/useClipboard.ts new file mode 100644 index 0000000..44b391f --- /dev/null +++ b/phone/src/os/phone/hooks/useClipboard.ts @@ -0,0 +1,8 @@ +export const setClipboard = (value: string) => { + const clipElem = document.createElement('input'); + clipElem.value = value; + document.body.appendChild(clipElem); + clipElem.select(); + document.execCommand('copy'); + document.body.removeChild(clipElem); +}; diff --git a/phone/src/os/phone/hooks/usePhoneService.ts b/phone/src/os/phone/hooks/usePhoneService.ts index 528340e..78faa4e 100644 --- a/phone/src/os/phone/hooks/usePhoneService.ts +++ b/phone/src/os/phone/hooks/usePhoneService.ts @@ -1,12 +1,12 @@ -import { useSetRecoilState } from "recoil"; -import { phoneState } from "./state"; -import { useNuiEvent } from "../../nui-events/hooks/useNuiEvent"; -import { usePhone } from "./usePhone"; +import { useSetRecoilState } from 'recoil'; +import { phoneState } from './state'; +import { useNuiEvent } from '../../nui-events/hooks/useNuiEvent'; +import { usePhone } from './usePhone'; export const usePhoneService = () => { const setVisibility = useSetRecoilState(phoneState.visibility); const setPhoneConfig = useSetRecoilState(phoneState.phoneConfig); - useNuiEvent("PHONE", "setVisibility", setVisibility); - useNuiEvent("PHONE", "phoneConfig", setPhoneConfig); + useNuiEvent('PHONE', 'setVisibility', setVisibility); + useNuiEvent('PHONE', 'phoneConfig', setPhoneConfig); return usePhone(); }; diff --git a/resources/client/cl_main.ts b/resources/client/cl_main.ts index 55bf52c..9903859 100644 --- a/resources/client/cl_main.ts +++ b/resources/client/cl_main.ts @@ -207,7 +207,7 @@ async function carryingPhone(cb: any) { function noPhone() { if (ESX === null) return; - ESX.ShowNotification("Oi Mate, No El Telephono"); + ESX.ShowNotification("Oi Mate, No El Telephono", false, false, 1); } function sendPhoneConfig() { @@ -427,4 +427,4 @@ onNet("phone:sendCredentials", (number: string) => { data: number, }) ); -}); +}); \ No newline at end of file diff --git a/resources/utils/events.ts b/resources/utils/events.ts index af74ccd..967eea3 100644 --- a/resources/utils/events.ts +++ b/resources/utils/events.ts @@ -90,5 +90,8 @@ export default { CAMERA_FETCH_PHOTOS: 'phone:FetchPhotos', CAMERA_SEND_PHOTOS: 'phone:SendPhotos', CAMERA_DELETE_PHOTO: 'photo:deletePhoto', - CAMERA_DELETE_PHOTO_SUCCESS: 'phone:deletePhotoSuccess' + CAMERA_DELETE_PHOTO_SUCCESS: 'phone:deletePhotoSuccess', + + // copy + PHONE_USE_CLIPBOARD: 'phone:useClipboard' }