@eslam-elmeniawy/react-native-common-components
Version:
Common `ReactNative` components packed in library for usage in projects.
63 lines (59 loc) • 2.09 kB
JavaScript
;
// External imports.
import * as React from 'react';
import { FlatList as NativeFlatList, RefreshControl, StyleSheet } from 'react-native';
import { withTheme } from 'react-native-paper';
// Types imports.
// Internal imports.
import styles from "./FlatList.styles.js";
/**
* FlatListComponent (unwrapped, for testing)
* @internal For testing purposes only. Do not use in production code.
*/
import { jsx as _jsx } from "react/jsx-runtime";
const FlatListComponent = /*#__PURE__*/React.memo(props => {
const {
refreshing,
onRefresh,
refreshColor,
showsHorizontalScrollIndicator,
showsVerticalScrollIndicator,
horizontal,
keyboardShouldPersistTaps,
keyboardDismissMode,
keyExtractor,
onEndReachedThreshold,
style,
contentContainerStyle,
refreshControl,
theme,
data,
renderItem,
...other
} = props;
return /*#__PURE__*/_jsx(NativeFlatList, {
data: data,
renderItem: renderItem,
showsHorizontalScrollIndicator: showsHorizontalScrollIndicator ?? false,
showsVerticalScrollIndicator: showsVerticalScrollIndicator ?? false,
horizontal: horizontal,
keyboardShouldPersistTaps: keyboardShouldPersistTaps ?? 'handled',
keyboardDismissMode: keyboardDismissMode ?? 'none',
keyExtractor: keyExtractor ?? (item => item.key),
onEndReachedThreshold: onEndReachedThreshold ?? 0.01,
style: StyleSheet.compose(styles.list, style),
contentContainerStyle: horizontal ? StyleSheet.compose(styles.horizontalContainerStyle, contentContainerStyle) : contentContainerStyle,
refreshing: refreshing,
refreshControl: refreshControl ?? onRefresh ? /*#__PURE__*/_jsx(RefreshControl, {
colors: refreshColor ? [refreshColor] : [theme.colors.primary],
tintColor: refreshColor ?? theme.colors.primary,
refreshing: refreshing ?? false,
onRefresh: onRefresh ?? undefined
}) : undefined,
...other
});
});
const FlatList = withTheme(FlatListComponent);
export { FlatListComponent };
export default FlatList;
//# sourceMappingURL=FlatList.js.map