@istmx/skills 1.2.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/README.md +38 -20
  2. package/bin/cli.js +50 -24
  3. package/istm-animate/SKILL.md +31 -26
  4. package/istm-animate/core/motion-principles/SKILL.md +284 -0
  5. package/istm-animate/core/motion-principles/references/designers.md +127 -0
  6. package/istm-animate/core/motion-principles/references/easing-guide.md +231 -0
  7. package/istm-animate/core/motion-principles/references/enter-exit-recipes.md +466 -0
  8. package/istm-animate/frameworks/canvas-generative/SKILL.md +325 -0
  9. package/istm-animate/frameworks/canvas-generative/references/algorithms.md +925 -0
  10. package/istm-animate/frameworks/css-native/SKILL.md +319 -0
  11. package/istm-animate/frameworks/css-native/references/modern-css.md +465 -0
  12. package/istm-animate/frameworks/framer-motion/SKILL.md +187 -0
  13. package/istm-animate/frameworks/framer-motion/references/api.md +312 -0
  14. package/istm-animate/frameworks/gsap/SKILL.md +188 -0
  15. package/istm-animate/frameworks/gsap/references/core.md +218 -0
  16. package/istm-animate/frameworks/gsap/references/plugins.md +371 -0
  17. package/istm-animate/frameworks/gsap/references/scrolltrigger.md +325 -0
  18. package/istm-animate/frameworks/gsap/references/timeline.md +218 -0
  19. package/istm-animate/frameworks/threejs-r3f/SKILL.md +243 -0
  20. package/istm-animate/frameworks/threejs-r3f/references/scene-setup.md +392 -0
  21. package/istm-animate/frameworks/threejs-r3f/references/shaders.md +446 -0
  22. package/istm-animate/mobile/android/compose-graphics/SKILL.md +503 -0
  23. package/istm-animate/mobile/android/compose-graphics/references/agsl-recipes.md +356 -0
  24. package/istm-animate/mobile/android/compose-graphics/references/canvas-generative.md +282 -0
  25. package/istm-animate/mobile/android/compose-graphics/references/m3-expressive-deep.md +303 -0
  26. package/istm-animate/mobile/android/compose-motion/SKILL.md +359 -0
  27. package/istm-animate/mobile/android/compose-motion/references/gestures-compose.md +273 -0
  28. package/istm-animate/mobile/android/compose-motion/references/recomposition-and-anim.md +196 -0
  29. package/istm-animate/mobile/android/compose-motion/references/shared-transitions.md +281 -0
  30. package/istm-animate/mobile/android/compose-multiplatform/SKILL.md +311 -0
  31. package/istm-animate/mobile/android/compose-multiplatform/references/cmp-interop.md +288 -0
  32. package/istm-animate/mobile/android/compose-multiplatform/references/cmp-platform-quirks.md +156 -0
  33. package/istm-animate/mobile/apple/swiftui-graphics/SKILL.md +408 -0
  34. package/istm-animate/mobile/apple/swiftui-graphics/references/canvas-swiftui.md +239 -0
  35. package/istm-animate/mobile/apple/swiftui-graphics/references/liquid-glass-deep.md +252 -0
  36. package/istm-animate/mobile/apple/swiftui-graphics/references/metal-recipes.md +382 -0
  37. package/istm-animate/mobile/apple/swiftui-motion/SKILL.md +379 -0
  38. package/istm-animate/mobile/apple/swiftui-motion/references/gestures-swiftui.md +336 -0
  39. package/istm-animate/mobile/apple/swiftui-motion/references/phase-keyframe-deep.md +231 -0
  40. package/istm-animate/mobile/apple/swiftui-motion/references/springs-cheatsheet.md +129 -0
  41. package/istm-animate/references/animate.md +199 -0
  42. package/istm-animate/references/audit.md +115 -0
  43. package/istm-animate/references/design-engineering.md +674 -0
  44. package/istm-animate/references/improve.md +101 -0
  45. package/istm-animate/references/opportunities.md +132 -0
  46. package/istm-animate/references/plan-template.md +73 -0
  47. package/istm-animate/references/recipes.md +324 -0
  48. package/istm-animate/references/review.md +112 -0
  49. package/istm-animate/references/standards.md +187 -0
  50. package/istm-animate/references/vocabulary.md +173 -0
  51. package/istm-awwward-designer/SKILL.md +29 -17
  52. package/istm-design/SKILL.md +31 -59
  53. package/istm-design/core/design-audit/SKILL.md +248 -0
  54. package/istm-design/core/desktop-principles/SKILL.md +363 -0
  55. package/istm-design/core/desktop-principles/references/keyboard-patterns.md +137 -0
  56. package/istm-design/core/desktop-principles/references/multi-window.md +105 -0
  57. package/istm-design/core/mobile-principles/SKILL.md +289 -0
  58. package/istm-design/core/mobile-principles/references/accessibility-mobile.md +175 -0
  59. package/istm-design/core/mobile-principles/references/gestures-deep.md +220 -0
  60. package/istm-design/core/ui-ux-pro-max/SKILL.md +392 -0
  61. package/istm-design/core/ui-ux-pro-max/UPSTREAM.md +23 -0
  62. package/istm-design/core/ui-ux-pro-max/data/app-interface.csv +31 -0
  63. package/istm-design/core/ui-ux-pro-max/data/charts.csv +26 -0
  64. package/istm-design/core/ui-ux-pro-max/data/colors.csv +193 -0
  65. package/istm-design/core/ui-ux-pro-max/data/google-fonts.csv +1924 -0
  66. package/istm-design/core/ui-ux-pro-max/data/icons.csv +106 -0
  67. package/istm-design/core/ui-ux-pro-max/data/landing.csv +35 -0
  68. package/istm-design/core/ui-ux-pro-max/data/motion.csv +17 -0
  69. package/istm-design/core/ui-ux-pro-max/data/products.csv +193 -0
  70. package/istm-design/core/ui-ux-pro-max/data/react-performance.csv +45 -0
  71. package/istm-design/core/ui-ux-pro-max/data/stacks/angular.csv +51 -0
  72. package/istm-design/core/ui-ux-pro-max/data/stacks/astro.csv +54 -0
  73. package/istm-design/core/ui-ux-pro-max/data/stacks/avalonia.csv +57 -0
  74. package/istm-design/core/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  75. package/istm-design/core/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  76. package/istm-design/core/ui-ux-pro-max/data/stacks/javafx.csv +76 -0
  77. package/istm-design/core/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
  78. package/istm-design/core/ui-ux-pro-max/data/stacks/laravel.csv +51 -0
  79. package/istm-design/core/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  80. package/istm-design/core/ui-ux-pro-max/data/stacks/nuxt-ui.csv +71 -0
  81. package/istm-design/core/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  82. package/istm-design/core/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  83. package/istm-design/core/ui-ux-pro-max/data/stacks/react.csv +54 -0
  84. package/istm-design/core/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  85. package/istm-design/core/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  86. package/istm-design/core/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  87. package/istm-design/core/ui-ux-pro-max/data/stacks/threejs.csv +54 -0
  88. package/istm-design/core/ui-ux-pro-max/data/stacks/uno.csv +60 -0
  89. package/istm-design/core/ui-ux-pro-max/data/stacks/uwp.csv +56 -0
  90. package/istm-design/core/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  91. package/istm-design/core/ui-ux-pro-max/data/stacks/winui.csv +60 -0
  92. package/istm-design/core/ui-ux-pro-max/data/stacks/wpf.csv +57 -0
  93. package/istm-design/core/ui-ux-pro-max/data/styles.csv +85 -0
  94. package/istm-design/core/ui-ux-pro-max/data/typography.csv +75 -0
  95. package/istm-design/core/ui-ux-pro-max/data/ui-reasoning.csv +162 -0
  96. package/istm-design/core/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  97. package/istm-design/core/ui-ux-pro-max/references/pro-rules.md +109 -0
  98. package/istm-design/core/ui-ux-pro-max/references/quick-reference.md +240 -0
  99. package/istm-design/core/ui-ux-pro-max/scripts/core.py +464 -0
  100. package/istm-design/core/ui-ux-pro-max/scripts/design_system.py +1371 -0
  101. package/istm-design/core/ui-ux-pro-max/scripts/search.py +162 -0
  102. package/istm-design/core/ui-ux-pro-max/scripts/tests/test_core.py +134 -0
  103. package/istm-design/core/ui-ux-pro-max/scripts/validate_data.py +114 -0
  104. package/istm-design/references/apple-design.md +282 -0
  105. package/istm-design/references/generation-guide.md +209 -0
  106. package/istm-design/references/pick-ui-library.md +77 -0
  107. package/istm-design/references/picker.md +197 -0
  108. package/istm-design/references/prototype.md +90 -0
  109. package/istm-design/references/schema.md +366 -0
  110. package/package.json +1 -1
  111. package/RELEASE_v1.2.0.md +0 -40
@@ -0,0 +1,303 @@
1
+ # Material 3 Expressive: Deep-Dive
2
+
3
+ M3 Expressive is the 2025 Material 3 evolution. Springs replace fixed-duration tweens for spatial properties; shape morphing replaces step transitions; choreography becomes the unit of motion design rather than the individual easing curve. Use it where attention should anchor: hero moments, key actions, brand-defining surfaces. Default the rest to Standard.
4
+
5
+ ---
6
+
7
+ ## MotionScheme Tokens
8
+
9
+ The theme exposes six animation specs through `MaterialTheme.motionScheme`. They split along two axes.
10
+
11
+ ### Spatial vs Effects
12
+
13
+ | Domain | Token family | Implementation |
14
+ |---|---|---|
15
+ | **Spatial** - position, size, scale | `*SpatialSpec()` | Spring-based. Inertia, overshoot, settle. |
16
+ | **Effects** - opacity, color, elevation | `*EffectsSpec()` | Tween-based. Predictable, no overshoot. |
17
+
18
+ > Why split? A bouncing alpha looks broken (opacity overshoots into negative or above 1). A tweened position looks robotic (no inertia). The split codifies what works and what doesn't.
19
+
20
+ ### Speed Variants
21
+
22
+ | Speed | Spatial | Effects |
23
+ |---|---|---|
24
+ | Fast | `fastSpatialSpec()` (~ 200ms) | `fastEffectsSpec()` (~ 150ms) |
25
+ | Default | `defaultSpatialSpec()` (~ 350ms) | `defaultEffectsSpec()` (~ 250ms) |
26
+ | Slow | `slowSpatialSpec()` (~ 600ms) | `slowEffectsSpec()` (~ 400ms) |
27
+
28
+ ### When to Override
29
+
30
+ Rare. Reach for the tokens 95% of the time - they encode Material's calibrated spring stiffness, damping, and visibilityThreshold values. Only override when:
31
+
32
+ - The brand demands a unique signature spring (extra-bouncy hero, e.g. a game).
33
+ - You're animating a non-Material surface (custom canvas).
34
+ - A11y testing surfaces a specific issue (e.g. a token spring is too long for vestibular comfort).
35
+
36
+ In those cases, build a custom spring once and reuse it through a small abstraction. Don't sprinkle ad-hoc `spring(stiffness = ..., dampingRatio = ...)` calls across the app.
37
+
38
+ ---
39
+
40
+ ## Choreography Patterns
41
+
42
+ Choreography is sequencing multiple element animations into a single perceived motion. Three patterns cover most hero moments.
43
+
44
+ ### Sequential Reveal
45
+
46
+ Cards or list items stagger in. The eye reads left-to-right, top-to-bottom. Stagger 50ms per item.
47
+
48
+ ```kotlin
49
+ items.forEachIndexed { index, item ->
50
+ val visible by produceState(false, index) {
51
+ delay(index * 50L)
52
+ value = true
53
+ }
54
+ AnimatedVisibility(
55
+ visible = visible,
56
+ enter = slideInVertically(
57
+ animationSpec = MaterialTheme.motionScheme.defaultSpatialSpec()
58
+ ) + fadeIn(animationSpec = MaterialTheme.motionScheme.defaultEffectsSpec())
59
+ ) {
60
+ Card(item)
61
+ }
62
+ }
63
+ ```
64
+
65
+ ### Hero-First
66
+
67
+ The focal element animates first. Supporting elements follow 100-150ms later. Establishes hierarchy.
68
+
69
+ ```kotlin
70
+ val heroVisible by produceState(false) { value = true }
71
+ val supportingVisible by produceState(false) { delay(150); value = true }
72
+
73
+ Column {
74
+ AnimatedVisibility(heroVisible, /* hero springs */) { HeroCard() }
75
+ AnimatedVisibility(supportingVisible, /* supporting springs */) { Metadata() }
76
+ }
77
+ ```
78
+
79
+ ### Coordinated Exit
80
+
81
+ All elements exit on the same `slowEffectsSpec()`. No staggering on exit - it slows perceived dismissal and feels sluggish.
82
+
83
+ ```kotlin
84
+ AnimatedVisibility(
85
+ visible = sheetVisible,
86
+ enter = /* staggered enter */,
87
+ exit = fadeOut(animationSpec = MaterialTheme.motionScheme.slowEffectsSpec())
88
+ ) { /* ... */ }
89
+ ```
90
+
91
+ > **Enter is choreography. Exit is uniform.** Never stagger on exit unless you have a very specific narrative reason.
92
+
93
+ ---
94
+
95
+ ## Code Example: Hero Card with Full Choreography
96
+
97
+ Tap a card. Shape morphs (Circle to Cookie4Sided), color transitions (primary to primaryContainer), elevation springs up, content fades in 100ms after the morph starts.
98
+
99
+ ```kotlin
100
+ @Composable
101
+ fun ExpressiveHeroCard(item: Item) {
102
+ var expanded by remember { mutableStateOf(false) }
103
+ val transition = updateTransition(expanded, label = "hero")
104
+
105
+ val morphProgress by transition.animateFloat(
106
+ transitionSpec = { MaterialTheme.motionScheme.slowSpatialSpec() },
107
+ label = "morph"
108
+ ) { if (it) 1f else 0f }
109
+
110
+ val color by transition.animateColor(
111
+ transitionSpec = { MaterialTheme.motionScheme.defaultEffectsSpec() },
112
+ label = "color"
113
+ ) {
114
+ if (it) MaterialTheme.colorScheme.primaryContainer
115
+ else MaterialTheme.colorScheme.primary
116
+ }
117
+
118
+ val elevation by transition.animateDp(
119
+ transitionSpec = { MaterialTheme.motionScheme.defaultSpatialSpec() },
120
+ label = "elevation"
121
+ ) { if (it) 12.dp else 2.dp }
122
+
123
+ val contentAlpha by transition.animateFloat(
124
+ transitionSpec = {
125
+ tween(
126
+ durationMillis = 250,
127
+ delayMillis = 100,
128
+ easing = FastOutSlowInEasing
129
+ )
130
+ },
131
+ label = "alpha"
132
+ ) { if (it) 1f else 0f }
133
+
134
+ val morph = remember { Morph(MaterialShapes.Circle, MaterialShapes.Cookie4Sided) }
135
+
136
+ Box(
137
+ modifier = Modifier
138
+ .size(200.dp)
139
+ .shadow(elevation, shape = RoundedCornerShape(16.dp))
140
+ .clip(GenericShape { _, _ ->
141
+ addPath(morph.toPath(morphProgress).asAndroidPath().asComposePath())
142
+ })
143
+ .background(color)
144
+ .clickable { expanded = !expanded }
145
+ ) {
146
+ Box(modifier = Modifier.alpha(contentAlpha)) {
147
+ Text(item.title, modifier = Modifier.padding(24.dp))
148
+ }
149
+ }
150
+ }
151
+ ```
152
+
153
+ What ships in this 30-line composable: spatial spring on size and elevation, tweened color and content fade, content reveal delayed 100ms after the shape begins morphing. The hierarchy is preserved: shape leads, color and elevation join immediately, content waits its turn.
154
+
155
+ ---
156
+
157
+ ## Shape Morphing Patterns
158
+
159
+ `androidx.graphics.shapes` is the M3 Expressive shape engine. Two key APIs.
160
+
161
+ ### Predefined Shapes
162
+
163
+ ```kotlin
164
+ MaterialShapes.Circle
165
+ MaterialShapes.Square
166
+ MaterialShapes.Triangle
167
+ MaterialShapes.Pentagon
168
+ MaterialShapes.Cookie4Sided
169
+ MaterialShapes.Cookie6Sided
170
+ MaterialShapes.Cookie9Sided
171
+ MaterialShapes.Cookie12Sided
172
+ MaterialShapes.Heart
173
+ MaterialShapes.Sunny
174
+ MaterialShapes.Pill
175
+ ```
176
+
177
+ These are tuned for smooth morphing. They share consistent vertex counts after subdivision, which means `Morph` can interpolate without artifacts.
178
+
179
+ ### Morph
180
+
181
+ ```kotlin
182
+ val morph = remember { Morph(MaterialShapes.Circle, MaterialShapes.Cookie4Sided) }
183
+ val path = morph.toPath(progress) // progress in 0..1
184
+ ```
185
+
186
+ Combine with springs for organic feel:
187
+
188
+ ```kotlin
189
+ val progress by animateFloatAsState(
190
+ targetValue = if (active) 1f else 0f,
191
+ animationSpec = MaterialTheme.motionScheme.slowSpatialSpec(),
192
+ label = "morph"
193
+ )
194
+ ```
195
+
196
+ > **Always use the spring tokens with morphing.** A linear morph feels mechanical; a spring morph feels alive.
197
+
198
+ ### Custom Shapes
199
+
200
+ If `MaterialShapes` doesn't cover your need, use `RoundedPolygon` directly:
201
+
202
+ ```kotlin
203
+ val custom = remember {
204
+ RoundedPolygon(
205
+ numVertices = 5,
206
+ radius = 1f,
207
+ rounding = CornerRounding(0.2f, smoothing = 0.5f)
208
+ )
209
+ }
210
+ val morph = remember { Morph(MaterialShapes.Circle, custom) }
211
+ ```
212
+
213
+ Vertex counts must align between the two shapes for smooth morphing. The library subdivides automatically when they don't match, but the result is choppier.
214
+
215
+ ---
216
+
217
+ ## Anti-Patterns Specific to Expressive
218
+
219
+ ### 1. Expressive on Every Button
220
+
221
+ ```kotlin
222
+ // BAD - every micro-interaction overshoots, UI feels chaotic
223
+ MaterialTheme(motionScheme = MotionScheme.expressive()) {
224
+ Scaffold {
225
+ Button(onClick = ...) { Text("Action") }
226
+ IconButton(onClick = ...) { /* icon */ }
227
+ // Every press now overshoots
228
+ }
229
+ }
230
+
231
+ // GOOD - Standard for chrome, Expressive scoped to hero
232
+ MaterialTheme(motionScheme = MotionScheme.standard()) {
233
+ Scaffold {
234
+ // Hero region overrides locally
235
+ MaterialTheme(motionScheme = MotionScheme.expressive()) {
236
+ HeroCard()
237
+ }
238
+ // Buttons elsewhere stay calm
239
+ }
240
+ }
241
+ ```
242
+
243
+ ### 2. Expressive on Sub-100ms Interactions
244
+
245
+ Overshoot is wasted on a 100ms toggle - the eye doesn't perceive it. Use Standard or a flat tween.
246
+
247
+ ```kotlin
248
+ // BAD - bouncy 80ms toggle, the bounce is invisible
249
+ val color by animateColorAsState(
250
+ targetValue = if (on) Color.Green else Color.Gray,
251
+ animationSpec = MaterialTheme.motionScheme.fastSpatialSpec() // wrong domain too
252
+ )
253
+
254
+ // GOOD - effects spec for color, fast and flat
255
+ val color by animateColorAsState(
256
+ targetValue = if (on) Color.Green else Color.Gray,
257
+ animationSpec = MaterialTheme.motionScheme.fastEffectsSpec()
258
+ )
259
+ ```
260
+
261
+ ### 3. Mixing Spatial Spec on Effects (and vice versa)
262
+
263
+ ```kotlin
264
+ // BAD - bouncy alpha overshoots into invalid range, looks broken
265
+ val alpha by animateFloatAsState(
266
+ targetValue = if (visible) 1f else 0f,
267
+ animationSpec = MaterialTheme.motionScheme.defaultSpatialSpec()
268
+ )
269
+
270
+ // GOOD - effects spec for alpha
271
+ val alpha by animateFloatAsState(
272
+ targetValue = if (visible) 1f else 0f,
273
+ animationSpec = MaterialTheme.motionScheme.defaultEffectsSpec()
274
+ )
275
+ ```
276
+
277
+ ### 4. Stagger on Exit
278
+
279
+ ```kotlin
280
+ // BAD - staggered exit slows dismissal, feels sluggish
281
+ items.forEachIndexed { i, item ->
282
+ AnimatedVisibility(
283
+ visible = visible,
284
+ exit = fadeOut(animationSpec = tween(delayMillis = i * 50))
285
+ ) { Card(item) }
286
+ }
287
+
288
+ // GOOD - unified exit
289
+ items.forEach { item ->
290
+ AnimatedVisibility(
291
+ visible = visible,
292
+ exit = fadeOut(animationSpec = MaterialTheme.motionScheme.slowEffectsSpec())
293
+ ) { Card(item) }
294
+ }
295
+ ```
296
+
297
+ ---
298
+
299
+ ## Sources
300
+
301
+ - [Material 3 Expressive blog](https://m3.material.io/blog/m3-expressive-motion-theming)
302
+ - [Material 3 Motion specs](https://m3.material.io/styles/motion/overview/specs)
303
+ - [androidx.graphics.shapes release notes](https://developer.android.com/jetpack/androidx/releases/graphics-shapes)
@@ -0,0 +1,359 @@
1
+ ---
2
+ name: compose-motion
3
+ description: "Jetpack Compose animation foundations - animate*AsState, AnimatedVisibility, Crossfade, updateTransition, SharedTransitionLayout, gestures."
4
+ ---
5
+
6
+ # Compose Motion - Sub-skill
7
+
8
+ > Jetpack Compose animation core. Loaded for Android Compose and Compose Multiplatform projects.
9
+ > Concise rules here. Deep-dive in `references/`.
10
+ > Baseline: current stable Jetpack Compose (1.7+). Modern stable APIs only - no `swipeable`, no `animateContentSize` hacks where `AnimatedContent` is correct.
11
+
12
+ ---
13
+
14
+ ## API Decision Tree
15
+
16
+ | Need | API |
17
+ |---|---|
18
+ | Single value over time | `animateFloatAsState`, `animateDpAsState`, `animateColorAsState`, etc. |
19
+ | Visibility / mount-unmount | `AnimatedVisibility(visible) { ... }` |
20
+ | Crossfade between states | `Crossfade(target) { state -> ... }` |
21
+ | Multi-state coordinated | `updateTransition(target).animateFloat { ... }` |
22
+ | Manual control / interruption | `Animatable(initialValue)` + `animateTo(...)` |
23
+ | Looping / infinite | `rememberInfiniteTransition().animateFloat(...)` |
24
+ | Shared elements | `SharedTransitionLayout` + `Modifier.sharedElement(...)` (Compose 1.7+) |
25
+ | Layout swap with anim | `AnimatedContent(target) { ... }` |
26
+ | Drag / swipe | `Modifier.draggable` + `Animatable.snapTo`/`animateTo`, or `Modifier.anchoredDraggable` for snap-points |
27
+
28
+ **Rule:** climb the ladder only when needed. `animate*AsState` covers 70% of cases. Reach for `Animatable` only when you need to interrupt, chain, or read velocity.
29
+
30
+ ---
31
+
32
+ ## Spring API (opinionated defaults)
33
+
34
+ | Use | Spec |
35
+ |---|---|
36
+ | UI snap (modal, drawer, tab) | `spring(stiffness = Spring.StiffnessMediumLow, dampingRatio = Spring.DampingRatioNoBouncy)` |
37
+ | Tactile (button press release, toggle) | `spring(stiffness = Spring.StiffnessMedium, dampingRatio = 0.85f)` |
38
+ | Bouncy reveal (toast, FAB, success) | `spring(stiffness = Spring.StiffnessLow, dampingRatio = Spring.DampingRatioMediumBouncy)` |
39
+ | Drag follow (1:1 finger tracking) | `spring(stiffness = Spring.StiffnessHigh, dampingRatio = 1f)` |
40
+
41
+ Stiffness constants: `VeryLow` 200, `Low` 400, `MediumLow` 700, `Medium` 1500, `High` 10000. Higher = faster settle. Damping constants: `HighBouncy` 0.2, `MediumBouncy` 0.5, `LowBouncy` 0.75, `NoBouncy` 1.0. Below 1.0 overshoots. Springs ignore `durationMillis`; if you need a deterministic duration, use `tween(...)` instead.
42
+
43
+ ---
44
+
45
+ ## `animate*AsState` - The Bread and Butter
46
+
47
+ ```kotlin
48
+ val targetAlpha = if (visible) 1f else 0f
49
+ val alpha by animateFloatAsState(
50
+ targetValue = targetAlpha,
51
+ animationSpec = spring(stiffness = Spring.StiffnessMedium),
52
+ label = "alpha",
53
+ )
54
+ Box(modifier = Modifier.alpha(alpha))
55
+ ```
56
+
57
+ The `label` shows up in Layout Inspector / Animation Preview - always set it, future-you will thank present-you. Variants ship for `Dp`, `Color`, `Offset`, `IntOffset`, `Size`, `Rect`, `Float`, `Int`, and a generic `animateValueAsState` for custom types via `TwoWayConverter`.
58
+
59
+ ---
60
+
61
+ ## `AnimatedVisibility` - Mount / Unmount with Anim
62
+
63
+ ```kotlin
64
+ AnimatedVisibility(
65
+ visible = expanded,
66
+ enter = slideInVertically(initialOffsetY = { -it }) + fadeIn(),
67
+ exit = slideOutVertically(targetOffsetY = { -it }) + fadeOut(animationSpec = tween(150)),
68
+ ) {
69
+ Panel()
70
+ }
71
+ ```
72
+
73
+ Combine multiple enter/exit transitions with `+`. Respect motion-principles: exit shorter and simpler than enter (here 150ms tween fade vs full slide+fade enter). The content composable only runs while visible OR animating - safe to mount expensive children inside.
74
+
75
+ ---
76
+
77
+ ## `AnimatedContent` - State-Driven Layout Swap
78
+
79
+ ```kotlin
80
+ AnimatedContent(
81
+ targetState = currentTab,
82
+ transitionSpec = {
83
+ (slideInHorizontally { it } + fadeIn()) togetherWith
84
+ (slideOutHorizontally { -it } + fadeOut())
85
+ },
86
+ label = "tabs",
87
+ ) { tab ->
88
+ TabContent(tab)
89
+ }
90
+ ```
91
+
92
+ `togetherWith` runs enter and exit in parallel; `using SizeTransform(clip = false)` controls how the container resizes between contents. Keys matter: if `targetState` doesn't change identity, no transition fires.
93
+
94
+ ---
95
+
96
+ ## `Crossfade` - Simple Fade Between States
97
+
98
+ ```kotlin
99
+ Crossfade(targetState = isLoading, label = "loadState") { loading ->
100
+ if (loading) Spinner() else Content()
101
+ }
102
+ ```
103
+
104
+ Use when you only need a fade. For anything richer (slide, scale, layout-aware), reach for `AnimatedContent`. `Crossfade` does NOT animate size - the container takes the size of the new content immediately.
105
+
106
+ ---
107
+
108
+ ## `updateTransition` - Multi-Property Coordinated
109
+
110
+ ```kotlin
111
+ val transition = updateTransition(targetState = expanded, label = "expand")
112
+ val width by transition.animateDp(label = "width") { if (it) 300.dp else 100.dp }
113
+ val color by transition.animateColor(label = "color") { if (it) Color.Blue else Color.Gray }
114
+ val corner by transition.animateDp(label = "corner") { if (it) 24.dp else 8.dp }
115
+
116
+ Box(
117
+ Modifier
118
+ .width(width)
119
+ .background(color, RoundedCornerShape(corner)),
120
+ )
121
+ ```
122
+
123
+ Use when several properties animate together based on the same state. All children share the same transition timeline, so they finish in sync. Each `animate*` call accepts its own `transitionSpec` lambda for per-property tuning.
124
+
125
+ ---
126
+
127
+ ## `Animatable` - Manual Control
128
+
129
+ ```kotlin
130
+ val offsetX = remember { Animatable(0f) }
131
+ LaunchedEffect(triggerEvent) {
132
+ offsetX.animateTo(100f, spring())
133
+ offsetX.animateTo(0f, spring(dampingRatio = Spring.DampingRatioMediumBouncy))
134
+ }
135
+ Box(Modifier.offset { IntOffset(offsetX.value.roundToInt(), 0) })
136
+ ```
137
+
138
+ Reach for `Animatable` when you need to interrupt (`stop()`), chain (`animateTo` returns when finished), read live velocity, or kick off decay (`animateDecay`). It is the imperative escape hatch for drag-then-fling, snap-back, and any flow `animate*AsState` cannot express.
139
+
140
+ ---
141
+
142
+ ## `SharedTransitionLayout` (Compose 1.7+) - Hero Animations
143
+
144
+ ```kotlin
145
+ SharedTransitionLayout {
146
+ AnimatedContent(targetState = currentScreen, label = "nav") { screen ->
147
+ when (screen) {
148
+ Screen.List -> ListScreen(
149
+ sharedTransitionScope = this@SharedTransitionLayout,
150
+ animatedVisibilityScope = this@AnimatedContent,
151
+ )
152
+ is Screen.Detail -> DetailScreen(
153
+ item = screen.item,
154
+ sharedTransitionScope = this@SharedTransitionLayout,
155
+ animatedVisibilityScope = this@AnimatedContent,
156
+ )
157
+ }
158
+ }
159
+ }
160
+
161
+ // Inside ListScreen, on the card image:
162
+ with(sharedTransitionScope) {
163
+ Image(
164
+ painter = painter,
165
+ contentDescription = null,
166
+ modifier = Modifier.sharedElement(
167
+ state = rememberSharedContentState(key = "hero-${item.id}"),
168
+ animatedVisibilityScope = animatedVisibilityScope,
169
+ ),
170
+ )
171
+ }
172
+ ```
173
+
174
+ Two scopes plumbed down: `SharedTransitionScope` (where `Modifier.sharedElement` extension lives) and `AnimatedVisibilityScope` (the visibility context that drives the transition). `rememberSharedContentState(key)` keys MUST match across screens or no animation fires. Deep-dive in `references/shared-transitions.md`.
175
+
176
+ ---
177
+
178
+ ## `InfiniteTransition` - Looping
179
+
180
+ ```kotlin
181
+ val infinite = rememberInfiniteTransition(label = "loader")
182
+ val rotation by infinite.animateFloat(
183
+ initialValue = 0f,
184
+ targetValue = 360f,
185
+ animationSpec = infiniteRepeatable(
186
+ animation = tween(1000, easing = LinearEasing),
187
+ repeatMode = RepeatMode.Restart,
188
+ ),
189
+ label = "rotation",
190
+ )
191
+ Icon(Icons.Default.Refresh, contentDescription = null, modifier = Modifier.rotate(rotation))
192
+ ```
193
+
194
+ `RepeatMode.Restart` jumps back to start each cycle; `RepeatMode.Reverse` ping-pongs. Always provide a pause / off path for accessibility (see Reduced Motion section below). For one-shot decay (fling), use `Animatable.animateDecay` instead.
195
+
196
+ ---
197
+
198
+ ## Gestures (quick map)
199
+
200
+ | Need | Modifier |
201
+ |---|---|
202
+ | Tap | `Modifier.clickable(onClick = ...)` |
203
+ | Tap + long-press | `Modifier.combinedClickable(onClick = ..., onLongClick = ...)` |
204
+ | Drag (single axis) | `Modifier.draggable(state, orientation)` |
205
+ | Multi-touch / custom | `Modifier.pointerInput { detectDragGestures { ... } }` |
206
+ | Scroll offset reading | `LazyListState` or `ScrollState.value` |
207
+ | Swipe-to-dismiss / snap points | `Modifier.anchoredDraggable(state)` (Compose 1.6+, replaces `swipeable`) |
208
+ | Pinch + pan + rotate | `Modifier.transformable(state)` |
209
+
210
+ Deep-dive in `references/gestures-compose.md` (NestedScrollConnection, conflict resolution, fling decay).
211
+
212
+ ---
213
+
214
+ ## Anti-Patterns (BAD / GOOD)
215
+
216
+ ### 1. Animating layout size instead of transform
217
+
218
+ ```kotlin
219
+ // BAD - animateDpAsState on width forces a layout pass every frame
220
+ val w by animateDpAsState(if (expanded) 300.dp else 100.dp)
221
+ Box(Modifier.width(w).height(60.dp))
222
+ ```
223
+
224
+ ```kotlin
225
+ // GOOD - animate scale via graphicsLayer (composite-only, no layout)
226
+ val scale by animateFloatAsState(if (expanded) 3f else 1f, label = "scale")
227
+ Box(
228
+ Modifier
229
+ .width(100.dp)
230
+ .height(60.dp)
231
+ .graphicsLayer {
232
+ scaleX = scale
233
+ transformOrigin = TransformOrigin(0f, 0.5f)
234
+ },
235
+ )
236
+ ```
237
+
238
+ If the actual layout size MUST change (parent depends on it), use `Modifier.animateContentSize()` so neighbors animate too, or wrap the swap in `AnimatedContent`.
239
+
240
+ ### 2. `LaunchedEffect(true)` / `LaunchedEffect(Unit)` with hidden inputs
241
+
242
+ ```kotlin
243
+ // BAD - re-runs only once, BUT also fires on every recomposition surprise
244
+ // when callers swap the composable instance. Worse: anything captured
245
+ // in the lambda is stale.
246
+ LaunchedEffect(true) {
247
+ offsetX.animateTo(target)
248
+ }
249
+ ```
250
+
251
+ ```kotlin
252
+ // GOOD - explicit key tied to the trigger
253
+ LaunchedEffect(triggerKey) {
254
+ offsetX.animateTo(target)
255
+ }
256
+ ```
257
+
258
+ If you genuinely want "run once", use `LaunchedEffect(Unit)` on purpose AND ensure you don't capture varying state - or hoist the captured values out. When in doubt, key on the values you read.
259
+
260
+ ### 3. Forgetting `key` in a `LazyColumn` with item animations
261
+
262
+ ```kotlin
263
+ // BAD - on insert/delete/reorder, items animate to wrong slots
264
+ LazyColumn {
265
+ items(list) { item ->
266
+ AnimatedVisibility(visible = item.expanded) { ItemRow(item) }
267
+ }
268
+ }
269
+ ```
270
+
271
+ ```kotlin
272
+ // GOOD - stable key by id, plus Modifier.animateItem for reorder anim
273
+ LazyColumn {
274
+ items(list, key = { it.id }) { item ->
275
+ Row(modifier = Modifier.animateItem()) {
276
+ AnimatedVisibility(visible = item.expanded) { ItemRow(item) }
277
+ }
278
+ }
279
+ }
280
+ ```
281
+
282
+ `Modifier.animateItem()` (Compose 1.7+, replaces `animateItemPlacement`) handles insert/remove/move automatically when `key` is stable.
283
+
284
+ ### 4. Nesting `AnimatedContent` inside scrolling list items
285
+
286
+ ```kotlin
287
+ // BAD - every item runs its own transition graph; scroll = jank
288
+ LazyColumn {
289
+ items(list, key = { it.id }) { item ->
290
+ AnimatedContent(targetState = item.state) { state -> Row(state) }
291
+ }
292
+ }
293
+ ```
294
+
295
+ ```kotlin
296
+ // GOOD - lift state, animate only the changing prop on the row
297
+ LazyColumn {
298
+ items(list, key = { it.id }) { item ->
299
+ val color by animateColorAsState(if (item.selected) selBg else bg, label = "rowBg")
300
+ Row(Modifier.background(color)) { Content(item) }
301
+ }
302
+ }
303
+ ```
304
+
305
+ Rule: heavy animation containers (`AnimatedContent`, `SharedTransitionLayout`) belong at screen scope, not per row.
306
+
307
+ ---
308
+
309
+ ## Reduced Motion - Respect It
310
+
311
+ See `../motion-principles/SKILL.md` for the cross-platform doctrine.
312
+
313
+ ```kotlin
314
+ @Composable
315
+ fun rememberReduceMotion(): Boolean {
316
+ val context = LocalContext.current
317
+ return remember {
318
+ Settings.Global.getFloat(
319
+ context.contentResolver,
320
+ Settings.Global.ANIMATOR_DURATION_SCALE,
321
+ 1f,
322
+ ) == 0f
323
+ }
324
+ }
325
+
326
+ val reduce = rememberReduceMotion()
327
+ val alpha by animateFloatAsState(
328
+ targetValue = if (visible) 1f else 0f,
329
+ animationSpec = if (reduce) snap() else spring(),
330
+ label = "alpha",
331
+ )
332
+ ```
333
+
334
+ `ANIMATOR_DURATION_SCALE` reads the animator duration scale directly. The cleaner call is `ValueAnimator.areAnimatorsEnabled()` (API 26+), which returns `false` when that scale is 0 - set by the developer-options "Animation off" toggle, Battery Saver, and the user-facing "Remove animations" (Settings -> Accessibility) toggle alike. Deep-dive in `../mobile-principles/references/accessibility-mobile.md`.
335
+
336
+ ---
337
+
338
+ ## Quick Reference
339
+
340
+ | Need | Load |
341
+ |---|---|
342
+ | Shared transitions deep-dive | `references/shared-transitions.md` |
343
+ | Gestures + nestedScroll patterns | `references/gestures-compose.md` |
344
+ | Recomposition / jank / Layout Inspector | `references/recomposition-and-anim.md` |
345
+ | Advanced (M3 Expressive, AGSL, Canvas) | `../compose-graphics/SKILL.md` |
346
+ | CMP / KMP patterns | `../compose-multiplatform/SKILL.md` |
347
+ | Mobile UX context | `../mobile-principles/SKILL.md` |
348
+ | Foundation (timing, easing, a11y) | `../motion-principles/SKILL.md` |
349
+
350
+ ---
351
+
352
+ ## Sources
353
+
354
+ - [aldefy/compose-skill](https://github.com/aldefy/compose-skill) - animation reference
355
+ - [skydoves/Orbital](https://github.com/skydoves/Orbital) - shared element transitions
356
+ - [mutualmobile/compose-animation-examples](https://github.com/mutualmobile/compose-animation-examples)
357
+ - [fornewid/material-motion-compose](https://github.com/fornewid/material-motion-compose)
358
+ - [Android Compose animations docs](https://developer.android.com/develop/ui/compose/animation/introduction)
359
+ - [Android SharedTransitionLayout](https://developer.android.com/develop/ui/compose/animation/shared-elements)