jetc.dev Newsletter Issue #133
Published: 2022-09-20
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.
Composable Commentary
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
wrappers (e.g., 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 MutableState
.
Arkadii Ivanov separately suggests using Dispatchers.Main.immediate
to safely collect a MutableStateFlow
.
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
to a LazyColumn()
, leveraging collectAsLazyPagingItems()
to map a Pager
-backed
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
plays).
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
Resource Roundup
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, SeekBar
-style,
to choose a particular offset in the waveform.
GitHub: sagar-viradiya / koreography
Sagar Viradiya created a DSL for describing animations, via a rememberKoreography()
top-level function that offers DSL operations like parallelMoves()
and move()
.
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 StateObject
and 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.
Recent Issues:
- 2024-12-10: A Compose Multiplatform alpha! Hot reload! Presentation! Sprites! Calendars!
- 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?!?