Status Update
Placement/reordering animations in lists: Available since 1.1.0
Placement/reordering animations in grids: Available since 1.2.0
Placement/reordering animations in staggered grids: Available since 1.5.x betas
Additions/removals animations: In progress
Comments
cl...@google.com <cl...@google.com>
an...@google.com <an...@google.com>
ra...@twinhealth.com <ra...@twinhealth.com> #2
```
SwipeToDismissBox(
state = swipeToDismissBoxState,
onDismissed = { finish() },
hasBackground = false
) { isBackground ->
```
Google Map inside SwipeToDismissBox - scrolling works, but no swipe to dismiss.
Branch
an...@google.com <an...@google.com> #3
Running the code from the map_swipe branch - I'm seeing that MapActivity and MapWithDismissActivity are scrolling the map ok, but the SwipeToDismiss is not working (so that's different to the behaviour reported above). But I do see the reported behaviour in App itself, that within SwipeDismissableNavHost, that SwipeToDismissBox is always handling horizontal swipes, so probably the map does not receive those gestures. Not clear yet why this is, because Modifier.edgeSwipeToDismiss is working for other horizontally scrollable components.
ro...@gmail.com <ro...@gmail.com> #4
Having looked into this in more detail, GoogleMap does not support nested scrolling, so it's not compatible with Modifier.edgeSwipeToDismiss. Instead, we've seen that adding an 'enabled' parameter to SwipeDismissableNavHost and setting enabled = !cameraPositionState.isMoving would allow panning horizontally and vertically in the map (and adding a button to dismiss the screen). NB caveat is that there's a bug where the initial swipe needs to be vertical to avoid the parent handling it - this affects other scroll types as well as the Wear SwipeToDismiss.
We will look at adding the enabled parameter to Wear Compose in the near future (after release of 1.0).
ka...@gmail.com <ka...@gmail.com> #5
sh...@gmail.com <sh...@gmail.com> #6
Branch: androidx-main
commit 9ca92a49e6529a24f9678b319074a9c7c532d74b
Author: Rajat Biswas <rajatbiswas@google.com>
Date: Tue Jul 04 11:16:50 2023
userSwipeEnabled param added to SwipeDismissableNavHost
Bug: 230865655
Test: androidx.wear.compose.navigation.SwipeDismissableNavHostTest
Relnote: "Added a param userSwipeEnabled to SwipeDismissableNavHost
which can disable swipe gesture if turned false."
Change-Id: Id2a0befd6895598967ccc6d617a7d4b52756b8c6
M wear/compose/compose-navigation/api/current.txt
M wear/compose/compose-navigation/api/restricted_current.txt
M wear/compose/compose-navigation/src/androidTest/kotlin/androidx/wear/compose/navigation/SwipeDismissableNavHostTest.kt
M wear/compose/compose-navigation/src/main/java/androidx/wear/compose/navigation/SwipeDismissableNavHost.kt
ap...@google.com <ap...@google.com> #7
ma...@gmail.com <ma...@gmail.com> #8
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.wear.compose:compose-navigation:1.3.0-alpha02
an...@google.com <an...@google.com> #9
ro...@gmail.com <ro...@gmail.com> #10
In which version of Compose will the modifier be available?
an...@google.com <an...@google.com> #11
in 1.1.0-beta03
sh...@gmail.com <sh...@gmail.com> #12
Since there is no key param available in LazyVerticalGrid items or item. How are we supposed to use it with them.
Would it still work if I wrape item content in key composable
an...@google.com <an...@google.com> #13
om...@gmail.com <om...@gmail.com> #14
an...@google.com <an...@google.com> #15
sl...@gmail.com <sl...@gmail.com> #16
co...@gmail.com <co...@gmail.com> #17
jd...@google.com <jd...@google.com> #18
+1, can you please provide an update? :)
I think that list animations are pretty important and we can't always animate lists the way we want using the current APIs.
For instance, I'm trying to nicely animate a list whose items are updated every once in a while (some items are updated, some are removed, some are added). I tried to achieve this using an AnimatedVisibility
block for each item (see TransitionManager.beginDelayedTransition
in the traditional view system:
- when an item is added, we first expand the location of the item (and move the siblings and resize their ancestors) then fade it in.
- when an item is removed, we first fade it out then shrink the location of the item.
We can simulate something similar by adding some delays in the AnimatedVisibility
enter & exit transition specs, but it does not work well when removing and adding elements at the same time. This is illustrated in the video below: if my list has a single item and that I remove it but add a different item at the same time, then the following happens:
- The list grows because of the new item that is added. At the same time we fade out the item that is removed.
- The list shrinks because of the item that is being removed. At the same time we fade in the item that is added.
The ideal animation would just fade out the first item, then directly fade in the new item given that we don't need to shrink/grow the list.
It would be really great if this was handled out of the box by LazyColumn
/LazyRow
, for instance like this:
// Because we are using a MutableStateList
// or any other observable list, LazyColumn
// can keep track of the updates and animate
// its items in/out & move them accordingly.
val items = remember {
mutableStateListOf<Item>(/* some default list */)
}
LazyColumn {
items(items, { it.id }) { item ->
MyItem(item)
}
item {
Button(onClick = {
if (items.isNotEmpty()) {
// This will automatically animate given that we
// know exactly which item has been removed.
items.removeAt(0)
}
}) {
Text("Remove First")
}
}
}
We could also have an API that takes any kind of List<T>
+ DiffUtil.ItemCallback<T>
(or similar) :)
ka...@gmail.com <ka...@gmail.com> #20
in the example given, the list expands/shrinks for item insertion/deletion however it still does NOT fade in / fade out over time, if I'm not mistaken ?
Original diffutil animations have the short delayed fade in / fade out animations together with expansion / shrink when they're enabled on the recyclerview.
an...@google.com <an...@google.com> #21
ka...@gmail.com <ka...@gmail.com> #22
ma...@quantox.com <ma...@quantox.com> #23
I have a question regarding item animations.
Some of my layouts are laid out like this (copied from docs as valid case):
LazyVerticalGrid(
// ...
) {
item { Item(0) }
item {
Item(1)
Divider()
}
item { Item(2) }
// ...
}
Since most of my items have Item and Divider inside item {} block, and .animateItemPlacement() should be put directly on content, what should I do in situation like this? Do I have to wrap Item and Divider in a Column, and then put animation on a Column or is there another way?
Thanks.
an...@google.com <an...@google.com> #24
Can I ask for future to file separate bugs for questions like this as any new comment it this bug is currently sending an email to everyone who +1ed this bug. Thanks!
ra...@twinhealth.com <ra...@twinhealth.com> #25
ka...@gmail.com <ka...@gmail.com> #26
People are trying to come up with hacky answers on Stackoverflow without much success or any convenience.
this might not even be in backlog...
kl...@gmail.com <kl...@gmail.com> #27
ka...@gmail.com <ka...@gmail.com> #28
kl...@gmail.com <kl...@gmail.com> #29
an...@google.com <an...@google.com> #30
il...@gmail.com <il...@gmail.com> #31
Can you please provide any status update / dates if possible?
rl...@gmail.com <rl...@gmail.com> #32
pe...@gmail.com <pe...@gmail.com> #33
jo...@google.com <jo...@google.com> #34
Hi, the Play store team is working on a feature which could greatly benefit from LazyColumn's addition/deletion animation support. Do you have an updated ETA that you can share with you? Thanks!
da...@gmail.com <da...@gmail.com> #35
ry...@google.com <ry...@google.com> #36
ka...@gmail.com <ka...@gmail.com> #37
its almost been 2 years now and even your internal teams at play store are asking for the item addition deletion animations, I was the first to bring this up in this thread first.
Is there any ETA on this ? It was a core functionality with DiffUtils which we shouldnt find workarounds as an implementation for Compose !
Could anyone from Google please share an ETA on this
an...@google.com <an...@google.com> #38
Hello. We are currently finializing the design for the underlying mechanism we will be using for the disappearance animations. Sorry, we can't give exact estimations, but I can reassure you this feature is in works
mo...@gmail.com <mo...@gmail.com> #39
ka...@gmail.com <ka...@gmail.com> #40
bro
ka...@gmail.com <ka...@gmail.com> #41
I kind of agree with the last poster, if we all "bro" the developers every year or month to bump the thread, they might feel pressured to finish the removal/addition animations. Anyways, hang in there champ, they're probably almost done with that last piece of work
se...@gmail.com <se...@gmail.com> #42
it...@gmail.com <it...@gmail.com> #43
ta...@gmail.com <ta...@gmail.com> #44
Yesterday was the 4th year open anniversary of this issue lol
it...@gmail.com <it...@gmail.com> #45
mu...@gmail.com <mu...@gmail.com> #46
ph...@gmail.com <ph...@gmail.com> #47
ap...@google.com <ap...@google.com> #49
Branch: androidx-main
commit 36578696db7997ec73d1f81ae55e6b61951e7895
Author: Andrey Kulikov <andreykulikov@google.com>
Date: Tue Jul 04 16:14:07 2023
Item disappearance animation for lazy lists
We add support for the disappearance animation for lazy list items. The appearance animation was added as an internal api as part of aosp/2644850. We are using the new graphics layer implementation we recently added as part of aosp/2969199 and a set of preceding cls. This new graphics layer implementation is automatically counting the amount of usages for each layer, meaning that even when the layer is technically released by its main user, the underlying drawn content is not discarded until all the parent layers stop drawing it as well. It allows us to continue drawing the item being removed for the duration of disappearance animation. This logic was added in aosp/2967570.
As part of this cl we made both appearance and disappearance animation support public for LazyColumn and LazyRow. Support for other lazy layouts will be added in the next cls. Support for other types of animations is tracked in
Fixes: 150812265
Relnote: Item appearance and disappearance animation support was added into `LazyColumn` and `LazyRow`. Previously it was possible to add `Modifier.animateItemPlacement()` modifier in order to support placement (reordering) animations. We deprecated this modifier and introduced a new non-experimental modifier called `Modifier.animateItem()` which allows you to support all three animation types: appearance (fade in), disappearance (fade out) and reordering.
Test: new LazyListItemDisappearanceAnimationTest
Change-Id: I2d7f7a376cea26c0a36a59a4586d2705ab04cab7
M compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/lookahead/LookaheadWithAnimateItemPlacement.kt
M compose/foundation/foundation/api/current.txt
M compose/foundation/foundation/api/restricted_current.txt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/LazyColumnDragAndDropDemo.kt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/ListDemos.kt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/PopularBooksDemo.kt
M compose/foundation/foundation/integration-tests/lazy-tests/src/androidTest/kotlin/androidx/compose/foundation/lazy/list/LazyListItemAppearanceAnimationTest.kt
A compose/foundation/foundation/integration-tests/lazy-tests/src/androidTest/kotlin/androidx/compose/foundation/lazy/list/LazyListItemDisappearanceAnimationTest.kt
M compose/foundation/foundation/integration-tests/lazy-tests/src/androidTest/kotlin/androidx/compose/foundation/lazy/list/LazyListItemPlacementAnimationTest.kt
M compose/foundation/foundation/integration-tests/lazy-tests/src/androidTest/kotlin/androidx/compose/foundation/lazy/list/LazyListTest.kt
M compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/LazyDslSamples.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyItemScope.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyItemScopeImpl.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyList.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListItemAnimator.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListMeasure.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListMeasuredItem.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/grid/LazyGridItemPlacementAnimator.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/grid/LazyGridItemScopeImpl.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/layout/LazyLayoutAnimation.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridItemPlacementAnimator.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridItemScope.kt
an...@google.com <an...@google.com> #50
Item appearance and disappearance animation support was added into LazyColumn
and LazyRow
. Previously it was possible to add Modifier.animateItemPlacement()
modifier in order to support placement (reordering) animations. We deprecated this modifier and introduced a new non-experimental modifier called Modifier.animateItem()
which allows you to support all three animation types: appearance (fade in), disappearance (fade out) and reordering.
This change is expected to be released as part of 1.7.0-alpha06
release.
Port of this modifier into lazy grids is tracked here:
To staggered grids here:
Support of other animation types aside of fade in/fade out is tracked here:
ca...@gmail.com <ca...@gmail.com> #51
Failed to transform lifecycle-livedata-core-2.8.0-alpha04.aar (androidx.lifecycle:lifecycle-livedata-core:2.8.0-alpha04) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=26, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}.
Caused by: [CIRCULAR REFERENCE: java.lang.NullPointerException]
When I try to use 1.7.0-alpha06, any recommendation?
ry...@google.com <ry...@google.com> #52
@
lo...@gmail.com <lo...@gmail.com> #53
Hello, in the doc, under the heading "Item animations", the last sentence that references this issue should be changed, or removed:
It still says:
Aside from reorderings, item animations for additions and removals is currently in development. You can track the progress in issue
. 150812265
jo...@google.com <jo...@google.com> #54
Thank you for letting us know! We've updated the documentation page :)
Description
Placement/reordering animations in lists: Available since 1.1.0
Placement/reordering animations in grids: Available since 1.2.0
Placement/reordering animations in staggered grids: Available since 1.5.x betas
Additions/removals animations: In progress