Status Update
Comments
co...@google.com <co...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
Author: Louis Pullen-Freilich <
Link:
Adds OverscrollEffect#withoutDrawing and OverscrollEffect#withoutEventHandling
Expand for full commit details
Adds OverscrollEffect#withoutDrawing and OverscrollEffect#withoutEventHandling
These APIs allow overscroll to have events dispatched to it by one component, and rendered in a separate component.
Fixes: b/266550551
Fixes: b/204650733
Fixes: b/255554340
Fixes: b/229537244
Test: OverscrollTest
Relnote: "Adds OverscrollEffect#withoutDrawing and OverscrollEffect#withoutEventHandling APIs - these APIs create a wrapped instance of the provided overscroll effect that doesn't draw / handle events respectively, which allows for rendering overscroll in a separate component from the component that is dispatching events. For example, disabling drawing the overscroll inside a lazy list, and then drawing the overscroll separately on top / elsewhere."
Change-Id: Idbb3d91546b49c1987a041f959bce4b2b09a9f61
Files:
- 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/OverscrollDemo.kt
- M
compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/OverscrollSample.kt
- M
compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/OverscrollTest.kt
- M
compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Overscroll.kt
Hash: f64e25b7a473c757d080521e7dd97b3f6670f60d
Date: Fri Nov 01 18:43:56 2024
lp...@google.com <lp...@google.com> #3
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.compose.foundation:foundation:1.8.0-alpha06
androidx.compose.foundation:foundation-android:1.8.0-alpha06
androidx.compose.foundation:foundation-jvmstubs:1.8.0-alpha06
androidx.compose.foundation:foundation-linuxx64stubs:1.8.0-alpha06
lp...@google.com <lp...@google.com> #4
Andrey, curious if you have any thoughts here - for classes relating to list state, like in this case app bar behavior, should we just always be encouraging using rememberSaveable
for consistency with the list / scroll state?
al...@gmail.com <al...@gmail.com> #5
The issue exists in the current material catalog app (which is the code I linked too) so I figured they could just use that to reproduce it (since all you have to do is go to the top app bar screen in the catalog demo app, scroll the screen container, and then rotate the screen). But I could also create a standalone separate Android Studio project with the same code as what is in the material catalog app if that is the preferred format.
an...@google.com <an...@google.com> #6
LazyListState knows nothing about how other participants of nested scrolling mechanism used the unused deltas. So you will not be able to get this info from the restored LazyListState.
So
remember { TopAppBarDefaults.pinnedScrollBehavior() }
is the only source of truth for such info and if it is desired to be able to restore its state it should have rememberSaveable.
Also note that it is in fact not only about restoration after screen rotation. Does AppBar display the state you want it to when you initialise LazyColumn with not 0 offset straight away? I mean something like
LazyColumn(state = rememberLazyListState(initialFirstVisibleItemIndex = 2, initialFirstVisibleItemScrollOffset = 10))
al...@gmail.com <al...@gmail.com> #7
In response to
I think there would still be a problem using rememberSaveable
though. Because for example consider:
- You start out in landscape in a list screen
- You scroll down a tiny bit in the list screen causing the top app bar to animate its color
- You rotate the device to portrait (and let's assume the list is small enough such that the entire list is shown, making the list no longer scrollable).
The desired behavior here would be that the top app bar would switch back to its initial state since the scroll position in portrait has now become 0, right?
So seems like there would need to be some way to have the top app bar and scroll position linked somehow...
sg...@google.com <sg...@google.com>
sg...@google.com <sg...@google.com>
ap...@google.com <ap...@google.com> #8
Branch: androidx-main
commit e260141f2a679c33bfbe576d3a73fd4338d54d1a
Author: Shalom Gibly <sgibly@google.com>
Date: Fri May 06 12:50:36 2022
Adds support for saving a top app bar state
- Adds a TopAppBarScrollState and use it inside the
TopAppBarScrollBehavior implementations.
- The state is provides a Saver and used by a rememberSaveable to
maintain the app bar position on configuration change.
Test: AppBarTest
Bug: 216160958
Relnote: "Supports maintaining the top app bar position on configuration
change."
Change-Id: I104599fa724196bbf1fec1bfa424a2a70abaf2fe
M compose/material3/material3/api/restricted_current.txt
M compose/material3/material3/samples/src/main/java/androidx/compose/material3/samples/AppBarSamples.kt
M compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/AppBar.kt
M compose/material3/material3/api/current.txt
M compose/material3/material3/integration-tests/material3-catalog/src/main/java/androidx/compose/material3/catalog/library/ui/common/CatalogScaffold.kt
M compose/material3/material3/api/public_plus_experimental_current.txt
M compose/material3/material3/src/androidAndroidTest/kotlin/androidx/compose/material3/AppBarTest.kt
M compose/integration-tests/demos/src/main/java/androidx/compose/integration/demos/DemoApp.kt
sg...@google.com <sg...@google.com> #9
The main part of this issue was fixed, and we made changes to the API to support it.
Example usage:
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarScrollState())
SmallTopAppBar(
....
scrollBehavior = scrollBehavior
) ...
We may still have issues with cases mentioned at
al...@gmail.com <al...@gmail.com> #10
Does it make sense to create a separate issue to track the remaining bug?
Description
When you scroll a screen using a material3 top app bar, the top app bar's scroll container color changes. However, if you rotate the screen afterwards, the
LazyColumn
's scroll position will persist but the top app bar's color will reset back as if the screen was not scrolled at all.I attached a video illustrating the problem. The video is taken from the material demo app in AOSP, specifically this demo here (I made the app bar's scroll container color red to make it more obvious).