-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
1,106 additions
and
77 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,53 @@ | ||
import React from "react"; | ||
import React from 'react'; | ||
import { Typography, AppBar } from '@material-ui/core'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
|
||
import VideoPlayer from './VideoPlayer'; | ||
import Sidebar from './Sidebar'; | ||
import Notifications from './Notification'; | ||
|
||
|
||
const useStyles = makeStyles((theme) => ({ | ||
appBar: { | ||
borderRadius: 15, | ||
margin: '30px 100px', | ||
display: 'flex', | ||
flexDirection: 'row', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
width: '600px', | ||
border: '2px solid black', | ||
|
||
[theme.breakpoints.down('xs')]: { | ||
width: '90%', | ||
}, | ||
}, | ||
image: { | ||
marginLeft: '15px', | ||
}, | ||
wrapper: { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
width: '100%', | ||
}, | ||
})); | ||
|
||
const Dashboard = () => { | ||
return <div>Dashboard</div>; | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<div className={classes.wrapper}> | ||
<AppBar className={classes.appBar} position="static" color="inherit"> | ||
<Typography variant="h2" align="center">Video Chat</Typography> | ||
</AppBar> | ||
<VideoPlayer /> | ||
<Sidebar> | ||
<Notifications /> | ||
</Sidebar> | ||
</div> | ||
); | ||
}; | ||
|
||
|
||
export default Dashboard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React, { useContext } from 'react'; | ||
import { Button } from '@material-ui/core'; | ||
|
||
import { SocketContext } from '../../Context'; | ||
|
||
const Notifications = () => { | ||
const { answerCall, call, callAccepted } = useContext(SocketContext); | ||
|
||
return ( | ||
<> | ||
{call.isReceivingCall && !callAccepted && ( | ||
<div style={{ display: 'flex', justifyContent: 'space-around' }}> | ||
<h1>{call.name} is calling:</h1> | ||
<Button variant="contained" color="primary" onClick={answerCall}> | ||
Answer | ||
</Button> | ||
</div> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default Notifications; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import React, { useState, useContext } from 'react'; | ||
import { Button, TextField, Grid, Typography, Container, Paper } from '@material-ui/core'; | ||
import { CopyToClipboard } from 'react-copy-to-clipboard'; | ||
import { Assignment, Phone, PhoneDisabled } from '@material-ui/icons'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
|
||
import { SocketContext } from '../../Context'; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
root: { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
}, | ||
gridContainer: { | ||
width: '100%', | ||
[theme.breakpoints.down('xs')]: { | ||
flexDirection: 'column', | ||
}, | ||
}, | ||
container: { | ||
width: '600px', | ||
margin: '35px 0', | ||
padding: 0, | ||
[theme.breakpoints.down('xs')]: { | ||
width: '80%', | ||
}, | ||
}, | ||
margin: { | ||
marginTop: 20, | ||
}, | ||
padding: { | ||
padding: 20, | ||
}, | ||
paper: { | ||
padding: '10px 20px', | ||
border: '2px solid black', | ||
}, | ||
})); | ||
|
||
const Sidebar = ({ children }) => { | ||
const { me, callAccepted, name, setName, callEnded, leaveCall, callUser } = useContext(SocketContext); | ||
const [idToCall, setIdToCall] = useState(''); | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<Container className={classes.container}> | ||
<Paper elevation={10} className={classes.paper}> | ||
<form className={classes.root} noValidate autoComplete="off"> | ||
<Grid container className={classes.gridContainer}> | ||
<Grid item xs={12} md={6} className={classes.padding}> | ||
<Typography gutterBottom variant="h6">Account Info</Typography> | ||
<TextField label="Name" value={name} onChange={(e) => setName(e.target.value)} fullWidth /> | ||
<CopyToClipboard text={me} className={classes.margin}> | ||
<Button variant="contained" color="primary" fullWidth startIcon={<Assignment fontSize="large" />}> | ||
Copy Your ID | ||
</Button> | ||
</CopyToClipboard> | ||
</Grid> | ||
<Grid item xs={12} md={6} className={classes.padding}> | ||
<Typography gutterBottom variant="h6">Make a call</Typography> | ||
<TextField label="ID to call" value={idToCall} onChange={(e) => setIdToCall(e.target.value)} fullWidth /> | ||
{callAccepted && !callEnded ? ( | ||
<Button variant="contained" color="secondary" startIcon={<PhoneDisabled fontSize="large" />} fullWidth onClick={leaveCall} className={classes.margin}> | ||
Hang Up | ||
</Button> | ||
) : ( | ||
<Button variant="contained" color="primary" startIcon={<Phone fontSize="large" />} fullWidth onClick={() => callUser(idToCall)} className={classes.margin}> | ||
Call | ||
</Button> | ||
)} | ||
</Grid> | ||
</Grid> | ||
</form> | ||
{children} | ||
</Paper> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default Sidebar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React, { useContext } from 'react'; | ||
import { Grid, Typography, Paper, makeStyles } from '@material-ui/core'; | ||
|
||
import { SocketContext } from '../../Context'; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
video: { | ||
width: '550px', | ||
[theme.breakpoints.down('xs')]: { | ||
width: '300px', | ||
}, | ||
}, | ||
gridContainer: { | ||
justifyContent: 'center', | ||
[theme.breakpoints.down('xs')]: { | ||
flexDirection: 'column', | ||
}, | ||
}, | ||
paper: { | ||
padding: '10px', | ||
border: '2px solid black', | ||
margin: '10px', | ||
}, | ||
})); | ||
|
||
const VideoPlayer = () => { | ||
const { name, callAccepted, myVideo, userVideo, callEnded, stream, call } = useContext(SocketContext); | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<Grid container className={classes.gridContainer}> | ||
{stream && ( | ||
<Paper className={classes.paper}> | ||
<Grid item xs={12} md={6}> | ||
<Typography variant="h5" gutterBottom>{name || 'Name'}</Typography> | ||
<video playsInline muted ref={myVideo} autoPlay className={classes.video} /> | ||
</Grid> | ||
</Paper> | ||
)} | ||
{callAccepted && !callEnded && ( | ||
<Paper className={classes.paper}> | ||
<Grid item xs={12} md={6}> | ||
<Typography variant="h5" gutterBottom>{call.name || 'Name'}</Typography> | ||
<video playsInline ref={userVideo} autoPlay className={classes.video} /> | ||
</Grid> | ||
</Paper> | ||
)} | ||
</Grid> | ||
); | ||
}; | ||
|
||
export default VideoPlayer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters