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';
|
2022-09-19 20:46:15 +00:00
|
|
|
// import { FlatList } from 'react-native-gesture-handler';
|
|
|
|
import { FlashList } from '@shopify/flash-list';
|
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
|
|
|
|
2022-09-19 20:46:15 +00:00
|
|
|
const AnimatedFlatList = Animated.createAnimatedComponent(FlashList);
|
2021-05-26 17:24:54 +00:00
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
list: {
|
|
|
|
flex: 1
|
|
|
|
},
|
|
|
|
contentContainer: {
|
|
|
|
paddingTop: 10
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-09-19 20:46:15 +00:00
|
|
|
// export type TListRef = React.RefObject<FlatList & { getNode: () => FlatList }>;
|
2022-05-02 22:58:23 +00:00
|
|
|
|
2022-09-19 20:46:15 +00:00
|
|
|
export type IListProps = FlatListProps<any>;
|
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}
|
2022-09-19 20:46:15 +00:00
|
|
|
// style={styles.list}
|
2021-05-26 17:24:54 +00:00
|
|
|
inverted
|
2022-09-19 20:46:15 +00:00
|
|
|
estimatedItemSize={150}
|
|
|
|
// removeClippedSubviews={isIOS}
|
|
|
|
// initialNumToRender={7}
|
2021-05-26 17:24:54 +00:00
|
|
|
onEndReachedThreshold={0.5}
|
2022-09-19 20:46:15 +00:00
|
|
|
// maxToRenderPerBatch={5}
|
|
|
|
// windowSize={10}
|
2021-05-26 17:24:54 +00:00
|
|
|
{...props}
|
|
|
|
{...scrollPersistTaps}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
List.propTypes = {
|
|
|
|
listRef: PropTypes.object
|
|
|
|
};
|
|
|
|
|
|
|
|
export default List;
|