jetc.dev Newsletter Issue #87
Published: 2021-10-19
1.0.4
and 1.1.0-alpha06
were released, so we take a peek at them!
Also, we look at the impact of composables on garbage collection, where Wear OS is going with its Compose integration, and adding ExoPlayer for video playback. Plus, we explore Clean Architecture, GraphQL, and yet another attempt to make Navigation for Compose easier.
Patch Preview and Alpha Analysis
Reviewing the release notes for the latest Jetpack Compose update!
Compose 1.0.4
was released. The headline is that it works with Kotlin 1.5.31.
In fact, that appears to be the only actual change.
We also got Compose 1.1.0-alpha06
. Of note:
-
If you have tests that inject input events, note that the default time between those events was raised from 10ms to 16ms. This might affect the timing of your tests.
-
There is a new
ExposedDropdownMenu
. -
PopupProperties
renameddismissOnClickOutside
todismissOnOutsideClick
and changed the parameter list. -
Recomposer.state
was deprecated. The alternative is aStateFlow
namedRecomposer.currentState
. -
A
ViewConfiguration
is now supplied toLayoutInfo
andInjectionScope
.InjectionScope
now also implementsDensity
(for easierpx
/dp
conversions) and hasflush()
anddispose()
functions.
One Off the Stack, One Off the Slack
You’ve got questions. That’s understandable!
How Do I Add Strikethrough to Text?
Sometimes, we want to strike out some text. In Compose UI,
Text()
handles this via TextStyle
and TextDecoration.LineThrough
, as we see
in this week’s highlighted Stack Overflow question.
When Do Composition Contents Get GC’d?
Migrating from object models to function-centric programming is confusing enough in Compose.
The fact that composables hold onto some objects past the function call adds to the confusion.
We see what is and what is not retained for recompositions in this week’s
highlighted Kotlinlang #compose
Slack thread.
Composable Commentary
Posts, videos, and other new information related to Jetpack Compose!
Compose for Wear OS now in Developer Preview!
The Wear Compose / Compose for Wear OS artifacts were bumped up to 1.0.0-alpha08
.
According to this official blog post, that is a “developer preview”. 🤷 Regardless, Compose for Wear OS
is progressing fairly nicely.
Compose for Wear OS: Scaffold
Nikit Bhandari examines some of the core composables in Compose for Wear OS,
including Scaffold()
, Vignette()
, and PositionIndicator()
.
Learn with code: Jetpack Compose — Playing Media (Part 3)
Ruben Quadros is back, continuing a series of posts examining Compose UI-based app
development. This time, Ruben shows how to integrate ExoPlayer via an AndroidView
wrapping SimpleExoPlayer
, to play back videos within the app.
Medium: Jetpack Compose Side Effects — DisposableEffect: effects that require cleanup
Umair Khalid resumes a tour of Compose effects, looking at DisposableEffect()
for
cases where you need to do some work to “undo” a side effect when the composition
is disposed, such as unregistering a listener.
Medium: Clean Architecture in the flavour of Jetpack Compose
“Clean Architecture” is one of those things that lots of people agree with in principle
but not all that many implement fully. Here, Paul Allies explores what it takes to create
a fairly faithful implementation of Clean Architecture, complete with use cases, Jetpack’s
ViewModel
, and more.
Video: Using GraphQL in a KMM project with Jetpack Compose and SwiftUI
John O’Reilly has been exploring Kotlin/Multiplatform, sharing common code while using customized UIs for Android (via Compose UI) and iOS (via SwiftUI). In this presentation to Brighton Kotlin, John talks about those experiences, specifically when using the Apollo client library for accessing GraphQL-based Web services.
Jetpack Compose Hourglass animation on canvas in Android
Rajasekhar walks through what it takes to render custom shapes to a Compose UI Canvas()
,
in this case drawing a basic hourglass shape.
Jetpack Compose vs Tetris®
Graziano Rizzi did not write a post about Tetris®. Rather, Graziano wrote a post about rendering a game-style UI using Compose UI, where that UI consists of falling blocks that can be rotated. Any resemblance of this to Tetris® is purely coincidental. 😉
Other Interesting Links
- Learn with code: Jetpack Compose — Lists and Pagination (Part 1)
- Jetpack Compose: Drag-and-drop reorder for lists
- Medium: Jetpack Composable to Bitmap Image
- Rebuilding The Flutter Counter App In Jetpack Compose
- Bottom Navigation in Jetpack Compose
- Modern Design Practices: Jetpack Compose
- Jetpack Compose Basics
- Medium: Getting Started With Jetpack Compose
- Medium: JETPACK COMPOSE: Understanding Prerequisite, Use-case, and Code flow
Resource Roundup
100% pure code!
GitHub: STAR-ZERO / compose-navgen
Another week, another library to try to simplify the use of Navigation for Compose.
In this case, Kenji Abe is working on a KSP-based Gradle plugin to take @NavGen
-annotated
composables and create routes and helper functions for you, to make navigating
to those composables look more like just calling ordinary functions.
GitHub: warting / permissions-ui
Runtime permissions are annoying. Location runtime permissions are even more annoying,
particularly for background use and on Android 12+. Stefan Wärting created a
LocationInBackgroundTutorialView()
composable that aims to hide all of that
complexity, while also providing an explanatory UI to help guide the user through
the process.
Other Interesting Links
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?!?