Created
May 31, 2019 09:07
-
-
Save anchetaWern/a5b4d9c07f08a1969f6416d1a5199eff to your computer and use it in GitHub Desktop.
React Native Stream Group Chat Tutorial: Render Chat screen UI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/screens/Chat.js | |
render() { | |
if (this.channel_state) { | |
const { messages, is_users_modal_visible } = this.state; | |
const channel_users = this.channel_state.members; | |
return ( | |
<View style={styles.container}> | |
<GiftedChat | |
messages={messages} | |
onSend={messages => this.onSend(messages)} | |
user={{ | |
_id: this.user_id | |
}} | |
/> | |
<Modal isVisible={is_users_modal_visible}> | |
<View style={styles.modal}> | |
<View style={styles.modal_header}> | |
<Text style={styles.modal_header_text}>Users</Text> | |
<TouchableOpacity onPress={this.hideModal.bind(this, 'users')}> | |
<View> | |
<Text>Close</Text> | |
</View> | |
</TouchableOpacity> | |
</View> | |
<View style={styles.modal_body}> | |
<FlatList | |
keyExtractor={item => item.user.id.toString()} | |
data={channel_users} | |
renderItem={this.renderUser} | |
/> | |
</View> | |
</View> | |
</Modal> | |
</View> | |
); | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment