11'use strict' ;
22
33import React from 'react' ;
4- import ReactNative from 'react-native' ;
4+ import ReactNative , { ScrollView } from 'react-native' ;
55import JMessage from 'jmessage-react-plugin' ;
66
77import FormButton from '../../../views/FormButton'
@@ -48,14 +48,17 @@ const styles = StyleSheet.create({
4848 backgroundColor : 'rgba(0, 0, 0, 0.5)' ,
4949 } ,
5050 modalContent : {
51- width : 200 ,
52- height : 150 ,
53- justifyContent : 'center ' ,
51+ width : 300 ,
52+ height : 300 ,
53+ justifyContent : 'space-between ' ,
5454 alignItems : 'center' ,
5555 backgroundColor : '#ffffff' ,
5656 } ,
5757 modalButton : {
58-
58+ margin : 10 ,
59+ } ,
60+ inputStyle : {
61+ width : 200
5962 }
6063} ) ;
6164
@@ -84,11 +87,11 @@ export default class ConversationList extends React.Component {
8487 tabBarIcon : ( {
8588 tintColor
8689 } ) => (
87- < Image
90+ < Image
8891 source = { require ( '../../../resource/chat-icon.png' ) }
8992 style = { [ styles . icon , { tintColor : tintColor } ] }
9093 />
91- ) ,
94+ ) ,
9295 }
9396 } ;
9497
@@ -231,16 +234,32 @@ export default class ConversationList extends React.Component {
231234 } )
232235 }
233236
237+ enterChatRoom ( params ) {
238+ JMessage . enterChatRoom ( params . roomId , ( conversation ) => {
239+ var chatRoom = {
240+ conversationType : 'chatroom' ,
241+ key : conversation . roomId ,
242+ owner : conversation . owner ,
243+ totalMemberCount : conversation . totalMemberCount
244+ }
245+ this . props . navigation . navigate ( 'Chat' , {
246+ conversation : chatRoom
247+ } )
248+ } , ( error ) => {
249+ console . alert ( "error, code: " + error . code + ", description: " + error . description )
250+ } )
251+ }
252+
234253 render ( ) {
235254 this . listView = < FlatList
236- data = {
237- this . state . data
238- }
239- renderItem = {
255+ data = {
256+ this . state . data
257+ }
258+ renderItem = {
240259 ( {
241260 item
242261 } ) => (
243- < View >
262+ < View >
244263 < TouchableHighlight
245264 style = { [ styles . conversationContent ] }
246265 underlayColor = '#dddddd'
@@ -259,10 +278,10 @@ export default class ConversationList extends React.Component {
259278 </ View >
260279 </ TouchableHighlight >
261280 </ View >
262- )
281+ )
263282 } >
264283
265- </ FlatList >
284+ </ FlatList >
266285 return (
267286
268287 < View >
@@ -274,6 +293,7 @@ export default class ConversationList extends React.Component {
274293 < View
275294 style = { styles . modalContent } >
276295 < TextInput
296+ style = { styles . inputStyle }
277297 placeholder = "用户名或群聊名称"
278298 onChangeText = { ( e ) => { this . setState ( { modalText : e } ) } } >
279299 </ TextInput >
@@ -303,6 +323,22 @@ export default class ConversationList extends React.Component {
303323 } }
304324 style = { styles . modalButton }
305325 title = '创建群聊' />
326+ < Button
327+ onPress = { ( ) => {
328+ JMessage . createChatRoomConversation ( "1000" , ( conversation ) => {
329+ var params = {
330+ type : conversation . type ,
331+ roomId : conversation . roomId ,
332+ name : conversation . roomName ,
333+ appKey : conversation . appKey ,
334+ owner : conversation . owner ,
335+ }
336+ this . setState ( { isShowModal : false } )
337+ this . enterChatRoom ( params )
338+ } )
339+ } }
340+ style = { styles . modalButton }
341+ title = '创建聊天室' />
306342
307343 < Button
308344 onPress = { ( ) => { this . setState ( { isShowModal : false } ) } }
0 commit comments