Status Update
Comments
ma...@google.com <ma...@google.com> #2
I'm also interested in this. Perhaps there could be some equivalent to TextOverflow
for how to handle when not all items fit, but with a Composable
arg for the ellipsis.
ki...@gmail.com <ki...@gmail.com> #3
Our team is also affected by this. Please keep us in the loop if you add this support into FlowRow!
ma...@google.com <ma...@google.com> #4
Branch: androidx-main
commit eed1e666ab45070e18718653c99fc4aee50315d6
Author: Faithful Uchenna Okoye <uokoye@google.com>
Date: Thu Nov 23 03:13:50 2023
Enhance FlowRow/Column & Introduce ContextualFlowRow with MaxLines & Overflow
This update enhances FlowRow and FlowColumn with support for maxLines and an overflow parameter, improving layout flexibility. It also introduces the ContextualFlowRow, utilizing SubcomposeLayout for efficient handling of large number of items by composing only those within the viewport.
Key Additions: maxLines/maxHeight/maxWidth overflow support in FlowRow/FlowColumn for improved item management. ContextualFlowRow/ContextualFlowColumn for efficient lazy initialization perfect for large number of items
Bug: 293577082
Test: Tested
Relnote: "Introducing ContextualFlowRow & Enhanced FlowRow/Column with MaxLines and Overflow. We are excited to announce enhancements to the experimental FlowRow and FlowColumn, now featuring maxLines and overflow support, alongside the debut of ContextualFlowRow and ContextualFlowColumn. This update is designed to provide performance optimal components, where ContextualFlow* is perfect for large number of items making using of a small maxLines config and dynamic +N see more buttons, and FlowRow and FlowColumn is perfect for small number of items, less than 100 items. Important: To maintain existing behavior in FlowRow or FlowColumn where all items are composed regardless of if they fit the cross axis max, set overflow to FlowRowOverflow.Visible or FlowColumnOverflow.Visible during initialization. Explore ContextualFlowRowSample and FlowRowSample for examples of these new features in action."
Change-Id: Ib913509969a79ff002eafb0075e6722a7a118531
M compose/foundation/foundation-layout/api/current.txt
M compose/foundation/foundation-layout/api/restricted_current.txt
M compose/foundation/foundation-layout/build.gradle
A compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/ContextualFlowLayout.kt
M compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/FlowLayout.kt
A compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/FlowLayoutBuildingBlocks.kt
A compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/FlowLayoutOverflow.kt
M compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/RowColumnImpl.kt
M compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/RowColumnMeasurementHelper.kt
M compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/MultiContentMeasurePolicy.kt
ki...@gmail.com <ki...@gmail.com> #5
Branch: androidx-main
commit 4c048675c6a0ecf03ff264945289559d4b19c8af
Author: Faithful Uchenna Okoye <uokoye@google.com>
Date: Sat Dec 02 09:48:08 2023
Created tests for FlowRow and ContextualFlowRow with maxLines
Bug: 293577082
Test: Tested in topic
Change-Id: I25946921d5169a6b6595f7d189f49b4846e5fac6
A compose/foundation/foundation-layout/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/layout/ContextualFlowRowColumnTest.kt
M compose/foundation/foundation-layout/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/layout/FlowRowColumnTest.kt
M compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/layout/LookaheadScopeTest.kt
ap...@google.com <ap...@google.com> #6
Branch: androidx-main
commit fa4ea5b238c4e46144c955ffdf456c1041e61f01
Author: Faithful Uchenna Okoye <uokoye@google.com>
Date: Wed Nov 29 05:54:51 2023
Created samples for FlowRow and ContextualFlowRow with maxLines
Bug: 293577082
Test: Tested in topic
Change-Id: I9c10084c67eb78d24fb23df6ae11db192f230c7c
A compose/foundation/foundation-layout/integration-tests/layout-demos/src/main/java/androidx/compose/foundation/layout/demos/ContextualFlowColumnDemo.kt
A compose/foundation/foundation-layout/integration-tests/layout-demos/src/main/java/androidx/compose/foundation/layout/demos/ContextualFlowRowDemo.kt
M compose/foundation/foundation-layout/integration-tests/layout-demos/src/main/java/androidx/compose/foundation/layout/demos/LayoutDemos.kt
M compose/foundation/foundation-layout/integration-tests/layout-demos/src/main/java/androidx/compose/foundation/layout/demos/SimpleFlowColumnDemo.kt
M compose/foundation/foundation-layout/integration-tests/layout-demos/src/main/java/androidx/compose/foundation/layout/demos/SimpleFlowRowDemo.kt
A compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/ContextualFlowColumnSample.kt
A compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/ContextualFlowRowSample.kt
M compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/FlowColumnSample.kt
M compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/FlowRowSample.kt
M compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/ContextualFlowLayout.kt
M compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/FlowLayout.kt
M compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/FlowLayoutOverflow.kt
am...@gmail.com <am...@gmail.com> #8
You're very welcome!
al...@gmail.com <al...@gmail.com> #9
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.compose.foundation:foundation-layout:1.7.0-alpha03
androidx.compose.foundation:foundation-layout-android:1.7.0-alpha03
androidx.compose.foundation:foundation-layout-desktop:1.7.0-alpha03
androidx.compose.ui:ui:1.7.0-alpha03
androidx.compose.ui:ui-android:1.7.0-alpha03
androidx.compose.ui:ui-desktop:1.7.0-alpha03
ma...@google.com <ma...@google.com> #10
Will there ever be support for Android 11 and below?
Stretch effect overscroll will be supported only for android 12 and above. For versions prior to that, the original glow edge overscroll will be shown.
This is done by design, so that overscroll in every app will feel the same, leaving users with the feel of consistency.
I hope that makes sense.
ku...@gmail.com <ku...@gmail.com> #11
ma...@google.com <ma...@google.com> #12
This looks broken indeed. I believe this should not happen if you are using latest snapshot where we properly support stretch effect. Could you share more information about this sample's setup? Compose version, code with snippet (is it LazyColumn, Modifier.verticalScroll or your own Modifier.scrollable) and any other relevant info.
Thanks.
ku...@gmail.com <ku...@gmail.com> #13
I used LazyColumn in compose_version = '1.1.0-alpha03'
. I just created a brand new project to test this, still the same issue. I am attaching android version,build number... if that helps.
//code snippet
@Composable
fun ScreenMain() {
LazyColumn(
modifier = Modifier.fillMaxSize(),
content = {
items(30) {
RowItem(number = it)
}
})
}
@Composable
fun RowItem(number: Int) {
Box(
modifier = Modifier
.fillMaxWidth()
.height(50.dp)
.padding(all = 8.dp)
.border(width = 1.dp, color = Color.Red),
contentAlignment = Alignment.Center,
) {
Text(text = "Row $number", color = Color.Black)
}
}
ma...@google.com <ma...@google.com> #14
Thanks for additional info.
I tried this example in the emulator, pixel 3 and some various Samsungs, and I cannot reproduce the issue for some reason.
There's a version check that prohibits any kind of overscroll for S devices on 1.1.0-alpha03.
Could you please try a real phone with android S if you have some? Or a fresh emulator image?
Alternatively, you can turn off overscroll for now and wait for alpha04 where stretch overscroll for S devices will be fully supported.
ku...@gmail.com <ku...@gmail.com> #15
Thanks for the reply. I reinstalled Android S Images and then created a new virtual device. Issue seems to be resolved now. Probably issue was with the S preview.
ma...@google.com <ma...@google.com> #16
Oh, that makes sense as well, as some S previews had incomplete support for stretch in the RenderNode, so it might have been broken there.
I'm glad that everything is working well for you now!
al...@gmail.com <al...@gmail.com> #17
Is the default material color correct for both light mode and dark mode? I see 0xff666666
hardcoded here:
But IIRC this color is themed using android:colorEdgeEffect
, for example here:
Might need to update MaterialTheme.kt
and the
ma...@google.com <ma...@google.com> #18
Yup, you are right.
The default color is design system agnostic. Since we're waiting for API feedback - we cannot wire up foundation glow api with material just yet. It will be done as soon as we will graduate OverScrollConfiguration from experimental.
you can do it manually for now in your app.
Description
On Android, over-scroll ripples show up by default on scrollable containers such as
ScrollView
andRecyclerView
. Internally they are implemented usingEdgeEffect
and their colors are typically customized in the application theme usingandroid:colorEdgeEffect
.I noticed this behavior does not seem to exist in Compose. It would be great if it could be supported to achieve parity with the traditional view system!
(I'm filing this under the
material
tracker because the default edge effect renders a ripple animation on Android, but I realize the scope of this likely falls under thefoundation
category as well).