jetc.dev Newsletter Issue #128
Releases are getting more complicated, where we got 1.2.1, 1.3.0, and
all at the same time!
Beyond that, we look at text in a
Canvas() spend a lot of time on performance,
including the use (or non-use) of
@Stable. We examine consuming flows, implementing
effects, and how Live Literals work. And we see how, with an annotation and a library,
we can even get rid of having an
Activity in our Compose UI apps.
Release Roundup and Alpha Analysis
Reviewing the release notes for the latest Jetpack Compose update!
Compose Compiler 1.3.0 is now stable, mostly for getting us up to Kotlin 1.7.10.
We also got 1.2.1 patch versions for the rest of the Compose artifacts. Those fix memory leaks and other bugs.
1.3.0-alpha03 is out!
LayoutCoordinatesgot a bunch of changes, including
Font support was improved with
Paragraph is now a
sealed interface, mostly to help with implementing
it for both Compose for Android and Compose for Desktop.
One Off the Stack, One Off the Slack
You’ve got questions. That’s understandable!
We now have
Canvas(). However, controlling the positioning is
not as straightforward as it might be in a
Box(). Learn how to use a
to center the text in this week’s highlighted Stack Overflow question!
@Immutable are recommended for Compose, to help guide where
we can skip recompositions. But, how awful is it to have never used them?
Learn more in this week’s highlighted Kotlinlang
#compose Slack thread!
Posts, videos, and other new information related to Jetpack Compose!
Google’s Manuel Vivo walks us through the use of the new
to convert a
Flow into a
State for use in a Compose app. As one might
collectAsStateWithLifecycle() is also lifecycle-aware, defaulting to
only collecting while the associated lifecycle is at least
Compose performance is a recurring concern for developers. Pratham Arora did some
performance analysis of two screens implemented both in the classic
system and in Compose UI, using
FrameMetricsAggregator for measuring results.
OK, so, what can we do about performance? One common area of poor performance is over-composition, where we recompose again and again and again unnecessarily. Radhika S’s post reminds us of how recomposition works and points out some common mistakes one can make when dealing with recomposition.
Ji Sungbin then looks at a specific aspect of recomposition: stability. Proper use of stable/immutable data types can greatly enhance Compose’s ability to optimize recompositions, ignoring branches that should be unchanged because the inputs have not changed.
Ji Sungbin also looked at how Live Literals work, indicating that the build process
is converting literals (of some types) into
State wrappers around those literals,
so they can be updated on the fly by the IDE. Ji also points out the
annotation to block this code generation for places where it is unnecessary and
Auto-sizing text is used to help ensure everything fits in a given space… but
frequently it is only for static text. Ban Markovic wanted auto-sizing text in
a field. Ban accomplished this using
BoxWithConstraints() as a wrapper around
Other Interesting Links
- Video: Animating Your Way Into Jetpack Compose
- How to use Downloadable Fonts with Jetpack Compose
- How To Build a Custom Pager Indicator In Jetpack Compose
- Medium: Accompanist — the first chord. A Jetpack Compose library reviewed
- Medium: Why We Adopted Jetpack Compose
- Medium: Is Jetpack Compose Ready for You?
- Medium: Appyx vs Jetpack Compose Navigation
- Medium: How to Do Runtime Permission Handling in Jetpack Compose
- Medium: How to use Palette API with Jetpack Compose
- Medium: Android Jetpack Compose Permissions
- Lazy Layouts in Jetpack Compose
- Build a Real-Time Android WhatsApp Clone With Jetpack Compose
- Jetpack Compose 101: The Basics
- Medium: Jetpack Compose and the conundrum of selecting a suitable architecture
- Medium: Getting Started With MVVM in Jetpack Compose
- Medium: Basic Android Compose - Dynamic Lazy Column
- How to create GridView using Jetpack Compose
100% pure code!
Mori Atsushi noticed that our Compose UI activities tend to be rather boilerplate,
so Mori created a library that code-generates them for us. Simply add
annotations to composables that represent the content for activities, and Mori’s
KSP-based generator will set up the activity class and the manifest entry for you.
- 2023-11-21: Compose/Material3/Wear Compose updates! remember()! Adaptive layouts! Compose Multiplatform in 2024! @firstname.lastname@example.org on BasicTextField2()! Compose Multiplatform charts! And... is TV Compose in trouble?!?
- 2023-11-14: Compose Compiler! BasicTextField2()! @email@example.com and animations! Optimization! @firstname.lastname@example.org, JetBrains, and Fleet! JetBrains and plotting! And... we collapse?!?
- 2023-11-07: Compose Multiplatform! Chips in fields! Diffing! Custom fonts in Glance app widgets! Heatmaps! PIN input! And @email@example.com is in a bit of a haze?!?