jetc.dev Newsletter Issue #88

Published: 2021-10-26

This week, we try to make sense of SubcomposeLayout() and janky lists. We look at text entry validation, tooltips, and nested navigation.

Plus, Chris Banes tries to have an “Oprah moment” with your composables: “You get a Modifier! And you get a Modifier! Everybody gets a Modifier!”

One Off the Stack, One Off the Slack

You’ve got questions. That’s understandable!

What Does SubcomposeLayout() Do?

One of the more mystifying composables in the base Compose UI roster is SubcomposeLayout()… in part because the verb “subcompose” is never defined. Learn a bit more about SubcomposeLayout() in this week’s highlighted Stack Overflow question.

Why Is My List So Sluggish?

If you see X is behaving slowly, see whether you are recomposing it too often. And, if so, see if you can rework your state access to reduce the frequency or breadth of the recompositions. You can see more about how this works in this week’s highlighted Kotlinlang #compose Slack thread.

Composable Commentary

Posts, videos, and other new information related to Jetpack Compose!

Always Provide a Modifier

Chris Banes would like every composable function to accept a Modifier as a parameter. That may seem like overkill — in this post, Chris tries to convince you otherwise.

Medium: How to Validate Fields Using Jetpack Compose in Android

Ideally, your users always provide valid input data. That… does not always work out. Siva Ganesh Kantamani demonstrates basic input validation and how to render errors for flawed entries in text fields.

Medium: Simple MVI implementation with Jetpack Compose

Volodymyr Shcherbyuk explores the model-view-intent (MVI) unidirectional data flow architecture and how one can implement it in Compose UI. Along the way, Volodymyr uses @Immutable sealed classes for events and states, a Jetpack ViewModel implementing the “reducer” logic, event record/playback, and more!

Video: Nested Navigation

Stevda-San brings us another screencast, this time examining nested navigation graphs with Navigation for Compose, particularly looking at how to use a nested graph for authentication screens, separate from the main app navigation graph.

Medium: Building your first Custom Chart in Android with Jetpack Compose

Christopher Elias needed a line chart to show cryptocurrency prices. In this post, Christopher shows us how to render that sort of chart directly using a Canvas(), avoiding any of the various composable charting libraries.

Resource Roundup

100% pure code!

Snapper

I linked to Chris Banes’ Snapper library a couple of weeks ago, before it had any documentation. Now that the documentation is available, it is worth another look! Basically, if you have a LazyRow() or LazyColumn() and want fling gestures to “snap” to a specific spot (e.g., an item is always centered in the available space), Snapper may be your solution!

Gist: amal / Tooltip.kt

Amal Samally provides us with a small Tooltip() composable, to display a short-term popup near something else (e.g., near some other UI element that the user long-clicked upon). Tooltips are particularly useful for icon-only buttons, so users have a way to find out what the icon represents, if it is not obvious to them.