jetc.dev Newsletter Issue #168

Published: 2023-06-06

This week, we avoid duplicate navigation and unit test State. We look at performance, animations, and sticky headers. And we see libraries for dialogs, countries, … and squircles.

NOTE: I am taking next weekend off. As a result, the next issue of this newsletter will be published on June 20.

One Off the Stack, One Off the Slack

You’ve got questions. That’s understandable!

How Can I Avoid Navigating Twice?

If you are not careful, you can wind up in situations where multiple user inputs, such as multiple button clicks, lead you to trigger navigation more than once. Google’s Ian Lake shows us how to detect duplicate-navigation events in this week’s highlighted Stack Overflow question. See also this related Medium post.

How Do I Unit Test State Emissions?

If you have a viewmodel that exposes a State, probably you should have some tests for that State. Jake Wharton points out the snapshotFlow() solution in this week’s highlighted Kotlinlang #compose Slack thread.

Composable Commentary

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

Video: Jetpack Compose Performance Performance and a bit more Performance

The Code with the Italians crew hosted Google’s Sean McMillan, exploring Android Studio’s tools for helping you measure the performance of your composables, plus some approaches towards fixing the performance issues that you encounter.

Medium: How to create an amazing CollapsingTopAppBar in Jetpack Compose with Motion Layout

Collapsing app bars let you have a rich set of top content on a screen that then slides away as the user scrolls. Adolfo Chavez uses MotionLayout() and JSON-defined transitions to implement the effect.

Blossoming love for Compose animation

Kristen Halper wraps up her blog series on Compose animations, extending the previous posts to show multiple parallel animations and using shaders to provide background (in this case, grass behind sunflowers).

Medium: Observing Network Connection State using Jetpack Compose — Android

Daniel Atitienei shows how to build a Flow of network connection states using callbackFlow(), then shows how to convert that Flow to State via a custom rememberConnectivityState() composable function.

Medium: Jetpack Compose — Deep-dive into derivedStateOf and comparison with remember(key)

Saqib looks at derivedStateOf(), showing when you should use it and how it relates to using a key value with remember(). In a nutshell, derivedStateOf() is great for state that depends on other state, but where changes in that other state might not result in changes to the derived state. In this fashion, you may be able to minimize some recompositions.

Medium: Kotlin with Jetpack Compose -Tabs

Maneesha Erandi examines the TabRow() and Tab() composables for implementing a top tab bar, with a HorizontalPager() implementing the tab content itself.

Medium: Jetpack Compose List Sticky Header

Igor Stevanovic examines the stickyHeader() DSL function for LazyColumn() and LazyRow(), used for adding sticky rows or columns.

Resource Roundup

100% pure code!

GitHub: stoyan-vuchev / squircle-shape

Stoyan Vuchev brings us a Shape implementation, SquircleShape, which offers a flexible API for defining squircles with a variety of corner radii and smoothing approaches. This can be used wherever you use other Shape objects, such as in a clip() modifier.

GitHub: akshaaatt / Dialogs-Android

Akshat Tiwari published a library with a variety of canned composable dialog implementations, for input boxes, simple messages, and more.

GitHub: nkuppan / country

Naveen Kumar Kuppan created CountrySelectionDialog() and CountrySelectionPage() composables, as part of a pair of libraries (for Compose and classic views) that let you pick a country from a list of countries.