jetc.dev Newsletter Issue #255

Published: 2025-02-25

This week, we look at viewmodels for previews and whether we opt out of being remembered. We peek at TV Compose and create a safer marquee effect. And we explore a server-defined UI framework for Compose Multiplatform.

Note that I will not be publishing an issue on March 4. Issue #2^8 (#256) will be released on March 11.

One Off the Stack, One Off the Slack

You’ve got questions. That’s understandable!

Can I Use a ViewModel In My @Preview?

Generally speaking, the answer is “no”. The recommendation is to limit how deep you pass a ViewModel in general, preferring simple parameters for the sorts of composables that need to be previewed. See how to split a composable into a ViewModel-based one and a simple parameter-based one in this week’s highlighted Stack Overflow question.

Do We Have a Right to be Forgotten?

A request came in to have an annotation or something that indicates the value should not be remembered, even though it could be. After the initial “WTF?” reaction, the consensus was that there are better solutions for the problem, as we see in this week’s highlighted Kotlinlang #compose Slack thread.

Composable Commentary

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

Video: Compose for TV

Google’s Paul Lammertsma (Mastodon) provides an overview of TV Compose, including the TV Material library, and how you can use it to provide a TV-centric interface in parallel with the one for your mobile app.

Flat approach for tabbed Navigation in Jetpack Compose

The Pale Blue Apps team compares using nested nav graphs for tabbed navigation to having a single nav graph with conditional rules for whether or not to display tabs when on a particular destination.

Making basicMarquee-Modifier More Accessible

Eevis Panula (Mastodon, Bluesky) shows how to use a custom composition local to be able to inject a global setting through your composition hierarchy — in this case, the value of the user’s “remove animations” setting. Eevis then demonstrates how to use that composition local to wrap an existing modifier in a “safe” variety that honors the setting, in places where Google’s code does not.

Building a Swipe Left / Right Card Experience in Jetpack Compose

Souvik Sarkar walks us through the steps to create cards that swipe off the screen — often referred to as the “Tinder” UX. The cards are powered by AnchoredDraggableState, determining whether or not a given card has reached the thresholds for being swiped.

Medium: Composing smooth animation transition with Pager in Jetpack Compose

Max Yablochkin demonstrates how to change the background behind a HorizontalPager() between gradients as the user pages, with a smooth transition from one gradient to another.

Medium: How to create an audio player in Compose multiplatform

Nikhil Biju wrote an extensive post on how to build audio playback — with a simple Compose UI — for Compose Multiplatform. Nikhil used ExoPlayer for Android, AVPlayer for iOS, VLCJ for desktop, and the native <audio> element for Web/Wasm.

How I prototype with colors in Jetpack Compose

sinasamaki (Mastodon, Bluesky) is less than impressed with the MaterialTheme() color system and demonstrates setting up a separate color system based on Tailwind CSS.

Resource Roundup

100% pure code!

GitHub: utsmannn / compose-remote-layout

Muhammad Utsman has created a server-defined UI framework for Compose Multiplatform. You supply JSON-based UI declarations, and the framework renders them based on your supplied design system components. See this Medium post for more.

GitHub: arcanegolem / Materialize

Mikhail Kleyzer offers us a Compose for Android PDF viewer, in the form of a PdfRenderer-powered Compose Material3-based ColumnPdfViewer() composable.

GitHub: dzirbel / compose-material-context-menu

Dominic Zirbel published a library extending the Compose Multiplatform context menu with additional Material feature support, such as items with icons, keyboard shortcuts, nested sub-menus, and more.

GitHub: oikvpqya / fastscroller-compose-multiplatform

GitHub user oikvpqya brings us an implementation of a fast-scroller UI for Compose Multiplatform (excluding Android).

Notable Releases

Accompanist released 0.37.1 and 0.37.2 to attempt to address some Maven issues.