mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
fix: store chips mark the shown store without faking focus, and step-outs open and fold cleanly (#604)
* fix: a chip selection hopping past a chip fades across instead of crawling over as a drop * fix: the store chips' fill only shows where a pad's focus is, not on the shown store * feat: the shown store's chip carries a bar on its foot, every chip pulses when picked, and the queue's settings live only in the cog * fix: step-outs grow and fold in one move with no tail, keep the ring out while moving, and hand focus back to their control
This commit is contained in:
1 parent
674e679884
commit
4bfc7154cd
6 files changed
+103
-66
No files matched your search
@@ -23,6 +23,7 @@ import androidx.compose.runtime.staticCompositionLocalOf
|
||||
import androidx.compose.runtime.withFrameNanos
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.drawWithContent
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.geometry.CornerRadius
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.geometry.Rect
|
||||
@@ -58,6 +59,8 @@ internal class GlideSource {
|
||||
var shape: Shape by mutableStateOf<Shape>(androidx.compose.ui.graphics.RectangleShape)
|
||||
var color by mutableStateOf(Color.Transparent)
|
||||
var width by mutableStateOf(2.dp)
|
||||
/** Focuses the control again: a step-out hands focus back to the control it came out of. */
|
||||
val requester = androidx.compose.ui.focus.FocusRequester()
|
||||
}
|
||||
|
||||
internal class FocusGlide(val view: View) {
|
||||
@@ -135,7 +138,7 @@ internal fun Modifier.glideBorder(
|
||||
onDispose { glide.release(src) }
|
||||
}
|
||||
val base = if (restColor.alpha > 0f) border(restWidth, restColor, shape) else this
|
||||
return base.onGloballyPositioned { src.coords = it; glide.moved(src) }
|
||||
return base.focusRequester(src.requester).onGloballyPositioned { src.coords = it; glide.moved(src) }
|
||||
}
|
||||
|
||||
/** Leading edge on a focus move: quick and a little loose. */
|
||||
|
||||
@@ -13,6 +13,7 @@ import androidx.compose.runtime.key
|
||||
import androidx.compose.runtime.mutableStateListOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberUpdatedState
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.geometry.CornerRadius
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
@@ -44,9 +45,10 @@ internal enum class GlideAxis { Horizontal, Vertical }
|
||||
/**
|
||||
* The selection under a row of chips: [at] (in the row) of chip [index], in [tint]. A move to the
|
||||
* next chip stretches it - the leading edge on the focus ring's lead spring, the trailing one a
|
||||
* beat later on its trail spring - and a hop past a chip pinches it to a drop, carries it and
|
||||
* opens it. [axis] runs it down a column instead (the rail, a stack of layers). [corner] is the
|
||||
* chips' own corner; null draws a capsule. [fill] and [outline] are the resting alphas.
|
||||
* beat later on its trail spring - and a hop past a chip fades it out where it was and in where it
|
||||
* lands (carried over as a drop, it sat on chips the pad had already left). [axis] runs it down a column instead (the rail, a stack of layers). [corner] is the
|
||||
* chips' own corner; null draws a capsule. [fill] and [outline] are the resting alphas. Not
|
||||
* [visible], it fades away, and comes back on whichever chip it is on by then.
|
||||
*/
|
||||
@Composable
|
||||
internal fun BoxScope.ChipGlide(
|
||||
@@ -57,12 +59,16 @@ internal fun BoxScope.ChipGlide(
|
||||
corner: Dp? = null,
|
||||
fill: Float = 0.16f,
|
||||
outline: Float = 0.7f,
|
||||
visible: Boolean = true,
|
||||
) {
|
||||
val density = androidx.compose.ui.platform.LocalDensity.current
|
||||
// The two edges along the axis (left and right, or top and bottom), and the two across it.
|
||||
val start = remember { Animatable(Float.NaN) }
|
||||
val end = remember { Animatable(0f) }
|
||||
val pinch = remember { Animatable(0f) }
|
||||
val shown = remember { Animatable(if (visible) 1f else 0f) }
|
||||
val visibleNow = rememberUpdatedState(visible)
|
||||
LaunchedEffect(visible) { shown.animateTo(if (visible) 1f else 0f, Motion.tw(if (visible) 160 else 120)) }
|
||||
val crossStart = remember { mutableStateOf(0f) }
|
||||
val crossEnd = remember { mutableStateOf(0f) }
|
||||
val was = remember { intArrayOf(-1) }
|
||||
@@ -76,20 +82,25 @@ internal fun BoxScope.ChipGlide(
|
||||
val from = was[0]
|
||||
was[0] = index
|
||||
if (start.value.isNaN() || from == index || from < 0 || Motion.scale == 0f) {
|
||||
start.snapTo(s); end.snapTo(e); pinch.snapTo(0f)
|
||||
if (visibleNow.value) shown.snapTo(1f)
|
||||
return@LaunchedEffect
|
||||
}
|
||||
// Away or on its way back: it goes straight to the chip, unseen.
|
||||
if (!visibleNow.value || shown.value < 0.5f) {
|
||||
start.snapTo(s); end.snapTo(e); pinch.snapTo(0f)
|
||||
return@LaunchedEffect
|
||||
}
|
||||
coroutineScope {
|
||||
if (abs(index - from) > 1) {
|
||||
// Too far to stretch: pinch into a drop where it is, carry it over, open it there.
|
||||
pinch.animateTo(1f, Motion.tw(90))
|
||||
val l = launch { start.animateTo(s, Motion.sp(0.7f, 380f)) }
|
||||
val r = launch { end.animateTo(e, Motion.sp(0.7f, 380f)) }
|
||||
l.join(); r.join()
|
||||
pinch.animateTo(0f, Motion.sp(0.6f, 500f))
|
||||
// Too far to stretch: out where it is, in where it lands.
|
||||
shown.animateTo(0f, Motion.tw(90))
|
||||
pinch.snapTo(0f); start.snapTo(s); end.snapTo(e)
|
||||
shown.animateTo(1f, Motion.tw(160))
|
||||
} else {
|
||||
// An adjacent move can interrupt a long hop while it is still pinched.
|
||||
// An adjacent move can interrupt a long hop while it is still faded.
|
||||
launch { pinch.animateTo(0f, Motion.sp(0.6f, 500f)) }
|
||||
launch { shown.animateTo(1f, Motion.tw(120)) }
|
||||
val forward = index > from
|
||||
val (lead, trail) = if (forward) end to start else start to end
|
||||
val leadTo = if (forward) e else s
|
||||
@@ -108,13 +119,14 @@ internal fun BoxScope.ChipGlide(
|
||||
val round = minOf(size.width, size.height) / 2f
|
||||
val r = CornerRadius(corner?.let { lerp(minOf(with(density) { it.toPx() }, round), round, p) } ?: round)
|
||||
// A drop in flight is solid; on a chip it is the chip's tinted fill and outline.
|
||||
drawRoundRect(tint.value.copy(alpha = lerp(fill, 0.9f, p)), at0, size, r)
|
||||
val a = shown.value
|
||||
drawRoundRect(tint.value.copy(alpha = lerp(fill, 0.9f, p) * a), at0, size, r)
|
||||
if (outline > 0f) {
|
||||
// Inside the chip's edge: a stroke on it would lose its outer half to a scrolling row's clip.
|
||||
val w = with(density) { 1.dp.toPx() }
|
||||
val inset = w / 2f
|
||||
drawRoundRect(
|
||||
tint.value.copy(alpha = outline * (1f - p)), at0 + Offset(inset, inset), Size(size.width - w, size.height - w),
|
||||
tint.value.copy(alpha = outline * (1f - p) * a), at0 + Offset(inset, inset), Size(size.width - w, size.height - w),
|
||||
CornerRadius((r.x - inset).coerceAtLeast(0f)), style = Stroke(w),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -181,6 +181,15 @@ internal fun StepOut(
|
||||
var grown by remember { mutableStateOf(false) }
|
||||
var measured by remember { mutableStateOf<IntSize?>(null) }
|
||||
val first = remember { FocusRequester() }
|
||||
// The control focus was on as it opened: focus goes back to it as it folds, not to wherever
|
||||
// the screen puts a pad with nothing focused (the rail).
|
||||
val glide = LocalFocusGlide.current
|
||||
val opener = remember { arrayOfNulls<GlideSource>(1) }
|
||||
val openNow = androidx.compose.runtime.rememberUpdatedState(open)
|
||||
// While the box grows or folds the ring keeps out (it flew across the moving shape) and comes
|
||||
// back on whatever has focus once it has settled: the first choice, or the control again.
|
||||
var moving by remember { mutableStateOf(false) }
|
||||
if (moving) VeilRing()
|
||||
val pull = with(density) { OutPull.toPx() }
|
||||
val corner = pillCorner?.let { with(density) { it.toPx() } } ?: minOf(pill.height, pill.width) / 2f
|
||||
|
||||
@@ -204,6 +213,7 @@ internal fun StepOut(
|
||||
val boxBottom = pill.bottom + pull + c.height
|
||||
if (open) {
|
||||
if (!grown) {
|
||||
opener[0] = glide?.current
|
||||
edge.snapTo(rest); bottom.snapTo(pill.bottom); tint.snapTo(0f)
|
||||
pieces.forEach { it.snapTo(0f) }
|
||||
grown = true
|
||||
@@ -211,8 +221,12 @@ internal fun StepOut(
|
||||
coroutineScope {
|
||||
launch { dim.animateTo(1f, Motion.tw(260)) }
|
||||
launch { tint.animateTo(1f, Motion.tw(200)) }
|
||||
launch { bottom.animateTo(boxBottom, Motion.sp(0.7f, 380f)) }
|
||||
launch { delay(Motion.ms(110).toLong()); edge.animateTo(out, Motion.sp(0.55f, 300f)) }
|
||||
// Down and out together, on one spring: down first drew the control as a stick
|
||||
// that then snapped out sideways.
|
||||
moving = true
|
||||
val down = launch { bottom.animateTo(boxBottom, Motion.sp(0.8f, 380f)) }
|
||||
val across = launch { edge.animateTo(out, Motion.sp(0.8f, 380f)) }
|
||||
launch { down.join(); across.join(); moving = false }
|
||||
pieces.forEachIndexed { i, a ->
|
||||
launch { delay(Motion.ms(260 + i * 55).toLong()); a.animateTo(1f, Motion.tw(220)) }
|
||||
}
|
||||
@@ -223,14 +237,20 @@ internal fun StepOut(
|
||||
}
|
||||
}
|
||||
} else {
|
||||
opener[0]?.let { o -> if (inputMode.inputMode == InputMode.Keyboard) runCatching { o.requester.requestFocus() } }
|
||||
opener[0] = null
|
||||
coroutineScope {
|
||||
pieces.forEach { launch { it.animateTo(0f, Motion.tw(90)) } }
|
||||
launch { delay(Motion.ms(60).toLong()); dim.animateTo(0f, Motion.tw(300)) }
|
||||
launch { delay(Motion.ms(60).toLong()); edge.animateTo(rest, Motion.sp(1f, 420f)) }
|
||||
launch { delay(Motion.ms(160).toLong()); bottom.animateTo(pill.bottom, Motion.sp(1f, 380f)) }
|
||||
// In and up together on a timed ease: width first left a tall tail under the
|
||||
// control, and a damped spring's tail kept a nub of it on screen.
|
||||
moving = true
|
||||
launch { delay(Motion.ms(60).toLong()); edge.animateTo(rest, Motion.tw(240)) }
|
||||
launch { delay(Motion.ms(60).toLong()); bottom.animateTo(pill.bottom, Motion.tw(240)) }
|
||||
launch { delay(Motion.ms(200).toLong()); tint.animateTo(0f, Motion.tw(200)) }
|
||||
}
|
||||
grown = false
|
||||
moving = false
|
||||
onClosed()
|
||||
}
|
||||
}
|
||||
@@ -256,8 +276,14 @@ internal fun StepOut(
|
||||
if (side == StepSide.Left) stepPath(path, pill, edge.value, bottom.value, pill.bottom + pull, boxCorner, fillet, corner)
|
||||
else stepPathRight(path, pill, edge.value, bottom.value, pill.bottom + pull, boxCorner, fillet, corner)
|
||||
if (up) path.transform(Matrix().apply { this[1, 1] = -1f; this[3, 1] = pill.top + pill.bottom })
|
||||
drawPath(path, lerp(hotFill, restFill, tint.value))
|
||||
drawPath(path, accent.copy(alpha = lerpF(0.9f, 0.55f, tint.value)), style = Stroke(rim))
|
||||
// Barely bigger than the control, the pull and its fillet drew a hook off the control's
|
||||
// foot: the outline is only seen once it is well out of the control, by how far.
|
||||
val rest = if (side == StepSide.Left) pill.left else pill.right
|
||||
val a = (((bottom.value - pill.bottom - pull) / 40.dp.toPx()).coerceIn(0f, 1f) *
|
||||
(kotlin.math.abs(edge.value - rest) / 24.dp.toPx()).coerceIn(0f, 1f))
|
||||
if (a <= 0.01f) return@Canvas
|
||||
drawPath(path, lerp(hotFill, restFill, tint.value), alpha = a)
|
||||
drawPath(path, accent.copy(alpha = lerpF(0.9f, 0.55f, tint.value) * a), style = Stroke(rim))
|
||||
}
|
||||
// The control's label rides on top, as the pull's handle.
|
||||
if (grown) Box(
|
||||
@@ -274,7 +300,7 @@ internal fun StepOut(
|
||||
.onSizeChanged { if (measured != it) measured = it }
|
||||
.controllerBack(onDismiss)
|
||||
// A pad stays in the box until it is answered or folded, as it did in Stop's dialog.
|
||||
.focusProperties { exit = { FocusRequester.Cancel } }
|
||||
.focusProperties { exit = { if (openNow.value) FocusRequester.Cancel else FocusRequester.Default } }
|
||||
.focusGroup()
|
||||
.verticalScroll(rememberScrollState())
|
||||
.padding(start = 14.dp, end = 14.dp, top = 12.dp, bottom = 12.dp),
|
||||
|
||||
@@ -48,6 +48,7 @@ import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.focusGroup
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.BoxWithConstraints
|
||||
import androidx.compose.foundation.layout.Column
|
||||
@@ -93,17 +94,10 @@ import com.droiddeck.launcher.stores.formatSpeed
|
||||
|
||||
// The Downloads chip: one queue for the three stores, its settings and the engine log.
|
||||
|
||||
/** The queue. Its settings (speed tier, downloads at a time) live in the chip row's cog only. */
|
||||
@Composable
|
||||
internal fun StoresDownloadsPane(s: FrontEndState, a: FrontEndActions) {
|
||||
BoxWithConstraints(Modifier.fillMaxWidth()) {
|
||||
val wide = maxWidth >= 700.dp
|
||||
val list: @Composable () -> Unit = { DownloadList(s, a) }
|
||||
val side: @Composable () -> Unit = { DownloadSettings(s, a) }
|
||||
if (wide) Row(horizontalArrangement = Arrangement.spacedBy(24.dp)) {
|
||||
Box(Modifier.weight(3f)) { list() }
|
||||
Box(Modifier.weight(2f)) { side() }
|
||||
} else Column { list(); side() }
|
||||
}
|
||||
DownloadList(s, a)
|
||||
}
|
||||
|
||||
@Composable
|
||||
@@ -453,21 +447,9 @@ private fun eta(seconds: Long): String = when {
|
||||
else -> "~${seconds / 3600} h ${(seconds % 3600) / 60} m"
|
||||
}
|
||||
|
||||
/** The queue's settings beside it: speed tier, downloads at a time, and the engine log. */
|
||||
@Composable
|
||||
private fun DownloadSettings(s: FrontEndState, a: FrontEndActions) {
|
||||
val ctx = LocalContext.current
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
SectionTitle(stringResource(R.string.stores_download_manager), null)
|
||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.fillMaxWidth().clip(Shape12).background(colors.surface).border(1.dp, pal.line, Shape12).padding(horizontal = 14.dp, vertical = 10.dp)) {
|
||||
DownloadControls(s, a)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The queue's two knobs on one line - the speed tier on the left, downloads at a time on the
|
||||
* right; the same control sits in the cog's popup. A narrow page puts them on two tight lines.
|
||||
* right; it sits in the cog's popup. A narrow page puts them on two tight lines.
|
||||
*/
|
||||
@Composable
|
||||
internal fun DownloadControls(s: FrontEndState, a: FrontEndActions) {
|
||||
@@ -500,7 +482,7 @@ internal fun DownloadControls(s: FrontEndState, a: FrontEndActions) {
|
||||
*/
|
||||
internal fun storesSettingsStep(at: Rect, s: androidx.compose.runtime.State<FrontEndState>, a: FrontEndActions, accent: androidx.compose.ui.graphics.Color): StepAsk =
|
||||
StepAsk(
|
||||
anchor = at, side = StepSide.Left, accent = accent, items = 3, maxWidth = 440.dp,
|
||||
anchor = at, side = StepSide.Left, accent = accent, items = 2, maxWidth = 440.dp,
|
||||
handle = { androidx.compose.material3.Icon(androidx.compose.material.icons.Icons.Filled.Settings, null, tint = accent, modifier = Modifier.size(20.dp)) },
|
||||
) {
|
||||
StepTitle(stringResource(R.string.stores_settings_eyebrow))
|
||||
@@ -509,11 +491,12 @@ internal fun storesSettingsStep(at: Rect, s: androidx.compose.runtime.State<Fron
|
||||
verticalArrangement = Arrangement.spacedBy(6.dp),
|
||||
) {
|
||||
val st = s.value
|
||||
// No OK: B or a tap outside folds it, and a pad starts on the first choice.
|
||||
SettingsRow(stringResource(R.string.setup_stores_open_on), null, stacked = true) {
|
||||
SegmentedTabs(
|
||||
Box(Modifier.focusRequester(first).focusGroup()) { SegmentedTabs(
|
||||
listOf(SessionPrefs.STORES_OPEN_LIBRARY to stringResource(R.string.stores_tab_library), SessionPrefs.STORES_OPEN_STORE to stringResource(R.string.stores_tab_store)),
|
||||
st.storesOpenTab,
|
||||
) { a.onStoresOpenTab(it) }
|
||||
) { a.onStoresOpenTab(it) } }
|
||||
}
|
||||
SettingsRow(stringResource(R.string.stores_show_mature), null) {
|
||||
ToggleSwitch(st.storesShowMature, label = stringResource(R.string.stores_show_mature)) { a.onStoresShowMature(it) }
|
||||
@@ -522,7 +505,4 @@ internal fun storesSettingsStep(at: Rect, s: androidx.compose.runtime.State<Fron
|
||||
Column(Modifier.fillMaxWidth().padding(horizontal = 14.dp, vertical = 11.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) { DownloadControls(st, a) }
|
||||
StoresEngineRow()
|
||||
}
|
||||
Row(horizontalArrangement = Arrangement.End, modifier = Modifier.fillMaxWidth().stepItem(2).padding(top = 8.dp)) {
|
||||
StepChoice(stringResource(R.string.common_ok), enabled = open, modifier = Modifier.focusRequester(first)) { StoresMotion.fold() }
|
||||
}
|
||||
}
|
||||
@@ -585,6 +585,10 @@ private fun StoreChips(
|
||||
val rootBounds = remember { HashMap<String, Rect>() }
|
||||
// The fill travels with focus; only the expensive pane change waits for the debounce.
|
||||
val highlighted = focused ?: selected
|
||||
// With a pad the fill is only where focus is: on a chip that does not have it (the row first
|
||||
// drawn with focus on the rail, or focus on the cog or the page) it read as focus.
|
||||
val inputMode = androidx.compose.ui.platform.LocalInputModeManager.current.inputMode
|
||||
val fillShown = focused != null || inputMode != androidx.compose.ui.input.InputMode.Keyboard
|
||||
val tint = androidx.compose.animation.animateColorAsState(
|
||||
Store.byId(highlighted)?.let { sourceColours(it.id).dot } ?: pal.signal, Motion.tw(160), label = "chipTint",
|
||||
)
|
||||
@@ -593,22 +597,15 @@ private fun StoreChips(
|
||||
for (store in Store.entries) {
|
||||
val signedIn = StoresState.isSignedIn(store) && StoresState.expired[store] != true
|
||||
StoreChip(
|
||||
label = store.shortLabel, on = selected == store.id, key = store.id,
|
||||
label = store.shortLabel, on = selected == store.id, under = fillShown && highlighted == store.id, key = store.id, mark = sourceColours(store.id).dot,
|
||||
modifier = Modifier.weight(1f).onGloballyPositioned { bounds[store.id] = it.boundsInParent(); rootBounds[store.id] = it.boundsInRoot() },
|
||||
lead = {
|
||||
val c = sourceColours(store.id)
|
||||
// A store's dot pulses once when it is picked signed in, and when a sign-in lands.
|
||||
var picked by remember { mutableStateOf(0) }
|
||||
val on = selected == store.id
|
||||
val wasOn = remember { booleanArrayOf(on) }
|
||||
LaunchedEffect(on) {
|
||||
if (on && !wasOn[0] && signedIn) picked++
|
||||
wasOn[0] = on
|
||||
}
|
||||
// A store's dot pulses when a sign-in lands (and, with the chip's lead, when picked).
|
||||
Box(
|
||||
Modifier.size(12.dp)
|
||||
.onGloballyPositioned { StoresMotion.dots[store] = it.boundsInRoot() }
|
||||
.pulseRing(picked + (StoresMotion.pulses[store] ?: 0), c.dot),
|
||||
.pulseRing(StoresMotion.pulses[store] ?: 0, c.dot),
|
||||
) { Box(Modifier.matchParentSize().clip(CircleShape).background(c.dot).alpha(if (signedIn) 1f else 0.35f)) }
|
||||
},
|
||||
description = store.label + if (signedIn) "" else " " + stringResource(R.string.stores_chip_signed_out),
|
||||
@@ -616,7 +613,7 @@ private fun StoreChips(
|
||||
) { onStore(store, rootBounds[store.id]) }
|
||||
}
|
||||
StoreChip(
|
||||
label = stringResource(R.string.stores_tab_downloads), on = selected == DOWNLOADS, key = DOWNLOADS,
|
||||
label = stringResource(R.string.stores_tab_downloads), on = selected == DOWNLOADS, under = fillShown && highlighted == DOWNLOADS, key = DOWNLOADS, mark = pal.signal,
|
||||
modifier = Modifier.weight(1f).onGloballyPositioned {
|
||||
bounds[DOWNLOADS] = it.boundsInParent()
|
||||
StoresMotion.downloadsChip = it.boundsInRoot()
|
||||
@@ -631,13 +628,13 @@ private fun StoreChips(
|
||||
}
|
||||
}
|
||||
// Over the chips: the fill is translucent, and the other chips' rest fill would hide it in flight.
|
||||
ChipGlide(keys.indexOf(highlighted), bounds[highlighted], tint)
|
||||
ChipGlide(keys.indexOf(highlighted), bounds[highlighted], tint, visible = fillShown)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun StoreChip(
|
||||
label: String, on: Boolean, key: String, modifier: Modifier, lead: @Composable () -> Unit,
|
||||
label: String, on: Boolean, under: Boolean, key: String, mark: Color, modifier: Modifier, lead: @Composable () -> Unit,
|
||||
trail: (@Composable () -> Unit)? = null, description: String? = null,
|
||||
onFocused: (String?) -> Unit = {}, onClick: () -> Unit,
|
||||
) {
|
||||
@@ -650,7 +647,16 @@ private fun StoreChip(
|
||||
val scale by animateFloatAsState(if (pressed) 0.95f else 1f, Motion.sp(0.5f, Spring.StiffnessMedium), label = "chipScale")
|
||||
val shape = RoundedCornerShape(99.dp)
|
||||
val ink = if (on) colors.onBackground else if (hot) colors.onBackground else colors.onSurfaceVariant
|
||||
// The selected look is the row's glide under the chip, so a chip here draws only its rest state.
|
||||
// The chip whose page shows: a bar of its colour along the pill's foot, not an outline or a
|
||||
// fill, so it never reads as focus. Picking it pulses its lead (a store's dot, Downloads' icon).
|
||||
val shown by animateFloatAsState(if (on) 1f else 0f, Motion.tw(if (on) 140 else 100), label = "chipShown")
|
||||
var picked by remember { mutableStateOf(0) }
|
||||
val wasOn = remember { booleanArrayOf(on) }
|
||||
LaunchedEffect(on) {
|
||||
if (on && !wasOn[0]) picked++
|
||||
wasOn[0] = on
|
||||
}
|
||||
// The row's glide draws the look of the chip [under] it, so that one draws no rest state of its own.
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.CenterHorizontally),
|
||||
modifier = modifier.paneItem("storechip:$key")
|
||||
@@ -659,14 +665,24 @@ private fun StoreChip(
|
||||
else if (!f.isFocused) onFocused(null)
|
||||
}
|
||||
.heightIn(min = 44.dp).graphicsLayer { scaleX = scale; scaleY = scale }.clip(shape)
|
||||
.background(if (on) Color.Transparent else colors.surface)
|
||||
.glideBorder(hot, shape, pal.signal, if (on) Color.Transparent else pal.line)
|
||||
.background(if (under) Color.Transparent else colors.surface)
|
||||
.drawWithContent {
|
||||
drawContent()
|
||||
if (shown > 0.01f) {
|
||||
val h = 3.dp.toPx()
|
||||
val w = size.width * 0.36f
|
||||
drawRect(mark, Offset((size.width - w) / 2f, size.height - h), androidx.compose.ui.geometry.Size(w, h), alpha = shown)
|
||||
}
|
||||
}
|
||||
.glideBorder(hot, shape, pal.signal, if (under) Color.Transparent else pal.line)
|
||||
.hoverable(src).clickable(interactionSource = src, indication = LocalIndication.current, role = Role.Tab, onClick = onClick)
|
||||
.controllerConfirm(onClick = onClick)
|
||||
.then(if (description != null) Modifier.semantics { contentDescription = description } else Modifier)
|
||||
.padding(horizontal = 12.dp, vertical = 8.dp),
|
||||
) {
|
||||
androidx.compose.runtime.CompositionLocalProvider(androidx.compose.material3.LocalContentColor provides ink) { lead() }
|
||||
androidx.compose.runtime.CompositionLocalProvider(androidx.compose.material3.LocalContentColor provides ink) {
|
||||
Box(Modifier.pulseRing(picked, mark), contentAlignment = Alignment.Center) { lead() }
|
||||
}
|
||||
Text(label, fontSize = 13.sp, fontWeight = FontWeight.Bold, color = ink, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
trail?.invoke()
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ internal fun StoresEngineRow() {
|
||||
val version = StoresNative.version
|
||||
SettingsRow(
|
||||
stringResource(R.string.setup_stores_engine),
|
||||
version,
|
||||
null,
|
||||
) {
|
||||
Chip(if (version != null) stringResource(R.string.setup_stores_engine_chip_ready) else stringResource(R.string.setup_stores_engine_chip_missing), ok = version != null)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user