jetc.dev Newsletter Issue #178
Published: 2023-08-22
This week, we look at sending results back to previous composables via Navigation for Compose, both from the navigated-to composable and from a viewmodel.
We also explore conditional modifiers, accessible graphs, and how the K2 compiler helps with Compose Multiplatform build times. And, we examine both a drag-and-drop framework and a Material-free pull-to-refresh implementation.
One Off the Stack, One Off the Slack
You’ve got questions. That’s understandable!
Can We Send Back Results from a ViewModel?
Sending results back from one composable to a previous one (using Navigation for Compose) works, but doing that from a viewmodel gets a bit tricky. Google’s Ian Lake walks us through the approach in this week’s highlighted Stack Overflow question.
Do We Need The Latest Compiler?
Suppose we have newer Compose libraries but an older compiler. Will that cause a rupture
in the space-time continuum? Or will it work fine? Explore more with Google’s Ben Trengrove
in this week’s highlighted Kotlinlang #compose
Slack thread.
Composable Commentary
Posts, videos, and other new information related to Jetpack Compose!
Medium: Jetpack Compose Tricks: Conditionally Applying Modifiers for Dynamic UIs
Katie Barnett demonstrates a conditional()
custom modifier, one that applies other modifiers
based on the result of a Boolean
condition. This can improve readability compared to trying
to have the conditional logic lie outside the modifier chain.
Medium: Appyx 2.0 — Gesture-driven navigation for Compose Multiplatform
Zsolt Kocsi walks us through the changes in Appyx 2.0. Appyx now has a layered set of artifacts, along with Compose Multiplatform support and gesture-based navigation options (e.g., Tinder-style card swipes).
K2 Compiler Chronicles: Jetpack Compose
Ian Okumu looks at using the new pre-release K2 compiler for Kotlin on Compose UI modules. In particular, Ian explores the performance gains of K2 when building Compose Multiplatform code, finding that it is an improvement if not quite to the level that JetBrains touts.
More Accessible Graphs with Jetpack Compose Part 3: Differentiating without Color
Eeva-Jonna Panula continues her series of posts examining the intersection of accessibility and graphs in Compose UI. This time, Eeva-Jonna looks at the impact of color blindness on typical graphs and how to use shapes and patterns to differentiate graph lines, in addition to using color.
Passing Arguments While Navigating Back in Jetpack Compose
Joel Kanyi examines what it takes to send a result along the back stack with Navigation for
Compose, to deliver information to some prior screen or navigation point. This leverages
the SavedStateHandle
that is part of each Navigation for Compose back stack entry, providing
a communications bridge between the navigated-to composable and the composable that initiated
that navigation.
Medium: Animated Circular Progress Indicator using Jetpack Compose
Shoaib Mushtaq walks us through the implementation of an AnimatedCircularProgressIndicator()
composable, which uses a Canvas()
to draw the overall circle and the completion arc,
while animating the changes as you increase or decrease how much has been completed.
Medium: Improving Compose horizontal pager indicator
Alexandre Bruneau wanted a HorizontalPager()
with lots of pages: 100 or more.
The ordinary “pager dots” approach does not scale well to this many pages.
Alexandre explores making the pager indicator itself be paged, so users get a sense
that there are more pages without flooding them with dots.
Medium: Mastering Jetpack Compose State Management: A Deep Dive into Modern UI Data Flow
Joseph James takes a tour of State
and related items, such as rememberSaveable()
and derivedStateOf()
. Joseph also examines composition locals, including when to use
them (and when not to use them).
Other Interesting Links
- Custom Media3 ExoPlayer Layout with Jetpack Compose — Android
- Guide to Building Your First Android Calculator App with Jetpack Compose and Kotlin: A Beginner’s Android Development Tutorial
- How to Create Eye-Catching Animations in Android with Jetpack Compose
- Medium: An Easy To Build First App Using Jetpack Compose
- Medium: Basic Views in Compose with Examples
- Medium: Benefits of Compose with Examples
- Medium: Building custom shapes with Canvas in Jetpack Compose: Practical Guide
- Medium: Dynamic Animations with Lottie Animation in Jetpack Compose
- Medium: Exploring the Rotate Button Composable in Jetpack Compose
- Medium: Google Sign-In with Firebase Using Jetpack Compose
- Medium: Implementing grid UI in easy way with GridLayout for Compose library
- Medium: Jetpack Compose color picker with hex values
- Medium: Jetpack Compose: Mastering States
- Medium: ModalBottomSheet and the system navigation bar — Jetpack Compose
- Medium: Side Effects in Jetpack Compose : A Beginner’s Guide
- Medium: Streamline permission handling in Android Jetpack Compose applications with Compose Permissions
- Medium: Unleashing Creativity with Custom Modifiers in Android Jetpack Compose
Resource Roundup
100% pure code!
GitHub: TinyHai / ComposeDragDrop
GitHub user TinyHai offers us DragTarget()
and DropTarget()
composables,
designed to be wrapped in a DragDropBox()
that can manage the drag-and-drop state.
The result is the ability to drag any drag targets onto any drop targets, with an
onDrop
event for when the drop occurs.
GitHub: MateriiApps / pullrefresh
GitHub user MateriiApps published a library with a Material-free pull-to-refresh
implementation, centered around a PullToRefreshIndicator()
composable and associated
state.
GitHub: levinzonr / jetpack-compose-ui-arch-plugin
Roman Levinzon built a plugin for Android Studio that offers live templates and a new feature dialog that make it easy to implement Roman’s approach to Compose UI architecture.
Other Interesting Links
- Gist: hrules6872 / SwipeableSnackbarHost.kt (swipe snackbars off the screen)
- Gist: oianmol / SplitView.kt (top/bottom split with movable divider)
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?!?