jetc.dev Newsletter Issue #240
Published: 2024-11-12
This week, we get bitten in the [REDACTED] by experimental Compose APIs, accept some stylus input,
and add a FAB to NavigationSuiteScaffold()
. We look at swapping in some Swift UI in place of
an Android composable, all while retaining a standard Compose API. And we celebrate Coil’s 3.0.0
release.
One Off the Stack, One Off the Slack
You’ve got questions. That’s understandable!
The Kotlinlang Slack archive is still stuck in late October. 😞
How Can I Have a FAB in NavigationSuiteScaffold()
?
Right now, NavigationSuiteScaffold()
does not support a FloatingActionButton()
, though
they are considering it. It is possible
to pull this off, blending a Scaffold()
with the NavigationSuiteScaffold()
, as we see in
this week’s highlighted Stack Overflow question.
Composable Commentary
Posts, videos, and other new information related to Jetpack Compose!
Unbreaking the changes in Compose 1.7
Christian Brüggemann (@cbruegg@mastodon.green) explains one source of breaking changes in the Compose 1.7 update: Google
changing experimental APIs without a deprecation period. While changing experimental APIs is
reasonable, either Google needs to stop advising people to use them or give them a proper
deprecation cycle. Christian illustrates one case for this with ModalBottomSheet()
, then
shows how to implement a compatibility layer that can support both old and new versions
of the experimental API, depending on what is available on the classpath.
Medium: Android Ink Practical Guide
Manel Martos Roldán walks us through how to use the new AndroidX Ink library, wrapping the
InProgressStrokesView()
in an AndroidView()
to make it available to Compose for Android.
Not a Phase - Text with Compose and Canvas
Eevis Panula (@eevis@mas.to, @eevis.codes) is back, this time teaching us how to render text via rememberTextMeasurer()
and the drawText()
canvas DSL function. Eevis also explains how to import Google Fonts within
Android Studio and how to animate the rendered text.
Centered Slider in Jetpack Compose
sinasamaki (@sinasamaki@androiddev.social, @sinasamaki.com) returns, wondering why Compose Material3 lacks an implementation of the Centered
Slider from Material Design… then goes ahead and builds a CenteredSlider()
implementation
to fill the gap.
Medium: TransformableBrush for Efficient Brush Animations in Jetpack Compose
AmirHossein Aghajari points out a source of performance issues: allocating new shader objects on
each frame of an animation, such as a shimmer effect. The post illustrates one approach for
avoiding that, by means of a custom TransformableBrush
that can take animated effects into
account without fresh allocations.
Medium: Android: NavBackStackEntry’s Lifecycle in Jetpack Compose Navigation
Medium user Michael M.H shows us how to access the Lifecycle
associated with a NavBackStackEntry
in Navigation for Compose and explains some use cases for observing it, such as to pause a video
when the user leaves the player screen or auto-saving data as the user navigates.
Medium: Jetpack Compose Adaptive library I: Switch navigation menu
Oliver Vicente is embarking on a tour of Compose Material3 Adaptive composables and support
code, starting with
NavigationSuiteScaffold()
to switch between bottom navigation and a navigation rail (expanded
or collapsed) depending on the window size.
Medium: Component-based Approach. Organizing Navigation with the Decompose Library
Artur Artikov demonstrates how to use Decompose for navigating with dozens or hundreds of screens, by subdividing them into distinct flows and coupling those flows together.
Other Interesting Links
- Medium: Best Practices for Managing State in Android Apps with Kotlin Coroutines and Flow
- Medium: Building a Simple Camera2 API App with Jetpack Compose
- Medium: Compose Navigation The Old Way
- Medium: Compose Tip: Using LaunchedEffect and derivedStateOf for Effective UI State Management
- Medium: Designing Modern Gradient Bars in Android Using XML and Compose
- Medium: Implementing Soft Navigation Requests in Jetpack Compose Navigation — Part 2 : The Back Press
- Medium: Navigation in Jetpack Compose: Handling the Back Stack and Passing Data
- Medium: Pixel Perfect: Creating a Retro Button with Jetpack Compose
- Medium: Reactive State in Jetpack Compose: Leveraging
remember
,mutableStateOf
, andrememberSaveable
- Navigating Compose’s Pathways: A Type-Safe Expedition
Resource Roundup
100% pure code!
GitHub: touchlab / compose-swift-bridge
The Touchlab crew (@touchlab@mastodon.social, @touchlab.co) has released an interesting tool for Compose Multiplatform. If there are certain
composables that you want to handle natively in Swift, you can use a @ExpectSwiftView
annotation
on an expect
function — the Compose Swift Bridge will help you set up the Swift implementation
and keep its state in sync. See the docs and
the launch blog post for more.
GitHub: Kashif-E / Voyant
Kashif Mehmood (@KashifMehmood@androiddev.social) created libraries for Voyager and for Navigation for Compose to help you use native iOS navigation.
Notable Releases
Horologist is up to 0.7.4-alpha
,
with a variety of small improvements.
Maps for Compose is out with a 6.2.1
release,
fixing a clustinerg bug.
And Coil reached its 3.0.0
stable release…
then continued on to 3.0.2
to fix some bugs. This upgrade guide
will help you move to Coil 3.
Or, you can subscribe to the Atom feed or follow Mark Murphy in the Fediverse.
Recent Issues:
- 2024-12-03: Rebecca Franks on clipping and masking! Stefano Natali on graphicsLayer()! FunkyMuse on type-safe nav results! And... if we have enough maps, do we need to store our maps in a Map?!?
- 2024-11-26: Math! Shared element transitions! Custom modifiers! Macrobenchmark! Adapting to platform-specific design systems! And... why does wrapContentSize() not wrap my content size?!?
- 2024-11-19: Compose alphas! Compose Multiplatform patch! PaddingValues! Graphics layers! Swiping! Heatmaps! Navigation! And... why did we get a new production Compose BOM?!?