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 265d2ed..02bd0b6 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,12 +91,18 @@ fun VideoListScreen( LaunchedEffect(source) { viewModel.loadChannelHeader(AppGraph.repository) } } - // 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 + // Row starts of the grid: LEFT from a row's first card opens the drawer + // (issue #7). The adaptive columns use a `rowCardWidth() - 12` minimum with + // zero spacing, and the content pane eats 40dp (8 start + 32 end), so the + // resolved card count is exactly Compose's arithmetic here — 4 on a full- + // width TV pane; a narrow/portrait TV gets fewer columns and keeps working. + val cardsPerRow = maxOf( + 1, + ( + (androidx.compose.ui.platform.LocalConfiguration.current.screenWidthDp - 40) / + (rowCardWidth().value - 12) + ).toInt(), + ) if (viewModel.loadingInitial && items.isEmpty()) { Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {