jetc.dev Newsletter Issue #188

Published: 2023-10-31

This week, we look at how to tell that you’re on a TV (for composables) and whether we can have Modifier be returned by a composable. We explore slot APIs, ConstraintLayout(), and MapBox’s Compose UI support. Plus, we examine libraries for placeholders, calendars, and button toggle groups.

One Off the Stack, One Off the Slack

You’ve got questions. That’s understandable!

How Can I Have TV-Specific Composables?

In other words, how does the system decide to apply layout-television for layout resources? The answer appears to be that it detects FEATURE_LEANBACK, and so we can use that to decide whether to use a mobile or a TV-specific composable. However, I argue that there may be better options than doing this on a granular basis, in this week’s highlighted Stack Overflow question.

Is It OK to Make a Modifier Returned By a @Composable?

We’re told to move away from using Modifier.composed(). However, sometimes, we need to read a composition local from within a modifier… and reading a composition local can only be done inside of a composable. Learn why composed() is still OK for the short term, and other limits of using a composable to return a modifier, in this week’s highlighted Kotlinlang #compose Slack thread.

Composable Commentary

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

Meta built threads in only 5 months using Jetpack Compose

Yasmine Evjen and Florina Muntenescu walk through some high-level notes about how Meta assembled the Threads app.

Medium: Passing a Function from a Parent to a Child Composable

Michihiro Iwasaki examines slot APIs, a foundational concept in composable development, starting at the Kotlin concept of function types and building up from there.

Medium: Designing a Login Page By Using the Constraint Layout in Jetpack

Bharadwaj Rns takes a practical look at ConstraintLayout(), the Compose UI equivalent of the ConstraintLayout that dominated newer View-based Android UI construction. The sample code explores creating and employing references to describe the relationships between composables via the ConstraintLayoutScope() DSL.

Medium: How to use Official Mapbox Maps Compose Extension with Permission Flow and FusedLocationProviderClient

Debanshu Datta explores MapBox’s official support for Compose UI, from simple maps to markers, location tracking, and more!

Resource Roundup

100% pure code!

GitHub: eygraber / compose-placeholder

Eliezer Graber took the deprecated Accompanist Placeholder and ported it to Compose Multiplatform, offering both Material and Material3 implementations.

GitHub: robertlevonyan / composable-button-toggle-group

GitHub user robertlevonyan created a Compose UI implementation of the MaterialButtonToggleGroup from the Material3 spec. You provide the RowToggleButtonGroup() with the icons, or the ColumnToggleButtonGroup() with the icons and labels, and the composables render the toggle button group from there.

GitHub: GuilhE / JsonBroadcaster

Guilherme Delgado created a framework for triggering UI updates in Compose UI apps (and traditional iOS Xcode apps) from the command line, for rapid manual testing.

GitHub: Felix-Kariuki / MultiSelectCalendar

Felix Kariuki created a calendar composable that supports multiple date selections, not just a date range.

Notable Releases

Compose WebView Multiplatform released 1.5.0 and 1.6.0 in rapid succession. Kevin Zou covers the 1.5.0 changes in this Medium post.

Maps for Compose released 4.0.0, 4.1.0, and 4.1.1 in a flurry of activity.