jetc.dev Newsletter Issue #123
Two sets of releases came out this week for Compose, including one with support for Kotlin 1.7.0!
Beyond that, we look at what droidcon SF 2022 had to offer, what “stability”
means in the world of Compose, and how to apply
AnimatedContent(). We explore
shared element transitions and permission flows. And I’m grateful for the
new stable Compose Compiler and what that means for Compose development going forward.
NOTE: This newsletter will not be published next week, as I take a week off for the summer (Northern Hemisphere edition). The next issue after this one will be out in two weeks (July 19/20, depending on where you are).
Reviewing the release notes for the latest Jetpack Compose update!
The updates this week were complicated.
Compose Compiler is out with a
1.2.0 stable release. That contrasts with the
rest of Compose, which is on
1.2.0-rc03. This is because Compose library versions
are starting to become independent — more on this later in the newsletter.
Of note, Compose Compiler
1.2.0 supports Kotlin 1.7.0.
1.2.0-rc03 seems to contain only a few bug fixes, we also got
of the Compose libraries. Of note:
LookaheadLayoutadds a “lookahead” pass through the composition before the regular measure-and-layout pass. This can help with animations, such as shared element transitions.
AnnotatedStringnow supports a
UrlAnnotation, with an eye towards accessibility for links.
WindowInfo.keyboardModifierslets us observe a flow of states for keyboard modifiers (e.g., Shift)
Also, Wear Compose has
1.1.0-alpha01, with some improvements for
One Off the Stack, One Off the Slack
You’ve got questions. That’s understandable!
If you have ever looked at Compose Material composables, they are composables
calling composables calling composables calling yet more composables. At some
point, though, something somewhere has to be drawing some pixels, right? Learn
where that code resides in this week’s highlighted Kotlinlang
Droidcon San Francisco 2022
A bunch of great Compose and Compose UI presentations were included as part of droidcon San Francisco 2022, including:
- Branching out to Jetpack Compose
- Compose Beyond Material
- Something old, something new: Adding Jetpack Compose to a large open source Android app
- Retrofitting Legacy Code with Jetpack Compose at Scale
- Testing Jetpack Compose UI
- The Workflow Pattern, Composed
- What does Recomposition mean to your app?
Posts, videos, and other new information related to Jetpack Compose!
Google’s Jolanda Verhoef wrote the announcement post about how the Compose artifacts
will now be independently versioned for make it easier for you to incrementally
update your app. The first such independently-versioned artifact is the Compose
Compiler, where you can use
1.2.0 (and its support for Kotlin 1.7.0) while
1.1.0 of other Compose artifacts.
Google’s Ben Trengrove walks us through the concept of “stability” in Compose, including using compiler reports to help identify stability gaps and how to replace unstable types with stable counterparts. The net result: Compose can do a better job of skipping unnecessary recompositions, improving your app’s performance.
Google’s Rebecca Franks contributed another post on animation, this time examining
AnimatedContent() composable for things like transitions between
two screens and a custom
transitionSpec to tailor how those transitions get
Alex Zhukovich explains how we can use
createAndroidComposeRule() to write
tests where we have ways of getting the values of string resources in test code,
for use in comparing with text rendered by our composables.
The SemicolonSpace team looks at using Accompanist’s
SystemUiController to get
at our system bars and use that to customize the color of the system bar and the
navigation bar. They also explore hiding those bars and displaying content behind
Frequently, our app widgets need to be updated in the background periodically.
Ahmed Samir demonstrates how to accomplish this with a Glance-powered composable
app widget, using
WorkManager for periodically hitting a Web service using Retrofit.
Marco Gomiero has been experimenting with Kotlin/Multiplatform;
he wrote a couple of years ago about setting up the shared architecture.
In this new post, Marco reports on efforts to improve the implementation, including
how to use
Flow in Swift and how that simplified the shared use case and the
Other Interesting Links
- Medium: No emulator needed for screenshot tests of Compose @Previews on CI
- Jetpack Compose :Managing UI State Changes in our ViewModel
- Animation in Jetpack Compose
- Video: Migrating an existing project to Jetpack Compose
- Medium: Jetpack Compose Theming: Typography — Part I
- Medium: The Future of Writing Tests for Jetpack Compose in Android
- Medium: How to display HTML using Android Compose
- Video+Chat and Calculator samples for Jetpack Compose
- Medium: Parallel processing with state management in Lazy Column
- Creating custom layouts with Jetpack Compose
- Medium: Collapsible Extended Floating Action Buttons with a LazyColumn in Jetpack Compose
- Creating a Nested Scroll Music Player App in Jetpack Compose
100% pure code!
Shreyas Patil is back, this time with a library that allows you to subscribe
to updates to permission availability via
StateFlow, to make it easier to write
composables that render differently depending on whether or not you have a
Bishal Singh brings us another composable implementation of a PIN or OTP code entry widget. This one supports both filled and outlined styles, along with a variety of other look-and-feel customizations.
Other Interesting Links
- GitHub: Wavesonics / richtext-compose-multiplatform (Kotlin/Multiplatform editor composable)
- GitHub: manalkaff / JetStick (joystick widget)
- GitHub: syslogic / androidx-colorpicker (color picker)
- Appyx (navigation)
- GitHub: holixfactory / bottomsheetdialog-compose (bottom sheets)
…And One More Thing
This week’s announcement that Compose libraries will be versioned independently on the whole should be a positive development. In particular, decoupling the Compose compiler version from the runtime library versions will help with the ever-present “hey, when will Compose support such-and-so Kotlin version” — we see the first example of that with this announcement.
Ordinary developers will need to keep track of which library versions work with which other library versions. That will be particularly important for those who use pre-release versions, as they might not necessarily work well with stable releases of other Compose libraries. While transitive dependency declarations mean that you should get the right versions of the libraries automatically most of the time, you might find that you wound up with newer versions of some Compose libraries than you expected.
Hopefully, this will not impact developers of third-party libraries too much. It will be important that they document their Compose version expectations, particularly where they are unusual. For example, Jaewoong Eum did that with Orbitary, noting how it relies it relies on some pre-release library versions.
Overall though, independent versioning, particularly of the Compose compiler, is a sign that the Compose system is maturing, IMHO. I’m sure that the Compose developers would have loved to have been at this state with the initial stable release, but we don’t always get what we want. And while we may stub our toes from time to time with changes like this, that’s a price we pay with any transition, and one that experienced developers are very used to.
- 2022-08-09: droidcon Berlin 2022! Animating text! Shimmers! Recompositions! Animations! Charts! Cameras!
- 2022-08-02: Compose 1.2.0! Wear Compose 1.0.0! Gradients and text! Foldables! Drag-and-drop! And @andersullnass on snapshot testing!
- 2022-07-26: New compiler beta! Overlapping composables! RecyclerView! movableContentOf()! JSON forms! And @anafthdev_ shows us composable picker wrappers!