diff --git a/android/app/src/main/java/tv/orbit/classic/GuideGrid.kt b/android/app/src/main/java/tv/orbit/classic/GuideGrid.kt index c3d90ecd..0ceb00e5 100644 --- a/android/app/src/main/java/tv/orbit/classic/GuideGrid.kt +++ b/android/app/src/main/java/tv/orbit/classic/GuideGrid.kt @@ -11,7 +11,6 @@ import androidx.compose.foundation.layout.* import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clipToBounds import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusProperties import androidx.compose.ui.focus.focusRequester @@ -189,14 +188,12 @@ internal fun GuideGrid(channels: List, selectedNumber: Int, modif if (nowFraction != null) Box(Modifier.align(Alignment.BottomStart).offset(x = maxWidth * nowFraction - 3.dp).size(6.dp, 6.dp).background(Yellow)) } } - BoxWithConstraints(Modifier.fillMaxWidth().weight(1f).clipToBounds()) { + BoxWithConstraints(Modifier.fillMaxWidth().weight(1f)) { val visibleRows = ((maxHeight + 3.dp) / 41.dp).toInt().coerceAtLeast(1) firstRow = guideFirstRow(row, firstRow, visibleRows, channels.size) rowsShown = minOf(visibleRows, channels.size) - // The channels ease under the focus a row at a time (design/motion); a held button doesn't wait. - // One row is drawn beyond each edge, out of sight, so a row easing in arrives already drawn. - val lead = if (firstRow > 0) 1 else 0 - Column(Modifier.fillMaxWidth().wrapContentHeight(Alignment.Top, unbounded = true).easeRows(firstRow, 41.dp, lead).focusRequester(gridFocus).onFocusChanged { gridFocused = it.isFocused }.focusable().onPreviewKeyEvent { event -> + // The rows step at once (Paul, 6 November 2026: easing them stuttered and seemed to jump back and forth). + Column(Modifier.fillMaxWidth().focusRequester(gridFocus).onFocusChanged { gridFocused = it.isFocused }.focusable().onPreviewKeyEvent { event -> val native = event.nativeKeyEvent if (native.action != KeyEvent.ACTION_DOWN) return@onPreviewKeyEvent false when (native.keyCode) { @@ -222,8 +219,8 @@ internal fun GuideGrid(channels: List, selectedNumber: Int, modif else -> false } }, verticalArrangement = Arrangement.spacedBy(3.dp)) { - channels.subList(firstRow - lead, minOf(firstRow + visibleRows + 1, channels.size)).forEachIndexed { offset, line -> - val index = firstRow - lead + offset + channels.subList(firstRow, minOf(firstRow + visibleRows, channels.size)).forEachIndexed { offset, line -> + val index = firstRow + offset Row(Modifier.fillMaxWidth().height(38.dp), horizontalArrangement = Arrangement.spacedBy(6.dp)) { val mark = ChannelBrands.forNumber(line.number) // A takeover on at the guide's time wears its own mark (Paul, 6 November 2026). diff --git a/android/app/src/main/java/tv/orbit/classic/MainActivity.kt b/android/app/src/main/java/tv/orbit/classic/MainActivity.kt index b0a7a5d5..866c87b8 100644 --- a/android/app/src/main/java/tv/orbit/classic/MainActivity.kt +++ b/android/app/src/main/java/tv/orbit/classic/MainActivity.kt @@ -175,12 +175,9 @@ private fun OrbitApp() { CompositionLocalProvider(LocalNavFocus provides navFocus, LocalDriveInFocus provides driveInFocus) { // The Drive-In and a game in play take the whole screen; the bar sits over the Drive-In's sky. val fullBleed = section == "Drive-In" || playingGame - // A new section slides on from the side it lies on along the top bar (design/motion); the Drive-In and a - // game have their own openings, and full-screen viewing never moves. - val cameFrom = remember { arrayOf(section) } - val direction = remember(section) { sectionDirection(cameFrom[0], section).also { cameFrom[0] = section } } - val slides = !fullBleed && !FullScreen.active - Column((if (fullBleed) Modifier.fillMaxSize() else Modifier.fillMaxSize().padding(start = 36.dp, end = 36.dp, top = 56.dp, bottom = 16.dp)).arrive(section, direction, slides)) { + // Sections change at once (Paul, 6 November 2026: the slide stuttered on the box while the new screen was + // being built, between the guide, the channels and the Arcade). + Column(if (fullBleed) Modifier.fillMaxSize() else Modifier.fillMaxSize().padding(start = 36.dp, end = 36.dp, top = 56.dp, bottom = 16.dp)) { if (section == "Arcade" && realChannelAvailable && chosen) OrbitArcade(Modifier.weight(1f), onPlaying = { playingGame = it }) EmbyConnectionScreen(if (section == "Arcade") Modifier else Modifier.weight(1f), visible = section == "Connect Emby", onboarding = onboarding, onSignedIn = { if (Onboarding.step == OnboardStep.SignIn) Onboarding.go(OnboardStep.Channels) }, diff --git a/android/app/src/main/java/tv/orbit/classic/Motion.kt b/android/app/src/main/java/tv/orbit/classic/Motion.kt index db693e94..5509f075 100644 --- a/android/app/src/main/java/tv/orbit/classic/Motion.kt +++ b/android/app/src/main/java/tv/orbit/classic/Motion.kt @@ -32,22 +32,18 @@ import kotlinx.coroutines.launch /** * Orbit motion (Paul, 6 November 2026, from the approved design/motion sheet): one set of timings for moving around the * app. Only position and fade move, a press always acts at once, and Reduce motion turns everything into a short fade. + * Screens and the guide's rows change at once: sliding them stuttered on the box while the new screen was built. */ internal object Motion { /** Quick out, gentle landing: the one curve used everywhere. */ val Ease = CubicBezierEasing(.2f, 0f, 0f, 1f) const val FOCUS = 140 - const val SCREEN = 240 - const val BACK = 200 const val CARD = 180 const val STAGGER = 40 const val STAGGERED = 6 const val DIM = 160 const val RISE = 200 - const val GUIDE = 220 const val CALM = 120 - /** A guide press sooner than this after the last is a held button: no easing, full speed. */ - const val HELD_MS = 250L /** Settings › On screen › Reduce motion, kept here so every screen follows it as it changes. */ var reduce by mutableStateOf(false) @@ -55,36 +51,11 @@ internal object Motion { fun load(settings: OrbitSettings) { reduce = settings.reduceMotion } } -/** The order of the top bar, so a move to the right slides on from the right and Back slides the other way. */ -internal fun sectionDirection(from: String, to: String): Int { - val order = listOf("Home", "What's On", "TV Guide", "Catch Up", "Drive-In", "Arcade", "Connect Emby") - return if (order.indexOf(to) >= order.indexOf(from)) 1 else -1 -} - /** A focus fill that eases in [Motion.FOCUS] instead of snapping. */ @Composable internal fun focusColor(target: Color) = animateColorAsState(target, if (Motion.reduce) tween(0) else tween(Motion.FOCUS, easing = Motion.Ease), label = "focus").value -/** - * A new screen slides on 24 dp from the side it came from and fades up; nothing waits for it, and the first screen - * Orbit opens on just appears. - */ -internal fun Modifier.arrive(key: Any, direction: Int, enabled: Boolean = true): Modifier = composed { - val shift = remember { Animatable(0f) } - var first by remember { mutableStateOf(true) } - var calm by remember { mutableStateOf(false) } - LaunchedEffect(key) { - if (first || !enabled) { first = false; shift.snapTo(0f); return@LaunchedEffect } - // Reduce motion: the same arrival as a short fade, with no slide. - calm = Motion.reduce - shift.snapTo(direction.toFloat()) - shift.animateTo(0f, if (calm) tween(Motion.CALM) else tween(if (direction > 0) Motion.SCREEN else Motion.BACK, easing = Motion.Ease)) - } - val distance = with(LocalDensity.current) { 24.dp.toPx() } - graphicsLayer { translationX = if (calm) 0f else shift.value * distance; alpha = 1f - kotlin.math.abs(shift.value) } -} - /** Cards rise into place in turn, 40 ms apart, for the first six only; later ones are simply there. */ internal fun Modifier.riseIn(index: Int): Modifier = composed { val calm = remember { Motion.reduce } @@ -113,26 +84,6 @@ internal fun OverlayCard(scrim: Color, content: @Composable BoxScope.() -> Unit) Box(Modifier.fillMaxSize().graphicsLayer { translationY = if (calm) 0f else (1f - rise.value) * lift; alpha = rise.value }, contentAlignment = Alignment.Center, content = content) } -/** - * The guide's channels ease under the focus by one row in [Motion.GUIDE]. A held button scrolls at full speed: a move - * sooner than [Motion.HELD_MS] after the last one snaps. - */ -internal fun Modifier.easeRows(firstRow: Int, rowHeight: Dp, lead: Int = 0): Modifier = composed { - val shift = remember { Animatable(0f) } - var last by remember { mutableIntStateOf(firstRow) } - var lastAt by remember { mutableLongStateOf(0L) } - LaunchedEffect(firstRow) { - val moved = firstRow - last - last = firstRow - val at = System.currentTimeMillis(); val held = at - lastAt < Motion.HELD_MS; lastAt = at - if (moved == 0 || Motion.reduce || held || kotlin.math.abs(moved) > 3) { shift.snapTo(0f); return@LaunchedEffect } - shift.snapTo(moved.toFloat()) - shift.animateTo(0f, tween(Motion.GUIDE, easing = Motion.Ease)) - } - val height = with(LocalDensity.current) { rowHeight.toPx() } - graphicsLayer { translationY = (shift.value - lead) * height } -} - /** * The gold that glides from one item to the next (Home's list, the top bar). The area draws one gold box behind its * items and moves it to whichever item has focus; the items leave their own focused fill clear. @@ -142,6 +93,13 @@ internal class Glide(private val scope: CoroutineScope) { private val w = Animatable(0f); private val h = Animatable(0f) internal var area: LayoutCoordinates? = null internal var shown by mutableStateOf(false) + private set + + /** + * Focus coming back into the area lands the gold where it is, never sliding over from where it was last (Paul, + * 6 November 2026: on the top bar it glided and then seemed to jump somewhere else entirely). + */ + fun focusInside(inside: Boolean) { if (!inside) { placed = false; shown = false } } private var placed = false private var target = Offset.Zero private var targetSize = androidx.compose.ui.unit.IntSize.Zero @@ -156,7 +114,7 @@ internal class Glide(private val scope: CoroutineScope) { val jump = !placed || Motion.reduce placed = true scope.launch { - if (jump) { x.snapTo(at.x); y.snapTo(at.y); w.snapTo(size.width.toFloat()); h.snapTo(size.height.toFloat()); return@launch } + if (jump) { x.snapTo(at.x); y.snapTo(at.y); w.snapTo(size.width.toFloat()); h.snapTo(size.height.toFloat()); shown = true; return@launch } val spec = tween(Motion.FOCUS, easing = Motion.Ease) launch { x.animateTo(at.x, spec) }; launch { y.animateTo(at.y, spec) } launch { w.animateTo(size.width.toFloat(), spec) }; h.animateTo(size.height.toFloat(), spec) @@ -177,7 +135,7 @@ internal val LocalGlide = staticCompositionLocalOf { null } /** The area the gold glides within: it draws the box behind its items, and only while one of them has focus. */ internal fun Modifier.glideArea(glide: Glide, color: Color, corner: Dp): Modifier = composed { val radius = with(LocalDensity.current) { corner.toPx() } - onPlaced { glide.area = it }.onFocusChanged { glide.shown = it.hasFocus }.drawBehind { glide.draw(this, color, radius) } + onPlaced { glide.area = it }.onFocusChanged { glide.focusInside(it.hasFocus) }.drawBehind { glide.draw(this, color, radius) } } /** An item the gold glides to when it takes focus. */ diff --git a/android/app/src/test/java/tv/orbit/classic/MotionTest.kt b/android/app/src/test/java/tv/orbit/classic/MotionTest.kt index 0c686a2d..d4796653 100644 --- a/android/app/src/test/java/tv/orbit/classic/MotionTest.kt +++ b/android/app/src/test/java/tv/orbit/classic/MotionTest.kt @@ -5,20 +5,13 @@ import org.junit.Test /** Orbit motion (Paul, 6 November 2026, design/motion): one set of timings, and a moment for every Arcade game. */ class MotionTest { - @Test fun screensSlideFromTheSideTheyLieOnAlongTheBar() { - assertEquals(1, sectionDirection("Home", "TV Guide")) - assertEquals(-1, sectionDirection("Arcade", "Home")) - assertEquals(1, sectionDirection("Home", "Connect Emby")) - } - @Test fun everyArcadeGameHasItsOpening() { for (game in listOf("OrbMan", "Blast", "Sky", "Hive", "Snake", "Blocks", "Bricks", "Pairs", "Patience")) assertNotNull(game, Moment.forGame(game)) assertNull(Moment.forGame("Welcome".lowercase())) } @Test fun theTimingsMatchTheSheet() { - assertEquals(140, Motion.FOCUS); assertEquals(240, Motion.SCREEN); assertEquals(200, Motion.BACK) - assertEquals(180, Motion.CARD); assertEquals(40, Motion.STAGGER); assertEquals(220, Motion.GUIDE); assertEquals(120, Motion.CALM) - assertTrue(Motion.BACK < Motion.SCREEN) + assertEquals(140, Motion.FOCUS) + assertEquals(180, Motion.CARD); assertEquals(40, Motion.STAGGER); assertEquals(120, Motion.CALM) } }