jetc.dev Newsletter Issue #83
1.1.0-alpha04 was released, bringing the oft-requested Kotlin 1.5.30 support! 🎉
Beyond that, we look at getting common concerns in migrating to Compose UI: getting
Intent extras and showing classic dialogs. We look at form validation, drop-down
menus, and palettes. We see a sweet KSP annotation processor to help with Navigation for Compose.
And I take a glance at some work-in-progress Compose libraries for app widgets and Wear OS tiles.
Reviewing the release notes for the latest Jetpack Compose update!
Beyond the Kotlin 1.5.30 support,
1.1.0-alpha04 has a few changes, including:
There has been a fair bit of change with touch events, such as the deprecation of
GestureScopeand the addition of
Android 12 stretch overscroll is now supported
One Off the Stack, One Off the Slack
You’ve got questions. That’s understandable!
Just because you are using Compose UI does not change many of the fundamental needs
of Android app development. But the fact that Compose UI encourages pure functions
means that to fulfill those needs you need to wade through a seemingly-endless
CompositionLocal values. So, if you want to get the extras delivered to your
Intent, you will need to work with
LocalContext, as we see in this week’s highlighted
Stack Overflow question.
Similarly, you may have the need to integrate with existing UI elements — perhaps
from third-party libraries — that are stuck in the activity/fragment/view system.
To show a classic
Dialog from a composable, you can use
DisposableEffect(), as we see
in this week’s highlighted Kotlinlang
#compose Slack thread.
Posts, videos, and other new information related to Jetpack Compose!
Two years ago, Brandon Wever wrote a Medium post on form validation using data binding and
Brandon rewrote that post to use Compose UI, while retaining the same
LiveData that was used in the original post.
Testing! We really should do some of that! In this post, Dmytro tours the mechanics
of testing our composables using
ComposeTestRule (for testing composables in isolation)
AndroidComposeTestRule (for testing composables in an activity).
Joe Birch returns, looking at how we can deal with scalable text sizes. The
MaterialTheme() work in
sp units… but what about the composables around your text?
Joe examines using modifiers such as
widthIn() to have your outer composables handle text scaling
according to your design rules.
Angelo Marchesin needed a bottom sheet with some particular behaviors, just enough that the stock implementations were not quite right. In this post, Angelo looks at how to create a bottom sheet, particularly one that not only expands and collapses but has scrollable content as well.
Other Interesting Links
- Themes in Jetpack Compose
- Lift on scroll in Jetpack Compose
- Video: Jetpack Compose Navigation - Navigating with Parcelables
- One Tap Phone Number Login With Jetpack Compose
- Video: Custom UI Component with Jetpack Compose & Canvas | Part #1 - Preview
- Jetpack compose – Retrofit with Recyclerview
- Video: Jetpack Compose - Build a Login Screen
- Medium: Building Responsive Layouts with Jetpack Compose
- Video: Creating a TabBar Layout in Jetpack Compose
100% pure code!
Rafael Costa created a KSP processor that lets you create Navigation for Compose routes
@Destination annotations on composables. It determines arguments from the actual
composable function arguments, including support for default values, and deep links.
Compose UI has nice support for applying
Shape objects to things like a
but there are only so many built in shapes. GitHub user pz64 has a library with two
more: a rounded star and a polygon.
If you need to render LaTeX math functions, the Timeline Notes team ported an earlier function rendering library to Compose UI.
Other Interesting Links
- GitHub: dbaelz / StellarPresentation
- Gist: MatrixText
- GitHub: rabross/ SevenSegmentDisplay
- GitHub: CuriousNikhil / compose-explode
- GitHub: keygenqt / compose-forms
- GitHub: burnoo / cokoin
…And One More Thing
Back at Google I|O 2021, as part of the “Compose all the things” theme, Google showed some sample code for creating app widgets via composables. I reviewed that code and pointed out that while we might use Compose for app widgets, Compose UI — at least as we use it for Android and desktop — was unrealistic.
Dylan Roussel pointed out that Google is creating a “Glance” library
that seems reminiscent of the sample code from I|O. We get a set of composables
that resembles a tiny subset of Compose UI, and those get mapped to corresponding
constructs in a
Android Code Search shows three modules:
glance, containing core code
glance-appwidget, containing the
RemoteViewscomposables for app widgets
glance-wear, for Wear OS tiles
These in turn depend on other things that do not yet exist as published artifacts.
glance-appwidget depends on a
core-remoteviews library, for example. However,
as expected, none of these depend on Compose UI, just the Compose compiler and runtime.
Instead, Glance has its own composables for
Text(), along with related modifiers and classes. The same composable
API is used for both app widgets and Wear OS tiles, as far as I can tell.
These projects have interesting elements in their implementations. They serve
as yet more examples of how to apply Compose in non-traditional use cases. Also,
glance-appwidget has an
AppWidgetHostRule for writing instrumented tests for
app widgets, and it seems like it might be usable beyond these Compose-crafted
It is nice to see that Google is continuing work on the API they previewed at I|O!
- 2023-09-12: Compose 1.5.1! Glance 1.0.0! Compose Multiplatform! Themes! Photos! Coachmarks! A bit of CommonsWare history! And @email@example.com tells us what not to do!
- 2023-09-05: Compose Compiler 1.5.3! Compose Multiplatform 1.5.0! @firstname.lastname@example.org on greyscaling composables! @email@example.com on Espresso testing with Compose interop! Scrollbars! AnnotatedString!
- 2023-08-29: Compose Compiler 1.5.2! Compose and Wear Compose alphas! Capture composables to bitmaps! Testing! Recomposition! Compose Multiplatform! And... Accompanist is downsizing?!?