Skip to content

refactor(ui): take motion from the theme's MotionScheme - #107

Merged
thisislvca merged 2 commits into
mainfrom
claude/dazzling-bardeen-0vg0kz-motion
Dec 2, 2026
Merged

thisislvca merged 2 commits into
mainfrom
claude/dazzling-bardeen-0vg0kz-motion

Conversation

@thisislvca

@thisislvca thisislvca commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

Alba's motion now comes from the theme's MotionScheme, as docs/design.md asks: "Springs from the theme's MotionScheme: critically damped by default, a little bounce only after a fling. Reduced motion becomes a cross-fade." This was item 1 of "Doing wrong" in the Material 3 review. Material 3 1.5.0 makes MotionScheme and MaterialTheme(motionScheme = …) public, with no opt-in.

What changed

  • AlbaTheme passes AlbaMotionScheme = MotionScheme.standard() to MaterialTheme, so stock components use it too. The stale KDoc saying MotionScheme is internal until 1.5 is gone. It uses standard(), not expressive(): its effects springs are critically damped and its spatial springs (damping 0.9) barely overshoot.
  • NavigationMotion no longer copies spring values by hand (fastSpatial()/fastEffects()), and the M2-style duration tokens (SHORT2, SHORT4, MEDIUM1, MEDIUM2, FADE_THROUGH_OUT, EmphasizedDecelerate) are gone. navigationTransform takes the MotionScheme: shared axis slides on defaultSpatialSpec, the outgoing screen fades on fastEffectsSpec and the incoming one on defaultEffectsSpec. FadeThrough (the gallery's tab switch) fades out on fastEffectsSpec and in on defaultEffectsSpec. A cancelled back gesture springs back on fastSpatialSpec.
  • Every hand-written tween( and spring( under app/src/main/java/me/lvca/alba/app/ui now uses a scheme spec, except the exceptions listed below. Anything that moves, scales or resizes uses a spatial spec; alpha and colour use an effects spec:
    • Fast spatial: floating bars, the overflow menu's scale, the destination pill, the selection top bar, the scrubber, tile selection toggle and corner, the header snap, the pinch settle and rubber-band return, the photo's shared-element bounds.
    • Default spatial: the floating navigation's reveal, the snackbar slide, the shared-axis steps on sign-in, the selection-mode inset and check scale, the grid's reflow placement (was a hand-tuned spring(1f, 450f)), the unfolding forms (AlbaReveal, the shared-album invite), double-tap zoom, the viewer's dismiss, details and back settles.
    • Slow spatial: the progress ring.
    • Effects specs for every fade and colour change: menu, bars, rail, checks, tile reveal, backup badge, scrolling date, header surface, viewer chrome and canvas, video controls, avatar, editor panel, the shared-link icon.
  • Non-composable state holders that animate (ViewerMotion, PhotoZoomState, GridPinch, GalleryHeaderScroll, FadeThrough, DestinationMotion) take the MotionScheme, read once in composition as MaterialTheme.motionScheme and passed down.
  • Spatial springs can overshoot a little, so the progress values that drive a pose are clamped where overshoot would matter: the details sheet (a negative height would crash), double-tap zoom and the dismiss settle (they would zoom past fit), and predictive-back retraction.
  • The duration constants these replaced are removed from GalleryFeel, ViewerSpec, SnackbarSpec and a few files' private constants. The Google Photos geometry (thresholds, scales, distances) stays.

Deliberate exceptions (kept as tweens)

  • navigationTransform's gesture branch (NavigationMotion.GESTURE_MILLIS and its exit fade). The system back gesture seeks this transition by fraction (GESTURE_SEEK_LIMIT), and the screen being left must hold its opacity for the part the finger scrubs. That needs a fixed timeline; a spring has no fraction-to-time mapping that keeps the fade delay.
  • AlbumArtwork's rotating cover cross-fade (GalleryFeel.COVER_CROSSFADE_MILLIS, 900 ms). It is an ambient, timed change, not a response to a touch, and is meant to be far slower than any MotionScheme spring (the slowest effects spring settles in about 0.25 s).
  • Timed delays (snackbar timeouts, the scrubber's and date pill's auto-hide, the "Copied" confirmation) are delays, not animation specs, and are unchanged.

Fling bounce: no current animation adds bounce after a fling (there were no bouncy springs before), so there was nothing to keep. The header's post-fling snap uses the fast spatial spring.

Reduced motion behaves as before. Each reduceGalleryMotion() branch still snaps or skips the animation, and where it was a short cross-fade (navigation, snackbar, viewer chrome) it is still a cross-fade, now on fastEffectsSpec. The viewer canvas colour now snaps under reduced motion; before, it ran a 0 ms tween.

No strings or test tags were added or removed.

Tests

  • New motionMillis { … } helper (app/src/sharedTest/.../testing/MotionTiming.kt). It asks an AlbaMotionScheme spec how long it takes, so tests that run the clock past an animation follow the spring instead of a hard-coded duration.
  • TabSwitchMotionTest: the "fade out takes about 90 ms" bound is now the fast effects spring's duration (plus the two frames before the fade starts). The other assertions are unchanged.
  • CoverShapeTest: runs the clock past the tile reveal by the fast effects spring's duration instead of TILE_FADE_IN_MILLIS.
  • ViewerTest (device): waits for the fast effects spring instead of ViewerSpec.CHROME_FADE_MILLIS.
  • Local, in a cloud session: :app:compileDebugUnitTestKotlin :app:compileDebugAndroidTestKotlin detekt ktlintCheck pass. TabSwitchMotionTest, CoverShapeTest, FloatingDateTest, FloatingNavigationTest, GalleryFastScrollTest, GalleryZoomTest and the ui.viewer JVM tests pass. The whole :app:testDebugUnitTest suite also passes: 715 tests, 0 failures, 44 skipped. Screenshots render locally but are not compared.
  • Device tests were not run locally. The ones that touch these timings are PhotoTransitionTest and GalleryPinchAnimationTest, which advance 400 ms after a release, and ViewerTest. CI runs them.

Screenshots

No golden changed: CI compared all 93 screens pixel for pixel against main and every one is identical. Screenshots are still frames, and this PR only changes how screens move between them, so there is no before/after image to show. The difference is visible on a device: transitions, sheets and the viewer now settle on Material's standard springs.

The goldens are still frames, so few or none should change.


Generated by Claude Code

Pass MotionScheme.standard() to MaterialTheme and drive every animation
under ui/ from MaterialTheme.motionScheme: spatial specs for movement,
scale and size, effects specs for alpha and colour. Drop the hand-copied
springs and M2-style durations in NavigationMotion and the duration
constants in GalleryFeel, ViewerSpec and SnackbarSpec.

Kept as tweens: the gesture-seeked predictive back transition, which
needs a fixed timeline, and the slow ambient album cover cross-fade.
Reduced motion still snaps or cross-fades as before.

Tests that ran the clock past an animation now ask the spring for its
duration through a shared motionMillis helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vGQ3zr1LSQtH3D545V8mU
@thisislvca
thisislvca merged commit 770d640 into main Dec 2, 2026
5 checks passed
@thisislvca
thisislvca deleted the claude/dazzling-bardeen-0vg0kz-motion branch December 2, 2026 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants