diff --git a/app/src/main/java/net/jeena/jtubetv/ui/screens/list/VideoListScreen.kt b/app/src/main/java/net/jeena/jtubetv/ui/screens/list/VideoListScreen.kt index 498025b..265d2ed 100644 --- a/app/src/main/java/net/jeena/jtubetv/ui/screens/list/VideoListScreen.kt +++ b/app/src/main/java/net/jeena/jtubetv/ui/screens/list/VideoListScreen.kt @@ -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),