@@ -15,7 +15,10 @@ import {
1515 requireNativeComponent ,
1616 Alert ,
1717 Dimensions ,
18- DeviceEventEmitter
18+ DeviceEventEmitter ,
19+ Platform ,
20+ UIManager ,
21+ findNodeHandle ,
1922} from 'react-native' ;
2023
2124var ReactNative = require ( 'react-native' ) ;
@@ -42,7 +45,7 @@ export default class Chat extends Component {
4245 constructor ( props ) {
4346 super ( props ) ;
4447 this . state = {
45- inputViewLayout : { width :window . width , height :86 , } ,
48+ inputViewLayout : { width :window . width , height :100 , } ,
4649 menuContainerHeight : 1000 ,
4750 isDismissMenuContainer : false ,
4851 } ;
@@ -77,14 +80,21 @@ export default class Chat extends Component {
7780 }
7881
7982 var user = {
80- userId : "" ,
83+ userId : "1 " ,
8184 displayName : "" ,
8285 avatarPath : ""
8386 }
8487 user . userId = jmessage . from . username
8588 user . displayName = jmessage . from . nickname
8689 user . avatarPath = jmessage . from . avatarThumbPath
90+ if ( user . displayName == "" ) {
91+ user . displayName = jmessage . from . username
92+ }
93+ if ( user . avatarPath == "" ) {
94+ user . avatarPath = "ironman"
95+ }
8796 auroraMsg . fromUser = user
97+ console . log ( "from user: " + JSON . stringify ( auroraMsg . fromUser ) )
8898 auroraMsg . status = "send_going"
8999
90100 auroraMsg . isOutgoing = true
@@ -140,7 +150,12 @@ export default class Chat extends Component {
140150 }
141151 return normalMessage
142152 } )
143- AuroraIController . insertMessagesToTop ( auroraMessages )
153+ if ( Platform . OS == 'ios' ) {
154+ AuroraIController . insertMessagesToTop ( auroraMessages )
155+ } else {
156+ AuroraIController . insertMessagesToTop ( auroraMessages )
157+ // AuroraIController.scrollToBottom(true)
158+ }
144159 } , ( error ) => {
145160 Alert . alert ( 'error!' , JSON . stringify ( error ) )
146161 } )
@@ -174,6 +189,7 @@ export default class Chat extends Component {
174189 componentWillUnmount ( ) {
175190 JMessage . removeReceiveMessageListener ( this . receiveMessageCallBack )
176191 AuroraIController . removeMessageListDidLoadListener ( this . messageListDidLoadCallback )
192+ UIManager . dispatchViewManagerCommand ( findNodeHandle ( this . refs [ "MessageList" ] ) , 1 , null )
177193 }
178194
179195 updateLayout ( layout ) {
@@ -188,13 +204,18 @@ export default class Chat extends Component {
188204 console . log ( "Touch msg list, hidding soft input and dismiss menu" ) ;
189205 this . setState ( {
190206 isDismissMenuContainer : true ,
191- chatInputStyle : {
207+ inputViewLayout : {
192208 width : Dimensions . get ( 'window' ) . width ,
193209 height : 100
194210 } ,
195211 } ) ;
196212 }
197213
214+ onTouchEditText ( ) {
215+ console . log ( "scroll to bottom" )
216+ AuroraIController . scrollToBottom ( true ) ;
217+ }
218+
198219 onMsgClick = ( message ) => {
199220 console . log ( message )
200221 }
@@ -337,15 +358,15 @@ export default class Chat extends Component {
337358 }
338359
339360 onSwitchToMicrophoneMode = ( ) => {
340- this . updateLayout ( { width :window . width , height :256 , } )
361+ this . updateLayout ( { width :window . width , height :420 , } )
341362 }
342363
343364 onSwitchToGalleryMode = ( ) => {
344- this . updateLayout ( { width :window . width , height :256 , } )
365+ this . updateLayout ( { width :window . width , height :420 , } )
345366 }
346367
347368 onSwitchToCameraMode = ( ) => {
348- this . updateLayout ( { width :window . width , height :256 , } )
369+ this . updateLayout ( { width :window . width , height :420 , } )
349370 }
350371
351372 onShowKeyboard = ( keyboard_height ) => {
@@ -363,6 +384,7 @@ export default class Chat extends Component {
363384 return (
364385 < View style = { styles . container } >
365386 < MessageListView style = { styles . messageList }
387+ ref = "MessageList"
366388 onAvatarClick = { this . onAvatarClick }
367389 onMsgClick = { this . onMsgClick }
368390 onStatusViewClick = { this . onStatusViewClick }
@@ -373,7 +395,7 @@ export default class Chat extends Component {
373395 avatarSize = { { width :40 , height :40 } }
374396 sendBubbleTextSize = { 18 }
375397 sendBubbleTextColor = { "#000000" }
376- sendBubblePadding = { { left :10 , top :10 , right :10 , bottom :10 } }
398+ sendBubblePadding = { { left :10 , top :10 , right :15 , bottom :10 } }
377399 />
378400 < InputView style = { this . state . inputViewLayout }
379401 menuContainerHeight = { this . state . menuContainerHeight }
@@ -390,6 +412,7 @@ export default class Chat extends Component {
390412 onSwitchToGalleryMode = { this . onSwitchToGalleryMode }
391413 onSwitchToCameraMode = { this . onSwitchToCameraMode }
392414 onShowKeyboard = { this . onShowKeyboard }
415+ onTouchEditText = { this . onTouchEditText }
393416 />
394417 </ View >
395418 ) ;
@@ -404,7 +427,6 @@ const styles = StyleSheet.create({
404427 backgroundColor : '#F5FCFF' ,
405428 } ,
406429 messageList : {
407- backgroundColor : 'red' ,
408430 flex : 1 ,
409431 marginTop : 0 ,
410432 width : window . width ,
0 commit comments