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!
How Do We Center Text in a Canvas()?
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!
Do We Really Need @Stable?
@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!
Medium: Consuming flows safely in 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
Medium: Comparing Jetpack Compose performance with XML
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.
Medium: Quick Note on Jetpack Compose Recomposition
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.
Medium: Optimizing Recomposition in Jetpack Compose: Stability System
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.
Medium: Exploring Jetpack Compose’s Hot-Reload Feature
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
Jetpack Compose Effect Handlers
Jorge Castillo has a new edition of his post reviewing the different types of effects
SideEffect, etc.), reviewing their distinct
roles and use cases.
Medium: AutoSize TextField in Android Jetpack Compose
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!
GitHub: Mori-Atsushi / compose-launcher
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.
GitHub: jaikeerthick / Composable-Graphs
Jai Keerthick created a library offering composables for rendering line and bar graphs, with some flexibility in terms of colors, labels, etc.
Or, you can subscribe to the Atom feed or follow Mark Murphy in the Fediverse.
- 2023-05-30: Compose beta! Tracking continuous composable presses! Animated carousels! MVI! 2D scrolling layouts! Tables! And... a stable function?!?
- 2023-05-23: Focus and preview cards for Compose for TV! Interactions and visual states! ViewCompositionStrategy! Compose for iOS, for real! @firstname.lastname@example.org is zooming! Data tables! And... BasicTextField2, the sequel?!?
- 2023-05-16: Google I/O! New Compose BOM and alpha! Viewmodels! BottomScaffold()! SealedX! Lottie! Dynamic themes! Floating action menus!