Skip to content

Commit 18e9836

Browse files
KenChoiKenChoi
authored andcommitted
Merge branch 'dev' of github.com:jpush/jmessage-react-plugin into dev
2 parents 1863df0 + 7a38dd7 commit 18e9836

File tree

23 files changed

+533
-102
lines changed

23 files changed

+533
-102
lines changed

example/app/routes/Chat/index.js

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,16 @@ export default class Chat extends Component {
4343
constructor(props) {
4444
super(props);
4545
this.state = {
46-
inputViewLayout: { width: window.width, height: 200, },
4746
menuContainerHeight: 1000,
4847
isDismissMenuContainer: false,
4948
shouldExpandMenuContainer: false,
5049
};
51-
50+
if (Platform.OS == 'ios') {
51+
this.state.inputViewLayout = { width: window.width, height: 86, }
52+
} else {
53+
this.state.inputViewLayout = { width: window.width, height: 200, }
54+
}
55+
5256
this.updateLayout = this.updateLayout.bind(this);
5357
this.onTouchMsgList = this.onTouchMsgList.bind(this);
5458
this.conversation = this.props.navigation.state.params.conversation
@@ -138,7 +142,7 @@ export default class Chat extends Component {
138142
message.isOutgoing = true
139143
message.content = '<body bgcolor="#ff3399"><h5>This is a custom message. </h5>\
140144
<img src="/storage/emulated/0/XhsEmoticonsKeyboard/Emoticons/wxemoticons/icon_040_cover.png"></img></body>'
141-
message.contentSize = {'height': 400, 'width': 400}
145+
message.contentSize = {'height': 200, 'width': 200}
142146
message.extras = {"extras": "fdfsf"}
143147
var user = {
144148
userId: "1",
@@ -156,6 +160,7 @@ export default class Chat extends Component {
156160
}
157161

158162
componentDidMount() {
163+
this.resetMenu()
159164
var parames = {
160165

161166
'from': 0, // 开始的消息下标。
@@ -227,6 +232,31 @@ export default class Chat extends Component {
227232

228233
}
229234

235+
resetMenu() {
236+
if (Platform.OS === "android") {
237+
console.log("reset menu, count: " + this.state.lineCount)
238+
if (this.lineCount == 1) {
239+
this.setState({
240+
inputHeight: 120,
241+
inputViewLayout: { width: window.width, height: 200 }
242+
})
243+
} else {
244+
this.setState({
245+
inputHeight: 80 + this.state.lineCount * 40,
246+
inputViewLayout: { width: window.width, height: 160 + 40 * this.state.lineCount }
247+
})
248+
}
249+
this.setState({
250+
shouldExpandMenuContainer: false,
251+
})
252+
} else {
253+
this.setState({
254+
inputViewLayout: { width: window.width, height: 86 }
255+
})
256+
AuroraIController.hidenFeatureView(true)
257+
}
258+
}
259+
230260
updateLayout(layout) {
231261
this.setState({ inputViewLayout: layout })
232262
}
@@ -237,14 +267,7 @@ export default class Chat extends Component {
237267

238268
onTouchMsgList() {
239269
console.log("Touch msg list, hidding soft input and dismiss menu");
240-
this.setState({
241-
isDismissMenuContainer: true,
242-
inputViewLayout: {
243-
width: Dimensions.get('window').width,
244-
height: 200
245-
},
246-
shouldExpandMenuContainer: false,
247-
});
270+
this.resetMenu()
248271
}
249272

250273
onTouchEditText = () => {
@@ -560,7 +583,6 @@ export default class Chat extends Component {
560583
sendBubbleTextColor={"#000000"}
561584
sendBubblePadding={{ left: 10, top: 10, right: 15, bottom: 10 }}
562585
/>
563-
}
564586
<InputView style={this.state.inputViewLayout}
565587
menuContainerHeight={this.state.menuContainerHeight}
566588
isDismissMenuContainer={this.state.isDismissMenuContainer}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
'use strict';
2+
3+
import React from 'react';
4+
import ReactNative from 'react-native';
5+
import JMessage from 'jmessage-react-plugin';
6+
import {
7+
TabNavigator
8+
} from 'react-navigation';
9+
10+
11+
const {
12+
View,
13+
Text,
14+
TouchableHighlight,
15+
StyleSheet,
16+
Button,
17+
Alert,
18+
TextInput,
19+
Image,
20+
FlatList,
21+
ScrollView,
22+
} = ReactNative;
23+
24+
25+
26+
export default class ConversationDetail extends React.Component {
27+
static navigationOptions = {
28+
title: "会话详情",
29+
};
30+
31+
static navigationOptions = ({
32+
navigation
33+
}) => {
34+
const {
35+
params = {}
36+
} = navigation.state;
37+
return {
38+
headerLeft: <Button title="返回" onPress={() => {
39+
// this.props.navigation.goBack()
40+
navigation.goBack()
41+
// this.props.navigation.goBack()
42+
// this.onGoBack()
43+
// Alert.alert("navigation", this.)
44+
setTimeout(() => {
45+
params.onGoBack()
46+
}, 100);
47+
48+
// Alert.alert("goback",par)
49+
}} />,
50+
title: "会话详情",
51+
52+
}
53+
};
54+
55+
constructor(props) {
56+
super(props)
57+
this.state = {
58+
data: [],
59+
}
60+
// this.props.navigation.state.params.onGoBack();
61+
// Alert.alert("navigation", JSON.stringify(this.props.navigation.state.params.onGoBack))
62+
}
63+
64+
componentWillMount() {
65+
}
66+
67+
68+
render() {
69+
70+
return (
71+
<ScrollView>
72+
73+
</ScrollView>
74+
);
75+
}
76+
}

example/app/routes/Home/ConversationList/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ export default class ConversationList extends React.Component {
181181
}
182182

183183
_onPress() {
184-
Alert.alert("click", "fasdf")
185184
JMessage.createConversation({
186185
type: 'single',
187186
username: '0002'
@@ -197,7 +196,6 @@ export default class ConversationList extends React.Component {
197196
key: conv.target.id
198197
}
199198
item.conversationType = 'group'
200-
Alert.alert('conversaion', JSON.stringify(conv))
201199
}
202200
this.setState({})
203201
Alert.alert('the item', JSON.stringify(item))
@@ -223,7 +221,6 @@ export default class ConversationList extends React.Component {
223221
key: conv.target.id
224222
}
225223
item.conversationType = 'group'
226-
Alert.alert('conversaion', JSON.stringify(conv))
227224
}
228225
this.reloadConversationList()
229226
this.props.navigation.navigate('Chat', {

example/app/routes/Home/MyInfo/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ export default class MyNotificationsScreen extends React.Component {
7272
}
7373
componentWillMount() {
7474
JMessage.getMyInfo((user) => {
75-
Alert.alert("RNFS.MainBundlePath", RNFS.MainBundlePath)
76-
Alert.alert("user.avatarThumbPath", user.avatarThumbPath)
7775
this.setState({
7876
myInfo: user,
7977
})

example/app/routes/Login/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default class Login extends React.Component {
5151
Alert.alert('login success')
5252
navigate('Home')
5353
}, (error) => {
54-
Alert.alert('login success', JSON.stringify(error))
54+
Alert.alert('login fail', JSON.stringify(error))
5555
})
5656
}
5757

ios/RCTJMessageModule.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/* Begin PBXBuildFile section */
1010
6212EB1A1F3C34BB00BDF51A /* RCTJMessageModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 6212EB191F3C34BB00BDF51A /* RCTJMessageModule.m */; };
1111
6212EB1B1F3C34BB00BDF51A /* RCTJMessageModule.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 6212EB181F3C34BB00BDF51A /* RCTJMessageModule.h */; };
12-
6212EB221F3C38D200BDF51A /* JMessage.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6212EB211F3C38D200BDF51A /* JMessage.framework */; };
12+
623E44691FE245FA00FB7AD8 /* JMessage.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 623E44681FE245FA00FB7AD8 /* JMessage.framework */; };
1313
62D683E21F4469820083CDF6 /* JMessageHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 62D683E11F4469820083CDF6 /* JMessageHelper.m */; };
1414
/* End PBXBuildFile section */
1515

@@ -30,7 +30,7 @@
3030
6212EB151F3C34BB00BDF51A /* libRCTJMessageModule.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTJMessageModule.a; sourceTree = BUILT_PRODUCTS_DIR; };
3131
6212EB181F3C34BB00BDF51A /* RCTJMessageModule.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTJMessageModule.h; sourceTree = "<group>"; };
3232
6212EB191F3C34BB00BDF51A /* RCTJMessageModule.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RCTJMessageModule.m; sourceTree = "<group>"; };
33-
6212EB211F3C38D200BDF51A /* JMessage.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = JMessage.framework; sourceTree = "<group>"; };
33+
623E44681FE245FA00FB7AD8 /* JMessage.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = JMessage.framework; sourceTree = "<group>"; };
3434
62D683E01F4469820083CDF6 /* JMessageHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JMessageHelper.h; sourceTree = "<group>"; };
3535
62D683E11F4469820083CDF6 /* JMessageHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JMessageHelper.m; sourceTree = "<group>"; };
3636
/* End PBXFileReference section */
@@ -40,7 +40,7 @@
4040
isa = PBXFrameworksBuildPhase;
4141
buildActionMask = 2147483647;
4242
files = (
43-
6212EB221F3C38D200BDF51A /* JMessage.framework in Frameworks */,
43+
623E44691FE245FA00FB7AD8 /* JMessage.framework in Frameworks */,
4444
);
4545
runOnlyForDeploymentPostprocessing = 0;
4646
};
@@ -66,7 +66,7 @@
6666
6212EB171F3C34BB00BDF51A /* RCTJMessageModule */ = {
6767
isa = PBXGroup;
6868
children = (
69-
6212EB211F3C38D200BDF51A /* JMessage.framework */,
69+
623E44681FE245FA00FB7AD8 /* JMessage.framework */,
7070
62D683E01F4469820083CDF6 /* JMessageHelper.h */,
7171
62D683E11F4469820083CDF6 /* JMessageHelper.m */,
7272
6212EB181F3C34BB00BDF51A /* RCTJMessageModule.h */,
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
/*
2+
* | | | | \ \ / / | | | | / _______|
3+
* | |____| | \ \/ / | |____| | / /
4+
* | |____| | \ / | |____| | | | _____
5+
* | | | | / \ | | | | | | |____ |
6+
* | | | | / /\ \ | | | | \ \______| |
7+
* | | | | /_/ \_\ | | | | \_________|
8+
*
9+
* Copyright (c) 2011 ~ 2015 Shenzhen HXHG. All rights reserved.
10+
*/
11+
12+
#import <Foundation/Foundation.h>
13+
#import <JMessage/JMSGConstants.h>
14+
15+
@class JMSGUser;
16+
17+
/*!
18+
* 聊天室
19+
*
20+
* #### 主要特点
21+
*
22+
* 聊天室的消息没有推送通知和离线保存,也没有常驻成员的概念,只要进入聊天室即可接收消息,开始聊天,
23+
一旦退出聊天室,不再会接收到任何消息、通知和提醒。
24+
*
25+
* #### 发送消息
26+
*
27+
* 聊天室消息的发送与单聊、群聊是一样的,通用的发送接口
28+
*
29+
* #### 接收消息
30+
*
31+
* 聊天室消息的接收与单聊、群聊做了区分,聊天室消息的接收将通过 JMSGConversationDelegate 类里的 onReceiveChatRoomConversation:messages: 方法通知到上层
32+
*
33+
*/
34+
@interface JMSGChatRoom : NSObject
35+
JMSG_ASSUME_NONNULL_BEGIN
36+
37+
/*!
38+
* @abstract 分页获取聊天室详情
39+
*
40+
* @param appKey 选填,为 nil 则获取当前应用下的聊天室
41+
* @param start 分页获取的下标,第一页从 index = 0 开始
42+
* @param count 一页的数量,每页最大值是 50
43+
* @param handler 结果回调. 正常返回时 resultObject 类型是 NSArray<JMSGChatRoom>
44+
*
45+
* @discussion 该接口总是向服务器端发起请求.
46+
*/
47+
+ (void)getChatRoomListWithAppKey:(NSString *JMSG_NULLABLE)appKey
48+
start:(NSInteger)start
49+
count:(NSInteger)count
50+
completionHandler:(JMSGCompletionHandler JMSG_NULLABLE)handler;
51+
52+
/*!
53+
* @abstract 获取当前用户已加入的聊天室列表
54+
*
55+
* @param handler 结果回调. 正常返回时 resultObject 类型是 NSArray<JMSGChatRoom>
56+
*
57+
* @discussion 该接口总是向服务器端发起请求.
58+
*/
59+
+ (void)getMyChatRoomListCompletionHandler:(JMSGCompletionHandler JMSG_NULLABLE)handler;
60+
61+
/*!
62+
* @abstract 获取聊天室详情
63+
*
64+
* @param roomIds 待获取详情的聊天室 ID 数组
65+
* @param handler 结果回调. 正常返回时 resultObject 类型是 NSArray<JMSGChatRoom>
66+
*
67+
* @discussion 该接口总是向服务器端发起请求.
68+
*/
69+
+ (void)getChatRoomInfosWithRoomIds:(NSArray *JMSG_NONNULL)roomIds
70+
completionHandler:(JMSGCompletionHandler JMSG_NULLABLE)handler;
71+
72+
/*!
73+
* @abstract 加入聊天室
74+
*
75+
* @param roomId 聊天室 id
76+
* @param handler 结果回调. error = nil 表示加入成功,resultObject 为 JMSGConversation 类型
77+
*
78+
* @discussion 成功进入聊天室之后,会将聊天室中最近若干条聊天记录同步下来并以 onReceiveChatRoomConversation: 事件的形式通知到上层。
79+
*/
80+
+ (void)enterChatRoomWithRoomId:(NSString *JMSG_NONNULL)roomId
81+
completionHandler:(JMSGCompletionHandler JMSG_NULLABLE)handler;
82+
83+
/*!
84+
* @abstract 退出聊天室
85+
*
86+
* @param roomId 聊天室 id
87+
* @param handler 结果回调. error = nil 表示加入成功.
88+
*
89+
* @discussion 退出聊天室后获取不到任何消息和通知.
90+
*/
91+
+ (void)leaveChatRoomWithRoomId:(NSString *JMSG_NONNULL)roomId
92+
completionHandler:(JMSGCompletionHandler JMSG_NULLABLE)handler;
93+
94+
///----------------------------------------------------
95+
/// @name Group basic fields 群组基本属性
96+
///----------------------------------------------------
97+
98+
99+
/*!
100+
* @abstract 聊天室 id
101+
*/
102+
@property(nonatomic, strong, readonly) NSString *JMSG_NONNULL roomID;
103+
/*!
104+
* @abstract 名称
105+
*/
106+
@property(nonatomic, strong, readonly) NSString *JMSG_NONNULL name;
107+
/*!
108+
* @abstract 聊天室所属应用 AppKey
109+
*/
110+
@property(nonatomic, strong, readonly) NSString *JMSG_NONNULL appkey;
111+
/*!
112+
* @abstract 描述信息
113+
*/
114+
@property(nonatomic, strong, readonly) NSString *JMSG_NULLABLE desc;
115+
116+
/*!
117+
* @abstract 聊天室人数
118+
*/
119+
@property(nonatomic, assign, readonly) NSInteger totalMemberCount;
120+
121+
/*!
122+
* @abstract 聊天室最大人数限制
123+
*/
124+
@property(nonatomic, strong, readonly) NSString *JMSG_NULLABLE maxMemberCount;
125+
126+
/*!
127+
* @abstract 聊天室的创建时间
128+
*/
129+
@property(nonatomic, strong, readonly) NSNumber *ctime;
130+
131+
/*!
132+
* @abstract 聊天室创建者
133+
*
134+
* @param handler 结果回调. error = nil 表示获取成功, resultObject 为 JMSGUser 类型.
135+
*/
136+
- (void)getChatRoomOwnerInfo:(JMSGCompletionHandler JMSG_NULLABLE)handler;
137+
138+
/*!
139+
* @abstract 聊天室的展示名
140+
*
141+
* @discussion 如果 chatroom.name 为空, 则此接口会返回 chatroom.roomID.
142+
*/
143+
- (NSString *)displayName;
144+
145+
JMSG_ASSUME_NONNULL_END
146+
@end

0 commit comments

Comments
 (0)