scrollview works with an outer view to set its sizing and also adding in shadow and also the input field mulitple lines
This commit is contained in:
+31
-12
@@ -77,7 +77,7 @@ export default class Chat extends Component<Props> {
|
|||||||
|
|
||||||
if (this.state.prevMessageUser != msg.user_id && this.state.prevMessageUser) {
|
if (this.state.prevMessageUser != msg.user_id && this.state.prevMessageUser) {
|
||||||
var dotSeparator = (
|
var dotSeparator = (
|
||||||
<View key={msg.text} style={styles.separatorCont}>
|
<View key={msg.created} style={styles.separatorCont}>
|
||||||
<Text>. .</Text>
|
<Text>. .</Text>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
@@ -155,9 +155,19 @@ export default class Chat extends Component<Props> {
|
|||||||
</View>
|
</View>
|
||||||
</View>)
|
</View>)
|
||||||
:
|
:
|
||||||
(<ScrollView style={styles.chatField}>
|
(
|
||||||
{this.state.messagesDOM}
|
<View style={styles.chatField}>
|
||||||
</ScrollView>)
|
<ScrollView
|
||||||
|
ref={ref => this.scrollView = ref}
|
||||||
|
onContentSizeChange={(contentWidth, contentHeight) => {
|
||||||
|
this.scrollView.scrollToEnd({animated: true});
|
||||||
|
}}
|
||||||
|
scrollEnabled={true}
|
||||||
|
contentContainerStyle={styles.chatFieldScroll}>
|
||||||
|
{this.state.messagesDOM}
|
||||||
|
</ScrollView>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
<View style={styles.inputMsgField}>
|
<View style={styles.inputMsgField}>
|
||||||
@@ -167,6 +177,9 @@ export default class Chat extends Component<Props> {
|
|||||||
placeholder="Type a message..."
|
placeholder="Type a message..."
|
||||||
onChangeText={this.messageInput}
|
onChangeText={this.messageInput}
|
||||||
value={this.state.messageToSend}
|
value={this.state.messageToSend}
|
||||||
|
multiline = {true}
|
||||||
|
numberOfLines = {4}
|
||||||
|
maxLength = {220}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.iconCont}>
|
<View style={styles.iconCont}>
|
||||||
@@ -191,8 +204,10 @@ const styles = {
|
|||||||
backgroundColor: '#e8ebef'
|
backgroundColor: '#e8ebef'
|
||||||
},
|
},
|
||||||
chatField: {
|
chatField: {
|
||||||
flex: 8,
|
flex: 8
|
||||||
flexDirection: 'column',
|
},
|
||||||
|
chatFieldScroll: {
|
||||||
|
flexGrow: 1,
|
||||||
justifyContent: 'flex-end'
|
justifyContent: 'flex-end'
|
||||||
},
|
},
|
||||||
chatFieldEmpty: {
|
chatFieldEmpty: {
|
||||||
@@ -207,10 +222,10 @@ const styles = {
|
|||||||
padding: 5
|
padding: 5
|
||||||
},
|
},
|
||||||
userMsg: {
|
userMsg: {
|
||||||
alignSelf: 'flex-end'
|
justifyContent: 'flex-end'
|
||||||
},
|
},
|
||||||
otherMsg: {
|
otherMsg: {
|
||||||
alignSelf: 'flex-start'
|
justifyContent: 'flex-start'
|
||||||
},
|
},
|
||||||
avatarAlready: {
|
avatarAlready: {
|
||||||
marginRight: 45,
|
marginRight: 45,
|
||||||
@@ -227,10 +242,14 @@ const styles = {
|
|||||||
padding: 10,
|
padding: 10,
|
||||||
borderBottomRightRadius: 10,
|
borderBottomRightRadius: 10,
|
||||||
borderBottomLeftRadius: 10,
|
borderBottomLeftRadius: 10,
|
||||||
shadowColor: '#000',
|
shadowColor:'black',
|
||||||
shadowOffset: { width: 0, height: 2 },
|
shadowOffset: {
|
||||||
shadowOpacity: 0.8,
|
width: 0,
|
||||||
shadowRadius: 2,
|
height: 3
|
||||||
|
},
|
||||||
|
shadowRadius: 5,
|
||||||
|
shadowOpacity: 1.0,
|
||||||
|
elevation: 5
|
||||||
},
|
},
|
||||||
userMsgBox: {
|
userMsgBox: {
|
||||||
backgroundColor: '#0e8f9e',
|
backgroundColor: '#0e8f9e',
|
||||||
|
|||||||
Reference in New Issue
Block a user