2021-05-26 17:24:54 +00:00
|
|
|
import React from 'react';
|
2022-03-02 14:18:01 +00:00
|
|
|
import { FlatList, FlatListProps, StyleSheet } from 'react-native';
|
2021-05-26 17:24:54 +00:00
|
|
|
import Animated from 'react-native-reanimated';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
import { isIOS } from '../../../utils/deviceInfo';
|
|
|
|
import scrollPersistTaps from '../../../utils/scrollPersistTaps';
|
|
|
|
|
|
|
|
const AnimatedFlatList = Animated.createAnimatedComponent(FlatList);
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
list: {
|
|
|
|
flex: 1
|
|
|
|
},
|
|
|
|
contentContainer: {
|
|
|
|
paddingTop: 10
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-05-02 22:58:23 +00:00
|
|
|
export type TListRef = React.RefObject<FlatList & { getNode: () => FlatList }>;
|
|
|
|
|
2022-03-02 14:18:01 +00:00
|
|
|
export interface IListProps extends FlatListProps<any> {
|
2022-05-02 22:58:23 +00:00
|
|
|
listRef: TListRef;
|
2022-03-02 14:18:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const List = ({ listRef, ...props }: IListProps) => (
|
2021-05-26 17:24:54 +00:00
|
|
|
<AnimatedFlatList
|
|
|
|
testID='room-view-messages'
|
|
|
|
ref={listRef}
|
2022-03-02 14:18:01 +00:00
|
|
|
keyExtractor={(item: any) => item.id}
|
2021-05-26 17:24:54 +00:00
|
|
|
contentContainerStyle={styles.contentContainer}
|
|
|
|
style={styles.list}
|
|
|
|
inverted
|
|
|
|
removeClippedSubviews={isIOS}
|
|
|
|
initialNumToRender={7}
|
|
|
|
onEndReachedThreshold={0.5}
|
|
|
|
maxToRenderPerBatch={5}
|
|
|
|
windowSize={10}
|
|
|
|
{...props}
|
|
|
|
{...scrollPersistTaps}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
List.propTypes = {
|
|
|
|
listRef: PropTypes.object
|
|
|
|
};
|
|
|
|
|
|
|
|
export default List;
|