jetc.dev Newsletter Issue #187

Published: 2023-10-24

We have a new BOM and new alphas for Compose and Wear Compose, so we check them out.

We also try to infer the importance of @Stable and look at supporting both views and composables from a library. We explore dialog animations and Paparazzi. And we see a pair of Kevin Zou libraries for Compose Multiplatform, including a WebView wrapper.

Ooooo… What Did We Get?

Reviewing the release notes for the latest Jetpack Compose update!

The Compose BOM is up to 2023.10.01, corresponding with the 1.5.4 patch release, which presumably contained bug fixes.

We also got a 1.6.0-alpha08 release, with various optimizations, along with:

  • A new draggable2D() modifier

  • New isDisplayed() and isNotDisplayed() functions on SemanticsNodeInteraction

  • The LoremIpsum PreviewParameterProvider is now open

Wear Compose now has a 1.2.1 patch release with bug fixes. It also has a 1.3.0-alpha08 release with better control over PositionIndicator animations.

And, in Compose-adjacent libraries, we have 1.1.0-rc01 for the Hilt Compose Navigation integration (androidx.hilt:hilt-navigation-compose) and 2.7.0-alpha03 of the Lifecycle integration with Compose, notably androidx.lifecycle:lifecycle-viewmodel-compose.

One Off the Stack, One Off the Slack

You’ve got questions. That’s understandable!

What’s the Point of rememberUpdatedState()?

While rememberUpdatedState() might not be needed much, if you use effects, it may prove useful, as we see in this week’s highlighted Stack Overflow question.

How Important is @Stable?

The original vision of Compose was that stability — correctly determining what has not changed — would be inferred by the compiler without much help. Some developers more aggressively use @Stable and @Immutable to help out the compiler. However, before long, strong skipping mode may reduce the need for such manual interventions, as we see in this week’s highlighted Kotlinlang #compose Slack thread.

Composable Commentary

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

Medium: Adopt Compose for View-based libraries

Google’s Chris Arriola reviews different approaches for supporting both Views and composables, with an eye towards library publishers. Chris specifically looks at how your composable API might influence the implementation (even if that implementation is a View), the stateful-vs.-stateless decision, and how to cleanly support @Preview.

Video: #TheAndroidShow 2023

This year’s edition of Google’s #TheAndroidShow included a few bits on Compose, including screenshot testing, supporting Wear OS and foldables, integration of DataStore, and more.

Medium: Building Reddit Recap with Jetpack Compose on Android

Google’s Medium account ran a guest post from Reddit’s Aaron Oertel, describing how Reddit Recap leveraged Compose UI in its 2022 revamp, from rich animations to performance tuning.

Medium: Unlock Interactive Possibilities with SwipeBox: A Compose Multiplatform Library for Swipe-to-Action Widget

Kevin Zou writes about compose-swipebox-multiplatform, Kevin’s Compose Multiplatform library for supporting horizontal swipes exposing actions that users can take.

Custom Dialog Animation in Jetpack Compose

sinasamaki reviews how to wrap Dialog() in a CustomDialog() composable, then progressively replace default behaviors with custom ones. In particular, this post explores custom animations, such as for when the dialog is dismissed().

Medium: Capturing Pixel-Perfect Android UIs: A Snapshot Testing Journey with Paparazzi

Ivan Dimitrov examines using Paparazzi for screenshot testing, both of composables and of classic Views. Ivan also looks at overcoming certain challenges when using Paparazzi, such as dealing with locale differences between developer machines.

Medium: Editing currency TextFields in Jetpack Compose

Damian Petla looks at currency fields in Compose UI, where there are limits on what is input (digits only) and where the visual result needs to be formatted as a currency. Damian demonstrates how a custom VisualTransformation, along with filtering logic in onValueChanged of a TextField(), can deliver the desired results.

Medium: Requesting Permission Jetpack Compose — The Complete Guide

Chirag T walks us through using accompanist-permissions to request one or several permissions from our composables.

Resource Roundup

100% pure code!

GitHub: KevinnZou / compose-webview-multiplatform

Kevin Zou worked on a Compose Multiplatform wrapper around platform-specific Web rendering options: WebView on Android, WKWebView on iOS, and Java CEF Browser for desktop.

GitHub: oas004 / VerifyComposeMetricsPlugin

Odin Asbjørnsen created a library that leverages the Compose compiler report to alert you if your code has exceeded a developer-determined threshold for unstable classes.

GitHub: OrlanDroyd / ComposeCalendar

Orlando Peña Fernández brings us a set of composables for selecting a date, a date-time, a date range, or just a month and year.

GitHub: journiapp / pinch-to-zoom

GitHub user journiapp offers up another pinch-to-zoom implementation that can be applied to arbitrary composables, not just images.