lists: constant cards-per-row instead of measuring the grid
The adaptive grid resolves to exactly four cards on the TV's fixed full- width pane — index % 4 needs no layout probing and cannot be skewed by spanned items. Measuring existed only to re-derive the constant.
This commit is contained in:
parent
ec2b1f03b1
commit
effc2bd9ae
1 changed files with 7 additions and 15 deletions
|
|
@ -91,20 +91,12 @@ fun VideoListScreen(
|
|||
LaunchedEffect(source) { viewModel.loadChannelHeader(AppGraph.repository) }
|
||||
}
|
||||
|
||||
// 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 { it.size.width < info.viewportSize.width }
|
||||
?.size?.width ?: 0
|
||||
if (w > 0) (info.viewportSize.width / w).coerceIn(1, 10) else 0
|
||||
}
|
||||
}
|
||||
// Row starts of the 4-per-row grid: LEFT from a row's first card opens the
|
||||
// drawer (issue #7). rowCardWidth() sizes the adaptive columns to resolve
|
||||
// to exactly 4 on the full-width TV pane, so the row start is index % 4 —
|
||||
// no layout measuring needed (measuring the first visible item instead was
|
||||
// what made the full-span page header count as "one card per row").
|
||||
val cardsPerRow = 4
|
||||
|
||||
if (viewModel.loadingInitial && items.isEmpty()) {
|
||||
Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
|
||||
|
|
@ -170,7 +162,7 @@ fun VideoListScreen(
|
|||
onClick = { lastOpenedIndex = index; onOpenVideo(video) },
|
||||
showPrivacy = source is ListSource.MyVideos,
|
||||
compact = true,
|
||||
onLeftAtStart = if (index % cellsPerRow.coerceAtLeast(1) == 0) onOpenDrawer else null,
|
||||
onLeftAtStart = if (index % cardsPerRow == 0) onOpenDrawer else null,
|
||||
onUpToTopBar = upToTopBar?.takeIf { index < 4 },
|
||||
modifier = Modifier
|
||||
.focusRequester(fr),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue