Skip to content

Repository files navigation

compose-lab — small honest Jetpack Compose experiments

Small Compose experiments, each with the why written down. Clearly labelled as learning in public — not a product.

 1 · FlowRow — a custom Layout

A wrapping row built with the Layout composable: measure children, break to a new line when the next one won't fit, place each one.

The wrapping maths is factored out into flowLayout(itemSizes, maxWidth, hGap, vGap), a pure function — so the logic that's easy to get wrong (row height = tallest item, an item wider than the container, the off-by-one gap on the last item) is covered by 5 unit tests with no Compose runtime.

FlowRow(Modifier.fillMaxWidth()) {
    tags.forEach { Chip(it) }   // wraps across lines automatically
}

 2 · Recomposition — stable vs unstable, shown not argued

rememberRecompositionCount() returns a live count of how many times its owner composed. The demo screen renders two rows:

Row Param type On unrelated parent recomposition
UnstableRow List<String>unstable to the compiler recomposes every time
StableRow @Immutable Labels(List<String>) skipped when unchanged

Tap "bump unrelated parent state" and watch the unstable counter climb while the stable one holds. That's the whole argument for stability annotations, made concrete.

 Build

./gradlew :app:assembleDebug        # the demo app
./gradlew :app:testDebugUnitTest    # the flowLayout tests

 Roadmap

  • A gesture component (anchoredDraggable swipe-to-reveal)
  • SubcomposeLayout experiment — measure-then-decide
  • Recomposition counts captured in a Macrobenchmark, not just on screen
  • Modifier.Node custom modifier vs the old composed { } approach

 License

Apache-2.0 · Chinmay Tayade · LinkedIn

About

Small, honest Jetpack Compose experiments — a custom layout, a recomposition study with real counts, a gesture component. Learning in public.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages