jetc.dev Newsletter Issue #159
This week, we wonder about stateful composables and long for a donut. We
explore circuits, paparazzi, pagers, and
LiveData problems. And we see
a way to figure out why our composables might be recomposing, along with
a Kotlin/Mutliplatform project generator.
One Off the Stack, One Off the Slack
You’ve got questions. That’s understandable!
In theory, we prefer stateless composables, for easier testing and greater
flexibility. In practice, we sometimes prefer composables like
which manage some state internally, because they are easier to use. We explore
this dichotomy in this week’s highlighted Kotlinlang
#compose Slack thread.
Posts, videos, and other new information related to Jetpack Compose!
The Talking Kotlin crew met up with Amrita Venkatraman, Kieran Elliott, and Zac Sweers of Slack, to discuss Circuit. Circuit was mentioned here back in issue #144 and is a Kotlin/Multiplatform library that implements the entire UI architecture via composables, not just the UI elements.
codedogg likes Paparazzi for UI testing,
comparing screenshots with known-good copies. However, by default, Paparazzi
requires you to manually set up those UI tests. codedogg illustrates how we can
use reflection to identify relevant
@Preview-annotated functions and test
them from a single test class.
Many developers used the pager composables from Accompanist, and now they have been
replaced by official implementations. Domen Lanišnik examines the
VerticalPager() composables, including manually setting the page size and
content padding, the impact of
beyondBoundsPageCount, and more.
Roman Kamyshnikov reports on a specific problem with using
where composables that depend on the
LiveData as a source of state might lag
due to the asynchronous nature of
Patryk Kosieradzki ran into problems with Compose 1.4.0,
ComposeView, where the soft keyboard (IME) stopped working. While there is an
official bug report for the problem, Patryk demonstrates how to create a
replacement that works around the bug.
Other Interesting Links
- Using the Navigation Component in Jetpack Compose
- How to handle state in Jetpack Compose
- Medium: Jetpack Compose: Creating Expandable Cards With Content
- Medium: Making a custom shape widget on jetpack compose using Figma and AndroidVectors
- Decimal Input Formatting with Jetpack Compose’s VisualTransformation
- Medium: Migrate from MVVM to MVI
- Medium: Jetpack Compose — Respect the contract of Modifiers
- Medium: Beautiful way to access touch interactions in Jetpack Compose
- Medium: The Pitfalls of Jetpack Compose Recomposition: How to Avoid Breaking Your App
- Medium: Top 5 Android Studio Plugins for Jetpack Compose to Boost Your Productivity
- Medium: How to change status bar color to match your app’s theme in Compose
- Medium: All about AnnotatedString (Jetpack Compose)
- Medium: Android Jetpack Compose for beginners — Part 2
- Medium: Jetpack Compose Tutorial Part 2
- Getting Started with Jetpack Compose Textfield
- What is Jetpack Compose
100% pure code!
GitHub user theapache64 gives us a
Rebugger() composable that logs to Logcat
State change(s) triggered a recomposition. This is helpful to
determine the “why” of recomposition, given that you have an idea of what composables
Ygor Frazão offers up a library that helps to hide the complexity of runtime
permission requests, via a
WithPermission() composable that has a slot-based
API for the content to show before permission is granted, after the permission is
granted, and after the permission is denied.
This site generates a Compose-centric Kotlin/Multiplatform project for you, given an application ID and display name. You can choose from a small set of initial dependencies for networking, navigation, resource management, and more.
Jonathan Mercandalli released a small library that adds an
modifier, to allow you to specify an aspect ratio whose sizes are tied to a parent
composable. See this Medium post
Other Interesting Links
- 2023-11-21: Compose/Material3/Wear Compose updates! remember()! Adaptive layouts! Compose Multiplatform in 2024! @email@example.com on BasicTextField2()! Compose Multiplatform charts! And... is TV Compose in trouble?!?
- 2023-11-14: Compose Compiler! BasicTextField2()! @firstname.lastname@example.org and animations! Optimization! @email@example.com, JetBrains, and Fleet! JetBrains and plotting! And... we collapse?!?
- 2023-11-07: Compose Multiplatform! Chips in fields! Diffing! Custom fonts in Glance app widgets! Heatmaps! PIN input! And @firstname.lastname@example.org is in a bit of a haze?!?