jetc.dev Newsletter Issue #157

Published: 2023-03-21

This week, we look at code organization, custom layouts, and text entry in Wear Compose. We also peek at a preference UI and a custom switch implementation.

One Off the Stack, One Off the Slack

You’ve got questions. That’s understandable!

Unfortunately, the Linen archive of Kotlinlang Slack is somewhat broken as I prepare this newsletter, so I will not have a highlighted #compose Slack post 😞. Also, if you use Kotlinlang Slack, note that they created a separate #compose-android channel, so #compose can be limited to general Compose and Compose UI questions.

Why Do We Lose Weight?

Weight on a Row() needs to be applied to the direct children of the row… even if those children are not the actual UI elements that you might think need the weight. See how AnimatedVisibility() can break your weight expectations in this week’s highlighted Stack Overflow question.

Composable Commentary

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

Video: Compose Layouts and Modifiers: Live Q&A - MAD Skills

Google’s Chris Arriola, Andrei Shikov, Simona Stojanovic, and Jolanda Verhoef spent about 45 minutes taking Compose UI questions, ranging from when it makes sense to create a custom layout to the state of experimental Compose features.

Organize your Views: Jetpack Compose edition

Marco Gomiero walks through one possible way of organizing your Navigation for Compose code, including how to have a simpler NavHost() and how to structure the screens that you navigate to.

Custom Compose Layouts

Beatrice Kinya explores SubcomposeLayout(), how it ties into the composition/layout/drawing triad of phases, and when you might consider using it.

Medium: Infinite Scroll with Paginated API calls in Jetpack Compose

Medium user MathRoda examines how to detect when the user has scrolled to the bottom of a LazyColumn(), so you can load the next page of data from a paginated server API.

Medium: Overlapping profile pictures with Jetpack Compose Modifier

A common UI pattern for social screens is having overlapping user avatars, often with a circular crop. Baptiste Carlier explores how to implement that sort of overlap effect, creating some custom modifiers (like circleCrop()) along the way.

Medium: Typing on a Tiny Screen

Entering text on a watch sucks. Entering text on a Compose UI app on a watch is worse, because EditText() does not appear to be available yet there. Katie Barnett shows how to handle this the hard way, using RemoteInput.

Jetpack Compose: Switch

Alex Zhukovich takes a deep dive into the Switch() composable, including what differs between Compose Material and Compose Material3 and how to test composables that contain switches.

Medium: Jetpack Compose: Remember vs RememberSaveable

Morteza Taghdisi reviews the differences between ordinary remember() and rememberSaveable(), including the benefits and limitations of the latter.

Resource Roundup

100% pure code!

GitHub: markusressel / KutePreferences

Markus Ressel brings us a library for rendering a preference UI using Compose Material3m including a KutePreferencesScreen() composable and associated KutePreferencesViewModel.

GitHub: razaghimahdi / ImageSwitch

GitHub user razaghimahdi shows us an ImageSwitch() composable that uses an image for the track portion of a switch.

Gist: bagus2x / ExoPlayerState.kt

Tubagus Saifulloh shows some Compose snippets for pausing ExoPlayer playback when the activity is paused, then resuming playback when the activity is resumed, via a rememberExoPlayerState() composable.