Repository navigation
refactor(ui): take motion from the theme's MotionScheme - #107
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Alba's motion now comes from the theme's
MotionScheme, as docs/design.md asks: "Springs from the theme'sMotionScheme: 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 makesMotionSchemeandMaterialTheme(motionScheme = …)public, with no opt-in.What changed
AlbaThemepassesAlbaMotionScheme = MotionScheme.standard()toMaterialTheme, so stock components use it too. The stale KDoc sayingMotionSchemeis internal until 1.5 is gone. It usesstandard(), notexpressive(): its effects springs are critically damped and its spatial springs (damping 0.9) barely overshoot.NavigationMotionno longer copies spring values by hand (fastSpatial()/fastEffects()), and the M2-style duration tokens (SHORT2,SHORT4,MEDIUM1,MEDIUM2,FADE_THROUGH_OUT,EmphasizedDecelerate) are gone.navigationTransformtakes theMotionScheme: shared axis slides ondefaultSpatialSpec, the outgoing screen fades onfastEffectsSpecand the incoming one ondefaultEffectsSpec.FadeThrough(the gallery's tab switch) fades out onfastEffectsSpecand in ondefaultEffectsSpec. A cancelled back gesture springs back onfastSpatialSpec.tween(andspring(underapp/src/main/java/me/lvca/alba/app/uinow 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:spring(1f, 450f)), the unfolding forms (AlbaReveal, the shared-album invite), double-tap zoom, the viewer's dismiss, details and back settles.ViewerMotion,PhotoZoomState,GridPinch,GalleryHeaderScroll,FadeThrough,DestinationMotion) take theMotionScheme, read once in composition asMaterialTheme.motionSchemeand passed down.GalleryFeel,ViewerSpec,SnackbarSpecand a few files' private constants. The Google Photos geometry (thresholds, scales, distances) stays.Deliberate exceptions (kept as tweens)
navigationTransform's gesture branch (NavigationMotion.GESTURE_MILLISand 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 anyMotionSchemespring (the slowest effects spring settles in about 0.25 s).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 onfastEffectsSpec. 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
motionMillis { … }helper (app/src/sharedTest/.../testing/MotionTiming.kt). It asks anAlbaMotionSchemespec 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 ofTILE_FADE_IN_MILLIS.ViewerTest(device): waits for the fast effects spring instead ofViewerSpec.CHROME_FADE_MILLIS.:app:compileDebugUnitTestKotlin :app:compileDebugAndroidTestKotlin detekt ktlintCheckpass.TabSwitchMotionTest,CoverShapeTest,FloatingDateTest,FloatingNavigationTest,GalleryFastScrollTest,GalleryZoomTestand theui.viewerJVM tests pass. The whole:app:testDebugUnitTestsuite also passes: 715 tests, 0 failures, 44 skipped. Screenshots render locally but are not compared.PhotoTransitionTestandGalleryPinchAnimationTest, which advance 400 ms after a release, andViewerTest. CI runs them.Screenshots
No golden changed: CI compared all 93 screens pixel for pixel against
mainand 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