jetc.dev Newsletter Issue #232

Published: 2024-09-17

Adaptive layouts got a lot of love this week, between Google posts and a Compose Multiplatform beta.

Also, we look at flow layouts and SharedBounds, and we peek at a pair of image cropping libraries. Plus, I describe a problem I had with remember() not remembering.

Ooooo… What Did We Get?

Reviewing the release notes for the latest Jetpack Compose update!

A Compose 1.7.1 patch release (and a 2024.09.01 BOM) were released. It does not appear as though there were any bugs fixed. Instead, it was mostly for Compose Multiplatform downstream.

Speaking of Compose Multiplatform, JetBrains released 1.7.0-beta02. Material3 Adaptive Navigation is included, iOS has basic support for BasicTextField(), etc.

One Off the Stack, One Off the Slack

You’ve got questions. That’s understandable!

Why Am I Getting the Wrong Context?

One of the dangers with composables being top-level functions is that developers sometimes think that they can be used from anywhere. Technically, they can, but it may not work as you might expect. For example, having a composable be in the same file as an activity does not mean that navigating to that composable starts that activity, as we see in this week’s highlighted Stack Overflow question.

Can I Do Screenshot Testing with Compose Multiplatform?

Google is working on Compose Preview Screenshot Testing, but there may be some limitations when using CMP resources, as we see in this week’s Kotlinlang #compose Slack thread.

Composable Commentary

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

Jetpack Compose APIs for building adaptive layouts using Material guidance now stable

Google’s Alex Vanyo reviews the Compose Material3 Adaptive family of libraries for helping developers better deal with varying screen sizes, foldable postures, etc. One interesting finding: despite the name, most of these libraries have no actual dependency on the Material3 design system and might be usable with non-Material custom design systems.

SAP integrated NavigationSuiteScaffold in just 5 minutes to create adaptive navigation UI

Google’s Alex Vanyo profiles SAP’s use of NavigationSuiteScaffold() and related composables from Compose Material3 to better adapt to varying screen sizes.

Video: Flow Layouts

Google’s Rebecca Franks continues the Jetpack Compose Tips video series with one exploring FlowRow() and FlowColumn(), including using arrangements for spacing, capping the maximum number of items per row/column, achieving grid-like effects, and more.

Video: Navigation Compose meet Type Safety

Google’s Clara Fok walks us through the type safety options provided in the now-stable 2.8.0 edition of Navigation for Compose. Clara reviews the basics of declaring type-safe routes and using them, plus explores how these work with deeplinks.

Medium: Migrating Jetpack Compose for TV from alpha to stable

Google’s Paul Lammertsma explains what all changed in the TV Compose world since the earlier alpha releases. Some containers (e.g., TvLazy*()) were deprecated and replaced by similar functionality in Compose Foundation, though you now need to deal with pivot offsets yourself. A few composables were renamed, and a few others were removed.

Video: Android Developers Backstage: Compose Animations

Google’s Doris Liu met with the Android Developers Backstage team to provide a deep dive into animations in Compose, from foundational concepts to newer options like shared element transitions.

Medium: Mastering Jetpack Compose: SharedBounds vs SharedElement (Part 2)

Akbar Dzulfikar has a two-post series on Compose animations! Part 1 looks at shared element transitions. Part 2 contrasts that with shared bounds transitions and shows how to implement those using the sharedBounds() modifier.

Medium: How to Integrate ViewModel in Kotlin Multiplatform with Koin

Medium user Meet looks at using Koin for injecting Jetpack ViewModel instances into your composables in a Compose Multiplatform project for Android, iOS, and Desktop.

When remember() Does Not Remember, Consider if()

I ran into some challenges where it felt like my remember() calls were no longer working. The results demonstrate how Compose magic can make subtle code changes have farther-reaching impacts than one might expect.

Resource Roundup

100% pure code!

GitHub: dellisd / maplibre-compose

Derek Ellis provides us with composables for rendering maps powered by MapLibre.

GitHub: Lilytreasure / MultiplatformWebview

Dennis Wanja has a WebView wrapper for Compose Multiplatform, supporting Android and iOS, with a simple API for finding out when links are clicked.

GitHub: timhuang1018 / Krop

Tim Huang brings us a Compose Multiplatform library (all platforms) for image cropping, powered by Coil. Just wrap an AsyncImage() in a Croppable(), and you are set!

GitHub: arielmazor / cropper

Ariel Mazor also implemented an image cropper, in the form of a Cropper() composable.

Notable Releases

Accompanist is up to 0.36.0, fixing a documentation bug and upgrading its Compose dependencies to 1.7.0.

Horologist is up to 0.6.19, also upgrading its dependencies to Compose 1.7.0.

Similarly, Compose Destinations is up to 1.11.6, with dependency updates to Compose 1.7.0 and Navigation for Compose 2.8.0.