jetc.dev Newsletter Issue #154
Published: 2023-02-21
This week, we explore the limits of infinity and the instability of words.
(OK, perhaps those items are not quite that profound)
In addition, we get a double helping of videos featuring Rebecca Franks, examine a framework for errors, and spend a lot of time on modifiers. And we see a slick QR code composable plus a Kotlin/Multiplatform starter project.
Also, one update regarding this passage from last week’s issue:
Compose Runtime Tracing is up to
1.0.0-alpha02
, though it is unclear if any tooling exists to use it.
Google’s Ben Trengrove reached out and indicated that Android Studio Flamingo supports runtime tracing. Thanks, Ben!
One Off the Stack, One Off the Slack
You’ve got questions. That’s understandable!
How Can I Have an Infinite Pager?
A question that has come up ever since the original ViewPager
widget is:
how can I have a pager with infinite pages? Infinity is a really big number [citation needed],
so the standard trick is to substitute something smaller, but big enough that the
user will never swipe that far. See how that applies to HorizontalPager()
in this
week’s highlighted Stack Overflow question.
Why Isn’t CharSequence
Stable?
It feels like CharSequence
ought to be marked as @Stable
, given that a String
is stable. But, not every CharSequence
is stable (think StringBuilder
). Ponder
the ramifications in this week’s highlighted Kotlinlang #compose
Slack thread.
Composable Commentary
Posts, videos, and other new information related to Jetpack Compose!
Medium: Constraints and modifier order
Google’s Jolanda Verhoef is back, this time looking at how the order of modifiers matters and why that order matters for the measurement and placement of composable content. Jolanda also covers this subject in the associated YouTube video.
Video: Introduction to drawing in Compose
Google’s Rebecca Franks walks us through using Canvas()
, DrawScope
, and the
drawBehind()
modifier to add custom drawings to some other composable.
Video: Custom graphics and animations in Jetpack Compose
Google’s Rebecca Franks also appeared in a Code with the Italians episode, which also looks at drawing APIs, animated effects, and more, all in the context of the JetLagged sample app.
Medium: Migrating Sunflower to Jetpack Compose
Google’s Chris Arriola walks us through migrating a classic View
-based app to
one using Compose, showing how Google accomplished this with
the Sunflower sample app. Chris reviews
the screen-at-a-time approach for migration, where composables replace views as
the contents of fragments, allowing you to eventually eliminate those fragments
once the entire UI is made up of composables.
Medium: Errors are Features, not Bugs!
Marius Mora Bosch looks at presenting errors to users in Compose UI and SwiftUI. Marius recommends treating errors as state, updating that state as needed once the error no longer needs to be presented. Wrapped around that concept is a declarative error architecture for describing how errors should be managed.
Layout modifiers in Jetpack Compose
Jorge Castillo contributed a post
to Alex Styl’s blog, exploring the layout()
modifier, including use cases, internal
implementation, and how other modifiers (like padding()
) are built atop layout()
.
Medium: Pagination in Jetpack Compose with Unit Tests
In this post, Özgür Taş applies the Paging Compose library to an app, one that
displays GitHub users pulled from GitHub’s Web service API. The post also explores
using Pager
and collectAsLazyPagingItems()
to render the paged data in a LazyColumn()
,
with some unit tests as well!
Other Interesting Links
- Consuming Compose for iOS in a SwiftUI application
- Medium: Avoid applying modifiers to the provided modifier
- Getting Started with Jetpack Compose
- Foldable-aware app layout
- Medium: Dependency Injection Guide with Dagger-Hilt and Jetpack Compose
- How to Test Your Compose UI
- Medium: Jetpack Compose Lifecycle
- Medium: Declarative Form Validation with Jetpack Compose
- Medium: Navigation in Jetpack Compose Android
- Medium: [Part 3] Jetpack Compose — Migration of Component View (Input Text) on Existing Layout
- Medium: Remove Ripple Effect from Clickable and Toggleable Widget In Jetpack Compose
- Medium: Gaining focus in Jetpack Compose and a small issue in Modifier API to be careful about
- My process for creating Custom Jetpack compose Components
- Image URL to Bitmap using Coil in Jetpack Compose
- Medium: Lists — the old way vs the new way with Android Compose
Resource Roundup
100% pure code!
GitHub: lightsparkdev / compose-qr-code
GitHub user lightsparkdev published a QR code rendering library with a QrCodeView()
composable. You can choose the colors for rendering the QR code in addition to
wrapping the QR code around a central composable (e.g., for an icon in the center).
GitHub: 2307vivek / Seeker
Vivek Singh gives us a Seeker()
composable for a seek bar UI designed for media
playback, such as a podcast or video. In particular, it shows a “read-ahead” indicator
to illustrate how much content is downloaded already. It also offers the ability to
divide the seek range into segments, perhaps to correspond to segments in the media
(e.g., sections of a video).
GitHub: Kashif-E / KMPTemplate
Kashif Mehmood created a project template for Kotlin/Multiplatform, to make it easier to support Android, iOS, and Desktop targets at once… including Compose for iOS.
GitHub: ayhanunal / android-compose-ccview
Ayhan Ünal brings us a CreditCardView()
composable, to render credit card information,
styled a bit like a credit card.
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?!?