mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-05 06:28:51 +00:00
inital message app
This commit is contained in:
1 parent
e6bb7f39a6
commit
374d4c9269
12 files changed
+284
No files matched your search
@@ -0,0 +1,34 @@
|
|||||||
|
import React, { useState } from 'react'
|
||||||
|
import { Paper, TextField, Button } from '@material-ui/core'
|
||||||
|
import useStyles from './form.styles';
|
||||||
|
import SendIcon from '@material-ui/icons/Send';
|
||||||
|
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||||
|
|
||||||
|
export const MessageInput = ({ name }) => {
|
||||||
|
const classes = useStyles();
|
||||||
|
|
||||||
|
const [ message, setMessage ] = useState('')
|
||||||
|
|
||||||
|
Nui.send('phone:sendMessage', {
|
||||||
|
name,
|
||||||
|
message
|
||||||
|
})
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Paper
|
||||||
|
className={classes.form}
|
||||||
|
variant="outlined"
|
||||||
|
>
|
||||||
|
<TextField
|
||||||
|
value={message}
|
||||||
|
onChange={e => setMessage(e.target.value)}
|
||||||
|
placeholder="Message..."
|
||||||
|
className={classes.input}
|
||||||
|
inputProps={{
|
||||||
|
className: classes.messagesInput
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Button className={classes.sendButton}><SendIcon /></Button>
|
||||||
|
</Paper>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import { makeStyles } from '@material-ui/core';
|
||||||
|
|
||||||
|
const useStyles = makeStyles((theme) => ({
|
||||||
|
sendButton: {
|
||||||
|
float: 'right'
|
||||||
|
},
|
||||||
|
form: {
|
||||||
|
position: 'absolute',
|
||||||
|
bottom: 0,
|
||||||
|
display: 'flex',
|
||||||
|
width: '100%',
|
||||||
|
},
|
||||||
|
input: {
|
||||||
|
width: '100%',
|
||||||
|
margin: 10
|
||||||
|
},
|
||||||
|
messagesInput: {
|
||||||
|
fontSize: 20
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
|
export default useStyles;
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import { InputBase, Paper } from '@material-ui/core';
|
||||||
|
import SearchIcon from "@material-ui/icons/Search";
|
||||||
|
|
||||||
|
import useStyles from './list.styles';
|
||||||
|
|
||||||
|
export const MessageSearch = () => {
|
||||||
|
const classes = useStyles();
|
||||||
|
return (
|
||||||
|
<Paper elevation={24} variant="outlined" className={classes.bg}>
|
||||||
|
<div className={classes.search}>
|
||||||
|
<div className={classes.searchIcon}>
|
||||||
|
<SearchIcon />
|
||||||
|
</div>
|
||||||
|
<InputBase
|
||||||
|
//onChange={handleChange}
|
||||||
|
placeholder="Search contacts..."
|
||||||
|
classes={{
|
||||||
|
root: classes.inputRoot,
|
||||||
|
input: classes.inputInput,
|
||||||
|
}}
|
||||||
|
inputProps={{ "aria-label": "search" }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Paper>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import { List, ListItem, ListItemText, ListItemAvatar, Avatar as MuiAvatar } from '@material-ui/core';
|
||||||
|
import React from 'react'
|
||||||
|
import { useMessageModal } from '../../hooks/useMessageModal';
|
||||||
|
|
||||||
|
import { useMessages } from '../../hooks/useMessages';
|
||||||
|
|
||||||
|
const MessagesList = (): any => {
|
||||||
|
const messages = useMessages();
|
||||||
|
const { setMessageModal } = useMessageModal()
|
||||||
|
return (
|
||||||
|
<List>
|
||||||
|
{messages.map((message) => (
|
||||||
|
<ListItem divider onClick={() => setMessageModal(true)} button key={message.id}>
|
||||||
|
<ListItemAvatar>
|
||||||
|
<MuiAvatar />
|
||||||
|
</ListItemAvatar>
|
||||||
|
<ListItemText secondary="hello, how are...">
|
||||||
|
{message.name}
|
||||||
|
</ListItemText>
|
||||||
|
</ListItem>
|
||||||
|
))}
|
||||||
|
</List>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default MessagesList;
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
import { makeStyles, fade } from '@material-ui/core';
|
||||||
|
|
||||||
|
const useStyles = makeStyles((theme) => ({
|
||||||
|
bg: {
|
||||||
|
display: "flex",
|
||||||
|
height: 60,
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
},
|
||||||
|
textFieldInput: {
|
||||||
|
fontSize: 20,
|
||||||
|
},
|
||||||
|
inputRoot: {
|
||||||
|
fontWeight: 400,
|
||||||
|
fontSize: 18,
|
||||||
|
},
|
||||||
|
inputInput: {
|
||||||
|
padding: theme.spacing(1, 4, 1, 4),
|
||||||
|
// vertical padding + font size from searchIcon
|
||||||
|
transition: theme.transitions.create("width"),
|
||||||
|
width: "100%",
|
||||||
|
|
||||||
|
[theme.breakpoints.up("sm")]: {
|
||||||
|
width: "13ch",
|
||||||
|
"&:focus": {
|
||||||
|
width: "20ch",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
search: {
|
||||||
|
position: "relative",
|
||||||
|
borderRadius: theme.shape.borderRadius,
|
||||||
|
backgroundColor: fade(theme.palette.common.white, 0.25),
|
||||||
|
"&:hover": {
|
||||||
|
backgroundColor: fade(theme.palette.common.white, 0.25),
|
||||||
|
},
|
||||||
|
marginLeft: 0,
|
||||||
|
width: "100%",
|
||||||
|
[theme.breakpoints.up("sm")]: {
|
||||||
|
marginLeft: theme.spacing(1),
|
||||||
|
width: "auto",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
searchIcon: {
|
||||||
|
padding: theme.spacing(0, 0.5),
|
||||||
|
height: "100%",
|
||||||
|
position: "absolute",
|
||||||
|
pointerEvents: "none",
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
|
||||||
|
export default useStyles;
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { makeStyles } from '@material-ui/core';
|
||||||
|
|
||||||
|
const useStyles = makeStyles((theme) => ({
|
||||||
|
addMessageFab: {
|
||||||
|
position: "sticky",
|
||||||
|
bottom: theme.spacing(2),
|
||||||
|
left: theme.spacing(3)
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
|
export default useStyles;
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import React, { useState } from 'react'
|
||||||
|
import { Slide, Paper, Button } from '@material-ui/core'
|
||||||
|
import useStyles from './modal.styles';
|
||||||
|
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
|
||||||
|
|
||||||
|
import { useMessages } from '../../hooks/useMessages';
|
||||||
|
import { MessageInput } from '../form/MessageInput';
|
||||||
|
import { useMessageModal } from '../../hooks/useMessageModal';
|
||||||
|
|
||||||
|
export const MessageModal = () => {
|
||||||
|
const classes = useStyles();
|
||||||
|
const message = useMessages();
|
||||||
|
|
||||||
|
const {messageModal, setMessageModal} = useMessageModal()
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Slide direction="left" in={messageModal}>
|
||||||
|
<Paper className={messageModal ? classes.modalRoot : classes.modalHide}>
|
||||||
|
<Button onClick={() => setMessageModal(false)}><ArrowBackIcon /></Button>
|
||||||
|
{message.map((message) => (
|
||||||
|
<>
|
||||||
|
<Paper>{message.name}</Paper>
|
||||||
|
{message.messages.map((sms) => (
|
||||||
|
<div className={classes.messageContainer}>
|
||||||
|
<Paper className={sms.source == 'chip' ? classes.sourceSms : classes.sms} variant="elevation">
|
||||||
|
<p>{sms.sms}</p>
|
||||||
|
</Paper>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
))}
|
||||||
|
<MessageInput key={message.id} {...message}/>
|
||||||
|
</Paper>
|
||||||
|
</Slide>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import { makeStyles } from '@material-ui/core';
|
||||||
|
|
||||||
|
const useStyles = makeStyles((theme) => ({
|
||||||
|
modalRoot: {
|
||||||
|
zIndex: 30,
|
||||||
|
position: 'absolute',
|
||||||
|
height: '100%',
|
||||||
|
width: '100%'
|
||||||
|
},
|
||||||
|
modalHide: {
|
||||||
|
display: 'none'
|
||||||
|
},
|
||||||
|
messageContainer: {
|
||||||
|
marginTop: 25,
|
||||||
|
width: '100%'
|
||||||
|
},
|
||||||
|
sourceSms: {
|
||||||
|
float: 'right',
|
||||||
|
marginBottom: 20,
|
||||||
|
margin: 10,
|
||||||
|
width: 200,
|
||||||
|
background: '#0288d1',
|
||||||
|
paddingLeft: 5
|
||||||
|
},
|
||||||
|
sms: {
|
||||||
|
float: 'left',
|
||||||
|
marginBottom: 20,
|
||||||
|
margin: 10,
|
||||||
|
minWidth: 200,
|
||||||
|
maxWidth: 400,
|
||||||
|
background: '#ddd',
|
||||||
|
color: '#232323',
|
||||||
|
paddingLeft: 5
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
|
export default useStyles;
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import { atom } from 'recoil';
|
||||||
|
|
||||||
|
export const messageState = {
|
||||||
|
messageList: atom({
|
||||||
|
key: 'messageList',
|
||||||
|
default: []
|
||||||
|
}),
|
||||||
|
modal: atom({
|
||||||
|
key: 'messageModal',
|
||||||
|
default: true
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import { useRecoilState } from 'recoil';
|
||||||
|
import { messageState } from './state';
|
||||||
|
|
||||||
|
export const useMessageModal = () => {
|
||||||
|
const [ messageModal, setMessageModal ] = useRecoilState(messageState.modal)
|
||||||
|
return { messageModal, setMessageModal }
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import { useSetRecoilState } from 'recoil';
|
||||||
|
import { messageState } from './state';
|
||||||
|
import { useMessages } from './useMessages';
|
||||||
|
import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent';
|
||||||
|
|
||||||
|
export const useMessagesService = () => {
|
||||||
|
const setMessages = useSetRecoilState(messageState.messageList);
|
||||||
|
useNuiEvent('MESSAGES', 'setMessages', setMessages);
|
||||||
|
return useMessages();
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import { useRecoilValue } from 'recoil';
|
||||||
|
import { messageState } from './state';
|
||||||
|
|
||||||
|
export const useMessages = (): any => {
|
||||||
|
const message = useRecoilValue(messageState.messageList);
|
||||||
|
return message;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user