jetc.dev Newsletter Issue #42

Published: 2020-12-01

This was a bit of a quiet week, owing to the Thanksgiving holiday in the US. But, Jetpack Compose is a global phenomenon! So, this week, we look at Navigation for Compose, including nested nav graphs and passing arguments. We also peek at Paging for Compose, applying it to various Web service APIs. We also see an IDE plugin for Compose colors, and we ponder what else in the Jetpack might get Compose-ified.

Note: due to a publishing problem, issue #41 was published to the Web several days late — sorry about that!

One Off the Stack, One Off the Slack

You’ve got questions. That’s understandable!

Scoping States in Jetpack Compose

Scoping states for individual composables is easy. Scoping states for the entire app is easy. But, how do we scope states for intermediate structures, such as a group of screens? One answer comes from Navigation for Compose and viewmodels scoped to a navigation graph, as we see in this week’s highlighted Stack Overflow question.

How Big Can I Get?

Developers all too often ask how big the screen is. There is a Compose UI-specific solution for that, but it usually is the wrong question, as we explore in this week’s highlighted Kotlinlang Slack thread!

Composable Commentary

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

Android Jetpack Compose: Recomposition Made Easy

Elye returns with a post that illustrates what “recomposition” means in Compose and how it impacts which of your composables gets run at various times. Come for the post; stay for the GIFs showing the impacts of different composable structures on what gets recomposed!

Comparing Use of LiveData and StateFlow in a Jetpack Compose Project

John O’Reilly tried migrating his ViewModel to use StateFlow instead of LiveData. You won’t believe what happened next! Well, OK, you might believe it, if you are used to Android lifecycle headaches.

Passing String Typed Data with Jetpack Compose Navigation Component

Ziv Kesten continues his examination of Navigation for Compose with two new posts. This one examines the “stringly-typed” approach that Navigation for Compose uses for arguments by default. Another post looks at the options for passing non-string types as arguments.

Infinite Lists With Paging 3 in Jetpack Compose

Vivek Singh has been experimenting with Paging for Compose, in his case use the TMDB API for displaying a scrolling list of movies. This post, and the accompanying GitHub repo, show his results!

From Swing to Jetpack Compose

Thomas Kuenneth has been experimenting with Compose for Desktop and is chronicling his exploits! His initial post sets up a basic Compose for Desktop UI, while his second post explores integrating with the desktop for drag-and-drop, particularly for accepting files and directories dropped from a desktop file explorer.

Jetpack Compose: Navigation

Bevan Steele is back, this time with a quick review of Navigation for Compose and how you perform basic navigation of your composables with it.

Slides: Migrating Your Design System to Jetpack Compose

Adam Bennett has been delivering some presentations on the role of design systems and how one approaches them in Jetpack Compose. While video is not available (unfortunately!), Adam has published his slides.

Resource Roundup

100% pure code!

GitHub: KaustubhPatange / compose-color

In Compose UI, our colors often are simple constants in Kotlin code, and right now our IDEs lack gutter support to show what those colors look like, as we get with Android color resources. Kaustubh Patange created an IDEA/Android Studio plugin that offers such gutter previews for Color() properties.

GitHub: JoshHughes-Dev / EzNews

Josh Hughes is working on a sample app that consumes the NewsAPI Web service and displays news items using Compose UI and Paging for Compose.

Gist: loloof64/DragAndDropWithAnimation.kt

Laurent Bernabé posted a pair of gists showing experiments with drag-and-drop within Compose. The original gist was for a fairly simple drag-and-drop scenario, while this one offers a return animation as well.

…And One More Thing

We have been seeing a trickle of Jetpack libraries getting Compose-ready editions, such as Navigation and Paging. And some libraries have been Compose-friendly for a while, such as Lifecycle. What else needs similar treatment?

I see four major buckets of candidate libraries for Compose integration:

  • Libraries tied to specialized device types: Car, Leanback (for TV), Wear

  • Libraries that wrap framework UI: Biometric, CameraX, Media2, WebKit

  • Libraries that are Compose-adjacent: Emoji, Palette, Preference, Print

  • Libraries that already support LiveData but might be adapted to also support State, such as DataStore, Room, and WorkManager

Eventually, many of the libraries from the first three bullets seem likely to get Compose-friendly editions. Palette might get support for creating a MaterialTheme(), Preference might offer composables for matching the existing preference UI, and so on.

Not everything in the Jetpack will get the Compose treatment. Data binding, for example, is almost the anti-Compose at this point. Others, like ViewPager2, will get Compose equivalents but they may not necessarily be “branded” based on the original Jetpack library names. And others, like TextClassifier, may not have enough Compose ties to make a Compose-centric edition worthwhile.

In some cases, these libraries might be Compose-ified while Compose is still in pre-release form. Others might wind up waiting until Compose ships a stable release.

One way or another, the Jetpack is likely to have a Compose “vibe” to it in the coming years, if Compose keeps on its current trajectory.