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.
Other Interesting Links
- Medium: Jetpack Compose with Single Activity Navigation
- Medium: The Interesting case of ViewTree*Owner
- Adopting Jetpack Compose: ComposeView
- Video: MVVM Architecture To do App in Jetpack Compose
- Medium: Jetpack Compose: filling max width or height
- Jetpack Compose Basics - Showing images
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.
Other Interesting Links
Or, you can subscribe to the Atom feed or follow Mark Murphy in the Fediverse.
Recent Issues:
- 2024-10-29: Relay! Paparazzi! droidcon Lisbon 2024! Server-defined UI! And... desktop OS trays?!?
- 2024-10-22: Compose patch! Compose alpha! Compose Multiplatform stable! droidcon NYC! Adaptive UIs! MVI! HTML conversions! Math rendering! And... are we now Fluent in Compose?!?
- 2024-10-15: Alpha and beta BOMs! Compose Multiplatform UI testing! Compose Multiplatform camera apps! Passing data between screens in Navigation for Compose! JSON rendering!