diff --git a/src/components/InvertedFlatList/CellRendererComponent/index.android.js b/src/components/InvertedFlatList/CellRendererComponent/index.android.js new file mode 100644 index 000000000000..78ca24751187 --- /dev/null +++ b/src/components/InvertedFlatList/CellRendererComponent/index.android.js @@ -0,0 +1,35 @@ +import React from 'react'; +import {View} from 'react-native'; +import PropTypes from 'prop-types'; +import styles from '../../../styles/styles'; + +const propTypes = { + /** Position index of the list item in a list view */ + index: PropTypes.number.isRequired, +}; + +function CellRendererComponent(props) { + return ( + + ); +} + +CellRendererComponent.propTypes = propTypes; +CellRendererComponent.displayName = 'CellRendererComponent'; + +export default CellRendererComponent; diff --git a/src/components/InvertedFlatList/CellRendererComponent/index.ios.js b/src/components/InvertedFlatList/CellRendererComponent/index.ios.js new file mode 100644 index 000000000000..d6f02de2b942 --- /dev/null +++ b/src/components/InvertedFlatList/CellRendererComponent/index.ios.js @@ -0,0 +1,42 @@ +import React from 'react'; +import {View} from 'react-native'; +import PropTypes from 'prop-types'; + +const propTypes = { + /** Position index of the list item in a list view */ + index: PropTypes.number.isRequired, + + /** Styles that are passed to the component */ + style: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.object]), +}; + +const defaultProps = { + style: {}, +}; + +function CellRendererComponent(props) { + return ( + + ); +} + +CellRendererComponent.propTypes = propTypes; +CellRendererComponent.defaultProps = defaultProps; +CellRendererComponent.displayName = 'CellRendererComponent'; + +export default CellRendererComponent; diff --git a/src/components/InvertedFlatList/index.android.js b/src/components/InvertedFlatList/index.android.js index baf46c3f001a..0ffed10921d8 100644 --- a/src/components/InvertedFlatList/index.android.js +++ b/src/components/InvertedFlatList/index.android.js @@ -1,10 +1,11 @@ import React, {forwardRef} from 'react'; -import {View, FlatList} from 'react-native'; +import {FlatList} from 'react-native'; import PropTypes from 'prop-types'; import _ from 'underscore'; import BaseInvertedFlatList from './BaseInvertedFlatList'; import styles from '../../styles/styles'; import stylePropTypes from '../../styles/stylePropTypes'; +import CellRendererComponent from './CellRendererComponent'; const propTypes = { /** Passed via forwardRef so we can access the FlatList ref */ @@ -20,16 +21,6 @@ const defaultProps = { ListFooterComponentStyle: {}, }; -function InvertedCell(props) { - return ( - - ); -} - class InvertedFlatList extends React.Component { constructor(props) { super(props); @@ -57,7 +48,13 @@ class InvertedFlatList extends React.Component { style={styles.invert} ListFooterComponentStyle={[styles.invert, this.props.ListFooterComponentStyle]} verticalScrollbarPosition="left" // We are mirroring the X and Y axis, so we need to swap the scrollbar position - CellRendererComponent={InvertedCell} + CellRendererComponent={CellRendererComponent} + /** + * To achieve absolute positioning and handle overflows for list items, the property must be disabled + * for Android native builds. + * Source: https://reactnative.dev/docs/0.71/optimizing-flatlist-configuration#removeclippedsubviews + */ + removeClippedSubviews={false} /> ); } diff --git a/src/components/InvertedFlatList/index.ios.js b/src/components/InvertedFlatList/index.ios.js index d502162fe7bb..357f3d78ea9e 100644 --- a/src/components/InvertedFlatList/index.ios.js +++ b/src/components/InvertedFlatList/index.ios.js @@ -1,5 +1,6 @@ import React, {forwardRef} from 'react'; import BaseInvertedFlatList from './BaseInvertedFlatList'; +import CellRendererComponent from './CellRendererComponent'; export default forwardRef((props, ref) => ( ( {...props} ref={ref} inverted + CellRendererComponent={CellRendererComponent} /> ));