Newsletter Issue #184

Published: 2023-10-03

The BOM was bumped, but not by much.

Elsewhere, we dive into how measuring and touch input dispatching work with composables. We examine Roborazzi and a Material3 implementation of pull-to-refresh. Plus, we look at a PDF viewer and a Compose Multiplatform charting library.

Ooooo… What Did We Get?

Reviewing the release notes for the latest Jetpack Compose update!

The Compose BOM got a bump to 2023.09.02, which maps to the 1.5.2 patch release, which contains some crash fixes.

Also, JetBrains released 1.5.0-beta02 for Compose Multiplatform.

One Off the Stack, One Off the Slack

You’ve got questions. That’s understandable!

Why Does My LaunchedEffect ANR?

LaunchedEffect() is not magic. It still runs your code on the main application thread. You remain subject to the rules of that thread, such as “do not block it indefinitely”. Learn more in this week’s highlighted Stack Overflow question.

Why Are My Window Insets Late?

Usually mutable data, especially mutable remembered State data, is the wrong answer, because changes to the content of the mutable data do not trigger recompositions. But, occasionally, you need to break the rules, such as when changing the PaddingValues used by consumeWindowInsets(), as we see in this week’s highlighted Kotlinlang #compose Slack thread.

Composable Commentary

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

How Jetpack Compose Measuring Works

Helios Alonso takes a deep dive into Compose UI’s composition/measurement/placement flow, with an eye towards the measurement phase and how to optimize it.

ANR internals: touch dispatching through the view hierarchy

Pierre-Yves Ricau (of LeakCanary fame) explores the legendary Application Not Responding (ANR) dialog, particularly for when it is triggered due to the app failing to respond to touch events in a timely fashion. PY uses that to look at how touch events get dispatched in both the classic View system and composables.

Medium: Composing AnnotatedString — Poetry, Music, Code, Blogs, Expandables and Beyond

Nirbhay Pherwani looks at AnnotatedString and the buildAnnotatedString DSL for creating richly-formatted text in Compose UI, including addUrlAnnotation() for links, expandable text, and more.

Medium: Debugging Jetpack Compose

Kaaveh Mohamedi worked to eliminate overcomposition in a sample app, using Compose compiler metric reports to identify non-skippable functions and fix up unstable model classes.

How to do a Material 3 pull refresh

Andrei Mukomolov wanted pull-to-refresh in a Material3 project. That combination is not officially supported at this time. Andrei’s team cloned the Material implementation and adjusted it to use the Material3 design system, resulting in this library.

Medium: Constraint Layout in Jetpack Compose

Kaushal Vasava walks us through the use of ConstraintLayout() in Compose UI as an alternative for Row()/Column()-centric layouts, to end up with more readable layout code.

Medium: Screenshot testing in Compose

Stefano Natali examines Roborazzi, a Roboletric-integrated screenshot testing library for Android. Roborazzi lets you write your screenshot tests to run on the JVM, rather than in the emulator. Stefano shows us how to use Roborazzi to write screenshot tests of our composables.

Medium: Best Practices for Compose Navigation in Multi-Module Project

Medium user Saqib explores ways of having your Navigation for Compose routes support screens defined in separate modules.

Resource Roundup

100% pure code!

GitHub: pratikksahu / JetPDFVue

GitHub user pratikksahu offers a library for viewing PDFs in composables, powered by the OS-supplied PdfRenderer. It supports horizontal and vertical paging, pinch-to-zoom, rotating pages, and integrated sharing options.

GitHub: TheChance101 / AAY-chart

GitHub user TheChance101 published a Kotlin Multiplatform charting library, supporting Android, desktop, iOS, and Web targets. It supports line, pie, donut, bar, and radar chart types.

GitHub: boswelja / compose-menuprovider

Jack Boswell created a composition local-based system to allow a common Scaffold() to host varying top bar actions. As you navigate, the composables for each screen can post their own menu items, which trigger recomposition of the top app bar.

GitHub: lukasroberts / AndroidLinkView

Lukas Roberts brings us a library that parses Open Graph metadata for a Web page and offers to builds a preview card for that page.