jetc.dev Newsletter Issue #242
Published: 2024-11-26
This week, we render some math and ponder wrapContentSize()
behavior. We look at options
for custom modifiers and how to measure composable performance with macrobenchmark. And
we adapt our composables to platform-specific design systems… if that is what our designers
want, anyway.
One Off the Stack, One Off the Slack
You’ve got questions. That’s understandable!
How Can I Render Math Formulas in Compose?
Personally, my gut instinct for this is to turn to a library, such as CExpr. But, for lightweight use, rendering a mathematical expression is not hard to do on your own, as we see in this week’s highlighted Stack Overflow question.
Why Does wrapContentSize()
Not Wrap My Content Size?
This can happen for text, as wrapContentSize()
does not attempt to take word wrap fully
into account. While there is an open issue on this, it
may not be avoidable in the general case. For specifically text, this workaround
might help. Learn more in this week’s highlighted Kotlinlang #compose
Slack thread.
Composable Commentary
Posts, videos, and other new information related to Jetpack Compose!
Video: Animating Your World
Google’s Doris Liu joined the Code with the Italians team to talk about Compose animations, focusing on shared element transitions and Navigation for Compose.
Medium: Custom modifiers in Jetpack Compose
Siddharth Gupta walks us through the three main ways to build custom modifiers: composed()
,
a @Composable
function that serves as a modifier “factory”, and the newer
Modifier.Node
API. The latter is more complicated but is also more performant.
Benchmark Insights: Direct State Propagation vs. Lambda-based State in Jetpack Compose
Shreyas Patil (Mastodon, Bluesky) got some pushback for an earlier post on skipping intermediate composables. So, this time around, the focus is on how the benchmarking was done to help drive the conclusions from that earlier post, emphasizing the use of macrobenchmark.
Video: Authenticated Navigation in Jetpack Compose
Paul Jones delivered a presentation for GDG Wellington, examining how to have certain routes in Navigation for Compose require authentication, including handling deeplinks that are tied to those routes.
Centering in Compose
Zach Klippenstein (Bluesky)
is pivoting towards the center. Or, at least, he is trying to help you
get your composables centered. While using Box()
with a Center
contentAlignment
works,
Zach dives more into why that works and alternative solutions, such as by using the layout()
modifier.
Google Maps in Jetpack Compose: Polylines
Joe Birch (Mastodon) continues his tour of Maps for Compose, this time examining how to draw straight lines between points on the map, including configuring the line rendering (color, width, dashed, etc.).
Medium: Widgets With Glance: Beyond String States
Katie Barnett continues her series of posts on Glance, this time looking at GlanceStateDefinition
and building a custom implementation, rather than relying solely on a string-centric,
out-of-the-box PreferencesGlanceStateDefinition
solution.
Other Interesting Links
- Medium: 5 steps to use Paging3 library with Jetpack Compose
- Medium: Collapsing Toolbar in Compose— PART 2
- Medium: Dropdown Menu with icon in Jetpack Compose
- Medium: How I Refactored A 101+ Game Arcade App To Use Jetpack Compose!
- Medium: Jetpack Compose Best Practice
- Medium: Make a color darker in Compose
- Medium: Managing UI State in Jetpack Compose: The Essential Guide
- Medium: Mastering Modifiers in Jetpack Compose
- Medium: Modifying UI with Modifiers in Android Jetpack Compose: Simplified with Everyday Analogies!
- Medium: The Ultimate Guide to Writing Clean Jetpack Compose
- Medium: Type-Safe Navigation in Jetpack Compose
- Medium: Understanding Type-Safe Compose Library
- Slides: Practical Tips and Tricks to Improve Your Compose Previews
- Type-Safe Navigation in Jetpack Compose: Passing Custom Classes
- Understanding Atomicity in Jetpack Compose: A Case Study with State
Resource Roundup
100% pure code!
GitHub: shubhamsinghshubham777 / Adapt
Shubham Singh is building up libraries that implement Apple and Microsoft design systems (used on iOS/macOS and Windows, respectively). Adapt also has “platform agnostic” widgets that use the platform’s specific design system based on the platform the code runs on (e.g., Material 3 for Android/Web).
Compose Libraries
Alex Styl (Bluesky) is assembling a catalog of Compose libraries, including ones for Compose Multiplatform.
Notable Releases
Appyx is up to 1.5.1
, adding
global plugins and updating libraries.
Redwood has a 0.16.0
release,
fixing a handful of bugs and completing some announced code removals.
Or, you can subscribe to the Atom feed or follow Mark Murphy in the Fediverse.
Recent Issues:
- 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?!?
- 2024-11-19: Compose alphas! Compose Multiplatform patch! PaddingValues! Graphics layers! Swiping! Heatmaps! Navigation! And... why did we get a new production Compose BOM?!?
- 2024-11-12: @cbruegg@mastodon.green on Compose 1.7 and compatibility! @eevis@mas.to on rendering text in a Canvas! @sinasamaki@androiddev.social and a centered slider! @touchlab@mastodon.social with a Compose-Swift bridge! And... is NavigationSuiteScaffold() FAB?!?