2022-08-08 21:02:08 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2021-05-26 17:24:54 +00:00
|
|
|
import React from 'react';
|
2022-08-08 21:02:08 +00:00
|
|
|
import { FlatListProps, StyleSheet } from 'react-native';
|
|
|
|
import { FlatList } from 'react-native-gesture-handler';
|
2021-05-26 17:24:54 +00:00
|
|
|
import Animated from 'react-native-reanimated';
|
|
|
|
|
2022-06-06 14:17:51 +00:00
|
|
|
import { isIOS } from '../../../lib/methods/helpers';
|
|
|
|
import scrollPersistTaps from '../../../lib/methods/helpers/scrollPersistTaps';
|
2021-05-26 17:24:54 +00:00
|
|
|
|
|
|
|
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}
|
2023-08-18 17:48:33 +00:00
|
|
|
inverted={isIOS}
|
2021-05-26 17:24:54 +00:00
|
|
|
removeClippedSubviews={isIOS}
|
|
|
|
initialNumToRender={7}
|
|
|
|
onEndReachedThreshold={0.5}
|
|
|
|
maxToRenderPerBatch={5}
|
|
|
|
windowSize={10}
|
|
|
|
{...props}
|
|
|
|
{...scrollPersistTaps}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
List.propTypes = {
|
|
|
|
listRef: PropTypes.object
|
|
|
|
};
|
|
|
|
|
|
|
|
export default List;
|