jetc.dev Newsletter Issue #232
Published: 2024-09-17
Adaptive layouts got a lot of love this week, between Google posts and a Compose Multiplatform beta.
Also, we look at flow layouts and SharedBounds
, and we peek at a pair of image cropping libraries. Plus, I describe a problem I had with remember()
not remembering.
Ooooo… What Did We Get?
Reviewing the release notes for the latest Jetpack Compose update!
A Compose 1.7.1
patch release (and a 2024.09.01
BOM) were released. It does not appear as though there were any bugs fixed. Instead, it was mostly for Compose Multiplatform downstream.
Speaking of Compose Multiplatform, JetBrains released 1.7.0-beta02
. Material3 Adaptive Navigation is included, iOS has basic support for BasicTextField()
, etc.
One Off the Stack, One Off the Slack
You’ve got questions. That’s understandable!
Why Am I Getting the Wrong Context?
One of the dangers with composables being top-level functions is that developers sometimes think that they can be used from anywhere. Technically, they can, but it may not work as you might expect. For example, having a composable be in the same file as an activity does not mean that navigating to that composable starts that activity, as we see in this week’s highlighted Stack Overflow question.
Can I Do Screenshot Testing with Compose Multiplatform?
Google is working on Compose Preview Screenshot Testing, but there may be some limitations when using CMP resources, as we see in this week’s
Kotlinlang #compose
Slack thread.
Composable Commentary
Posts, videos, and other new information related to Jetpack Compose!
Jetpack Compose APIs for building adaptive layouts using Material guidance now stable
Google’s Alex Vanyo reviews the Compose Material3 Adaptive family of libraries for helping developers better deal with varying screen sizes, foldable postures, etc. One interesting finding: despite the name, most of these libraries have no actual dependency on the Material3 design system and might be usable with non-Material custom design systems.
SAP integrated NavigationSuiteScaffold in just 5 minutes to create adaptive navigation UI
Google’s Alex Vanyo profiles SAP’s use of NavigationSuiteScaffold()
and related composables from Compose Material3 to better adapt to varying screen sizes.
Video: Flow Layouts
Google’s Rebecca Franks continues the Jetpack Compose Tips video series with one exploring FlowRow()
and FlowColumn()
, including using arrangements for spacing, capping the maximum number of items per row/column, achieving grid-like effects, and more.
Video: Navigation Compose meet Type Safety
Google’s Clara Fok walks us through the type safety options provided in the now-stable 2.8.0
edition of Navigation for Compose. Clara reviews the basics of declaring type-safe routes and using them, plus explores how these work with deeplinks.
Medium: Migrating Jetpack Compose for TV from alpha to stable
Google’s Paul Lammertsma explains what all changed in the TV Compose world since the earlier alpha releases. Some containers (e.g., TvLazy*()
) were deprecated and replaced by similar functionality in Compose Foundation, though you now need to deal with pivot offsets yourself. A few composables were renamed, and a few others were removed.
Video: Android Developers Backstage: Compose Animations
Google’s Doris Liu met with the Android Developers Backstage team to provide a deep dive into animations in Compose, from foundational concepts to newer options like shared element transitions.
Medium: Mastering Jetpack Compose: SharedBounds vs SharedElement (Part 2)
Akbar Dzulfikar has a two-post series on Compose animations! Part 1 looks at shared element transitions. Part 2
contrasts that with shared bounds transitions and shows how to implement those using the sharedBounds()
modifier.
Medium: How to Integrate ViewModel in Kotlin Multiplatform with Koin
Medium user Meet looks at using Koin for injecting Jetpack ViewModel
instances into your composables in a Compose Multiplatform project for Android, iOS, and Desktop.
When remember() Does Not Remember, Consider if()
I ran into some challenges where it felt like my remember()
calls were no longer working. The results demonstrate how Compose magic can make subtle code changes have farther-reaching impacts than one might expect.
Other Interesting Links
- All about Google Maps in Jetpack compose
- Medium: A Fresh Start to Kotlin Decompose
- Medium: Best Practices for Managing Strings and Styles in Android Jetpack Compose
- Medium: Building A Custom Design System in Compose Multiplatform
- Medium: CameraX and Jetpack Compose: A Guide for Android Developers
- Medium: Creating Custom Shapes in Jetpack Compose Using Draw Functions
- Medium: Effortless Asynchronous Data Handling and Reactive UI in Jetpack Compose with Kotlin Coroutines: Crafting Next-Level Android Experiences
- Medium: How to Create a Custom Animated Hole Effect in Jetpack Compose
- Medium: How to Use ContextualFlowRow with custom overflow logic
- Medium: Jetpack Compose custom navigation with KSP
- Medium: Jetpack Compose Visibility Detection Made Simple: A Step-by-Step Guide
- Medium: Jetpack Compose — Improve performance via — one view, one state pattern
- Medium: Jetpack Compose: A Deep Dive into BasicTextField vs BasicTextField2
- Medium: LifeCycle in Jetpack Compose
- Medium: Making SVG truly Composable
- Medium: Rich Link Representation in Jetpack Compose
- Medium: Tab Navigation in Kotlin Decompose
- Medium: Take photo or pick pictures with Jetpack Compose: Step-by-step guide
- Medium: Use Custom Fonts In Jetpack Compose
- Type-safe navigation in Jetpack Compose - Quick Guide
- Working With Passwords in Jetpack Compose
Resource Roundup
100% pure code!
GitHub: dellisd / maplibre-compose
Derek Ellis provides us with composables for rendering maps powered by MapLibre.
GitHub: Lilytreasure / MultiplatformWebview
Dennis Wanja has a WebView
wrapper for Compose Multiplatform, supporting Android and iOS, with a simple API for finding out when links are clicked.
GitHub: timhuang1018 / Krop
Tim Huang brings us a Compose Multiplatform library (all platforms) for image cropping, powered by Coil. Just wrap an AsyncImage()
in a Croppable()
,
and you are set!
GitHub: arielmazor / cropper
Ariel Mazor also implemented an image cropper, in the form of a Cropper()
composable.
Other Interesting Links
- GitHub: abdullahalhakimi / SmoothMotion (progress indicators)
- GitHub: mohamedma872 / HijriDatePickerPlus (date picker for Islamic calendar)
Notable Releases
Accompanist is up to 0.36.0
, fixing a documentation bug and upgrading its Compose dependencies to 1.7.0
.
Horologist is up to 0.6.19
, also upgrading its dependencies to Compose 1.7.0
.
Similarly, Compose Destinations is up to 1.11.6
, with dependency updates to Compose 1.7.0
and Navigation for Compose 2.8.0
.
Or, you can subscribe to the Atom feed or follow Mark Murphy in the Fediverse.
Recent Issues:
- 2024-10-01: Lazy grids! Focus! @colinmarsch@androiddev.social on CMP accessibility! @skydoves@androiddev.social on Landscapist! @sinasamaki@androiddev.social on Slider()! And... what is it?!?
- 2024-09-24: A Compose security fix and a new alpha! clipToBounds()! Localization! offset()! @skydoves@androiddev.social on server-defined UI! Bottom sheets! And... someone set us up *3* BOMs?!?
- 2024-09-17: Compose 1.7.1 and Compose Multiplatform 1.7.0-beta02! Flow layouts! TV Compose! SharedBounds! Image cropping! And... why does remember() not seem always to remember?!?