Skip to content

Commit 6b73d96

Browse files
Merge pull request #136 from Detaysoft/audio-message
Audio message feature added. Thanks @emregudur
2 parents d9cc331 + fa72125 commit 6b73d96

14 files changed

Lines changed: 153 additions & 10 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ import { ChatItem } from 'react-chat-elements'
101101

102102
## MessageBox Component
103103

104-
| file | photo | text | location | video |
105-
| ---- | ---- | ---- | ---- | ---- |
106-
| ![file-message](https://user-images.githubusercontent.com/15075759/29243524-786baf8c-7fa9-11e7-92b2-3960cc34fcf4.png) | ![photo-message](https://user-images.githubusercontent.com/15075759/29243556-1368c4e8-7faa-11e7-9fdd-57b67542c381.png) | ![text-message](https://user-images.githubusercontent.com/15075759/29243573-a809456e-7faa-11e7-97b4-d258bc6a7728.png) | ![location-message](https://user-images.githubusercontent.com/15075759/30582943-2b3338aa-9d2e-11e7-93d5-8614563b9217.png) | ![](https://user-images.githubusercontent.com/15075759/98530021-74ca1300-228f-11eb-88ab-5ae5ae33616d.png)
104+
| file | photo | text | location | video | audio |
105+
| ---- | ---- | ---- | ---- | ---- | ---- |
106+
| ![file-message](https://user-images.githubusercontent.com/15075759/29243524-786baf8c-7fa9-11e7-92b2-3960cc34fcf4.png) | ![photo-message](https://user-images.githubusercontent.com/15075759/29243556-1368c4e8-7faa-11e7-9fdd-57b67542c381.png) | ![text-message](https://user-images.githubusercontent.com/15075759/29243573-a809456e-7faa-11e7-97b4-d258bc6a7728.png) | ![location-message](https://user-images.githubusercontent.com/15075759/30582943-2b3338aa-9d2e-11e7-93d5-8614563b9217.png) | ![](https://user-images.githubusercontent.com/15075759/98530021-74ca1300-228f-11eb-88ab-5ae5ae33616d.png) | ![](https://user-images.githubusercontent.com/41473129/105960654-98327c00-608e-11eb-9ac4-5b014974b87c.png)
107107

108108

109109
```javascript
@@ -128,7 +128,7 @@ import { MessageBox } from 'react-chat-elements'
128128
| ---- | ---- | ---- | ---- |
129129
| id | i (index) | string | message box id |
130130
| position | left | string | message box position |
131-
| type | text | string | message type (text, photo, file, location, spotify, video) |
131+
| type | text | string | message type (text, photo, file, location, spotify, video, audio) |
132132
| text | none | string | message text |
133133
| title | none | string | message title |
134134
| titleColor | none | string(color) | message title color |

android/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>example</name>
4+
<comment>Project android_ created by Buildship.</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
16+
</natures>
17+
</projectDescription>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
arguments=
2+
auto.sync=false
3+
build.scans.enabled=false
4+
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
5+
connection.project.dir=
6+
eclipse.preferences.version=1
7+
gradle.user.home=
8+
java.home=C\:/Program Files (x86)/Java/jdk1.8.0_251
9+
jvm.arguments=
10+
offline.mode=false
11+
override.workspace.settings=true
12+
show.console.view=true
13+
show.executions.view=true

android/app/.classpath

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
4+
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
5+
<classpathentry kind="output" path="bin"/>
6+
</classpath>

android/app/.project

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>app</name>
4+
<comment>Project app created by Buildship.</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.jdt.core.javanature</nature>
21+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
22+
</natures>
23+
</projectDescription>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
connection.project.dir=..
2+
eclipse.preferences.version=1

example/App.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class App extends Component {
4343
}
4444

4545
UNSAFE_componentWillMount() {
46-
this.addMessage(6)
46+
this.addMessage(7)
4747
}
4848

4949
getRandomColor() {
@@ -56,7 +56,7 @@ export class App extends Component {
5656
}
5757

5858
token() {
59-
return (parseInt(Math.random() * 10 % 7));
59+
return (parseInt(Math.random() * 10 % 8));
6060
}
6161

6262
photo(size) {
@@ -97,6 +97,9 @@ export class App extends Component {
9797
mtype = 'video';
9898
status = 'sent';
9999
break;
100+
case 7:
101+
mtype = 'audio';
102+
break;
100103
default:
101104
mtype = 'text';
102105
status = 'read';
@@ -119,7 +122,7 @@ export class App extends Component {
119122
date: +new Date(),
120123
collapseTitle: loremIpsum({ count: 2, units: 'words' }),
121124
participants: Array(this.token() + 6).fill(1).map(x => ({
122-
id: parseInt(Math.random() * 10 % 6),
125+
id: parseInt(Math.random() * 10 % 7),
123126
title: loremIpsum({ count: 1, units: 'words' }),
124127
})),
125128
dataSource: Array(this.token() + 5).fill(1).map(x => ({
@@ -153,6 +156,7 @@ export class App extends Component {
153156
text: mtype === 'spotify' ? 'spotify:track:0QjjaCaXE45mvhCnV3C0TA' : loremIpsum({ count: 1, units: 'sentences' }),
154157
data: {
155158
videoURL: this.token() >= 1 ? 'https://www.w3schools.com/html/mov_bbb.mp4' : 'http://www.exit109.com/~dnn/clips/RW20seconds_1.mp4',
159+
audioURL: 'https://www.w3schools.com/html/horse.mp3',
156160
uri: `data:image/png;base64,${this.photo(150)}`,
157161
status: {
158162
click: true,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-chat-elements",
3-
"version": "10.13.0",
3+
"version": "10.14.0",
44
"description": "Reactjs chat components",
55
"author": "Avare Kodcu <abdurrahmaneker58@gmail.com>",
66
"main": "dist/main.js",

src/AudioMessage/AudioMessage.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.rce-mbox-audio {
2+
padding-bottom: 10px;
3+
max-width: 300px;
4+
}
5+
6+
audio:focus {
7+
outline: none;
8+
}

src/AudioMessage/AudioMessage.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from 'react';
2+
3+
import './AudioMessage.css';
4+
5+
export default class AudioMessage extends React.PureComponent {
6+
render() {
7+
const audioURL = this.props.data.audioURL;
8+
const controlsList = this.props.data.controlsList;
9+
10+
return (
11+
<div className={'rce-mbox-audio'}>
12+
<audio controls controlsList={controlsList ? controlsList : "nodownload"}>
13+
<source src={audioURL} type="audio/mp3"/>
14+
Your browser does not support the audio element.
15+
</audio>
16+
17+
{
18+
this.props.text &&
19+
<div className='rce-mbox-text'>
20+
{this.props.text}
21+
</div>
22+
}
23+
</div>
24+
);
25+
}
26+
}
27+
28+
AudioMessage.defaultProps = {
29+
data: {},
30+
};

0 commit comments

Comments
 (0)