jetc.dev Newsletter Issue #133
This week, Google warns us that we may be using
TextField() wrong. 😮
Google also suggests that we should be thinking in Compose but… what if that
leads us to use
TextField() wrong?!? 😱
Beyond that, we look at accessibility and paging, we draw some waveforms, and we look at an undo system for letting users correct errors!
(really, though, that seems superfluous — I, for one, nevre maek typose 😁)
One Off the Stack, One Off the Slack
You’ve got questions. That’s understandable!
How Do We Recompose When Clipboard Contents Change?
There are lots of ways to map platform callbacks to
State that can trigger
recomposition. See two approaches — using
DisposableEffect() and using
a viewmodel — for recomposing on clipboard changes in this week’s highlighted
Stack Overflow question.
Are State Holders Useful?
Some developers really dislike composables with lots of parameters, which is understandable.
Sometimes, they try bundling a bunch of would-be-parameters into more coarse-grained
objects, to reduce the parameter count. See an example, and arguments against
the approach, in this week’s highlighted Kotlinlang
#compose Slack thread.
Posts, videos, and other new information related to Jetpack Compose!
Medium: Effective state management for TextField in Compose
Google’s Alejandra Stamato points out that
BasicTextField() and its design system
OutlinedTextField()) suffer from some fairly significant
synchronization problems, especially when using reactive data sources… and
reactive data sources are fairly important nowadays. Alejandra’s primary
recommendation is to mutate the text state synchronously or via a
Arkadii Ivanov separately suggests using
to safely collect a
Medium: Thinking in Compose
Google’s Chris Arriola focuses on the declarative UI pattern: describing what the UI should be instead of how to get to that UI from whatever starting point you happen to be in at the moment. Google also published a video on the same subject.
Learn Jetpack Compose at a Compose Camp near you!
Google is offering a series of “Compose Camp” events in concert with Google Developer Groups and Google Developer Student Clubs.
Medium: Compose Component Builders
Tim Rijckaert discusses how to avoid too many overloads of the same function by using the builder pattern. In a nutshell, Tim advocates for writing a composable that takes a builder that in turn offers a DSL-style way to provide the input data for the composable.
Improving app accessibility with Jetpack Compose
Kristen Halper looks at how we can identify accessibility concerns in our Compose UI apps and how to help address them. Specifically, Kristen applies this to Microsoft’s Surface Duo Compose UI samples.
Medium: How to Use the Android Paging3 Library With Jetpack Compose
Daniel Dimovski demonstrates conumsing the Google Books API within a Compose UI
app. Specifically, Daniel looks at using
paging-compose to supply data page-at-a-time
collectAsLazyPagingItems() to map a
Flow to a
LazyPagingItems that can be used with the lazy containers.
Medium: Custom ExoPlayer Controls in Jetpack Compose
Ruben Quadros wanted to use ExoPlayer in a Compose UI app. Specifically, Ruben
wanted to use composables for the controls overlay (play, pause, etc.). Ruben’s
post focuses on how to create composables that interact with ExoPlayer to control
playback and to respond to events (e.g., update a
SeekBar() position as the video
Other Interesting Links
- Medium: Explore Compose MotionLayout
- Video: Large Screens and Foldables
- Medium: Build a Camera Android App in Jetpack Compose Using CameraX
- Medium: Provider Pattern in Jetpack Compose
- Slides: Migrating to Compose
- Medium: Firebase Phone Authentication in Jetpack Compose using MVVM architecture
- Measuring Composable size using BoxWithConstraints
- Video: What does recomposition mean to your app?
- Drawing QR Codes in Jetpack Compose
- Medium: Fact Check And Common Misconceptions Around Comparing SwiftUI & Jetpack Compose
- Medium: Jetpack Compose: Implicit Intents
- Should new Android developers learn Compose or XML?
- Medium: Using Jetpack Compose in an existing Android application
100% pure code!
GitHub: lincollincol / compose-audiowaveform
Andrew Linc brings us an
AudioWaveform() composable that renders a waveform
from a collection of amplitudes. The resulting UI is clickable,
to choose a particular offset in the waveform.
GitHub: sagar-viradiya / koreography
Sagar Viradiya created a DSL for describing animations, via a
top-level function that offers DSL operations like
GitHub: zach-klippenstein / compose-undo
Google’s Zach Klippenstein created a proof-of-concept universal undo system
for Compose. As Zach notes, “this is a very unconventional and probably unsupported
use case of the
StateRecord APIs”, so be careful in using
this approach in production. Still, it represents an approach that might get first-class
support in the future.
Or, you can subscribe to the Atom feed or follow Mark Murphy in the Fediverse.
- 2023-05-30: Compose beta! Tracking continuous composable presses! Animated carousels! MVI! 2D scrolling layouts! Tables! And... a stable function?!?
- 2023-05-23: Focus and preview cards for Compose for TV! Interactions and visual states! ViewCompositionStrategy! Compose for iOS, for real! @email@example.com is zooming! Data tables! And... BasicTextField2, the sequel?!?
- 2023-05-16: Google I/O! New Compose BOM and alpha! Viewmodels! BottomScaffold()! SealedX! Lottie! Dynamic themes! Floating action menus!