mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 22:16:54 +00:00
feat(phone/hooks): implemented clipboard
This commit is contained in:
1 parent
e13b064d73
commit
550eb8f38f
6 files changed
+51
-34
No files matched your search
@@ -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 (
|
||||
<Modal visible={shareModal} handleClose={_handleClose}>
|
||||
<div className={classes.shareModal}>
|
||||
<Button style={{ position: 'absolute', right: 0, width: '10%' }} onClick={_handleClose}><CloseIcon /></Button>
|
||||
<Button
|
||||
style={{ position: 'absolute', right: 0, width: '10%' }}
|
||||
onClick={_handleClose}
|
||||
>
|
||||
<CloseIcon />
|
||||
</Button>
|
||||
<div className={classes.innerShareModal}>
|
||||
<h4 style={{ textAlign: 'center', marginTop: 20 }}>Where do you want to share the photo?</h4>
|
||||
<Button>
|
||||
{<MessageIcon />} Message
|
||||
</Button>
|
||||
<h4 style={{ textAlign: 'center', marginTop: 20 }}>
|
||||
Where do you want to share the photo?
|
||||
</h4>
|
||||
<Button>{<MessageIcon />} Message</Button>
|
||||
<h4>Or just copy the image here:</h4>
|
||||
<p>{meta.image}</p>
|
||||
<Button onClick={handleCopyImage} variant='contained'>
|
||||
Copy image
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
@@ -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,
|
||||
}),
|
||||
};
|
||||
@@ -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);
|
||||
};
|
||||
@@ -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();
|
||||
};
|
||||
@@ -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,
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -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'
|
||||
}
|
||||
Reference in new issue
Block a user