lists: measure a card, not the header, for cards-per-row
LEFT from any card of a grid's first row opened the menu drawer. The cells-per-row estimate read the width of the first visible grid item, but near the top that is the page header, which spans the whole width — so it computed one card per row and treated every card as a row start. Skip full-span items when estimating; row starts resolve correctly even while the header is on screen.
This commit is contained in:
parent
710a0f23cc
commit
ec2b1f03b1
1 changed files with 6 additions and 1 deletions
|
|
@ -93,10 +93,15 @@ fun VideoListScreen(
|
|||
|
||||
// Cards-per-row of the adaptive grid — LEFT from the first card of ANY row
|
||||
// must open the drawer (issue #7: "every time I'm all the way on the left").
|
||||
// Measure a CARD, not the first visible item: the page header spans the full
|
||||
// width, and reading its width made cards-per-row = 1 — every card near the
|
||||
// top then thought it was a row start and opened the drawer.
|
||||
val cellsPerRow by remember {
|
||||
androidx.compose.runtime.derivedStateOf {
|
||||
val info = gridState.layoutInfo
|
||||
val w = info.visibleItemsInfo.firstOrNull()?.size?.width ?: 0
|
||||
val w = info.visibleItemsInfo
|
||||
.firstOrNull { it.size.width < info.viewportSize.width }
|
||||
?.size?.width ?: 0
|
||||
if (w > 0) (info.viewportSize.width / w).coerceIn(1, 10) else 0
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue