Skip to content

Commit d6b6b48

Browse files
guangyaoguangyao
authored andcommitted
2 parents 403d862 + 1a84ed7 commit d6b6b48

File tree

67 files changed

+859
-859
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+859
-859
lines changed

README.md

Lines changed: 29 additions & 194 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,44 @@
1-
## IMUI for React Native
1+
# ReactNative IMUI
2+
项目fork自 jpush 的 [Aurora IMUI](https://github.com/jpush/aurora-imui/tree/master/ReactNative)
23

3-
[中文文档](./README_zh.md)
4-
5-
## InstallREADME_zh.md
4+
## 使用
5+
参考[demo](https://github.com/reactnativecomponent/react-native-chat-demo)
6+
## 安装
67

78
```
89
npm install react-native-imui --save
910
react-native link
1011
```
1112

12-
If link Android failed, you need modify `settings.gradle`:
13+
如果 link 安卓失败,需要手动修改一下 `settings.gradle` 中的引用路径:
1314

1415
```
1516
include ':app', ':react-native-imui'
1617
project(':react-native-imui').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-imui/android')
1718
```
1819

19-
And add dependency in your app's `build.gradle`:
20+
然后在 app`build.gradle`中引用:
2021

2122
```
2223
dependencies {
2324
compile project(':react-native-imui')
2425
}
2526
```
2627

28+
**注意事项(Android):我们使用了 support v4, v7 25.3.1 版本,因此需要将你的 build.gradle 中 buildToolsVersion 及 compiledSdkVersion 改为 25 以上。可以参考 demo 的配置。**
2729

28-
29-
## Configuration
30+
## 配置
3031

3132
- ### Android
3233

33-
- Add Package:
34+
- 引入 Package:
3435

3536
> MainApplication.java
3637
3738
```
39+
import cn.jiguang.imui.messagelist.ReactIMUIPackage;
40+
...
41+
3842
@Override
3943
protected List<ReactPackage> getPackages() {
4044
return Arrays.<ReactPackage>asList(
@@ -44,33 +48,22 @@ dependencies {
4448
}
4549
```
4650

47-
- import IMUI from 'react-native-imui';
4851

4952

50-
- ### iOS
5153

54+
55+
56+
- ### iOS
5257
- PROJECT -> TARGETS -> Build Settings -> Enable Bitcode Set to No
53-
- Find PROJECT -> TARGETS -> General -> Embedded Binaries and add RNTAuroraIMUI.framework
54-
- Before build you project ,you should build RNTAuroraIMUI.framework
58+
- Find PROJECT -> TARGETS -> General -> Embedded Binaries and add RCTAuroraIMUI.framework
5559

56-
## Usage
57-
```
58-
import IMUI from 'react-native-imui';
59-
var MessageList = IMUI.MessageList;
60-
var ChatInput = IMUI.ChatInput;
61-
const AuroraIMUIModule = NativeModules.AuroraIMUIModule;
62-
```
63-
Refer to iOS,Android example
64-
> [iOS Example usage](./sample/index.ios.js)
65-
> [Android Example usage](./sample/react-native-android/pages/chat_activity.js)
66-
## Data format
60+
## 数据格式
6761

68-
By using MessageList, you need define `message` object and `fromUser` object.
62+
使用 MessageList,你需要定义 `message` 对象和 `fromUser` 对象。
6963

70-
- message object format:
64+
- `message` 对象格式:
7165

72-
** status must be one of the four values: "send_succeed", "send_failed", "send_going", "download_failed",
73-
if you haven't define this property, default value is "send_succeed".**
66+
**status 必须为以下四个值之一: "send_succeed", "send_failed", "send_going", "download_failed",如果没有定义这个属性, 默认值是 "send_succeed".**
7467

7568
```
7669
message = { // text message
@@ -96,7 +89,7 @@ message = { // voice message
9689
msgId: "msgid",
9790
msgType: "voice",
9891
isOutGoing: true,
99-
duration: number
92+
duration: number, // 注意这个值有用户自己设置时长,单位秒
10093
mediaPath: "voice path"
10194
fromUser: {}
10295
}
@@ -110,9 +103,15 @@ message = { // video message
110103
mediaPath: "voice path"
111104
fromUser: {}
112105
}
106+
107+
message = { // event message
108+
msgId: "msgid",
109+
msgType: "event",
110+
text: "the event text"
111+
}
113112
```
114113

115-
- fromUser object format:
114+
- `fromUser` 对象格式:
116115

117116
```
118117
fromUser = {
@@ -122,167 +121,3 @@ message = { // video message
122121
}
123122
```
124123

125-
126-
## Event Handling
127-
128-
### MessageList Event
129-
- onAvatarClick {message: {message json}} :Fires when click avatar
130-
131-
- onMsgClick {message: {message json} : Fires when click message bubble
132-
133-
- onStatusViewClick {message: {message json}} Fires when click status view
134-
135-
- onPullToRefresh Fires when pull MessageList to top, example usage: please refer sample's onPullToRefresh method.
136-
137-
138-
- onBeginDragMessageList (iOS only)
139-
140-
### MessageList append/update/insert message event:
141-
142-
For append/update/insert message to MessageList, you will use `MsgListModule`(Native Module) to send event to native.
143-
144-
- appendMessages([message])
145-
146-
example:
147-
148-
```
149-
var messages = [{
150-
msgId: "1",
151-
status: "send_going",
152-
msgType: "text",
153-
text: "Hello world",
154-
isOutgoing: true,
155-
fromUser: {
156-
userId: "1",
157-
displayName: "Ken",
158-
avatarPath: "ironman"
159-
},
160-
timeString: "10:00",
161-
}];
162-
AuroraIMUIModule.appendMessages(messages);
163-
```
164-
165-
- updateMessage(message)
166-
167-
example:
168-
169-
```
170-
var message = {
171-
msgId: "1",
172-
status: "send_going",
173-
msgType: "text",
174-
text: text,
175-
isOutgoing: true,
176-
fromUser: {
177-
userId: "1",
178-
displayName: "Ken",
179-
avatarPath: "ironman"
180-
},
181-
timeString: "10:00",
182-
};
183-
AuroraIMUIModule.updateMessage(message);
184-
```
185-
186-
- insertMessagesToTop([message])
187-
188-
**Notice that the order of message array must be sorted in chronological order**
189-
190-
example:
191-
192-
```
193-
var messages = [{
194-
msgId: "1",
195-
status: "send_succeed",
196-
msgType: "text",
197-
text: "This",
198-
isOutgoing: true,
199-
fromUser: {
200-
userId: "1",
201-
displayName: "Ken",
202-
avatarPath: "ironman"
203-
},
204-
timeString: "10:00",
205-
},{
206-
msgId: "2",
207-
status: "send_succeed",
208-
msgType: "text",
209-
text: "is",
210-
isOutgoing: true,
211-
fromUser: {
212-
userId: "1",
213-
displayName: "Ken",
214-
avatarPath: "ironman"
215-
},
216-
timeString: "10:10",
217-
},{
218-
msgId: "3",
219-
status: "send_succeed",
220-
msgType: "text",
221-
text: "example",
222-
isOutgoing: true,
223-
fromUser: {
224-
userId: "1",
225-
displayName: "Ken",
226-
avatarPath: "ironman"
227-
},
228-
timeString: "10:20",
229-
}];
230-
AuroraIMUIModule.insertMessagesToTop(messages);
231-
```
232-
233-
## Style
234-
235-
### MessageList custom style
236-
237-
**In android, if your want to define your chatting bubble, you need to put a drawable file in drawable folder, and that image file must be [nine patch drawable file](https://developer.android.com/reference/android/graphics/drawable/NinePatchDrawable.html), see our example for detail.**
238-
239-
240-
241-
**In iOS, if your want to define your chatting bubble,you need to put a image file to you xcode,and specifies ` sendBubble.imageName` or `receiveBubble.imageName` to image name. if you need to set the default avatar, you need put you default avatar image to you xcode,and adjust the image name to `defoult_header`,see our example for detail.**
242-
243-
- sendBubble: PropTypes.object :
244-
```
245-
// eg:
246-
{
247-
imageName:"inComing_bubble",
248-
padding:{left:10,top:10,right:15,bottom:10}
249-
}
250-
```
251-
252-
- receiveBubble: PropTypes.object,
253-
254-
- sendBubbleTextColor: PropTypes.string,
255-
256-
- receiveBubbleTextColor: PropTypes.string,
257-
258-
- sendBubbleTextSize: PropTypes.number,
259-
260-
- receiveBubbleTextSize: PropTypes.number,
261-
262-
263-
This Padding object includes four properties: left, top, right, bottom.
264-
```
265-
// eg:
266-
{
267-
left: 5,
268-
top: 5,
269-
right: 15,
270-
bottom: 5
271-
}
272-
```
273-
- sendBubblePadding: PropTypes.object
274-
275-
- receiveBubblePadding: PropTypes.object
276-
277-
- dateTextSize: PropTypes.number,
278-
279-
- dateTextColor: PropTypes.string,
280-
281-
- datePadding: PropTypes.number -- This is a number property, means padding left/top/right/bottom value is same.
282-
283-
Size object include width and height properties.
284-
285-
- avatarSize: PropTypes.object -- Example: avatarSize = {width: 50, height: 50}
286-
287-
- showDisplayName: PropTypes.bool,
288-

README_zh.md

Lines changed: 0 additions & 59 deletions
This file was deleted.

android/chatinput/src/main/java/cn/jiguang/imui/chatinput/ChatInputView.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ private void init(Context context, AttributeSet attrs) {
164164
mChatInput.setTextColor(mStyle.getInputTextColor());
165165
mChatInput.setHintTextColor(mStyle.getInputHintColor());
166166
mChatInput.setBackgroundResource(mStyle.getInputEditTextBg());
167-
mInputMarginLeft.getLayoutParams().width = mStyle.getInputMarginLeft();
168-
mInputMarginRight.getLayoutParams().width = mStyle.getInputMarginRight();
167+
// mInputMarginLeft.getLayoutParams().width = mStyle.getInputMarginLeft();
168+
// mInputMarginRight.getLayoutParams().width = mStyle.getInputMarginRight();
169169
mVoiceBtn.setImageResource(mStyle.getVoiceBtnIcon());
170170
mVoiceBtn.setBackground(mStyle.getVoiceBtnBg());
171171
mEmojiBtn.setBackground(mStyle.getPhotoBtnBg());
@@ -240,20 +240,22 @@ public void onClick(View view) {
240240
mListener.switchToActionMode();
241241
}
242242

243+
changeVoiceToInput(true);
243244
actionLayout.setVisibility(VISIBLE);
244245
emoticonPickerView.setVisibility(GONE);
245246

246247
} else if (view.getId() == R.id.imui_layout_emoji) {
247248
if (mListener != null) {
248249
mListener.switchToEmojiMode();
249250
}
251+
changeVoiceToInput(true);
250252
emoticonPickerView.setVisibility(VISIBLE);
251253
emoticonPickerView.show(emoticonSelectedListener);
252254
actionLayout.setVisibility(GONE);
253255
}
254256

255257
mLastClickId = view.getId();
256-
requestLayout();
258+
// mMenuContainer.requestLayout();
257259
}
258260
}
259261
};
@@ -390,7 +392,7 @@ public void dismissMenuAndResetSoftMode() {
390392
}
391393

392394
dismissMenuLayout();
393-
setMenuContainerHeight(1);
395+
// setMenuContainerHeight(1);
394396
mChatInput.requestFocus();
395397
}
396398

0 commit comments

Comments
 (0)