lists: derive cards-per-row from screen and card width

The adaptive grid resolves to exactly four cards on a full-width
landscape TV pane — but a portrait-mounted or otherwise narrow TV gets
fewer columns and the hardcoded row start broke there. Compute the
count with the same arithmetic Compose uses (pane padding minus card
minimum, integer division) so the drawer-from-row-start rule tracks
the real grid on every mounting.
This commit is contained in:
Jeena 2026-10-13 23:33:06 +00:00
parent effc2bd9ae
commit 64a01d8ca2

View file

@ -91,12 +91,18 @@ fun VideoListScreen(
LaunchedEffect(source) { viewModel.loadChannelHeader(AppGraph.repository) } LaunchedEffect(source) { viewModel.loadChannelHeader(AppGraph.repository) }
} }
// Row starts of the 4-per-row grid: LEFT from a row's first card opens the // Row starts of the grid: LEFT from a row's first card opens the drawer
// drawer (issue #7). rowCardWidth() sizes the adaptive columns to resolve // (issue #7). The adaptive columns use a `rowCardWidth() - 12` minimum with
// to exactly 4 on the full-width TV pane, so the row start is index % 4 — // zero spacing, and the content pane eats 40dp (8 start + 32 end), so the
// no layout measuring needed (measuring the first visible item instead was // resolved card count is exactly Compose's arithmetic here — 4 on a full-
// what made the full-span page header count as "one card per row"). // width TV pane; a narrow/portrait TV gets fewer columns and keeps working.
val cardsPerRow = 4 val cardsPerRow = maxOf(
1,
(
(androidx.compose.ui.platform.LocalConfiguration.current.screenWidthDp - 40) /
(rowCardWidth().value - 12)
).toInt(),
)
if (viewModel.loadingInitial && items.isEmpty()) { if (viewModel.loadingInitial && items.isEmpty()) {
Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {