jetc.dev Newsletter Issue #193

Published: 2023-12-05

This week, we peek at the latest Compose updates and determine when words are pressed upon. We play with Compose Multiplatform, implement in-app dynamic font scaling, and tell the Compose Compiler that we’re the stability boss. Plus, we look at a more powerful bottom sheet, supporting intermediate states between open and closed.

Note that I am taking a one-week break for an actual, honest-to-goodness vacation. The next issue will go out in two weeks (December 19th in my time zone), rather than in just one.

Ooooo… What Did We Get?

Reviewing the release notes for the latest Jetpack Compose update!

The main Compose libraries are up to 1.6.0-beta02, with a handful of small bug fixes. It feels like we should move to an RC release soon, though a 1.6.0 stable release probably will not happen until January at this point.

Compose Material3 is up to 1.2.0-alpha12. Of note, RangeSlider and SnapFlingBehavior now use an ordinary Kotlin range (e.g., 1f..10f) instead of a custom range implementation.

In Compose-adjacent dependencies, androidx.activity:activity-compose now has 1.9.0-alpha01.

One Off the Stack, One Off the Slack

You’ve got questions. That’s understandable!

How Do I Detect Press-Down Events Within Text?

ClickableText() supports onClick and onHover events, but not onPressDown or something similar. However, you can accomplish this using ordinary Text() by use of a pointerInput() modifier and detectTapGestures(), as we see in this week’s highlighted Stack Overflow question.

Why Do I Need null Checks In AnimatedVisibility()?

What starts with “can I get rid of this !! operator?” turns into a discussion of AnimatedVisibility() versus AnimatedContent(), using keys with AnimatedContent() to avoid unnecessary animations, what null means to AnimatedContent(), and more!

Composable Commentary

Posts, videos, and other new information related to Jetpack Compose!

Video: Build Apps for iOS, Android, and Desktop With Compose Multiplatform

Sebastian Aigner and Márton Braun of JetBrains delivered an online presentation walking through building a bird app using Compose Multiplatform, supporting Android, iOS, and desktop. See this Medium post for a longer summary of what was covered!

Dynamic Font Sizes With Jetpack Compose

Oya Canli shows how you can have dynamic typography in your design system theme courtesy of recomposition, so your theme can react to user-chosen in-app font scaling.

Medium: Exploring Jetpack Compose Compiler’s Stability Config

Francesc Vilarino Guell is back, explaining how Compose Compiler 1.5.5 and higher allow you to tell the compiler what classes should be treated as stable, via stabilityConfigurationPath and a plain text file (versus annotations, which you cannot apply to third-party code).

Medium: Inner Shadow in Jetpack Compose

We often talk about shadows, but we usually consider them to be outside of the composable casting the shadow. Medium user Kappdev explores inner shadows, where the shadow lies inside of a composable, because only part of the composable is casting that shadow. Kappdev creates an innerShadow() modifier to implement this pattern.

Custom Pull to Refresh in Jetpack Compose

sinsamaki walks us through using the official pull-to-refresh implementation, based on rememberPullRefreshState() and PullRefreshIndicator(). From there, sinsamaki adds haptic feedback and a few custom indicators.

Handling State in Jetpack Compose

Joel Muraguri explores mutableStateOf(), state hoisting, and viewmodel-based state management.

Medium: Drawing with Compose : The Animated String Path

Hugo Djemaa demonstrates animating an SVG path, using PathParser and PathMeasure.

Resource Roundup

100% pure code!

GitHub: skydoves / FlexibleBottomSheet

Jaewoong Eum created a library offering alternative bottom sheet options, including non-modal ones and ones with intermediate positions between open and closed. Versions are available for Compose Material and Compose Material3.

GitHub: afreakyelf / Pdf-Viewer

Rajat Mittal brings us an extensive PDF viewing library, including support for a PdfRendererViewCompose() that displays a PDF in a composable. It uses the platform PdfRenderer class, so the standard limits of that class apply.

GitHub: emirhanemmez / MultiStepsProgressBar

Emirhan Emmez created a MultipleStepsProgressBar() composable that shows progress for multiple items at a time.

GitHub: tfaki / CountryCP

Talha Fakıoğlu offers us a CountryCP() composable for allowing the user to find a particular country, with an eye towards obtaining the phone number prefix (e.g., +1 for US).