feat(chat/native) fixed scroll inside chat room
This commit is contained in:
parent
2e69ec71c5
commit
39d1ccff85
|
@ -6,7 +6,6 @@ import { FlatList } from 'react-native';
|
||||||
import { MESSAGE_TYPE_LOCAL, MESSAGE_TYPE_REMOTE } from '../../constants';
|
import { MESSAGE_TYPE_LOCAL, MESSAGE_TYPE_REMOTE } from '../../constants';
|
||||||
|
|
||||||
import ChatMessage from './ChatMessage';
|
import ChatMessage from './ChatMessage';
|
||||||
import styles from './styles';
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
|
||||||
|
@ -43,8 +42,7 @@ export default class ChatMessageGroup extends Component<Props> {
|
||||||
data = { this.props.messages }
|
data = { this.props.messages }
|
||||||
inverted = { true }
|
inverted = { true }
|
||||||
keyExtractor = { this._keyExtractor }
|
keyExtractor = { this._keyExtractor }
|
||||||
renderItem = { this._renderMessage }
|
renderItem = { this._renderMessage } />
|
||||||
style = { styles.messageContainer } />
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { FlatList, Text, View } from 'react-native';
|
import { FlatList, Text, View } from 'react-native';
|
||||||
|
import { ScrollView } from 'react-native-gesture-handler';
|
||||||
|
|
||||||
import { ColorSchemeRegistry } from '../../../base/color-scheme';
|
import { ColorSchemeRegistry } from '../../../base/color-scheme';
|
||||||
import { translate } from '../../../base/i18n';
|
import { translate } from '../../../base/i18n';
|
||||||
|
@ -54,6 +55,7 @@ class MessageContainer extends AbstractMessageContainer<Props> {
|
||||||
return (
|
return (
|
||||||
<FlatList
|
<FlatList
|
||||||
ListEmptyComponent = { this._renderListEmptyComponent }
|
ListEmptyComponent = { this._renderListEmptyComponent }
|
||||||
|
bounces = { false }
|
||||||
data = { data }
|
data = { data }
|
||||||
|
|
||||||
// Workaround for RN bug:
|
// Workaround for RN bug:
|
||||||
|
@ -61,8 +63,7 @@ class MessageContainer extends AbstractMessageContainer<Props> {
|
||||||
inverted = { Boolean(data.length) }
|
inverted = { Boolean(data.length) }
|
||||||
keyExtractor = { this._keyExtractor }
|
keyExtractor = { this._keyExtractor }
|
||||||
keyboardShouldPersistTaps = 'always'
|
keyboardShouldPersistTaps = 'always'
|
||||||
renderItem = { this._renderMessageGroup }
|
renderItem = { this._renderMessageGroup } />
|
||||||
style = { styles.messageContainer } />
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +111,11 @@ class MessageContainer extends AbstractMessageContainer<Props> {
|
||||||
* @returns {React$Element<*>}
|
* @returns {React$Element<*>}
|
||||||
*/
|
*/
|
||||||
_renderMessageGroup({ item: messages }) {
|
_renderMessageGroup({ item: messages }) {
|
||||||
return <ChatMessageGroup messages = { messages } />;
|
return (
|
||||||
|
<ScrollView>
|
||||||
|
<ChatMessageGroup messages = { messages } />
|
||||||
|
</ScrollView>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,10 +71,6 @@ export default {
|
||||||
flexDirection: 'row'
|
flexDirection: 'row'
|
||||||
},
|
},
|
||||||
|
|
||||||
messageContainer: {
|
|
||||||
flex: 1
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper View for the entire block.
|
* Wrapper View for the entire block.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue