diff --git a/app/src/main/java/com/droiddeck/launcher/ui/EmptyLibrary.kt b/app/src/main/java/com/droiddeck/launcher/ui/EmptyLibrary.kt new file mode 100644 index 0000000000..a605c38e9c --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/EmptyLibrary.kt @@ -0,0 +1,424 @@ +package com.droiddeck.launcher.ui + +import androidx.compose.animation.core.CubicBezierEasing +import androidx.compose.animation.core.Easing +import androidx.compose.foundation.Canvas +import androidx.compose.foundation.gestures.detectTapGestures +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.material3.MaterialTheme +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableFloatStateOf +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberUpdatedState +import androidx.compose.runtime.setValue +import androidx.compose.runtime.withFrameMillis +import androidx.compose.ui.Modifier +import androidx.compose.ui.geometry.CornerRadius +import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.geometry.Rect +import androidx.compose.ui.geometry.Size +import androidx.compose.ui.graphics.Brush +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.Path +import androidx.compose.ui.graphics.PathMeasure +import androidx.compose.ui.graphics.drawscope.DrawScope +import androidx.compose.ui.graphics.drawscope.Stroke +import androidx.compose.ui.graphics.drawscope.rotate +import androidx.compose.ui.graphics.drawscope.scale +import androidx.compose.ui.graphics.drawscope.translate +import androidx.compose.ui.graphics.lerp +import androidx.compose.ui.hapticfeedback.HapticFeedbackType +import androidx.compose.ui.input.pointer.pointerInput +import androidx.compose.ui.layout.onSizeChanged +import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.platform.LocalHapticFeedback +import androidx.compose.ui.unit.dp +import kotlin.math.PI +import kotlin.math.abs +import kotlin.math.cos +import kotlin.math.hypot +import kotlin.math.max +import kotlin.math.min +import kotlin.math.sin + +/** + * The Steam tab with nothing installed. The blank wall drifts as the full one does, and the + * DroidDeck mark wanders over it, bouncing off the page's edges and off [avoid] (the words and + * buttons) like an idle DVD logo, carrying a clearing in the wall with it. On arrival its outline + * traces in, the D fills, and the ball pops toward the viewer, flips twice and slams back into its + * socket; the ring the slam sends out fills each blank capsule it reaches. Poking the ball plays + * the pop again, without the mark stopping. [fade] is drawn over the wall and under the mark. + */ +@Composable +internal fun EmptyLibrary(avoid: Rect?, fade: @Composable () -> Unit) { + val clock = rememberMarkClock(avoid) + Box(Modifier.fillMaxSize().onSizeChanged { clock.page = Size(it.width.toFloat(), it.height.toFloat()) }) { + EmptyWall(clock) + fade() + Mark(clock) + } +} + +// The trace and fill, in ms from arrival. +private const val TRACE_MS = 1250f +private const val FILL_FROM = 450f +// The ball's timeline: its fade-in, pop, flip and slam, the ripple and the capsules it lights. +private const val POP_FROM = 900f +private const val IMPACT = 2200f +private const val RIPPLE_MS = 1250f +private const val HIT_MS = 900f +private const val END = 3600f +// Where a poke restarts the ball's timeline: just before the wind-up. +private const val POKE = 880f +private const val DRIFT_MS = 75_000f + +/** + * Time into the mark's arrival, into the ball's timeline (a poke restarts only that), into the + * wall's drift, and where the mark is on the page and where its last slam landed. + */ +private class MarkClock { + var intro by mutableFloatStateOf(0f) + var ball by mutableFloatStateOf(0f) + var wall by mutableFloatStateOf(0f) + var at by mutableStateOf(Offset.Unspecified) + var slam by mutableStateOf(Offset.Unspecified) + var page = Size.Zero + var poked = false + fun poke() { if (ball >= IMPACT + RIPPLE_MS) poked = true } +} + +@Composable +private fun rememberMarkClock(avoid: Rect?): MarkClock { + val clock = remember { MarkClock() } + val haptics = LocalHapticFeedback.current + val keepOff by rememberUpdatedState(avoid) + val speed = with(LocalDensity.current) { 64.dp.toPx() } + val inset = with(LocalDensity.current) { 10.dp.toPx() } + val clearance = with(LocalDensity.current) { 16.dp.toPx() } + LaunchedEffect(clock) { + var last = -1L + var vx = speed * 0.8f + var vy = -speed * 0.6f + while (true) { + if (clock.page == Size.Zero) { withFrameMillis { }; continue } + val f = MarkFrame(clock.page, Offset.Zero) + if (clock.at == Offset.Unspecified) clock.at = Offset(clock.page.width * 0.64f, clock.page.height * 0.42f) + // Animations off in the system settings: the finished mark, still, on a still wall. + if (Motion.scale == 0f) { + clock.intro = END + clock.ball = END + clock.wall = 0f + return@LaunchedEffect + } + withFrameMillis { now -> + val dt = if (last < 0) 0f else min(50f, (now - last) / Motion.scale) + last = now + clock.intro += dt + clock.wall += dt + if (clock.poked) { clock.poked = false; clock.ball = POKE } + val before = clock.ball + clock.ball += dt + + // Drift, bouncing off the page edges and off whatever it should keep clear of. + var x = clock.at.x + vx * dt / 1000f + var y = clock.at.y + vy * dt / 1000f + val hw = f.halfWidth + val hh = f.halfHeight + if (x - hw < inset) { x = inset + hw; vx = abs(vx) } + if (x + hw > clock.page.width - inset) { x = clock.page.width - inset - hw; vx = -abs(vx) } + if (y - hh < inset) { y = inset + hh; vy = abs(vy) } + if (y + hh > clock.page.height - inset) { y = clock.page.height - inset - hh; vy = -abs(vy) } + keepOff?.inflate(clearance)?.let { r -> + if (x + hw > r.left && x - hw < r.right && y + hh > r.top && y - hh < r.bottom) { + val outX = if (x < r.center.x) r.left - (x + hw) else r.right - (x - hw) + val outY = if (y < r.center.y) r.top - (y + hh) else r.bottom - (y - hh) + if (abs(outX) < abs(outY)) { x += outX; vx = if (outX < 0) -abs(vx) else abs(vx) } + else { y += outY; vy = if (outY < 0) -abs(vy) else abs(vy) } + } + } + clock.at = Offset(x, y) + + if (before < IMPACT && clock.ball >= IMPACT) { + clock.slam = clock.at + haptics.performHapticFeedback(HapticFeedbackType.LongPress) + } + } + } + } + return clock +} + +/** + * The mark on a page of [size], centred on [centre]: about a third of the page tall. [k] scales + * the timeline's distances, which were drawn on a 460px mark. + */ +private class MarkFrame(size: Size, val centre: Offset) { + val height = min(size.height * 0.3f, size.width * 0.28f * LogoShape.HEIGHT / LogoShape.WIDTH) + val s = height / LogoShape.HEIGHT + val halfWidth = (LogoShape.CX - LogoShape.LEFT) * s + val halfHeight = LogoShape.CY * s + val ball = LogoShape.BALL * s + val k = height / 460f + val ringFrom = ball + val ringTo = hypot(size.width, size.height) * 1.05f + fun px(x: Float, y: Float) = Offset(centre.x + (x - LogoShape.CX) * s, centre.y + (y - LogoShape.CY) * s) +} + +private val InOut = CubicBezierEasing(0.42f, 0f, 0.58f, 1f) +private val Out = CubicBezierEasing(0f, 0f, 0.58f, 1f) +private val TraceEase = CubicBezierEasing(0.45f, 0f, 0.25f, 1f) +private val PopEase = CubicBezierEasing(0.15f, 0.8f, 0.3f, 1f) +private val DropEase = CubicBezierEasing(0.6f, 0f, 0.9f, 0.5f) +private val FlipEase = CubicBezierEasing(0.25f, 0.7f, 0.35f, 1f) +private val RippleEase = CubicBezierEasing(0.2f, 0.6f, 0.35f, 1f) +private val HitEase = CubicBezierEasing(0.2f, 0.7f, 0.3f, 1f) + +private fun clamp01(v: Float) = v.coerceIn(0f, 1f) +private fun mix(a: Float, b: Float, t: Float) = a + (b - a) * t + +/** One stretch of a keyframed value: [from] to [to] while [p] runs from [a] to [b]. */ +private fun span(p: Float, a: Float, b: Float, from: Float, to: Float, ease: Easing) = + mix(from, to, ease.transform(clamp01((p - a) / (b - a)))) + +/** When the ripple's edge reaches [progress] of its way out, as a share of the ripple's time. */ +private val rippleTime: FloatArray = FloatArray(257) { RippleEase.transform(it / 256f) } +private fun rippleReaches(progress: Float): Float { + var lo = 0 + var hi = rippleTime.size - 1 + while (lo < hi) { + val mid = (lo + hi) / 2 + if (rippleTime[mid] < progress) lo = mid + 1 else hi = mid + } + return lo / 256f +} + +/** How lit a capsule the ripple reached [since] ms ago is: up fast, then fading back. */ +private fun hitAmount(since: Float): Float { + if (since < 0f || since > HIT_MS) return 0f + val p = since / HIT_MS + return if (p < 0.14f) HitEase.transform(p / 0.14f) else 1f - HitEase.transform((p - 0.14f) / 0.86f) +} + +/** The blank wall: the same tilted, drifting columns as [CapsuleWall], each capsule lit as the ripple passes. */ +@Composable +private fun EmptyWall(clock: MarkClock) { + val pal = LocalPalette.current + val bg = pal.background + val hit = lerp(pal.surface, pal.signal, 0.78f) + Canvas(Modifier.fillMaxSize()) { + if (clock.at == Offset.Unspecified) return@Canvas + val capW = 112.dp.toPx() + val capH = 168.dp.toPx() + val gap = 14.dp.toPx() + val corner = CornerRadius(10.dp.toPx()) + val line = 1.dp.toPx() + val tilt = Math.toRadians(13.0) + val cs = cos(tilt).toFloat() + val sn = sin(tilt).toFloat() + val wallW = (size.width * cs + size.height * sn) * 1.1f + val wallH = max(size.height * 2.4f, (size.width * sn + size.height * cs) * 1.1f) + val columns = ((wallW + gap) / (capW + gap)).toInt() + 1 + val perRun = ((wallH + gap) / (capH + gap)).toInt() + 1 + val run = (capH + gap) * perRun + val shift = run * ((clock.wall % DRIFT_MS) / DRIFT_MS) + val pivot = center + val left = pivot.x - wallW / 2 + val top = pivot.y - wallH / 2 + val f = MarkFrame(size, clock.at) + val origin = clock.slam + val reach = hypot(capW, capH) / 2 * 0.77f + val t = clock.ball + val rippling = origin != Offset.Unspecified && t in IMPACT..IMPACT + RIPPLE_MS + HIT_MS + rotate(-13f, pivot) { + for (c in 0 until columns) { + val x = left + c * (capW + gap) + val dy = if (c % 2 == 0) -shift else shift - run + for (i in 0 until perRun * 2) { + val y = top + i * (capH + gap) + dy + // The capsule's centre on the page, out of the wall's tilt. + val lx = x + capW / 2 - pivot.x + val ly = y + capH / 2 - pivot.y + val sx = pivot.x + lx * cs + ly * sn + val sy = pivot.y - lx * sn + ly * cs + if (sx < -capH || sx > size.width + capH || sy < -capH || sy > size.height + capH) continue + var a = 0f + if (rippling) { + val edge = max(0f, hypot(sx - origin.x, sy - origin.y) - reach) + val progress = (edge - f.ringFrom) / (f.ringTo - f.ringFrom) + if (progress <= 1f) a = hitAmount(t - (IMPACT + RIPPLE_MS * rippleReaches(clamp01(progress)))) + } + val grow = 1f + 0.045f * a + scale(grow, grow, Offset(x + capW / 2, y + capH / 2)) { + if (a > 0f) drawRoundRect( + pal.signal.copy(alpha = 0.22f * a), Offset(x - 4.dp.toPx(), y - 4.dp.toPx()), + Size(capW + 8.dp.toPx(), capH + 8.dp.toPx()), CornerRadius(14.dp.toPx()), + ) + drawRoundRect(lerp(pal.surface, hit, a), Offset(x, y), Size(capW, capH), corner) + drawRoundRect( + lerp(pal.line, pal.signal, a), Offset(x, y), Size(capW, capH), corner, + style = Stroke(line * (1f + a)), + ) + } + } + } + } + // The clearing the mark carries with it. + drawRect( + Brush.radialGradient( + 0f to bg, 255f / 420f to bg, 330f / 420f to bg.copy(alpha = 0.7f), 1f to Color.Transparent, + center = f.centre, radius = 420f * f.k, + ), + ) + } +} + +/** The mark, its ball's pop and flip, and the ring the slam sends out. */ +@Composable +private fun Mark(clock: MarkClock) { + val pal = LocalPalette.current + val ink = MaterialTheme.colorScheme.onBackground + val bg = pal.background + val slabEdge = lerp(bg, ink, 0.4f) + val rim = lerp(bg, pal.signal, 0.55f) + val left = remember { Path() } + val right = remember { Path() } + val piece = remember { Path() } + val measure = remember { PathMeasure() } + Canvas( + Modifier.fillMaxSize().pointerInput(clock) { + detectTapGestures { o -> + if (clock.at == Offset.Unspecified || Motion.scale == 0f) return@detectTapGestures + val f = MarkFrame(Size(size.width.toFloat(), size.height.toFloat()), clock.at) + if ((o - clock.at).getDistance() <= f.ball * 1.4f) clock.poke() + } + }, + ) { + if (clock.at == Offset.Unspecified) return@Canvas + val f = MarkFrame(size, clock.at) + val k = f.k + val t = clock.ball + val intro = clock.intro + + // The ripple, from where the slam landed, under the mark. + if (clock.slam != Offset.Unspecified && t in IMPACT..IMPACT + RIPPLE_MS) { + val p = (t - IMPACT) / RIPPLE_MS + val alpha = if (p < 0.7f) mix(0.9f, 0.35f, p / 0.7f) else mix(0.35f, 0f, (p - 0.7f) / 0.3f) + drawCircle( + pal.signal.copy(alpha = alpha), mix(f.ringFrom, f.ringTo, RippleEase.transform(p)), clock.slam, + style = Stroke(max(2.5f * k, 1.5.dp.toPx())), + ) + } + + val shake = if (t in IMPACT..IMPACT + 230f) { + val p = (t - IMPACT) / 230f + when { + p < 0.25f -> span(p, 0f, 0.25f, 0f, 7f, Out) + p < 0.55f -> span(p, 0.25f, 0.55f, 7f, -3f, Out) + else -> span(p, 0.55f, 1f, -3f, 0f, Out) + } * k + } else 0f + + translate(0f, shake) { + // The D, as flat raised slabs with a solid edge underneath. + val fill = Out.transform(clamp01((intro - FILL_FROM) / 450f)) + if (fill > 0f) { + val lift = 8f * k * (1f - fill) + val edge = 5f * f.s + LogoShape.left(left, 0f) { x, y -> f.px(x, y) + Offset(0f, lift + edge) } + LogoShape.right(right) { x, y -> f.px(x, y) + Offset(0f, lift + edge) } + drawPath(left, slabEdge.copy(alpha = fill)) + drawPath(right, slabEdge.copy(alpha = fill)) + LogoShape.left(left, 0f) { x, y -> f.px(x, y) + Offset(0f, lift) } + LogoShape.right(right) { x, y -> f.px(x, y) + Offset(0f, lift) } + drawPath(left, ink.copy(alpha = fill)) + drawPath(right, ink.copy(alpha = fill)) + } + + // The trace around both halves on arrival, the GameCube nod. + if (intro < TRACE_MS) { + val drawn = TraceEase.transform(clamp01(intro / 775f)) + val alpha = if (intro < 775f) 1f else 1f - (intro - 775f) / 475f + LogoShape.left(left, 0f, f::px) + LogoShape.right(right, f::px) + for (half in listOf(left, right)) { + measure.setPath(half, false) + piece.reset() + measure.getSegment(0f, measure.length * drawn, piece, true) + drawPath(piece, pal.signal.copy(alpha = alpha), style = Stroke(2f * f.s)) + } + } + + // The ball. + val shown = Out.transform(clamp01((intro - 650f) / 300f)) + if (shown > 0f) { + val p = (t - POP_FROM) / (IMPACT - POP_FROM) + val (pop, rise) = when { + p <= 0f || p >= 1f -> 1f to 0f + p < 0.11f -> span(p, 0f, 0.11f, 1f, 0.92f, InOut) to span(p, 0f, 0.11f, 0f, 7f, InOut) + p < 0.31f -> span(p, 0.11f, 0.31f, 0.92f, 1.6f, PopEase) to span(p, 0.11f, 0.31f, 7f, -42f, PopEase) + p < 0.88f -> span(p, 0.31f, 0.88f, 1.6f, 1.54f, InOut) to span(p, 0.31f, 0.88f, -42f, -34f, InOut) + else -> span(p, 0.88f, 1f, 1.54f, 1f, DropEase) to span(p, 0.88f, 1f, -34f, 0f, DropEase) + } + val q = clamp01((pop - 1f) / 0.6f) + val bob = if (t > END) -4f * k * (0.5f - 0.5f * cos(2f * PI.toFloat() * (t - END) / 5200f)) else 0f + + // Its shadow stays on the slabs, spreading and softening as the ball rises. + val blur = mix(10f, 28f, q) * k + val sr = f.ball * 0.93f * mix(1f, 1.4f, q) + val dark = Color.Black.copy(alpha = mix(0.6f, 0.25f, q) * shown) + val sc = f.centre + Offset(20f * k * q, 48f * k * q) + drawCircle( + Brush.radialGradient( + 0f to dark, (sr - blur).coerceAtLeast(0f) / (sr + blur) to dark, 1f to Color.Transparent, + center = sc, radius = sr + blur, + ), + sr + blur, sc, + ) + + val sq = if (t in IMPACT..IMPACT + 280f) { + val s = (t - IMPACT) / 280f + when { + s < 0.3f -> span(s, 0f, 0.3f, 1f, 1.1f, Out) to span(s, 0f, 0.3f, 1f, 0.88f, Out) + s < 0.65f -> span(s, 0.3f, 0.65f, 1.1f, 0.97f, Out) to span(s, 0.3f, 0.65f, 0.88f, 1.04f, Out) + else -> span(s, 0.65f, 1f, 0.97f, 1f, Out) to span(s, 0.65f, 1f, 1.04f, 1f, Out) + } + } else 1f to 1f + val grow = mix(0.6f, 1f, shown) * pop + val turn = 720f * FlipEase.transform(clamp01((t - 1290f) / 760f)) + translate(0f, rise * k + bob) { + scale(grow * sq.first, grow * sq.second, f.centre) { + coin(f.centre, f.ball, f.ball * 2f * 0.061f, turn, pal.signal.copy(alpha = shown), rim.copy(alpha = shown)) + } + } + } + + // The flash where it lands. + if (t in IMPACT..IMPACT + 420f) { + val p = Out.transform((t - IMPACT) / 420f) + drawCircle(pal.signal.copy(alpha = 1f - p), (f.ball + 6f * k) * mix(1f, 1.4f, p), f.centre, style = Stroke(max(4f * k, 2.dp.toPx()))) + } + } + } +} + +/** + * The ball as a coin of [thick]ness turned [deg] about its vertical axis: flat faces in the logo's + * blue, and between them a solid rim that shows as it turns edge-on. + */ +private fun DrawScope.coin(c: Offset, r: Float, thick: Float, deg: Float, face: Color, rim: Color) { + val a = Math.toRadians(deg.toDouble()) + val cs = cos(a).toFloat() + val half = thick / 2 * sin(a).toFloat() + val rx = r * abs(cs) + if (abs(half) > 0.01f) { + drawOval(rim, Offset(c.x - half - rx, c.y - r), Size(2 * rx, 2 * r)) + drawOval(rim, Offset(c.x + half - rx, c.y - r), Size(2 * rx, 2 * r)) + drawRect(rim, Offset(min(c.x - half, c.x + half), c.y - r), Size(abs(2 * half), 2 * r)) + } + val fx = c.x + if (cs >= 0f) half else -half + drawOval(face, Offset(fx - rx, c.y - r), Size(2 * rx, 2 * r)) +} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SteamHome.kt b/app/src/main/java/com/droiddeck/launcher/ui/SteamHome.kt index 832ea304d0..1184b3078f 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SteamHome.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SteamHome.kt @@ -30,9 +30,14 @@ import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.PlayArrow import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.geometry.Rect +import androidx.compose.ui.layout.boundsInParent +import androidx.compose.ui.layout.onPlaced import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip @@ -43,9 +48,7 @@ import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.layout.ContentScale -import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp import coil.compose.AsyncImage import com.droiddeck.launcher.frontend.Library @@ -54,7 +57,7 @@ private const val WALL_MIN_GAMES = 4 /** * The Steam tab: the library as a slowly drifting, tilted wall of capsules (a few games instead - * lean on their own; none, a wall of empty ones), and over it Steam and the one thing to do here - + * lean on their own; none, the DroidDeck mark wandering a blank wall), and over it the wordmark and the one thing to do here - * Play. Everything about a single game lives on the Games tab. */ @Composable @@ -64,43 +67,24 @@ internal fun SteamHome(s: FrontEndState, a: FrontEndActions, modifier: Modifier) val games = remember(s.steamGames) { s.steamGames.sortedWith(compareByDescending { it.lastPlayed }.thenBy { it.gameId }) } val narrow = LocalNarrowPane.current val colors = MaterialTheme.colorScheme - val pal = LocalPalette.current + // Where the words and buttons sit, for the empty library's wandering mark to keep off. + var words by remember { mutableStateOf(null) } Box(modifier = modifier.fillMaxSize().clipToBounds()) { - if (games.size in 1 until WALL_MIN_GAMES) CapsuleFan(games) - else { - if (games.isEmpty()) Box( - Modifier.fillMaxSize().drawBehind { - drawRect( - Brush.radialGradient( - listOf(pal.signal.copy(alpha = 0.12f), Color.Transparent), - center = Offset(size.width * 0.72f, size.height * 0.42f), radius = 380.dp.toPx(), - ), - ) - }, - ) - CapsuleWall(games) - // The wall fades out behind the words, and toward the bottom where the buttons sit. - Box( - Modifier.fillMaxSize().background( - Brush.horizontalGradient( - 0f to colors.background.copy(alpha = 0.97f), - 0.34f to colors.background.copy(alpha = 0.86f), - 0.68f to colors.background.copy(alpha = 0.25f), - 1f to colors.background.copy(alpha = 0.1f), - ), - ), - ) - Box(Modifier.fillMaxSize().background(Brush.verticalGradient(0.55f to Color.Transparent, 1f to colors.background.copy(alpha = 0.9f)))) + when { + games.isEmpty() -> EmptyLibrary(avoid = words) { WallFade() } + games.size < WALL_MIN_GAMES -> CapsuleFan(games) + else -> { + CapsuleWall(games) + WallFade() + } } Column( modifier = Modifier.align(Alignment.BottomStart) - .padding(start = if (narrow) 20.dp else 44.dp, bottom = if (narrow) 20.dp else 44.dp, end = 20.dp), + .padding(start = if (narrow) 20.dp else 44.dp, bottom = if (narrow) 20.dp else 44.dp, end = 20.dp) + .onPlaced { words = it.boundsInParent() }, ) { Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(12.dp)) { - Text( - stringResource(R.string.rail_steam), fontSize = if (narrow) 34.sp else 44.sp, lineHeight = if (narrow) 40.sp else 50.sp, - fontWeight = FontWeight.Bold, color = colors.onBackground, maxLines = 1, - ) + Wordmark(if (narrow) 30.dp else 40.dp) // Said only when something stands between Play and Steam; a ready runtime needs no words. if (s.busy || !s.ready || (s.available != null && s.available != s.installed)) RuntimeChip(s) } @@ -114,6 +98,23 @@ internal fun SteamHome(s: FrontEndState, a: FrontEndActions, modifier: Modifier) } } +/** The wall fades out behind the words, and toward the bottom where the buttons sit. */ +@Composable +private fun WallFade() { + val colors = MaterialTheme.colorScheme + Box( + Modifier.fillMaxSize().background( + Brush.horizontalGradient( + 0f to colors.background.copy(alpha = 0.97f), + 0.34f to colors.background.copy(alpha = 0.86f), + 0.68f to colors.background.copy(alpha = 0.25f), + 1f to colors.background.copy(alpha = 0.1f), + ), + ), + ) + Box(Modifier.fillMaxSize().background(Brush.verticalGradient(0.55f to Color.Transparent, 1f to colors.background.copy(alpha = 0.9f)))) +} + /** * Columns of capsules tilted a few degrees, alternate columns drifting up and down. Each column * holds its run of covers twice and moves by exactly one run, so the loop has no seam. An empty diff --git a/app/src/main/java/com/droiddeck/launcher/ui/Throbber.kt b/app/src/main/java/com/droiddeck/launcher/ui/Throbber.kt index c58be35e29..c08188bd8f 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/Throbber.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/Throbber.kt @@ -80,7 +80,7 @@ private val Turn = CubicBezierEasing(0.65f, 0f, 0.35f, 1f) * The left half is sampled along rays from the centre so it can bend, point for point, into the * mirror of the right half's arc. */ -private object LogoShape { +internal object LogoShape { const val LEFT = -55.98f const val WIDTH = 239.92f const val HEIGHT = 223.72f diff --git a/app/src/main/java/com/droiddeck/launcher/ui/Wordmark.kt b/app/src/main/java/com/droiddeck/launcher/ui/Wordmark.kt new file mode 100644 index 0000000000..48af1ea265 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/Wordmark.kt @@ -0,0 +1,70 @@ +package com.droiddeck.launcher.ui + +import androidx.compose.foundation.Canvas +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.width +import androidx.compose.material3.MaterialTheme +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import androidx.compose.ui.Modifier +import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.graphics.drawscope.scale +import androidx.compose.ui.graphics.drawscope.translate +import androidx.compose.ui.graphics.vector.PathParser +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.semantics.contentDescription +import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.unit.Dp +import com.droiddeck.launcher.R + +/** + * The DroidDeck wordmark from the README banner (artwork/droiddeck-banner-*.svg): the mark + * standing in as the D, then "roidDeck". Letters and D in the theme's ink, the ball in its blue. + */ +@Composable +internal fun Wordmark(height: Dp, modifier: Modifier = Modifier) { + val ink = MaterialTheme.colorScheme.onBackground + val ball = LocalPalette.current.signal + val name = stringResource(R.string.app_name) + val letters = remember { PathParser().parsePathString(LETTERS).toPath() } + val leftHalf = remember { PathParser().parsePathString(LEFT_HALF).toPath() } + val rightHalf = remember { PathParser().parsePathString(RIGHT_HALF).toPath() } + Canvas(modifier.height(height).width(height * (BOX_W / BOX_H)).semantics { contentDescription = name }) { + val k = size.height / BOX_H + scale(k, k, Offset.Zero) { + translate(-BOX_X, -BOX_Y) { + drawPath(letters, ink) + // The mark's placement in the banner: translate(239.135 123.36) scale(0.527445) translate(31.98 0). + translate(239.135f, 123.36f) { + scale(MARK_SCALE, MARK_SCALE, Offset.Zero) { + translate(31.98f, 0f) { + drawPath(leftHalf, ink) + drawPath(rightHalf, ink) + drawCircle(ball, 55.98f, Offset(63.98f, 111.86f)) + } + } + } + } + } + } +} + +// The banner's own units: the wordmark spans x 239.135..1040.7 and y 120.02..243.2. +private const val BOX_X = 239.135f +private const val BOX_Y = 120.02f +private const val BOX_W = 1040.7f - 239.135f +private const val BOX_H = 243.2f - 120.02f +private const val MARK_SCALE = 0.527445f + +private const val LEFT_HALF = "M-31.98 0H56.055V40.489A71.81 71.81 0 0 0 56.055 183.231V223.72H-31.98Z" +private const val RIGHT_HALF = "M71.885 0.28A111.86 111.86 0 0 1 71.885 223.44V183.234A71.81 71.81 0 0 0 71.885 40.486Z" +private const val LETTERS = + "M361.45 241.36V160.13H387.02V241.36ZM387.02 196.73 376.32 188.38Q379.5 174.17 387.02 166.31Q394.54 158.46 407.91 158.46Q413.76 158.46 418.19 160.21Q422.62 161.97 425.96 165.65L410.75 184.87Q409.08 183.03 406.57 182.03Q404.07 181.02 400.89 181.02Q394.54 181.02 390.78 184.95Q387.02 188.88 387.02 196.73" + + "ZM467.91 243.2Q455.38 243.2 445.27 237.6Q435.15 232 429.3 222.31Q423.45 212.61 423.45 200.58Q423.45 188.54 429.3 179.02Q435.15 169.49 445.18 163.89Q455.21 158.29 467.91 158.29Q480.62 158.29 490.64 163.81Q500.67 169.32 506.52 178.93Q512.37 188.54 512.37 200.58Q512.37 212.61 506.52 222.31Q500.67 232 490.64 237.6Q480.62 243.2 467.91 243.2" + + "ZM467.91 219.97Q473.43 219.97 477.61 217.54Q481.79 215.12 484.04 210.69Q486.3 206.26 486.3 200.58Q486.3 194.9 483.96 190.63Q481.62 186.37 477.52 183.95Q473.43 181.52 467.91 181.52Q462.56 181.52 458.39 183.95Q454.21 186.37 451.87 190.72Q449.53 195.06 449.53 200.75Q449.53 206.26 451.87 210.69Q454.21 215.12 458.39 217.54Q462.56 219.97 467.91 219.97" + + "ZM523.4 241.36V160.13H548.98V241.36ZM536.27 148.93Q530.26 148.93 526.33 144.84Q522.4 140.74 522.4 134.89Q522.4 128.88 526.33 124.86Q530.26 120.85 536.27 120.85Q542.29 120.85 546.13 124.86Q549.98 128.88 549.98 134.89Q549.98 140.74 546.13 144.84Q542.29 148.93 536.27 148.93ZM599.95 243.03Q588.42 243.03 579.48 237.52Q570.54 232 565.44 222.47Q560.34 212.95 560.34 200.75Q560.34 188.54 565.44 179.02Q570.54 169.49 579.48 163.97Q588.42 158.46 599.95 158.46Q608.31 158.46 615.08 161.63Q621.85 164.81 626.28 170.41Q630.71 176.01 631.21 183.2V217.46Q630.71 224.65 626.36 230.41Q622.02 236.18 615.16 239.61Q608.31 243.03 599.95 243.03" + + "ZM604.47 219.97Q609.98 219.97 613.99 217.54Q618 215.12 620.34 210.77Q622.68 206.43 622.68 200.75Q622.68 195.06 620.43 190.8Q618.17 186.54 614.08 184.03Q609.98 181.52 604.63 181.52Q599.28 181.52 595.19 184.03Q591.09 186.54 588.67 190.88Q586.25 195.23 586.25 200.75Q586.25 206.26 588.59 210.61Q590.93 214.95 595.11 217.46Q599.28 219.97 604.47 219.97" + + "ZM646.75 241.36H621.68V219.46L625.53 199.74L621.18 180.02V120.02H646.75ZM683.19 241.36V218.29H712.44Q723.13 218.29 731.16 214.03Q739.18 209.77 743.53 201.58Q747.87 193.39 747.87 182.19Q747.87 170.99 743.44 162.97Q739.01 154.95 731.07 150.6Q723.13 146.26 712.44 146.26H682.35V123.36H712.77Q726.14 123.36 737.42 127.62Q748.71 131.88 757.15 139.82Q765.59 147.76 770.18 158.54Q774.78 169.32 774.78 182.36Q774.78 195.23 770.18 206.09Q765.59 216.96 757.23 224.81Q748.87 232.67 737.59 237.01Q726.31 241.36 713.11 241.36" + + "ZM665.47 241.36V123.36H691.71V241.36ZM827.6 243.2Q814.39 243.2 804.11 237.77Q793.83 232.33 787.98 222.64Q782.13 212.95 782.13 200.75Q782.13 188.54 787.9 178.93Q793.67 169.32 803.53 163.81Q813.39 158.29 825.76 158.29Q837.79 158.29 846.98 163.47Q856.18 168.65 861.44 177.85Q866.71 187.04 866.71 198.91Q866.71 201.08 866.46 203.5Q866.21 205.93 865.54 209.1L795.51 209.27V191.72L854.67 191.55L843.64 198.91Q843.47 191.89 841.47 187.29Q839.46 182.69 835.54 180.27Q831.61 177.85 825.92 177.85Q819.91 177.85 815.48 180.61Q811.05 183.36 808.63 188.38Q806.2 193.39 806.2 200.58Q806.2 207.77 808.79 212.86Q811.38 217.96 816.15 220.72Q820.91 223.48 827.43 223.48Q833.45 223.48 838.29 221.39Q843.14 219.3 846.82 215.12L860.86 229.16Q854.84 236.18 846.32 239.69Q837.79 243.2 827.6 243.2" + + "ZM916.68 243.2Q904.15 243.2 893.95 237.68Q883.75 232.17 877.9 222.47Q872.05 212.78 872.05 200.75Q872.05 188.54 877.99 178.93Q883.92 169.32 894.12 163.81Q904.31 158.29 917.02 158.29Q926.54 158.29 934.48 161.55Q942.42 164.81 948.6 171.33L932.22 187.71Q929.38 184.53 925.62 183.03Q921.86 181.52 917.02 181.52Q911.5 181.52 907.24 183.95Q902.98 186.37 900.55 190.63Q898.13 194.9 898.13 200.58Q898.13 206.26 900.55 210.61Q902.98 214.95 907.32 217.46Q911.67 219.97 917.02 219.97Q922.03 219.97 925.96 218.21Q929.88 216.46 932.73 213.28L948.94 229.66Q942.59 236.35 934.56 239.77Q926.54 243.2 916.68 243.2" + + "ZM1010.61 241.36 982.2 199.24 1010.45 160.13H1039.03L1004.93 204.09L1005.77 193.56L1040.7 241.36ZM958.63 241.36V120.02H984.21V241.36Z"