jetc.dev Newsletter Issue #171
Published: 2023-07-04
There is a new Compose Compiler version, a new Compose beta, and a new Compose Multiplatform patch release — we peek at all three!
In addition, we examine the impacts of ordinary var
properties, @Immutable
,
and @Stable
on recompositions. We see floating bubbles and improved animations
in action menus. Our rounded rectangles get smoother. And our string resources
get typesafe composable builders.
Ooooo… What Did We Get?
Reviewing the release notes for the latest Jetpack Compose update!
Compose Compiler is up to 1.4.8
and is able to target Kotlin 1.8.22
. It also improves
some errors and warnings around @Composable
annotation usage.
The main Compose dependencies are up to 1.5.0-beta03
. Other than adding support
for custom FocusTarget
implementations, and a new progress
property on states like
BottomSheetState
and ModalBottomSheetState
, this release is mostly bug fixes.
It feels like we will move into RCs and a stable release fairly soon.
In Compose-adjacent dependencies, Navigation for Compose is up to 2.7.0-beta02
.
Finally, Compose Multiplatform is up to 1.4.1
,
mostly with bug fixes.
One Off the Stack, One Off the Slack
You’ve got questions. That’s understandable!
Why Does Mutable Data Not Trigger Recomposition?
This keeps coming up, so I keep pointing it out through these questions… Compose
is powerful but it is not magic. In particular, changing the value of a plain var
often does not trigger recomposition, as a plain var
is not some form of State
that is being observed. Learn more in this week’s highlighted Stack Overflow question.
Why Does @Immutable Data Not Trigger Recomposition?
Sometimes, we want recomposition to be skipped, such as when data really does not
change but Compose might think it is. Two key tools for that are the @Immutable
and @Stable
annotations. However, the documentation is a bit confusing
(“positional memoization”?). Learn more about the practical impacts of these two
annotations in this week’s highlighted Kotlinlang #compose
Slack thread.
Composable Commentary
Posts, videos, and other new information related to Jetpack Compose!
Crafting a Floating Bubble in Android with Jetpack Compose
Vaios Tsitsonis needed a floating draggable bubble, akin to Android’s notification bubbles, but
within an app. The resulting implementation leveraged onGloballyPositioned()
,
pointerInput()
, and offset()
modifiers.
Medium: Performance With Jetpack Compose — Part 1
Udit Verma created a two-post series, demonstrating how to dramatically reduce
recompositions. The fixes ranged from simple remember()
calls through immutable/stable
parameters, deferring state reads by converting parameters to lambdas, and more!
Medium: Demystify Jetpack Compose Layout Constraint and Size Setting
Elye is back, this time examining the layout()
modifier. layout()
is very
powerful, but also is sometimes unintuitive, and Elye spends a lot of time explaining
its use.
Animated action menu
Chris Mack refines the animations used in this earlier Medium post, to avoid some jank, have the menu expand from where the member tapped on it, and more.
Medium: Jetpack compose — How to implement Custom Pager Indicators
HorizontalPager()
is great, and it has low-level support for pager indicators, but there
is a lack of actual indicator implementations. Radhika S shows how to implement a wide
range of indicators, from simple sliding bars to bouncing dots and more.
Bottom Bar Navigation in Jetpack Compose Example Android
Rhytham Negi walks us through a typical bottom tab bar implementation, using Navigation for
Compose to control the content rendered based on the selected tab, using a sealed class
to represent the bar items and their associated navigation routes.
Other Interesting Links
- Medium: Text Scrolling in Jetpack Compose
- How to Create AnnotatedString in Android Jetpack Compose
- Medium: Music Player in Jetpack Compose with Media3 Exoplayer
- Introduction to Jetpack Compose Layouts
- Material 3 TextField in Jetpack Compose (with Examples)
- Medium: Crafting a Clock in Jetpack Compose with Canvas
- Medium: Dark Theme Switch in Jetpack Compose with CompositionLocal
- Medium: How to play beautiful lottie animations in Android Jetpack compose
- Medium: Lottie Animation and Jetpack Compose
- Medium: Mastering the Power of State Hoisting in Jetpack Compose: Unleashing Seamless State Management Across Your UI Galaxy
- Medium: Mocking APIs in a Better way in Android Jetpack Compose
- Medium: Navigation bar with Jetpack Compose
- Medium: Paging in Android Jetpack Compose: From Caching Data with Room to Displaying in LazyColumn
- Medium: Room DB pagination without Paging Android Jetpack Compose
- Medium: Simplifying Authentication with Google Sign-In in Jetpack Compose UI
Resource Roundup
100% pure code!
GitHub: c5inco / smoother
Google’s Chris Sinco published a sample app demonstrating a SmootherShape
that implements a rounded rectangle with smoother corners, matching Figma’s approach.
GitHub: chrisbanes / material3-windowsizeclass-multiplatform
Chris Banes created an implementation of Material3’s window size classes for Compose Multiplatform, with support for Android, iOS, and desktop.
Paraphrase
The Cash App folks created a Gradle plugin that takes ICU message string resources and creates typesafe formatters for them, so you do not accidentally try to put a number into a string or vice versa. The formatters support both Compose UI and classic views.
Other Interesting Links
- GitHub: atsushieno / compose-audio-controls (knobs and keyboards)
- GitHub: JGomez-Dev / drag-and-drop-compose-library (modifier for list drag-and-drop for reordering)
- GitHub: rafaeltonholo / svg-to-compose (SVG paths to
ImageVector
code generator) - GitHub: razaghimahdi / Compose-Persian-Date-Picker (Persian date picker)
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?!?