Open
Description
Current behavior
Hey I am trying to increase the amount a certain item is spanning across the columns. Here is the example of my code:
export const ViewTypes = {
HALF_WIDTH: 0,
FULL_WIDTH: 1,
};
const ListContainer = (props) => {
const [ listData, setListData ] = useState([]);
useEffect(() => {
setListData(ListManager.get());
}, []);
const _renderItem = ({ item, index }) => {
const height = ITEM_HEIGHT;
switch (item.type) {
case ViewTypes.HALF_WIDTH:
return (
<HalfWidthView
height={height}
/>
);
case ViewTypes.FULL_WIDTH:
return (
<FullWidthView
height={height}
/>
);
default:
return (
<HalfWidthView
height={height}
/>
);
}
}
_getItemType = (item) => {
return item.type;
}
_overrideItemLayout = (layout, item, index, maxColumns) => {
layout.size = ITEM_HEIGHT;
layout.span = index === 0 ? 2 : 1;
}
return (
<>
<MasonryFlashList
data={listData}
renderItem={_renderItem}
estimatedItemSize={ITEM_HEIGHT}
numColumns={2}
optimizeItemArrangement={true}
overrideItemLayout={_overrideItemLayout}
/>
</>
);
};
export default ListContainer;
Here is an example of the output:
Expected behavior
I am expecting the blue box to take up 2 columns span. So the top row would be full width of the screen and allow the blue box to take up that space. The rest of the "half width" items will naturally wrap to the next row.
To Reproduce
It seems doing the following is not working:
_overrideItemLayout = (layout, item, index, maxColumns) => {
layout.size = ITEM_HEIGHT;
layout.span = index === 0 ? 2 : 1;
}
Platform:
- [ X] iOS
- [ X] Android
Environment
"@shopify/flash-list": "^1.4.0",