jetc.dev Newsletter Issue #215
Published: 2024-05-21
Google I|O 2024 brought us lots of information, along with a newly-minted Compose beta and other goodies!
Beyond that, we look at taking images with CameraX and displaying images with Coil3’s Multiplatform support. We deal with Dagger and see the effects of JIT and AOT on Compose code. And we see an intriguing approach for helping steer your development teams to use your design system composables.
Ooooo… What Did We Get?
Reviewing the release notes for the latest Jetpack Compose update!
Compose Compiler is up to 1.5.14
, adding support for Kotlin 1.9.24
and fixing a bug.
The core Compose artifacts are up to 1.7.0-beta01
, suggesting that a stable 1.7.0
is
perhaps a couple of months away. Of note:
-
The
anchoredDraggable()
honors RTL in a horizontal container -
The API surface changed for getting Material-themed links into
Text()
Compose Material3 and its sub-artifacts are up to 1.3.0-beta01
. Unfortunately,
the Compose Material3 release notes
are broken — while sub-artifacts like androidx.compose.material3.adaptive:adaptive
are up that first beta, the docs do not cover the newer versions.
Glance now has a 1.1.0-rc01
release, so a stable 1.1.0
is not far off. Glance @Preview
composables now can have a custom height and width, but we lost support for Wear OS tile previews.
Note that androidx.glance:glance-appwidget-external-protobuf
is a new artifact.
Wear Compose is now at 1.4.0-beta01
.
CameraX now has a composable viewfinder, available in the new androidx.camera:camera-viewfinder-compose
library.
In Compose-adjacent artifacts, we got:
androidx.fragment:fragment-compose:1.7.1
androidx.fragment:fragment-compose:1.8.0-beta01
androidx.lifecycle:lifecycle-runtime-compose:2.8.0
androidx.lifecycle:lifecycle-runtime-compose-android:2.8.0
androidx.lifecycle:lifecycle-runtime-compose-desktop:2.8.0
androidx.lifecycle:lifecycle-viewmodel-compose:2.8.0
androidx.lifecycle:lifecycle-viewmodel-compose-android:2.8.0
androidx.lifecycle:lifecycle-viewmodel-compose-desktop:2.8.0
androidx.navigation:navigation-compose:2.8.0-beta01
androidx.navigation:navigation-fragment-compose:2.8.0-beta01
However, see the Stack Overflow question later in this newsletter for a problem with the stable Lifecycle for Compose release!
Also, Compose Multiplatform is up to 1.6.10-rc03
already!
Google I|O 2024!
Google I | O 2024 happened! And, surprisingly, not everything was about Gemini! 😜 |
The overall conference YouTube playlist has a number of Compose-centric talks, including:
- Build beautiful Android widgets with Jetpack Glance
- Building adaptive Android apps
- Building UI with the Material 3 adaptive library
- Designing scalable Compose APIs
- How to analyze and improve performance of your Jetpack Compose app
- How to build engaging Android Media & Camera experiences
- More with maps in your Android app with Jetpack Compose
- What’s new on Google TV and the Android TV OS
Compose-related blog posts tied to the conference include:
- Get the big picture with Large Screens at Google I/O 2024
- Scaling Across Screens with Jetpack Compose @ Google I/O ‘24
- SoundCloud supported more screens using 45% less code with Jetpack Compose
- What’s new in Jetpack Compose at I/O ‘24
mDevCamp 2024
Prague hosted mDevCamp 2024 in April, and there were two Compose-centric presentations:
- Build Apps for iOS, Android & Desktop in 100% Kotlin With Compose Multiplatform
- Compose-View Interop in Practice
One Off the Stack, One Off the Slack
You’ve got questions. That’s understandable!
Why Is CompositionLocal
LocalLifecycleOwner
Not Present?
The Lifecycle Compose stable 2.8.0
updates themselves depend on the beta release of
Compose, so be careful about updating. See this issue
for more, including some workarounds, as mentioned in an answer to this week’s highlighted
Stack Overflow question.
How Can I Track State Changes… As State?
If you wanted to track how many times a State<Boolean>
had a certain value, you are in a bit
of a bind. The State
snapshot system tracks state, and when a State
value changes is an
event. Learn more, including some workarounds and alternatives, in this week’s highlighted
Kotlinlang #compose
Slack thread.
Composable Commentary
Posts, videos, and other new information related to Jetpack Compose!
Video: Say cheese! Elevate your camera app with CameraX and Jetpack Compose
Google’s Jolanda Verhoef explores how to take photos from your Compose for Android app, both
using an Intent
to launch the built-in camera app to using CameraX with the
new androidx.camera.viewfinder-compose
library.
Medium: How to use Coil in Compose Multiplatform
Kashif Mehmood examines an early alpha version of Coil3, which adds Compose Multiplatform support for Android, iOS, desktop, and Web/Wasm to perhaps the most popular image loading library for Compose development.
Medium: Injecting Composables with Dagger without losing it
If you are doing Compose development, you are perhaps using Hilt, or maybe Koin if you are aiming for Compose Multiplatform. If instead you are limited to just Dagger 2, as Costa Fotiadis is for one app, you may be in for a bit of additional work. Costa helps explain how to blend Compose for Android and Dagger 2 together, allowing Dagger to inject dependencies into composables.
Medium: Comparing Jetpack Compose performance with XML
Rajan Gupta conducted a nice performance comparison of classic views with Compose for Android, taking into account AOT and JIT (i.e., taking into account that it takes some time for your composable code to “warm up”). While the experiments used an ancient Compose build, they do illustrate the impact of ART’s AOT/JIT support and show how in time your composables should perform fairly well.
Medium: Jetpack Compose Screen Navigation With Type Safety
Tomáš Repčík examines the latest Nav for Compose alpha, specifically at the new argument type safety feature. Tomáš looks at everything from simple routes to passing rich serialized data.
The Many Approaches to Providing @Preview data in Jetpack Compose
Donovan LaDuke explores all of the different ways you can supply data to a @Preview
composable for rendering, from simple hard-coding to PreviewParameterProvider
to
the use of factory functions.
Other Interesting Links
- Consuming Jetpack Paging KMP code in SwiftUI and Compose clients
- Medium: Android — Create Awesome Animation in Google Maps Compose
- Medium: Android, Compose and automated screenshots making
- Medium: Animate Text Appearance with Icon in Jetpack Compose
- Medium: Announcing the Compose Accessibility Techniques for Android™ Open Source Project
- Medium: Best practices in Jetpack Compose Navigation
- Medium: Building an Amazing 3D Pie Chart with Jetpack Compose
- Medium: Compose Chronicles: The Cleanup Crew — Keeping Your Compositions Tidy with DisposableEffect
- Medium: Do NOT Make This Navigation Mistake in Jetpack Compose
- Medium: Dynamic Theming in Jetpack Compose with Jetpack DataStore and View Models
- Medium: Exploring Shared Element Transitions in Jetpack Compose
- Medium: Level Up Your Career by Adding UI Tests to Your Jetpack Compose App
- Medium: Need of ViewCompositionStrategy in Jetpack Compose
- Medium: Understanding the Layout composable in Jetpack Compose
- Tidbits About Compose Web
- XML Based UI to Jetpack Compose Migration
Resource Roundup
100% pure code!
GitHub: ozontech / kelp
One challenge with using Compose is steering developers towards using your design system composables, rather than “raw” ones provided by Compose itself. The Ozon team took an interesting approach towards addressing that problem, in the form of an Android Studio plugin that puts an icon for your design system in code-completion lists and gutters, in addition to offering some live templates and other features. Here’s hoping that this eventually supports IDEA and Fleet for Compose Multiplatform development!
GitHub: j-roskopf / ComposeGuard
GitHub user j-roskopf published a Gradle plugin that helps you detect when you have added new code that contains Compose mal-optimizations, such as non-stable classes or “restartable but not skippable” composables.
GitHub: hehua2008 / ComposeSubsamplingImage
GitHub user hehua2008 created a version of a legendary Android library that supports rendering huge images by subsampling, with built-in zoom support. The important aspect: this library supports Compose Multiplatform for Android, iOS, and desktop targets.
GitHub: BadKiko / kige
GitHub user BadKiko brings us a bottom sheet image picker implementation, as an alternative to the standard Android one.
Other Interesting Links
- GitHub: ahmmedrejowan / CountryCodePickerCompose (country phone prefix picker)
- Mosaic Slider (alternative to
Slider()
)
Notable Releases
Alex Styl’s compose-menu
is up to 1.4.0
with support for alignment
on MenuContent
.
Conveyor — a multi-platform desktop software packaging tool with KMP and CMP support —
is up to 14.2
, mostly with bug fixes.
…And One More Thing
Google’s endorsement of Kotlin Multiplatform is rather nice. It was clear from moving some Jetpack libraries to be KMP-compatible that they supported KMP, but the announcement should help with skittish decision-makers.
Note that they did not mention Compose Multiplatform in that written announcement. The word “Compose” does not even appear. My guess is that they will endorse that in the future, as evidenced by the move of the Compose Compiler into the JetBrains ecosystem. But, even without that, having KMP be supported officially only helps CMP’s position.
Congratulations to JetBrains and the other firms backing KMP, such as my former compatriots at Touchlab!
Or, you can subscribe to the Atom feed or follow Mark Murphy in the Fediverse.
Recent Issues:
- 2024-11-12: @cbruegg@mastodon.green on Compose 1.7 and compatibility! @eevis@mas.to on rendering text in a Canvas! @sinasamaki@androiddev.social and a centered slider! @touchlab@mastodon.social with a Compose-Swift bridge! And... is NavigationSuiteScaffold() FAB?!?
- 2024-11-05: Compose patch release! Compose alpha! 2025 Compose Multiplatform plans! Glance! Side panels! @theapache64@androiddev.social on performance! Tables! And... reacting to a broadcast from a composable?!?
- 2024-10-29: Relay! Paparazzi! droidcon Lisbon 2024! Server-defined UI! And... desktop OS trays?!?