fix(ui): LB / RB keep focus everywhere, rows clear the chips, and a bobbing handle replaces the lip

This commit is contained in:
xXJsonDeruloXx committed 2026-10-11 14:19:56 -04:00
1 parent b9d4ad2b0a
commit 87e288a9ca
10 files changed
+125 -117

No files matched your search

@@ -249,9 +249,20 @@ fun ComponentsPage(
LaunchedEffect(requestInitialFocus) {
if (!requestInitialFocus || inputMode.inputMode != InputMode.Keyboard) return@LaunchedEffect
delay(Motion.ms(200).toLong())
focusWithinFrames({ false }) { layerFocus.getValue(layer) }
focusSoon { layerFocus.getValue(layer) }
}
var travel by remember { mutableIntStateOf(1) }
// LB / RB (taken by the activity before the page sees them): a pad anywhere on the page goes to
// the new layer's card, so one on a row - which leaves with its layer - is never left with nothing.
var pageFocused by remember { mutableStateOf(false) }
val seenLayer = remember { arrayOf(layer) }
LaunchedEffect(layer) {
if (seenLayer[0] == layer) return@LaunchedEffect
seenLayer[0] = layer
if (!pageFocused || inputMode.inputMode != InputMode.Keyboard) return@LaunchedEffect
if (narrowOpen != null) runCatching { firstRow.requestFocus() }
else focusSoon { layerFocus.getValue(layer) }
}
val pick: (String) -> Unit = { l ->
if (l != layer) { travel = if (LAYERS.indexOf(l) > LAYERS.indexOf(layer)) 1 else -1; onComp(l) }
}
@@ -514,7 +525,7 @@ fun ComponentsPage(
}
}
Box(Modifier.fillMaxSize().onGloballyPositioned { pageAt = it.positionInRoot() }) {
Box(Modifier.fillMaxSize().onGloballyPositioned { pageAt = it.positionInRoot() }.onFocusChanged { pageFocused = it.hasFocus }) {
Column(
Modifier.fillMaxSize().padding(horizontal = if (narrow) 16.dp else 22.dp, vertical = if (narrow) 12.dp else 18.dp)
.bumpers(onPrevious = { pick(layerStep(layer, -1)) }, onNext = { pick(layerStep(layer, 1)) }),
@@ -143,7 +143,7 @@ internal fun DesktopPage(s: FrontEndState, a: FrontEndActions, modifier: Modifie
// The wall stays inside the hero; the shelves sit on the page's own ground.
Box(Modifier.fillMaxWidth().height(paneH).clipToBounds()) {
LiftHero(
key = "desktop", tabs = tabs, lip = { lipFor(ctx, mode, full = false) },
key = "desktop", tabs = tabs,
onOpen = { scope.launch { scroll.animateScrollTo(0) }; a.onDesktopSettings() },
onPrimary = a.onDesktop, downOpens = false, onOpenChange = { sheetOpen = it },
start = if (narrow) 20.dp else 44.dp, bottom = if (narrow) 20.dp else 44.dp,
@@ -177,9 +177,10 @@ internal fun DesktopPage(s: FrontEndState, a: FrontEndActions, modifier: Modifie
ShelfTitle(stringResource(R.string.user_apps_section), (installed.size + apps.size).takeIf { it > 0 }?.toString())
val seen = remember { mutableSetOf<String>() }
val mounted = remember { booleanArrayOf(false) }
val yourScroll = rememberScrollState()
Row(
horizontalArrangement = Arrangement.spacedBy(10.dp),
modifier = Modifier.fillMaxWidth().onGloballyPositioned { yourAppsAt = it.boundsInRoot() }.horizontalScroll(rememberScrollState()).padding(vertical = 2.dp),
modifier = Modifier.fillMaxWidth().onGloballyPositioned { yourAppsAt = it.boundsInRoot() }.edgeFade(yourScroll).horizontalScroll(yourScroll).padding(vertical = 2.dp),
) {
val flatpaks = if (s.storeEnabled) com.droiddeck.launcher.store.StoreState.installed else emptyList()
val keys = installed.map { "emu:${it.id}" } + apps.map { "user:${it.key}" } + flatpaks.map { "flatpak:${it.id}" }
@@ -222,7 +223,8 @@ internal fun DesktopPage(s: FrontEndState, a: FrontEndActions, modifier: Modifie
// ---- Get more: the emulators not installed, adding an app, and Flathub ----
ShelfTitle(stringResource(R.string.desktop_get_more), null)
Row(horizontalArrangement = Arrangement.spacedBy(10.dp), modifier = Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).padding(vertical = 2.dp)) {
val moreScroll = rememberScrollState()
Row(horizontalArrangement = Arrangement.spacedBy(10.dp), modifier = Modifier.fillMaxWidth().edgeFade(moreScroll).horizontalScroll(moreScroll).padding(vertical = 2.dp)) {
available.forEach { e ->
key(e.id) {
val pkgId = Library.packageId(e.id)
@@ -390,6 +390,18 @@ internal suspend fun focusWithinFrames(done: () -> Boolean, target: () -> FocusR
}
}
/**
* Asks [target] for focus on the next frames until a request lands (a control can take focus only
* once it is laid out), for at most half a second; then leaves focus alone, so a press right after
* is never pulled back.
*/
internal suspend fun focusSoon(target: () -> FocusRequester) {
repeat(30) {
androidx.compose.runtime.withFrameNanos { }
if (runCatching { target().requestFocus() }.isSuccess) return
}
}
@Composable
fun FrontEndScreen(s: FrontEndState, a: FrontEndActions, page: (@Composable () -> Unit)? = null) {
val frontFocus = remember { FrontFocus() }
@@ -40,7 +40,7 @@ import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.KeyboardArrowDown
import androidx.compose.material.icons.filled.KeyboardArrowUp
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
@@ -60,6 +60,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.zIndex
import androidx.compose.ui.draw.drawWithContent
import androidx.compose.ui.focus.FocusDirection
import androidx.compose.ui.focus.FocusRequester
@@ -85,6 +86,9 @@ import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalInputModeManager
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.animation.core.animateFloat
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
@@ -116,21 +120,6 @@ internal object SheetTab {
const val FILES = "files"
}
/**
* What the lip says, in order, by part: the session's size, then its frame-rate cap, its upscaler
* and its touch mode, each left out at its default (null or 0) to keep the lip short.
*/
internal fun lipParts(size: Pair<Int, Int>, fps: Int, fpsLabel: (Int) -> String, upscaler: String?, touch: String?): List<Pair<String, String>> = buildList {
add("size" to "${size.first}×${size.second}")
if (fps > 0) add("fps" to fpsLabel(fps))
if (upscaler != null) add("upscaler" to upscaler)
if (touch != null) add("touch" to touch)
}
/** The parts of [now] whose value differs from what the lip showed last ([seen]); none the first time. */
internal fun lipChanged(seen: Map<String, String>?, now: List<Pair<String, String>>): Set<String> =
if (seen == null) emptySet() else now.filter { (k, v) -> seen[k] != v }.map { it.first }.toSet()
/**
* Where the open sheet's top edge sits in a pane [paneH] tall (px), for a button [buttonH] tall
* riding it: 82dp down a 360dp pane, the same share of any other, and never so high that the
@@ -140,11 +129,6 @@ internal fun lipChanged(seen: Map<String, String>?, now: List<Pair<String, Strin
internal fun sheetTop(paneH: Float, buttonH: Float, minAbove: Float, ride: Float): Float =
maxOf(paneH * 82f / 360f, minAbove + buttonH / 2f - ride)
/** What the lip showed last, per sheet: a value that changed since is lit the next time it shows. */
private object LipMemory {
val seen = HashMap<String, Map<String, String>>()
}
/** One piece of the sheet's rows fades and rises in on its own beat (a settings group asks for its index). */
internal class SheetBeat(private val pieces: List<Animatable<Float, AnimationVector1D>>) {
private var next = 1
@@ -185,7 +169,6 @@ private const val PIECES = 12
internal fun LiftHero(
key: String,
tabs: List<Pair<String, String>>,
lip: () -> List<Pair<String, String>>,
onOpen: () -> Unit,
onPrimary: () -> Unit,
background: @Composable () -> Unit,
@@ -230,7 +213,6 @@ internal fun LiftHero(
val hot = remember { Animatable(1f) }
val lipShow = remember { Animatable(0f) }
val lipGone = remember { Animatable(0f) }
val lipLit = remember { Animatable(0f) }
val fold = remember { Animatable(0f) }
val foldTop = remember { Animatable(0f) }
val pieces = remember { List(PIECES) { Animatable(0f) } }
@@ -240,7 +222,6 @@ internal fun LiftHero(
var playFocused by remember { mutableStateOf(false) }
var heroAt by remember { mutableStateOf(Offset.Zero) }
var rest by remember { mutableStateOf<Rect?>(null) }
var lit by remember { mutableStateOf(emptySet<String>()) }
fun focusPlay() { if (ff != null && inputMode.inputMode == InputMode.Keyboard) runCatching { ff.primary.requestFocus() } }
fun close() {
if (!open) return
@@ -338,20 +319,14 @@ internal fun LiftHero(
// The lip: there while Play has a pad or a pointer on it, or always with touch alone.
val touchOnly = inputMode.inputMode == InputMode.Touch
val lipFocus = remember { FocusRequester() }
val settingsLabel = stringResource(R.string.drawer_page_settings)
var lipFocused by remember { mutableStateOf(false) }
val lipWanted = !open && (!shown || lipBack) && (playFocused || playHovered || touchOnly || lipFocused)
val lipNow = rememberUpdatedState(lip)
LaunchedEffect(lipWanted) {
if (lipWanted) {
// Back from the sheet it comes straight away; otherwise a beat after Play has focus.
if (!lipBack) delay(Motion.ms(160).toLong())
val now = lipNow.value()
lit = lipChanged(LipMemory.seen[key], now)
LipMemory.seen[key] = now.toMap()
coroutineScope {
launch { lipShow.animateTo(1f, Motion.tw(220)) }
if (lit.isNotEmpty()) launch { lipLit.snapTo(1f); lipLit.animateTo(0f, Motion.tw(600)) }
}
lipShow.animateTo(1f, Motion.tw(220))
} else {
delay(Motion.ms(140).toLong())
lipShow.animateTo(0f, Motion.tw(220))
@@ -422,7 +397,9 @@ internal fun LiftHero(
if (narrow || pill == null) 16.dp.toPx() else pill.right + 20.dp.toPx() - sheetLeft
}
val chipsY = with(density) { if (narrow && pill != null) (pill.bottom - openTop) + 10.dp.toPx() else ChipsTop.toPx() }
val rowsY = with(density) { if (narrow && pill != null) chipsY + 54.dp.toPx() else RowsTop.toPx() }
// The rows start under the chips, which are 44dp to touch: from 54dp they ran under the
// chips' feet and, scrolled, covered them.
val rowsY = with(density) { maxOf(RowsTop.toPx(), chipsY + 52.dp.toPx()) }
val sheetW = sheetRight - sheetLeft
Box(
Modifier
@@ -432,8 +409,10 @@ internal fun LiftHero(
.pointerInput(Unit) { detectTapGestures { } }
.controllerBack { close() }
.bumpers(
onPrevious = { if (tab > 0) { travel = -1; tab-- } },
onNext = { if (tab < tabs.lastIndex) { travel = 1; tab++ } },
// LB / RB: focus goes to the new tab's chip, so a pad on a row (which goes with
// its tab) is never left with nothing.
onPrevious = { if (tab > 0) { travel = -1; tab--; runCatching { chipFocus[tab].requestFocus() } } },
onNext = { if (tab < tabs.lastIndex) { travel = 1; tab++; runCatching { chipFocus[tab].requestFocus() } } },
)
// A pad stays in the sheet until it folds; Left from it reaches Play, the handle.
.focusProperties { exit = { dir -> if (!openState.value || launchingState.value) FocusRequester.Default else if (dir == FocusDirection.Left && ff != null) ff.primary else FocusRequester.Cancel } }
@@ -442,6 +421,8 @@ internal fun LiftHero(
Box(
Modifier
.offset { IntOffset(chipsX.roundToInt(), chipsY.roundToInt()) }
// Over the rows, whatever they scroll under them.
.zIndex(1f)
.width(with(density) { (sheetW - chipsX - 16.dp.toPx()).coerceAtLeast(0f).toDp() })
.graphicsLayer { val v = pieces[0].value; alpha = v; translationY = (1f - v) * 6.dp.toPx() }
// A pull down on the chips folds the sheet; so does Up from them.
@@ -535,14 +516,15 @@ internal fun LiftHero(
val r0 = restRect
// A lip a pad can reach stays composed (unseen at rest) so Down always has it to land on.
if (r0 != null && (lipShow.value > 0.01f || pull.value > 0.5f || (!downOpens && !open && !shown))) {
val lipH = 26.dp + pull.value.dp
val lipH = 22.dp + pull.value.dp
val lift = { if (!open) open = true }
Box(
Modifier
.offset { IntOffset((r0.left + 16.dp.toPx()).roundToInt(), (r0.bottom + raise * ride.value + (lipShow.value - 1f) * 8.dp.toPx()).roundToInt()) }
.offset { IntOffset((r0.center.x - HandleWidth.toPx() / 2f).roundToInt(), (r0.bottom + raise * ride.value + (lipShow.value - 1f) * 8.dp.toPx()).roundToInt()) }
.graphicsLayer { alpha = lipShow.value * (1f - lipGone.value) }
// 44dp to touch; the tab itself is the top 26.
// 44dp to touch; the tab itself is the top 22.
.heightIn(min = 44.dp)
.semantics { contentDescription = settingsLabel }
.pointerInput(Unit) {
var dy = 0f
detectVerticalDragGestures(onDragStart = { dy = 0f }) { change, amount ->
@@ -556,36 +538,51 @@ internal fun LiftHero(
)
.clickable(interactionSource = remember { MutableInteractionSource() }, indication = null, role = Role.Button, onClick = lift),
) {
Box(Modifier.glideBorder(lipFocused, RoundedCornerShape(bottomStart = 14.dp, bottomEnd = 14.dp), LocalPalette.current.signal)) {
Lip(lip(), lit, lipLit.value, lipH)
Box(Modifier.glideBorder(lipFocused, RoundedCornerShape(bottomStart = 12.dp, bottomEnd = 12.dp), LocalPalette.current.signal)) {
Handle(lipH)
}
}
}
}
}
/** The lip's tab: what Play will do, a part lit while it says something new. */
/** The handle's width: a small tab, not a sentence. */
private val HandleWidth = 52.dp
/**
* The sheet's handle, tucked under Play: a small tab with a chevron that bobs up every so often,
* saying there is a drawer to pull up. Still with animations off.
*/
@Composable
private fun Lip(parts: List<Pair<String, String>>, lit: Set<String>, glow: Float, height: Dp) {
private fun Handle(height: Dp) {
val colors = MaterialTheme.colorScheme
val pal = LocalPalette.current
val shape = RoundedCornerShape(bottomStart = 14.dp, bottomEnd = 14.dp)
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.height(height).clip(shape).background(colors.surface)
.drawBorderSidesAndFoot(pal.line, 14.dp)
.padding(start = 12.dp, end = 8.dp),
val shape = RoundedCornerShape(bottomStart = 12.dp, bottomEnd = 12.dp)
val still = Motion.scale == 0f
val bob = androidx.compose.animation.core.rememberInfiniteTransition(label = "handle")
// A quick lift and settle, then a rest: a nudge, not a pulse.
val lift by bob.animateFloat(
0f, 0f,
androidx.compose.animation.core.infiniteRepeatable(
androidx.compose.animation.core.keyframes {
durationMillis = 2400
0f at 0
1f at 180 using androidx.compose.animation.core.FastOutSlowInEasing
-0.25f at 420
0f at 620
},
),
label = "handleBob",
)
Box(
contentAlignment = Alignment.Center,
modifier = Modifier.width(HandleWidth).height(height).clip(shape).background(colors.surface)
.drawBorderSidesAndFoot(pal.line, 12.dp),
) {
parts.forEachIndexed { i, (k, v) ->
if (i > 0) Text(" · ", fontSize = 12.sp, color = colors.onSurfaceVariant)
Text(
v, fontSize = 12.sp, fontWeight = FontWeight.SemiBold, color = colors.onSurfaceVariant, maxLines = 1,
modifier = Modifier.clip(RoundedCornerShape(4.dp))
.background(if (k in lit) pal.signal.copy(alpha = 0.25f * glow) else Color.Transparent)
.padding(horizontal = 2.dp),
)
}
Icon(Icons.Filled.KeyboardArrowDown, null, tint = colors.onSurfaceVariant, modifier = Modifier.padding(start = 4.dp).size(16.dp))
Icon(
Icons.Filled.KeyboardArrowUp, null, tint = colors.onSurfaceVariant,
modifier = Modifier.size(18.dp).graphicsLayer { translationY = if (still) 0f else -3.dp.toPx() * lift },
)
}
}
@@ -624,7 +621,7 @@ internal fun SheetChips(labels: List<String>, selected: Int, focus: List<FocusRe
BoxWithConstraints(Modifier.fillMaxWidth().onFocusChanged { within = it.hasFocus }) {
val equal = maxWidth / labels.size.coerceAtLeast(1) >= 96.dp
val scroll = rememberScrollState()
Box(if (equal) Modifier.fillMaxWidth() else Modifier.horizontalScroll(scroll)) {
Box(if (equal) Modifier.fillMaxWidth() else Modifier.edgeFade(scroll).horizontalScroll(scroll)) {
ChipGlide(selected, bounds[selected], tint)
Row(horizontalArrangement = Arrangement.spacedBy(6.dp), modifier = if (equal) Modifier.fillMaxWidth() else Modifier) {
labels.forEachIndexed { i, label ->
@@ -21,6 +21,8 @@ import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.graphics.drawscope.rotate
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.draw.drawWithContent
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
@@ -206,3 +208,22 @@ internal fun FlightDot(f: Flight, origin: Offset, onDone: () -> Unit) {
}
}
}
/**
* A row that scrolls sideways fades out at an edge it has more past, instead of slicing a pill or
* a card through: the content's own alpha, so whatever is behind the row shows through.
*/
internal fun Modifier.edgeFade(scroll: androidx.compose.foundation.ScrollState, width: Dp = 28.dp): Modifier =
this.graphicsLayer { compositingStrategy = androidx.compose.ui.graphics.CompositingStrategy.Offscreen }
.drawWithContent {
drawContent()
val w = width.toPx().coerceAtMost(size.width / 3f)
if (scroll.value > 0) drawRect(
androidx.compose.ui.graphics.Brush.horizontalGradient(0f to Color.Transparent, 1f to Color.Black, startX = 0f, endX = w),
size = Size(w, size.height), blendMode = androidx.compose.ui.graphics.BlendMode.DstIn,
)
if (scroll.value < scroll.maxValue) drawRect(
androidx.compose.ui.graphics.Brush.horizontalGradient(0f to Color.Black, 1f to Color.Transparent, startX = size.width - w, endX = size.width),
topLeft = Offset(size.width - w, 0f), size = Size(w, size.height), blendMode = androidx.compose.ui.graphics.BlendMode.DstIn,
)
}
@@ -1,35 +1,13 @@
package com.droiddeck.launcher.ui
import android.content.Context
import androidx.compose.foundation.layout.Box
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import com.droiddeck.launcher.R
import com.droiddeck.launcher.session.SessionDisplay
import com.droiddeck.launcher.session.SessionPrefs
// The rows the lifted sheets add to what the session settings already had: frame generation,
// Performance and the link to the GPU drivers on Components.
/**
* What a mode's lip says: its session size, then (when [full]) its frame-rate cap and upscaler,
* then its touch mode, each left out at its default.
*/
internal fun lipFor(ctx: Context, mode: String, full: Boolean): List<Pair<String, String>> {
val panel = SessionDisplay.panelSize(ctx)
val size = SessionDisplay.resolveChoice(panel, SessionPrefs.resolutionChoice(ctx, mode, panel))
val fps = if (full) SessionPrefs.fpsLimit(ctx, mode) else 0
val upscaler = if (!full) null else SessionPrefs.upscaler(ctx).takeIf { it != 0 }
?.let { m -> SessionPrefs.upscalerChoices(ctx).firstOrNull { it.first == m }?.second }
val touch = when (SessionPrefs.touchMode(ctx)) {
SessionPrefs.TOUCH_PAD -> ctx.getString(R.string.mode_touch_touchpad)
SessionPrefs.TOUCH_DIRECT -> ctx.getString(R.string.mode_touch_direct)
SessionPrefs.TOUCH_OFF -> ctx.getString(R.string.lip_touch_off)
else -> null
}
return lipParts(size, fps, { ctx.getString(R.string.lip_fps, it) }, upscaler, touch)
}
/** Frame generation, moved here from Setup: it is how Play's games are drawn. */
@Composable
internal fun FrameGenGroup(s: FrontEndState, a: FrontEndActions) {
@@ -83,7 +83,6 @@ internal fun SteamHome(s: FrontEndState, a: FrontEndActions, modifier: Modifier)
// came out differently from one read of the library to the next moved every capsule.
val games = remember(s.steamGames) { s.steamGames.sortedWith(compareByDescending<Library.SteamGame> { it.lastPlayed }.thenBy { it.gameId }) }
val narrow = LocalNarrowPane.current
val ctx = androidx.compose.ui.platform.LocalContext.current
// Where the words and buttons sit, for the empty library's wandering mark to keep off.
var words by remember { mutableStateOf<Rect?>(null) }
val mode = com.droiddeck.launcher.session.SessionService.MODE_STEAM
@@ -95,7 +94,7 @@ internal fun SteamHome(s: FrontEndState, a: FrontEndActions, modifier: Modifier)
drivers = { summary -> DriversLink(a, summary, "steam", back) },
)
LiftHero(
key = "steam", tabs = tabs, lip = { lipFor(ctx, mode, full = true) },
key = "steam", tabs = tabs,
onOpen = a.onSteamSettings, onPrimary = a.onPlay,
modifier = modifier.clipToBounds(),
start = if (narrow) 20.dp else 44.dp, bottom = if (narrow) 20.dp else 44.dp,
@@ -237,7 +237,7 @@ private fun SetupButton(s: FrontEndState, busy: Boolean, full: Dp, ring: Int, on
return
}
// A pad keeps its place on the rail that took the button's.
if (ff != null) LaunchedEffect(Unit) { if (inputMode.inputMode == InputMode.Keyboard) focusWithinFrames({ false }) { ff.primary } }
if (ff != null) LaunchedEffect(Unit) { if (inputMode.inputMode == InputMode.Keyboard) focusSoon { ff.primary } }
val width = androidx.compose.ui.unit.lerp(restW.coerceAtLeast(120.dp), full, grow)
val shape = RoundedCornerShape(12.dp)
val shimmer = rememberInfiniteTransition(label = "setupShimmer")
@@ -303,7 +303,7 @@ private fun Storefront(s: FrontEndState, a: FrontEndActions) {
detailFrom = cards[id]?.let { Origin(it.translate(-viewportAt), 16f * density.density) }
leaving = false
detail = id
if (inputMode.inputMode == InputMode.Keyboard && ff != null) { delay(Motion.ms(300).toLong()); focusWithinFrames({ false }) { ff.primary } }
if (inputMode.inputMode == InputMode.Keyboard && ff != null) { delay(Motion.ms(300).toLong()); focusSoon { ff.primary } }
} else if (detail != null) {
lastApp = detail
if (detailFrom != null) { leaving = true; delay(Motion.ms(PAGE_RETURN_MS).toLong()) }
@@ -314,7 +314,7 @@ private fun Storefront(s: FrontEndState, a: FrontEndActions) {
LaunchedEffect(detail) {
if (detail != null || inputMode.inputMode != InputMode.Keyboard || ff == null) return@LaunchedEffect
val id = lastApp ?: return@LaunchedEffect
ff.items["tile:store:$id"]?.let { req -> focusWithinFrames({ false }) { req } }
ff.items["tile:store:$id"]?.let { req -> focusSoon { req } }
}
BackHandler(enabled = openApp != null) { openApp = null }
// An app's card on Desktop asked for its page.
@@ -323,6 +323,14 @@ private fun Storefront(s: FrontEndState, a: FrontEndActions) {
val sink by animateFloatAsState(if (covering) 0.95f else 1f, if (covering) Motion.tw(480) else Motion.tw(460, 40), label = "flathubSink")
val fade by animateFloatAsState(if (covering) 0f else 1f, if (covering) Motion.tw(320, 80) else Motion.tw(300, 100), label = "flathubFade")
val modes = buildList { add(MODE_DISCOVER); add(MODE_INSTALLED); if (updates.isNotEmpty()) add(MODE_UPDATES) }
// LB / RB with a pad: focus goes to the new mode's chip; the cards it was on leave with the old mode.
val seenMode = remember { arrayOf(mode) }
LaunchedEffect(mode) {
if (seenMode[0] == mode) return@LaunchedEffect
seenMode[0] = mode
if (inputMode.inputMode != InputMode.Keyboard || ff == null) return@LaunchedEffect
ff.items["flathub:$mode"]?.let { req -> focusSoon { req } }
}
Column(
Modifier.fillMaxSize().padding(horizontal = padH, vertical = if (narrow) 10.dp else 14.dp)
@@ -443,9 +451,10 @@ private fun Discover(
stringResource(R.string.store_tab_discover), query, onQuery, stringResource(R.string.store_search_placeholder),
) {
// The categories as small pills, at the right of the header.
val pills = rememberScrollState()
Row(
horizontalArrangement = Arrangement.spacedBy(6.dp),
modifier = Modifier.widthIn(max = 420.dp).horizontalScroll(rememberScrollState()),
modifier = Modifier.widthIn(max = 420.dp).edgeFade(pills).horizontalScroll(pills),
) {
FlathubApi.categories.forEach { c -> PillButton(stringResource(c.label), selected = category == c.id) { onCategory(c.id) } }
}
@@ -509,7 +518,8 @@ private fun Shelf(title: String, apps: List<CardApp>?, first: Boolean, cards: Ha
if (apps == null) Text(stringResource(R.string.store_section_loading), fontSize = 13.sp, color = colors.onSurfaceVariant)
else if (apps.isNotEmpty()) BoxWithConstraints(Modifier.fillMaxWidth()) {
val size = cardSize(maxWidth)
Row(horizontalArrangement = Arrangement.spacedBy(10.dp), modifier = Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).padding(vertical = 2.dp)) {
val shelf = rememberScrollState()
Row(horizontalArrangement = Arrangement.spacedBy(10.dp), modifier = Modifier.fillMaxWidth().edgeFade(shelf).horizontalScroll(shelf).padding(vertical = 2.dp)) {
apps.take(18).forEachIndexed { i, app -> key(app.id) { AppCard(app, size, first && i == 0, cards) { onOpen(app.id) } } }
}
}
@@ -685,7 +695,8 @@ private fun AppDetail(s: FrontEndState, a: FrontEndActions, id: String, onBack:
if (d.screenshots.isNotEmpty()) {
Rise(3) { SectionTitle(stringResource(R.string.store_screenshots), null) }
Rise(3) {
Row(horizontalArrangement = Arrangement.spacedBy(10.dp), modifier = Modifier.fillMaxWidth().horizontalScroll(rememberScrollState())) {
val shots = rememberScrollState()
Row(horizontalArrangement = Arrangement.spacedBy(10.dp), modifier = Modifier.fillMaxWidth().edgeFade(shots).horizontalScroll(shots)) {
d.screenshots.take(6).forEach { shot ->
AsyncImage(
model = shot.thumb, contentDescription = null, contentScale = ContentScale.Crop,
-2
View File
@@ -2189,8 +2189,6 @@
<string name="hop_from_play">Play settings</string>
<string name="hop_from_desktop">Desktop settings</string>
<!-- The lifted settings sheets under Play and Open desktop. -->
<string name="lip_fps">%1$d fps</string>
<string name="lip_touch_off">Touch off</string>
<string name="sheet_graphics_drivers">Graphics drivers</string>
<!-- Components as one stack of layers. -->
<string name="comp_this_proton">This Proton</string>
@@ -4,27 +4,6 @@ import org.junit.Assert.assertEquals
import org.junit.Test
class LiftSheetTest {
private val fps: (Int) -> String = { "$it fps" }
@Test fun theLipSaysEverythingThatIsNotDefault() {
val parts = lipParts(1280 to 720, 60, fps, "FSR 1", "Touchpad")
assertEquals("1280×720 · 60 fps · FSR 1 · Touchpad", parts.joinToString(" · ") { it.second })
}
@Test fun defaultsAreLeftOut() {
assertEquals(listOf("size" to "1920×1080"), lipParts(1920 to 1080, 0, fps, null, null))
assertEquals(listOf("size", "touch"), lipParts(1920 to 1080, 0, fps, null, "Touchpad").map { it.first })
}
@Test fun nothingIsLitTheFirstTime() {
assertEquals(emptySet<String>(), lipChanged(null, lipParts(1280 to 720, 60, fps, null, null)))
}
@Test fun aChangedOrNewPartIsLit() {
val seen = lipParts(1280 to 720, 0, fps, null, "Touchpad").toMap()
assertEquals(setOf("size", "fps"), lipChanged(seen, lipParts(1920 to 1080, 60, fps, null, "Touchpad")))
}
@Test fun theSheetTopIs82dpDownA360dpPane() {
assertEquals(82f, sheetTop(360f, 56f, 16f, 3f), 0.01f)
assertEquals(164f, sheetTop(720f, 56f, 16f, 3f), 0.01f)