fix viewport fill padding and key cover art requests on both refs

This commit is contained in:
austinried
2026-10-04 00:29:53 +00:00
parent ee3bf734da
commit 61c467f826
2 changed files with 9 additions and 15 deletions
@@ -46,7 +46,7 @@ fun CoverArt(
} }
if (ref != null) { if (ref != null) {
AsyncImage( AsyncImage(
model = remember(ref) { imageRequest(context, ref, crossfade = thumbnailRef != null) }, model = remember(ref, thumbnailRef) { imageRequest(context, ref, crossfade = thumbnailRef != null) },
contentDescription = null, contentDescription = null,
contentScale = ContentScale.Crop, contentScale = ContentScale.Crop,
modifier = Modifier.fillMaxSize(), modifier = Modifier.fillMaxSize(),
@@ -18,15 +18,12 @@ fun rememberViewportFill(state: LazyListState): Dp {
derivedStateOf { derivedStateOf {
val info = state.layoutInfo val info = state.layoutInfo
val realCount = info.totalItemsCount - 1 val realCount = info.totalItemsCount - 1
if (realCount <= 0) { val visibleReal = info.visibleItemsInfo.filter { it.index < realCount }
if (realCount <= 0 || visibleReal.size < realCount) {
FILL_EPSILON_PX FILL_EPSILON_PX
} else { } else {
val visibleReal = info.visibleItemsInfo.filter { it.index < realCount } val contentBottom = visibleReal.maxOf { it.offset + it.size }
if (visibleReal.size < realCount) { (info.viewportSize.height - info.afterContentPadding - contentBottom).coerceAtLeast(0) + FILL_EPSILON_PX
FILL_EPSILON_PX
} else {
(info.viewportSize.height - visibleReal.sumOf { it.size }).coerceAtLeast(0) + FILL_EPSILON_PX
}
} }
} }
} }
@@ -40,15 +37,12 @@ fun rememberViewportFill(state: LazyGridState): Dp {
derivedStateOf { derivedStateOf {
val info = state.layoutInfo val info = state.layoutInfo
val realCount = info.totalItemsCount - 1 val realCount = info.totalItemsCount - 1
if (realCount <= 0) { val visibleReal = info.visibleItemsInfo.filter { it.index < realCount }
if (realCount <= 0 || visibleReal.size < realCount) {
FILL_EPSILON_PX FILL_EPSILON_PX
} else { } else {
val visibleReal = info.visibleItemsInfo.filter { it.index < realCount } val contentBottom = visibleReal.maxOf { it.offset.y + it.size.height }
if (visibleReal.size < realCount) { (info.viewportSize.height - info.afterContentPadding - contentBottom).coerceAtLeast(0) + FILL_EPSILON_PX
FILL_EPSILON_PX
} else {
(info.viewportSize.height - visibleReal.sumOf { it.size.height }).coerceAtLeast(0) + FILL_EPSILON_PX
}
} }
} }
} }