fix(stores): let a game's description fill the free height of the page (#1493)

Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
This commit is contained in:
MaxsTechReviewandKurt Himebauch authored and GitHub committed 2026-10-25 12:59:58 -04:00
1 parent 7ef52865d2
commit 067f82e5e2
2 files changed
+18 -3

No files matched your search

@@ -12,6 +12,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.verticalScroll import androidx.compose.foundation.verticalScroll
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.compositionLocalOf
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
@@ -37,6 +38,8 @@ import androidx.compose.runtime.setValue
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
/** A grid of cards with a game page that floods out of the opened card and drains back into it. */ /** A grid of cards with a game page that floods out of the opened card and drains back into it. */
internal val LocalDetailFloor = compositionLocalOf<() -> Float> { { Float.MAX_VALUE } }
@OptIn(androidx.compose.ui.ExperimentalComposeUiApi::class) @OptIn(androidx.compose.ui.ExperimentalComposeUiApi::class)
@Composable @Composable
internal fun CardDetailHost( internal fun CardDetailHost(
@@ -57,6 +60,7 @@ internal fun CardDetailHost(
var from by remember { mutableStateOf<Origin?>(null) } var from by remember { mutableStateOf<Origin?>(null) }
var art by remember { mutableStateOf<String?>(null) } var art by remember { mutableStateOf<String?>(null) }
var viewportAt by remember { mutableStateOf(Offset.Zero) } var viewportAt by remember { mutableStateOf(Offset.Zero) }
var viewportH by remember { mutableStateOf(0) }
LaunchedEffect(open) { LaunchedEffect(open) {
if (open != null) { if (open != null) {
val mark = StoresMotion.takeCard(open) val mark = StoresMotion.takeCard(open)
@@ -83,7 +87,7 @@ internal fun CardDetailHost(
val fade = with(density) { 14.dp.toPx() } val fade = with(density) { 14.dp.toPx() }
Box( Box(
modifier.clipToBounds() modifier.clipToBounds()
.onGloballyPositioned { viewportAt = it.positionInRoot() } .onGloballyPositioned { viewportAt = it.positionInRoot(); viewportH = it.size.height }
.graphicsLayer { compositingStrategy = androidx.compose.ui.graphics.CompositingStrategy.Offscreen } .graphicsLayer { compositingStrategy = androidx.compose.ui.graphics.CompositingStrategy.Offscreen }
.drawWithContent { .drawWithContent {
drawContent() drawContent()
@@ -114,7 +118,10 @@ internal fun CardDetailHost(
.onFocusChanged { onDetailFocus(it.hasFocus) } .onFocusChanged { onDetailFocus(it.hasFocus) }
.focusProperties { exit = { if (coveringNow.value && Steps.step == null && StoresMotion.step == null) FocusRequester.Cancel else FocusRequester.Default } } .focusProperties { exit = { if (coveringNow.value && Steps.step == null && StoresMotion.step == null) FocusRequester.Cancel else FocusRequester.Default } }
.focusGroup(), .focusGroup(),
) { detail(key) } ) {
val floor = { viewportAt.y + viewportH - with(density) { 16.dp.toPx() } - detailScroll.value }
CompositionLocalProvider(LocalDetailFloor provides floor) { detail(key) }
}
} }
} }
val origin = from val origin = from
@@ -56,6 +56,8 @@ import androidx.compose.ui.input.key.onPreviewKeyEvent
import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.layout.boundsInRoot import androidx.compose.ui.layout.boundsInRoot
import androidx.compose.ui.layout.onGloballyPositioned import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.layout.positionInRoot
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.testTag import androidx.compose.ui.platform.testTag
@@ -599,7 +601,13 @@ private fun AboutTab(developer: String, publisher: String, releaseDate: String,
val parts = listOf(developer, publisher, com.droiddeck.launcher.stores.GameFacts.releaseLabel(releaseDate).orEmpty()).filter { it.isNotBlank() }.distinct() val parts = listOf(developer, publisher, com.droiddeck.launcher.stores.GameFacts.releaseLabel(releaseDate).orEmpty()).filter { it.isNotBlank() }.distinct()
Text(parts.joinToString(" · "), fontSize = 13.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.readable()) Text(parts.joinToString(" · "), fontSize = 13.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.readable())
} }
if (description.isNotBlank()) StoreAbout(description, AboutHeight, Modifier.fillMaxWidth()) if (description.isNotBlank()) {
val floor = LocalDetailFloor.current
val density = LocalDensity.current
var room by remember { mutableStateOf(AboutHeight) }
val fill = Modifier.onGloballyPositioned { c -> room = maxOf(AboutHeight, with(density) { (floor() - c.positionInRoot().y).toDp() - 14.dp }) }
StoreAbout(description, room, Modifier.fillMaxWidth().then(fill))
}
} }
} }