jetc.dev Newsletter Issue #41

Published: 2020-11-24

This week, we look at lots of conference videos and screencasts on Compose, including a Googly panel discussion. We also explore units of state change, play more with Compose for Desktop, and look at a theme engine. Plus, we get just a bit more animated.

One Off the Stack, One Off the Slack

You’ve got questions. That’s understandable!

Acting Upon IME Actions

The TextField() composable supports a KeyboardOptions parameter where you can specify what the action button of the input method editor should show (e.g., Done, Next, 🔍, etc.). However, that just controls the action button caption. To do something based on the user tapping that button, use the onImeActionPerformed parameter to TextField(), as we see in this week’s highlighted Stack Overflow question.

The Scope of State

MutableState<List<T>> and SnapshotStateList<T> seem similar: they offer Compose state tracking for lists of some type T. However, their change semantics are significantly different, as we explore in this week’s #compose Slack thread.

Composable Commentary

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

Lottie for Jetpack Compose

Lottie is a powerful, cross-platform solution for encoding and rendering animations. Not surprisingly, there was a lot of interest in a version of Lottie for Compose, and in this Medium post, Gabriel Peal announces the first alpha of such a solution!

Video: Learn Jetpack Compose by Example

Vinay Gaba presented at the 2020 Android Summit and gives us a tour of the Compose and Compose UI foundation, from basic UI elements to dialogs, recomposition, and interoperability with existing View-based Android code.

Video: Compose ❤️️ Dino: Building Chrome’s T-Rex Game in Jetpack Compose

Another Compose UI presentation from the 2020 Android Summit comes from Wajahat Karim. In this case, he walks through his port of the Chrome T-Rex endless runner game that we mentioned here a few weeks ago.

Video: Ask Googlers About Jetpack Compose

Vinay Gaba is busy! He also moderated a panel discussion for droidcon Americas 2020, where Doris Liu, Ian Lake, Sean McQuillan, and Leland Richardson of Google weigh in on Compose and Compose UI concerns.

Jetpack Compose Effect Handlers

Jorge Castillo is back, with a post on effect handlers. Our composables can run at arbitrary times, as Compose determines what needs to be re-rendered based on state changes. Also, composables can get disposed at arbitrary times, such as when the user navigates to a completely different screen. This makes triggering work with side effects — such as I/O — a bit tricky in Compose. This post reviews how effect handlers can help us manage that work.

Getting Our Apps Ready for Jetpack Compose

Joe Birch returns with a long post on steps that you can take now to help prepare your app for a Compose UI future, even if you will not be migrating to Compose for a few years. He covers concepts like state management, unidirectional data flow architectures, and business concerns (do we really need to support Android 4.x and older?).

The Future of Apps: Declarative UIs with Kotlin MultiPlatform (D-KMP)

Daniele Baroncelli brings us a three-part Medium post series on declarative UIs in the world of Kotlin/Multiplatform, looking at architecture, particularly MVI and how to apply it for both Compose, SwiftUI, and React.

Build Desktop Apps With Kotlin And Jetpack Compose For Desktop

Soufiane Sakhi offers a walkthrough of setting up a Compose for Desktop app, specifically creating a calculator-style UI, with a custom keypad and display pane.

Fully Cross-Platform Kotlin Applications (Almost)

A few months ago, we saw Arkadii Ivanov’s Decompose library, which offers its own take on navigation within a Compose app. He returns this week with an article exploring how Decompose can also work with Compose for Desktop, offering cross-platform navigation support.

Video: Jetpack Compose Navigation

All Techies returns with a pair of screencasts around applying Navigation for Compose. This one covers the basics, while the follow-on screencast explores passing arguments as part of navigation.

Jetpack Compose: ViewModels

Bevan Steele has another post up, this time examining the use of ViewModel, particularly swapping out LiveData for MutableState that viewmodel.

Exploring Jetpack Compose

Chetan Bhalerao gives us a quick tour of the basics of creating a Compose UI-based app, using common composables like LazyColumnFor() and Text().

Why is Jetpack Compose So Exciting?

Jordan Dixon published an opinion piece, explaining why Compose and Compose UI are garnering so much interest, despite being in an early alpha state.

Resource Roundup

100% pure code!

GitHub - lcdsmao / JetTheme

Yao Mufeng is back, this time with a library that helps you manage a theme pack (for Material or a custom design system), including switching between themes at runtime.

GitHub - Gosunet / KrepesMultiPlatform

Jonathan Lagneaux created a sample Kotlin/Multiplatform library module, with client apps for Android and the desktop using Compose UI (along with an iOS client app). The library is for sharing crepe recipes, which is a tasty subject! 😁

GitHub - Gurupreet / ComposeSpotifyDesktop

Gurupreet Singh returns, this time with a Compose for Desktop sample app using the Spotify API to let you browse your music library.

GitHub - bentrengrove / chess

Ben Trengrove ported Nick Lockwood’s chess app for iOS to Android and Compose UI. An an extra benefit, the AI apparently needs work, so winning may be easy!

…And One More Thing

Jorge Castillo’s post on effect handlers is a nice introduction to the topic. It also scares the 💩 out of me, in terms of trying to train future generations of Android developers.

Effect handlers help to highlight how much Compose relies upon its Kotlin compiler plugin and the resulting “compiler magic”. Compiler magic is a double-edged sword:

  • Experts can get more done more quickly, by avoiding excess syntax

  • Complete newcomers can get up to speed more quickly, because there is less syntax to have to learn

  • Middle-tier developers who try to make sense of what is going on may become baffled, because they cannot see the missing syntax and cannot learn from it

Kotlin coroutines also relies upon compiler magic. However, that is limited to a single keyword: suspend. Everything else comes from a library and is fairly visible. Developers learn by identifying patterns and seeing how to apply them in new situations. With coroutines, much of what makes up those patterns is visible. With Compose, much of what makes up those patterns is hidden:

  • Why do calls to composables actually affect the UI, despite their being bare functions decoupled from any specific classes? Magic!

  • How does remember actually remember anything? Magic!

  • How can a function have a lifecycle? Magic!

  • And so on

You can try to explain the mechanics of that invisible stuff, in terms of slot tables and the other actual artifacts that make up a “composition”. But, they are largely hidden away, with good reason. The whole point of the compiler magic is to simplify Compose development. It just makes trying to explain to middle-tier developers that much harder.

That is not to say that the Compose team is making the wrong choice here. It does mean that I am scared for how this educational process will play out. As I described Kotlin when it gained popularity: there is a fine line between “concise” (little extraneous stuff) and “terse” (sub-standard intrinsic knowledge). Only time will tell whether we can categorize Compose as “concise” or “terse”.