feat: store game pages flood onto their hero art, and downloads survive a restart (#608)

* feat: a store game's page floods out of its card onto its own hero art, and draws back from it

* fix: installs interrupted by the app closing show in Downloads with Resume and Clear

* feat: finished and interrupted downloads share the running card's art look, and the queue sits under what is running

* fix: the download queue outlives the app: queued, running and paused downloads come back after a restart
This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-10-12 03:58:07 +00:00
1 parent 1603009687
commit 4ec2146019
9 files changed
+271 -27

No files matched your search

@@ -99,6 +99,8 @@ object StoresState {
/** Reads what is on disk for every store: sign-ins, installed games, the engine probe. Off the main thread. */
fun refresh(context: Context) {
val app = context.applicationContext
// The first refresh after the app starts brings back what was in the download queue.
com.droiddeck.launcher.stores.download.SavedQueue.restore(app)
Thread({
val found = Store.entries.mapNotNull { store -> StoreAccounts.signedInAs(app, store)?.let { store to it } }
val onDisk = StoreInstallRoot.gameFolders(app).mapNotNull { folder ->
@@ -217,6 +219,7 @@ object StoresState {
fun install(context: Context, item: CatalogItem, root: java.io.File? = null) {
val app = context.applicationContext
val target = root ?: StoreInstallRoot.installRoot(app)
com.droiddeck.launcher.stores.download.SavedQueue.remember(app, item, target)
backends[item.store]?.install(app, item, target) ?: logLine("${item.store.label}: this build cannot install yet")
}
@@ -137,6 +137,11 @@ object DownloadQueue {
private val lock = Any()
private val items = LinkedHashMap<String, Item>()
/** Keys a restart brings back paused: queued as paused, not started. */
private val heldPaused = HashSet<String>()
/** [key]'s next [enqueue] comes in paused (a paused download restored after a restart). */
fun holdPaused(key: String) = synchronized(lock) { heldPaused.add(key) }
private var running = 0
fun parallel(context: Context): Int = SessionPrefs.gameStoresParallel(context)
@@ -171,7 +176,8 @@ object DownloadQueue {
synchronized(lock) {
items[entry.key]?.let { if (it.entry.isActive) { Log.i(TAG, "${entry.key}: already queued"); return } }
items.remove(entry.key)
items[entry.key] = Item(entry.copy(state = DownloadState.QUEUED, stage = DownloadStage.MANIFEST, startedAt = System.currentTimeMillis()), factory)
val state = if (heldPaused.remove(entry.key)) DownloadState.PAUSED else DownloadState.QUEUED
items[entry.key] = Item(entry.copy(state = state, stage = DownloadStage.MANIFEST, startedAt = System.currentTimeMillis()), factory)
renumber()
}
StoresState.logLine("${entry.store.label}: queued \"${entry.name}\"" + if (entry.bytesTotal > 0) " (${com.droiddeck.launcher.stores.formatBytes(entry.bytesTotal)})" else "")
@@ -306,6 +312,8 @@ object DownloadQueue {
}
}
lastPublishAt = now
// A state change (not progress) is written down, so the queue outlives the app.
if (!progressOnly) SavedQueue.save(items.values.map { it.entry })
val list = items.values.map { it.entry }.sortedByDescending { it.startedAt }
StoresState.post { StoresState.publishDownloads(list) }
}
@@ -0,0 +1,108 @@
package com.droiddeck.launcher.stores.download
import android.content.Context
import android.util.Log
import com.droiddeck.launcher.stores.CatalogItem
import com.droiddeck.launcher.stores.Store
import com.droiddeck.launcher.stores.StoresState
import org.json.JSONArray
import org.json.JSONObject
import java.io.File
import java.util.concurrent.Executors
/**
* The download queue kept on disk, so what was queued, running or paused comes back after the app
* closes or is killed: the queue itself lives in memory, and a queued game that never started has
* nothing on disk to find. Each install records the game and where it goes ([remember]); every
* change of state writes the active rows in queue order ([save]); the first refresh after the app
* starts asks the stores for them again ([restore]) - running and queued ones carry on, paused ones
* come back paused.
*/
object SavedQueue {
private const val TAG = "StoreDownloads"
private const val FILE = "store-queue.json"
private class Wanted(val item: CatalogItem, val root: File?)
private val wanted = HashMap<String, Wanted>()
private val writer = Executors.newSingleThreadExecutor { r -> Thread(r, "store-queue-save") }
@Volatile private var app: Context? = null
private var restored = false
private fun key(item: CatalogItem) = "${item.store.id}:${item.id}"
/** An install is asked for: what to ask the store for again after a restart. */
@Synchronized
fun remember(context: Context, item: CatalogItem, root: File?) {
app = context.applicationContext
wanted[key(item)] = Wanted(item, root)
}
/** The active rows, in queue order, as they are now. Any thread; written off it. */
fun save(entries: List<DownloadEntry>) {
val context = app ?: return
val rows = synchronized(this) {
entries.filter { it.isActive }.mapNotNull { e -> wanted[e.key]?.let { e to it } }
}
val out = JSONArray()
for ((e, w) in rows) out.put(JSONObject().apply {
put("paused", e.state == DownloadState.PAUSED)
put("root", w.root?.absolutePath ?: "")
put("item", itemJson(w.item))
})
writer.execute {
runCatching {
val f = File(context.filesDir, FILE)
val tmp = File(context.filesDir, "$FILE.tmp")
tmp.writeText(out.toString())
tmp.renameTo(f)
}.onFailure { Log.w(TAG, "could not save the queue", it) }
}
}
/** Once per process: queues again what was in the queue when the app last closed. */
fun restore(context: Context) {
synchronized(this) { if (restored) return; restored = true }
val app = context.applicationContext
// Read before anything may write it: an install started at once must not save over it.
val rows = runCatching { JSONArray(File(app.filesDir, FILE).readText()) }.getOrNull()
this.app = app
rows ?: return
Thread({
val back = (0 until rows.length()).mapNotNull { i ->
runCatching {
val o = rows.getJSONObject(i)
Triple(itemOf(o.getJSONObject("item")), o.optString("root").takeIf { it.isNotEmpty() }?.let(::File), o.optBoolean("paused"))
}.getOrNull()
}
if (back.isEmpty()) return@Thread
StoresState.post {
for ((item, root, paused) in back) {
if (DownloadQueue.entry(key(item)) != null) continue
if (paused) DownloadQueue.holdPaused(key(item))
StoresState.install(app, item, root)
}
}
}, "store-queue-restore").start()
}
private fun itemJson(i: CatalogItem) = JSONObject().apply {
put("store", i.store.id); put("id", i.id); put("title", i.title)
put("image", i.imageUrl ?: ""); put("tall", i.tallImageUrl ?: "")
put("tags", i.tags); put("developer", i.developer); put("description", i.description)
put("size", i.sizeBytes); put("owned", i.owned)
put("extra", JSONObject(i.extra))
}
private fun itemOf(o: JSONObject): CatalogItem {
val extra = o.optJSONObject("extra")
return CatalogItem(
store = Store.byId(o.getString("store")) ?: error("unknown store"),
id = o.getString("id"), title = o.getString("title"),
imageUrl = o.optString("image").ifEmpty { null }, tallImageUrl = o.optString("tall").ifEmpty { null },
tags = o.optString("tags"), developer = o.optString("developer"), description = o.optString("description"),
owned = o.optBoolean("owned", true), sizeBytes = o.optLong("size"),
extra = extra?.keys()?.asSequence()?.associateWith { extra.getString(it) } ?: emptyMap(),
)
}
}
@@ -30,7 +30,9 @@ import androidx.compose.ui.graphics.drawscope.clipPath
import androidx.compose.ui.graphics.drawscope.translate
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.layout.positionInRoot
import androidx.compose.ui.unit.dp
import androidx.compose.ui.util.lerp
import kotlinx.coroutines.coroutineScope
@@ -109,6 +111,14 @@ internal fun PageFlood(
/** What the tile shows instead of the control's fill: a game card's art, cropped to the tile as it grows. */
art: Painter? = null,
sinks: Boolean = false,
/**
* Where on the page the control's tile lands (root px), when the page has its own picture of
* the control - a game page's hero art: the tile grows onto it instead of over the whole pane,
* corner to corner ([ontoCorner] there), and the page comes in around it. Back leaves from it.
* Null, or off screen: the pane, as any page.
*/
onto: (() -> Rect?)? = null,
ontoCorner: androidx.compose.ui.unit.Dp = 0.dp,
content: @Composable () -> Unit,
) {
val pal = LocalPalette.current
@@ -118,6 +128,10 @@ internal fun PageFlood(
val shown = remember { Animatable(0f) }
val tile = remember { Animatable(1f) }
var size by remember { mutableStateOf(Size.Zero) }
var at by remember { mutableStateOf(Offset.Zero) }
// Where this flood lands (in its own space), read as it opens and again as it leaves.
var target by remember { mutableStateOf<Rect?>(null) }
val density = androidx.compose.ui.platform.LocalDensity.current
LaunchedEffect(size != Size.Zero, leaving, sinks) {
if (sinks) {
// Whatever the flood in was doing, the page is shown whole and leaves with the pane.
@@ -128,6 +142,30 @@ internal fun PageFlood(
}
if (size == Size.Zero) return@LaunchedEffect
glide?.hidden = true
// The page lays out under the tile at once, so its picture is there within a frame or two.
target = onto?.let { get ->
kotlinx.coroutines.withTimeoutOrNull(300) { snapshotFlow { get() }.first { it != null } }
}?.translate(-at)?.takeIf { it.height > 1f && it.overlaps(Rect(Offset.Zero, size)) }
if (target != null) {
coroutineScope {
if (!leaving) {
// Onto the page's picture, every edge together on one firm spring: no blob, and
// nowhere to go past it.
val runs = edges.map { launch { it.animateTo(1f, Motion.sp(0.85f, 320f)) } }
snapshotFlow { edges.all { it.value >= 0.9f } }.first { it }
launch { shown.animateTo(1f, Motion.tw(240)) }
launch { delay(Motion.ms(140).toLong()); tile.animateTo(0f, Motion.tw(220)) }
runs.forEach { it.join() }
} else {
launch { shown.animateTo(0f, Motion.tw(160)) }
tile.animateTo(1f, Motion.tw(120))
edges.map { launch { it.animateTo(0f, Motion.sp(0.9f, 320f)) } }.forEach { it.join() }
tile.animateTo(0f, Motion.tw(120))
}
}
glide?.hidden = false
return@LaunchedEffect
}
val b = from.bounds
val travel = listOf(b.left, b.top, size.width - b.right, size.height - b.bottom).map { it.coerceAtLeast(0f) }
val far = travel.max().coerceAtLeast(1f)
@@ -160,10 +198,16 @@ internal fun PageFlood(
glide?.hidden = false
}
DisposableEffect(Unit) { onDispose { glide?.hidden = false } }
Box(Modifier.fillMaxSize().clipToBounds().onSizeChanged { size = Size(it.width.toFloat(), it.height.toFloat()) }) {
Box(Modifier.fillMaxSize().graphicsLayer { alpha = shown.value; translationY = (1f - shown.value) * 14.dp.toPx() }) { content() }
Box(
Modifier.fillMaxSize().clipToBounds().onSizeChanged { size = Size(it.width.toFloat(), it.height.toFloat()) }
.onGloballyPositioned { at = it.positionInRoot() },
) {
// Landing on the page's picture, the page must not rise: its picture would move off the tile.
val rise = if (onto != null) 0f else 1f
Box(Modifier.fillMaxSize().graphicsLayer { alpha = shown.value; translationY = (1f - shown.value) * 14.dp.toPx() * rise }) { content() }
val onCorner = with(density) { ontoCorner.toPx() }
Canvas(Modifier.fillMaxSize()) {
if (tile.value > 0.01f) drawTile(from, edges.map { it.value }, pal.surface, pal.line2, tile.value, art)
if (tile.value > 0.01f) drawTile(from, edges.map { it.value }, pal.surface, pal.line2, tile.value, art, target, onCorner)
}
}
}
@@ -172,22 +216,33 @@ internal fun PageFlood(
* The control's tile with its edges [v] of the way to the pane's (left, top, right, bottom):
* sinking with the page behind, blobby in flight, square once it fills the pane.
*/
private fun DrawScope.drawTile(from: Origin, v: List<Float>, fill: Color, line: Color, alpha: Float, art: Painter? = null) {
private fun DrawScope.drawTile(
from: Origin, v: List<Float>, fill: Color, line: Color, alpha: Float, art: Painter? = null,
/** Lands on this instead of the pane (a page's picture of the control), corner [toCorner]. */
to: Rect? = null, toCorner: Float = 0f,
) {
val (l, t, r, b) = v
val mean = v.sumOf { it.coerceIn(0f, 1f).toDouble() }.toFloat() / 4f
// The control sinks with the page behind it (scaled to 0.95 about the pane's centre).
val k = 1f - 0.05f * mean
val cx = size.width / 2f
val cy = size.height / 2f
val f = from.bounds
val left = lerp(cx + (f.left - cx) * k, 0f, l)
val top = lerp(cy + (f.top - cy) * k, 0f, t)
val right = lerp(cx + (f.right - cx) * k, size.width, r)
val bottom = lerp(cy + (f.bottom - cy) * k, size.height, b)
val left: Float; val top: Float; val right: Float; val bottom: Float
if (to != null) {
left = lerp(f.left, to.left, l); top = lerp(f.top, to.top, t)
right = lerp(f.right, to.right, r); bottom = lerp(f.bottom, to.bottom, b)
} else {
// The control sinks with the page behind it (scaled to 0.95 about the pane's centre).
val k = 1f - 0.05f * mean
val cx = size.width / 2f
val cy = size.height / 2f
left = lerp(cx + (f.left - cx) * k, 0f, l)
top = lerp(cy + (f.top - cy) * k, 0f, t)
right = lerp(cx + (f.right - cx) * k, size.width, r)
bottom = lerp(cy + (f.bottom - cy) * k, size.height, b)
}
val w = (right - left).coerceAtLeast(0f)
val h = (bottom - top).coerceAtLeast(0f)
val blob = sin(PI * mean).toFloat().coerceAtLeast(0f)
val corner = lerp(from.corner * (1f - mean), minOf(w, h) * 0.42f, blob)
// Onto a picture it keeps a card's shape, corner to corner; over the pane it blobs in flight.
val corner = if (to != null) lerp(from.corner, toCorner, mean).coerceAtMost(minOf(w, h) / 2f)
else lerp(from.corner * (1f - mean), minOf(w, h) * 0.42f, sin(PI * mean).toFloat().coerceAtLeast(0f))
drawRoundRect(fill, Offset(left, top), Size(w, h), CornerRadius(corner), alpha = alpha)
val pic = art?.intrinsicSize?.takeIf { it.isSpecified && it.width > 0f && it.height > 0f }
if (art != null && pic != null && w > 0f && h > 0f) {
@@ -61,8 +61,16 @@ internal fun StoreGameDetail(store: Store, key: String, s: FrontEndState, a: Fro
SourceChip(store.id)
}
}
Rise(1) {
Box(Modifier.fillMaxWidth().heightIn(min = if (narrow) 150.dp else 180.dp).clip(Shape16).background(artBrush(hueOf(title)))) {
// Out of a card, the hero holds still in its place: the card's flood lands on it, and a hero
// still rising in sat below where the flood had measured it (the art showed twice).
val hero: @Composable () -> Unit = {
androidx.compose.runtime.DisposableEffect(Unit) { onDispose { StoresMotion.heroAt = null } }
Box(
Modifier.fillMaxWidth().heightIn(min = if (narrow) 150.dp else 180.dp)
// The card it opened from floods onto this, and draws back into the card from it.
.onGloballyPositioned { StoresMotion.heroAt = it.boundsInRoot() }
.clip(Shape16).background(artBrush(hueOf(title))),
) {
val art = item?.imageUrl ?: installed?.sidecar?.hero ?: installed?.sidecar?.cover
if (art != null) AsyncImage(model = art, contentDescription = null, contentScale = ContentScale.Crop, modifier = Modifier.matchParentSize())
Spacer(Modifier.matchParentSize().background(Brush.horizontalGradient(0f to colors.background.copy(alpha = 0.94f), 0.5f to colors.background.copy(alpha = 0.55f), 1f to Color.Transparent)))
@@ -110,6 +118,7 @@ internal fun StoreGameDetail(store: Store, key: String, s: FrontEndState, a: Fro
}
}
}
if (StoresMotion.heroLands) hero() else Rise(1) { hero() }
// Plain text only, and nothing at all when the store sent a template key instead of words.
// A description that is only the title again (some stores fill it so) is no description.
val description = item?.let { com.droiddeck.launcher.stores.cleanStoreText(it.description) }.orEmpty()
@@ -111,10 +111,26 @@ private fun DownloadList(s: FrontEndState, a: FrontEndActions) {
var clearing by remember { mutableStateOf(false) }
// Under way on top; finished below a line whose X clears them all (rows only - a failed
// download's kept files stay until its game page's Clear).
val (active, finished) = entries.partition { it.isActive }
// Under way first, then paused, then the queue in its order: a queued row sat above the one running.
val (active, finished) = entries.partition { it.isActive }.let { (on, off) ->
on.sortedWith(compareBy<DownloadEntry>({ when (it.state) { DownloadState.RUNNING -> 0; DownloadState.PAUSED -> 1; else -> 2 } }, { it.queuePosition })) to off
}
val finishedShown = if (clearing) emptyList() else finished
// Installs that stopped without the queue knowing (the app closed or was killed): the queue
// lives in memory, so after a restart they were only on their game's page. They resume here too.
val queued = entries.mapTo(HashSet()) { it.key }
// Matched against each store's library: one not read yet (Downloads opened first) is read from
// its cache, quietly, so the rows are there without visiting the store.
val ctx = LocalContext.current
val missing = StoresState.unfinished.map { it.store }.filter { StoresState.library[it] == null }.toSet()
LaunchedEffect(missing) { missing.forEach { StoresState.backend(it)?.syncLibrary(ctx, false) } }
val interrupted = StoresState.unfinished.mapNotNull { u ->
StoresState.library[u.store]?.firstOrNull {
u.id == it.id || (u.id == null && u.folder.name == com.droiddeck.launcher.stores.StoreInstallRoot.folderName(it.title, it.id))
}
}.filter { "${it.store.id}:${it.id}" !in queued }.distinctBy { "${it.store.id}:${it.id}" }
Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
AnimatedVisibility(entries.isEmpty(), enter = fadeIn(Motion.tw(300, 300)), exit = fadeOut(Motion.tw(120))) {
AnimatedVisibility(entries.isEmpty() && interrupted.isEmpty(), enter = fadeIn(Motion.tw(300, 300)), exit = fadeOut(Motion.tw(120))) {
Box(Modifier.fillMaxWidth().padding(vertical = 40.dp), contentAlignment = Alignment.Center) {
Text(stringResource(R.string.stores_downloads_empty), fontSize = 13.sp, color = colors.onSurfaceVariant)
}
@@ -135,6 +151,11 @@ private fun DownloadList(s: FrontEndState, a: FrontEndActions) {
else shrinkHorizontally(Motion.tw(260), shrinkTowards = Alignment.End) + shrinkVertically(Motion.tw(300, 120)) + fadeOut(Motion.tw(200, 80))
},
) { row, _ -> DownloadCard(StoresState.download(row.key) ?: row, s, a) }
AnimatedRows(
interrupted, key = { "${it.store.id}:${it.id}" },
enter = { i, _ -> fadeIn(Motion.tw(300, 60 * i.coerceAtMost(5))) + expandVertically(Motion.tw(260)) },
exit = { _, _, _ -> fadeOut(Motion.tw(160)) + shrinkVertically(Motion.tw(220, 60)) },
) { item, _ -> InterruptedRow(item) }
AnimatedVisibility(
finishedShown.isNotEmpty(),
enter = expandVertically(Motion.tw(260)) + fadeIn(Motion.tw(220)),
@@ -172,21 +193,50 @@ private fun DownloadList(s: FrontEndState, a: FrontEndActions) {
}
}
/** An install that stopped before it finished, from an earlier run: Resume picks it up, Clear deletes what it had. */
@Composable
private fun InterruptedRow(item: com.droiddeck.launcher.stores.CatalogItem) {
val ctx = LocalContext.current
ArtStrip(item.imageUrl ?: item.tallImageUrl, item.title) {
Text(item.title, fontSize = 13.sp, fontWeight = FontWeight.Bold, color = Color.White, maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f, fill = false))
SourceChip(item.store.id, small = true)
Text(stringResource(R.string.stores_dl_interrupted), fontSize = 12.sp, color = Color(0xFFFFC24D), maxLines = 1)
Spacer(Modifier.weight(1f))
RoundAction(Icons.Filled.PlayArrow, stringResource(R.string.stores_dl_resume), primary = true) { StoresState.requestInstall(ctx, item) }
CancelAction { StoresState.clearUnfinished(ctx, item) }
}
}
/** How long a row that installed holds for its bar to gather into Play before it moves under the line. */
private const val GATHER_HOLD_MS = 900
/**
* A row in the download card's look, shorter: the game's art behind it under the same dark wash,
* the copy in white. Finished and interrupted downloads read as the same thing as one under way.
*/
@Composable
private fun ArtStrip(cover: String?, name: String, content: @Composable androidx.compose.foundation.layout.RowScope.() -> Unit) {
val pal = LocalPalette.current
Box(Modifier.fillMaxWidth().heightIn(min = 60.dp).clip(Shape12).background(Color(0xFF101318)).border(1.dp, pal.line, Shape12)) {
if (!cover.isNullOrEmpty()) AsyncImage(model = cover, contentDescription = null, contentScale = ContentScale.Crop, modifier = Modifier.matchParentSize())
else Spacer(Modifier.matchParentSize().background(artBrush(hueOf(name))))
Spacer(Modifier.matchParentSize().background(Brush.horizontalGradient(0f to Color.Black.copy(alpha = 0.92f), 0.5f to Color.Black.copy(alpha = 0.72f), 1f to Color.Black.copy(alpha = 0.2f))))
Row(
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp),
modifier = Modifier.fillMaxWidth().padding(horizontal = 14.dp, vertical = 8.dp), content = content,
)
}
}
/** A finished download: its name and store, and Play when it installed - blooming out of a dot when it just did. */
@Composable
private fun FinishedRow(d: DownloadEntry, s: FrontEndState, a: FrontEndActions, bloom: Boolean = false) {
val ctx = LocalContext.current
val colors = MaterialTheme.colorScheme
Row(
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp),
modifier = Modifier.fillMaxWidth().clip(Shape12).background(colors.surface).padding(horizontal = 12.dp, vertical = 6.dp),
) {
Text(d.name, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f, fill = false))
ArtStrip(d.cover, d.name) {
Text(d.name, fontSize = 13.sp, fontWeight = FontWeight.Bold, color = Color.White, maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f, fill = false))
SourceChip(d.store.id, small = true)
Text(stringResource(if (d.state == DownloadState.INSTALLED) R.string.stores_installed_chip else R.string.stores_dl_cancelled), fontSize = 11.sp, color = colors.onSurfaceVariant, maxLines = 1, modifier = Modifier.weight(1f))
Text(stringResource(if (d.state == DownloadState.INSTALLED) R.string.stores_installed_chip else R.string.stores_dl_cancelled), fontSize = 12.sp, color = Color.White.copy(alpha = 0.72f), maxLines = 1)
Spacer(Modifier.weight(1f))
if (d.state == DownloadState.INSTALLED) Box(Modifier.bloomIn(bloom, GATHER_HOLD_MS + 150)) {
RoundAction(Icons.Filled.PlayArrow, stringResource(R.string.stores_play), primary = true) { launchStoreGame(ctx, d.store, d.id, s, a) }
}
@@ -125,6 +125,12 @@ internal object StoresMotion {
/** Where each store's dot sits on its chip, for a sign-in to come home to. */
val dots = HashMap<Store, Rect>()
/** Where the open game page's hero art sits (root px): what a card's flood lands on, and leaves from. */
var heroAt by mutableStateOf<Rect?>(null)
/** The open game page came out of a card: its hero holds still, for the card's flood to land on. */
var heroLands by mutableStateOf(false)
/** The card a game page is about to open from. */
private var card: CardMark? = null
private var cardAt = 0L
@@ -311,6 +311,7 @@ internal fun StoresPage(s: FrontEndState, a: FrontEndActions, modifier: Modifier
val mark = StoresMotion.takeCard(g)
detailFrom = mark?.let { Origin(it.bounds.translate(-viewportAt), it.corner) }
detailArt = mark?.art
StoresMotion.heroLands = mark != null
leaving = false
detail = g
} else if (detail != null) {
@@ -450,7 +451,9 @@ internal fun StoresPage(s: FrontEndState, a: FrontEndActions, modifier: Modifier
},
)
}
PageFlood(from, leaving, art) { body() }
// Onto the page's own hero art, not the whole pane: grown to the pane, the art
// then cut down to the hero's banner (and back out to the pane to close).
PageFlood(from, leaving, art, onto = { StoresMotion.heroAt }, ontoCorner = 16.dp) { body() }
}
}
}