Newsletter Issue #28

Published: 2020-08-25

dev17 shipped! Fortunately, it is a bit smaller of a release than the previous two releases, to allow us to catch our breath. In this week’s issue, we will look at some dev17 changes, understand a bit more what RowScope really is, and see some preliminary code for dealing with system insets.

Also, the issue has some puns. If you are allergic to puns, please take appropriate steps.

One Off the Stack, One Off the Slack

You’ve got questions. That’s understandable!

<include> in Compose

In classic View-based Android development, we might use <include> to reuse a layout. In this Stack Overflow question and answer, Google’s Ryan Metzger and I try to convince someone that simply having a resuable composable is the equivalent in Compose.

Scoping Child Composables

You might have a composable that makes certain assumptions about where it gets called, such as “needs to be an immediate child of a Row”. In this week’s highlighted Slack thread, we explore how to try to limit the use of that child to the appropriate parent, via a “scope” marker object.

Composable Commentary

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

Compose Runtime dev17 Release Notes

The big change here is that state() is deprecated. They want you to use remember { mutableStateOf() }, as while that is more verbose, it makes remember() more visible, and remember() is important for Compose developers to… remember.

Compose UI dev17 Release Notes

Compose’s options for embedding classic Views are changing: switch to use AndroidView. A few more classes are now inline, such as Offset, Constraints, and IntSize. And there were a lot more focused changes… including adding a FocusManager and removing FocusModifier.

Compose Foundation dev17 Release Notes

The Row and Column Arrangement options were… rearranged, with new spacedBy and aligned options. Note that custom Arrangement implementations “will not be supported in the future”. Also, Modifier.drawBorder() is now Modifier.border(), and the various fillMax...() modifiers now support fractions in addition to full fills.

Compose Reddit AMA

The Jetpack and Jetpack Compose teams are holding a Reddit AMA. There are already 130 comments in the thread, even though answers will not be arriving until August 27.

Curated Reality on Jetpack Compose

This video is an hour-long recorded live-coding session on the basics of using Compose.

Resource Roundup

100% pure code!

GitHub: arkivanov / Decompose

Arkadii Ivanov brings us a library that offers a RIBs-inspired component-and-routing implementation, to help you create multiple screens with integrated back stack support.

GitHub: AliAzaz / ScaffoldItemsViewTemplate

Ali Azaz Alam has a repo that uses separate branches for separate tutorials related to Compose. The one linked to here demonstrates Scaffold, drawers, FABs, and more!

Gist: chrisbanes / Insets.kt

Google’s Chris Banes has a long gist with a series of ambient-driven Modifier functions that help you consume system insets from your Compose UI (e.g., Modifier.navigationBarWidth() to help inset away from navigation bars in landscape).

I am really glad that Chris spends as much time automating these things as he does. The only way that we will get developers to pay attention to insets is if we make them as easy as possible to address, and this stuff is terribly complicated. You might think of them as the… banes of my existence. 🥁

Gist: bmc08gt / TransientSnackbar.kt

Brandon McAnsh demonstrates using the delay() function from coroutines to automatically dismiss a Snackbar after a period of time, if it was not dismissed manually by then.

Gist: bmc08gt / Grid.kt

Brandon also offer this demonstration of his take on a Grid() composable, “with main axis and cross axis spacing support similar to FlowRow()”. This tweet has a short demo video.

…And One More Thing

Since this keeps coming up in Stack Overflow and in Slack

The @Preview annotations for dev16 and dev17 do not actually deliver previews to Android Studio 4.2 Canary 7 and earlier. The working theory is that the problem is tied to the new Compose compiler plugin for Kotlin, which is itself tied to the new Kotlin 1.4. However, I have not seen an official statement to that effect.

This @Preview limitation is supposed to be fixed in Android Studio 4.2 Canary 8. I hope that is the case. The fact that Canary 8 has been slow to roll out makes me a bit nervous.

Regardless, Google is aware of the issue and hopefully this will be resolved in the near future.

If you encounter problems in subscribing, let us know!
Spread the Word!
If you have ideas for items for future newsletter editions, reach out via email or contact Mark Murphy on kotlinlang Slack!