Status Update
Comments
co...@google.com <co...@google.com> #3
Does this happen if you temporarily remove/disable the pull-refresh part?
ma...@gmail.com <ma...@gmail.com> #4
ma...@gmail.com <ma...@gmail.com> #5
re...@lunabee.com <re...@lunabee.com> #6
We're facing the same issue with TopAppBar
and TopAppBarDefaults.pinnedScrollBehavior
. When scrolling quickly on a lazy layout, the app bar container color does not respond.
Repo:
Video:
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior()
Scaffold(
modifier = Modifier
.fillMaxSize()
.nestedScroll(scrollBehavior.nestedScrollConnection),
topBar = {
TopAppBar(
title = {
Text(
modifier = Modifier.fillMaxWidth(),
text = "Hello!",
textAlign = TextAlign.Center,
)
},
scrollBehavior = scrollBehavior,
)
},
) { innerPadding ->
LazyColumn(
modifier = Modifier.padding(innerPadding),
contentPadding = PaddingValues(16.dp),
verticalArrangement = Arrangement.spacedBy(8.dp),
) {
items(100) {
Text(
text = "Item $it",
modifier = Modifier
.fillMaxWidth()
.background(MaterialTheme.colorScheme.surfaceContainerHigh)
.padding(24.dp),
)
}
}
}
co...@google.com <co...@google.com> #7
I am facing the same bug and i think the root case for it is that the PinnedScrollBehavior
doesn't override the onPostFling
in its NestedScrollConnection
implementation.
I made a crude simple custom version and added
override suspend fun onPostFling(consumed: Velocity, available: Velocity): Velocity {
if (available.y > Velocity.Zero.y)
state.contentOffset = 0f
return super.onPostFling(consumed, available)
}
and then it works fine for me!
ap...@google.com <ap...@google.com> #8
Project: platform/frameworks/support
Branch: androidx-main
Author: Shalom Gibly <
Link:
Fix the app-bars behaviors to detect end of scroll
Expand for full commit details
Fix the app-bars behaviors to detect end of scroll
Apply a fix to all the behaviors to detect the end of scroll in the post
fling function. This will better ensure an app-bar color change when the
content is scrolled all the way.
Bug: 293665988
Test: Manual
Relnote: "Fix the top and bottom app-bar behaviors to reliably change
color when content is scrolled all the way."
Change-Id: Idc4e834695cbd7cb8099f7b63cf21d5b764f1c81
Files:
- M
compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/AppBar.kt
Hash: 792c8cdf7db425c674de1214e60c7d01f46e9750
Date: Mon Nov 25 06:03:57 2024
co...@google.com <co...@google.com>
na...@google.com <na...@google.com> #9
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.compose.material3:material3:1.2.0-rc01
androidx.compose.material3:material3-android:1.2.0-rc01
androidx.compose.material3:material3-desktop:1.2.0-rc01
Description
instead of broken content color for icons there are also bug with text
@Composable
fun ExpandableItem(
modifier: Modifier = Modifier,
visibleContent: @Composable RowScope.(Boolean) -> Unit,
expandableContent: @Composable ColumnScope.(Boolean) -> Unit,
initialState: Boolean = false,
verticalArrangement: Arrangement.Vertical = Arrangement.Top,
shape: RoundedCornerShape = RoundedCornerShape(20.dp),
color: Color = MaterialTheme.colorScheme.surfaceColorAtElevation(2.dp)
) {
val haptics = LocalHapticFeedback.current
Column(
Modifier
.animateContentSize()
.then(modifier)
.container(
color = color,
resultPadding = 0.dp,
shape = shape
)
) {
var expanded by rememberSaveable { mutableStateOf(initialState) }
val rotation by animateFloatAsState(if (expanded) 180f else 0f)
Row(
modifier = Modifier
.clip(shape)
.clickable {
haptics.performHapticFeedback(
HapticFeedbackType.LongPress
)
expanded = !expanded
}
.padding(8.dp),
verticalAlignment = Alignment.CenterVertically
) {
Row(Modifier.weight(1f)) {
visibleContent(expanded)
}
EnhancedIconButton(
containerColor = Color.Transparent,
contentColor = LocalContentColor.current,
enableAutoShadowAndBorder = false,
onClick = { expanded = !expanded }
) {
Icon(
imageVector = Icons.Rounded.KeyboardArrowDown,
contentDescription = null,
modifier = Modifier.rotate(rotation)
)
}
}
AnimatedVisibility(expanded) {
Column(verticalArrangement = verticalArrangement) {
Spacer(modifier = Modifier.height(8.dp))
expandableContent(expanded)
Spacer(modifier = Modifier.height(8.dp))
}
}
}
}
this code gives EnhancedIconButton black color instead of needed one, moreover, the text inside visible content is also black!!!!!!!!!!
BUT container modifier provides it and all were okay on previous version
fun Modifier.container(
shape: Shape = RoundedCornerShape(16.dp),
color: Color = Color.Unspecified,
resultPadding: Dp = 4.dp,
borderColor: Color? = null,
autoShadowElevation: Dp = 1.dp,
clip: Boolean = true,
composeColorOnTopOfBackground: Boolean = true,
isShadowClip: Boolean = false,
isStandaloneContainer: Boolean = true
) = composed {
val localContainerShape = LocalContainerShape.current
val resultShape = localContainerShape ?: shape
val settingsState = LocalSettingsState.current
val colorScheme = MaterialTheme.colorScheme
val color1 = if (color.isUnspecified) {
colorScheme.surfaceColorAtElevation(1.dp)
} else {
if (composeColorOnTopOfBackground) color.compositeOver(colorScheme.background)
else color
}
val density = LocalDensity.current
val genericModifier = Modifier.drawWithCache {
val outline = resultShape.createOutline(
size,
layoutDirection,
density
)
onDrawWithContent {
drawOutline(
outline = outline,
color = color1
)
if (settingsState.borderWidth > 0.dp) {
drawOutline(
outline = outline,
color = borderColor ?: colorScheme.outlineVariant(0.1f, color1),
style = Stroke(with(density) { settingsState.borderWidth.toPx() })
)
}
drawContent()
}
}
val cornerModifier = Modifier
.background(
color = color1,
shape = resultShape
)
.border(
width = LocalSettingsState.current.borderWidth,
color = borderColor ?: colorScheme.outlineVariant(0.1f, color1),
shape = resultShape
)
this
.materialShadow(
shape = resultShape,
elevation = animateDpAsState(
if (settingsState.borderWidth > 0.dp) {
0.dp
} else autoShadowElevation.coerceAtLeast(0.dp)
).value,
enabled = if (isStandaloneContainer) {
LocalSettingsState.current.drawContainerShadows
} else true,
isClipped = isShadowClip
)
.then(
if (resultShape is CornerBasedShape) cornerModifier
else genericModifier
)
.then(if (clip) Modifier.clip(resultShape) else Modifier)
.then(if (resultPadding > 0.dp) Modifier.padding(resultPadding) else Modifier)
}