mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
feat(messages/nui): modal for sending images
This commit is contained in:
1 parent
4c7ee4860a
commit
1249c3a364
2 files changed
+59
No files matched your search
@@ -0,0 +1,51 @@
|
|||||||
|
import { TextField, Button } from '@material-ui/core';
|
||||||
|
import React, { useState } from 'react'
|
||||||
|
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||||
|
import Modal from '../../../../ui/components/Modal'
|
||||||
|
import { useImageModal } from '../../hooks/useImageModal'
|
||||||
|
import CloseIcon from '@material-ui/icons/Close';
|
||||||
|
import useStyles from './modal.styles';
|
||||||
|
|
||||||
|
interface IProps {
|
||||||
|
messageGroupId: string | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const MessageImageModal = ({ messageGroupId }: IProps) => {
|
||||||
|
const classes = useStyles();
|
||||||
|
const { imageModal, setImageModal } = useImageModal();
|
||||||
|
const [ message, setMessage ] = useState("");
|
||||||
|
|
||||||
|
const _handleClose = () => {
|
||||||
|
setImageModal(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
const sendImageMessage = (event) => {
|
||||||
|
if (event.key ==="Enter") {
|
||||||
|
Nui.send('phone:sendMessage', {
|
||||||
|
groupId: messageGroupId,
|
||||||
|
message
|
||||||
|
})
|
||||||
|
setImageModal(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal visible={imageModal} handleClose={_handleClose}>
|
||||||
|
<div>
|
||||||
|
<Button onClick={_handleClose} className={classes.imageModalCloseButton} ><CloseIcon /></Button>
|
||||||
|
<TextField
|
||||||
|
placeholder="A link to your image or gif"
|
||||||
|
onChange={e => setMessage(e.target.value)}
|
||||||
|
value={message}
|
||||||
|
className={classes.input}
|
||||||
|
inputProps={{
|
||||||
|
className: classes.messagesInput,
|
||||||
|
}}
|
||||||
|
inputRef={(input) => input && input.focus()}
|
||||||
|
onKeyPress={sendImageMessage}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import { useRecoilState } from 'recoil';
|
||||||
|
import { messageState } from './state';
|
||||||
|
|
||||||
|
|
||||||
|
export const useImageModal = () => {
|
||||||
|
const [ imageModal, setImageModal ] = useRecoilState(messageState.imageModal);
|
||||||
|
return { imageModal, setImageModal };
|
||||||
|
}
|
||||||
Reference in new issue
Block a user