jetc.dev Newsletter Issue #34
alpha04 is here. The
Box() is dead; long live the new
Beyond that, we will explore more about how themes work and how you can create your own custom theme. Also, we will look at creating swipeable pages, sortable tables, and Compose-driven presentations.
alpha04 requires the use of Android Studio 4.2 Canary 13. That combination
seems to have stability issues, which is unfortunate, understandable, and explored
more at the end of the newsletter.
One Off the Stack, One Off the Slack
You’ve got questions. That’s understandable!
Many composables take function types as callback parameters, such as for click events
Button(). Sometimes, you might want to call a
suspend function from those
callbacks. However, usually those callback function types do not themselves declare
suspend, so you cannot just call a
suspend function from them — you need
to wrap it in a coroutine launcher. We explore a bit more about how that works in
this week’s highlighted Stack Overflow post.
What seemed like a simple question about how to get a material-styled
resulted in an exploration of how themes and colors work.
is not magic: it is just a collection of ambients. We explore more about this
in this week’s highlighted Slack thread.
Posts, videos, and other new information related to Jetpack Compose!
It appears that we now have two
Box() implementations, the original (now deprecated)
and the new one (formerly known as
Stack()). We now have
LazyListState for being
able to track the state of
LazyRow() composables, and that
state is already set up to save the scroll position in instance state. Also, if you were
using some modifiers tied specifically to
ColumnScope, those will
no longer be available outside of those scopes.
Part of the power of Compose UI is not just in being able to rapidly assemble user interfaces, but in creating a library of composables that implement a set of design primitives that designers can use to make it easier to match mockups to implementations. Howie Zuo is starting to explore this area, with a post on creating a custom theme implementation.
Jorge Castillo returns with a post on creating a swipeable container composable,
designed to provide similar capabilities to
It reviews the
Pager() implementation from Google’s JetCaster sample app.
Zhelyazko Atanasov brings us a review of various properties that you can declare
@Preview to configure how previews work, reminiscent of
this blog post from July.
100% pure code!
All the way back in issue #4 I mentioned Zach Klippenstein’s DSL for creating and rendering rich text in Compose UI. It gets a “re-up” in this issue because Zach added another library to the project, one that renders presentation-style slideshows, with a set of stock slide structures and a set of composables for populating them.
…And One More Thing
Based on the questions and comments appearing in Slack and Stack Overflow,
it appears that Compose ecosystem stability took a hit with Android Studio
4.2 Canary 13 and Compose
alpha04. Stability had been on a bit of a downward
trend in Studio support for Compose for a while, but this seems like a significant
jump in the wrong direction. This is exacerbated by the requirement
that you use Canary 13 for
Ideally, this stuff would work better.
However, do bear in mind that this is still “bleeding edge”. Given the definition of “Canary” builds, both Studio and Compose are alphas. Alphas are going to have problems from time to time. That is not unique to these two pieces of technology and it is not unique to Google. Just because we got past the “developer preview” phase does not mean that Compose is rock-solid and that everything we do with it comes up with rainbows and unicorns. Sometimes, the unicorns will be more like this one.
(WARNING: the preceding link contains unicorn-delivered violence, with lots of fake blood)
(WARNING: it also contains a scary clown, which in no way should be considered a metaphor for anything related to Android app development)
With luck, things will improve in the coming weeks.
In the meantime, though, you are going to need to live with the fact that, from time to time, you will need to put your Compose experiments to the side for a while and wait for stability to improve. Or, you will need to live with the fact that you are helping improve the stability, by filing bug reports with projects that reproduce problems. If enough developers contribute this way, stability can get better faster for everyone… but if you are not in position to contribute bug reports, that is fine.
Beyond that, keep calm and code on.
- 2021-10-12: Overscroll! Responsive layouts! Accessibility! Reorderable lists! Foldables! Testing with an Espresso wrapper! And... testing with robots?!?
- 2021-10-05: 1.0.3! 1.1.0-alpha05! Scopes! Compose in production! rememberUpdatedState()! And... particles of Compose?!?
- 2021-09-28: @androidamanda on declarative UIs! Keyboard handling! Swapping themes! Pickers, pickers, and more pickers! And... LED matrix displays?