Status Update
Comments
or...@gmail.com <or...@gmail.com> #2
Branch: androidx-master-dev
commit 23a7d960caf43390a554700d3c56ada189a9d10e
Author: Louis Pullen-Freilich <lpf@google.com>
Date: Mon Aug 10 15:11:36 2020
IconButton / IconToggleButton API scrub
Test: ./gradlew updateApi
Bug:
Bug:
Relnote: "Adds enabled parameter to IconButton, and reorders parameters in IconToggleButton"
Change-Id: I0a9419b1a631cadad451395302ad87b7f9214f96
M ui/ui-material/api/current.txt
M ui/ui-material/api/public_plus_experimental_current.txt
M ui/ui-material/api/restricted_current.txt
M ui/ui-material/src/commonMain/kotlin/androidx/compose/material/IconButton.kt
or...@gmail.com <or...@gmail.com> #3
I suspect issue is somehow related to fact that without that delay()
we're not recomposing with refreshing
set to true
....and end up showing CircularArrowIndicator
in PullRefreshIndicator
when we recompose with it set to false
jo...@google.com <jo...@google.com> #4
Louis, could you take a look at this? :) I had a quick look around but didn't find the cause.
st...@gmail.com <st...@gmail.com> #5
bo...@gmail.com <bo...@gmail.com> #6
I got the functionality working in my project but am left with the indicator visible on the screen. I thought perhaps there was some interaction with other things in my project, but I was able to reproduce it in a sample project. I used the Android Studio (macOS, see version at the bottom) new project wizard to create an empty compose activity project and then just added the code from the above PullRefreshSamples.kt. At first I thought I was not able to reproduce it but setting my background to be not white then showed me that it is reproducible. See the attached sample project.
I tried poking around to see if there was something obvious for why this is happening but didn't have any luck. For now, I'm going to revert to using the Accompanist implementation as a workaround. I hope this sample is helpful in figuring this out.
Android Studio Dolphin | 2021.3.1 Patch 1
Build #AI-213.7172.25.2113.9123335, built on September 29, 2022
Runtime version: 11.0.13+0-b1751.21-8125866 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 13.0
lp...@google.com <lp...@google.com> #7
PullRefresh
does not clip, so the indicator is drawn outside the bounds. You can change this in your project by doing:
Box(Modifier.clipToBounds().pullRefresh(state)) {
But maybe we should investigate better documentation for this / considering default behaviour
ap...@google.com <ap...@google.com> #8
Branch: androidx-main
commit b60f5bbe2a643390b95e1130e6a55048e22364cd
Author: Louis Pullen-Freilich <lpf@google.com>
Date: Thu Nov 17 18:07:08 2022
Adds clipping to Modifier.pullRefreshIndicatorTransform
This ensures that when the indicator is offset outside of its bounds (i.e it has not been dragged down yet / is not refreshing), it is not visible. This fixes cases where there is no app bar to draw over the offset indicator / the indicator background color is different from the background it is drawn over.
Bug:
Test: PullRefreshIndicatorTransformTest
Change-Id: Ic15dd35a5b3fd851bae3bc8cc6eda826e2005394
A compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/pullrefresh/PullRefreshIndicatorTransformTest.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/pullrefresh/PullRefreshIndicatorTransform.kt
ap...@google.com <ap...@google.com> #9
Branch: androidx-main
commit 4e301885e5b470a41320fd3900764a2ba5738d53
Author: Louis Pullen-Freilich <lpf@google.com>
Date: Mon Nov 21 19:03:53 2022
Fixes PullRefreshState not resetting indicator position back to 0
If onRefresh never ended up changing refreshing, or refreshing changed to true and false within the same frame so the state write was batched, the indicator would get stuck at its last position as we never animated it back to zero. Instead we now always animate the position back to zero, and any future change to setRefreshing will interrupt this animation and set it to the new correct position.
Fixes:
Test: PullRefreshStateTest
Relnote: "Fixed an issue where PullRefreshIndicator could get stuck after onRefresh is called, if the refreshing state was not changed to true."
Change-Id: Ie24160bf51bd010d165d75675cfb2c51f28dde04
M compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/pullrefresh/PullRefreshStateTest.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/pullrefresh/PullRefreshState.kt
ca...@gmail.com <ca...@gmail.com> #10
Hi, in what version can I see this fix ?
lp...@google.com <lp...@google.com> #11
It hasn't released yet, but it should be in 1.4.0-alpha03 when it released
ju...@google.com <ju...@google.com> #12
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.compose.material:material:1.4.0-alpha03
al...@onvista.de <al...@onvista.de> #13
The Box(Modifier.clipToBounds().pullRefresh(state)) {
did not fix the issue. A LaunchedEffect
delegated refreshing state fixes the issue:
@Composable
@OptIn(ExperimentalMaterialApi::class)
fun PullRefreshBox(
modifier: Modifier = Modifier,
refreshing: Boolean,
onRefresh: () -> Unit = {},
content: @Composable () -> Unit,
) {
// The LaunchedEffect is needed to fix the hiding of the indicator: https://issuetracker.google.com/issues/248274004
// Without this workaround the indicator would be visible even if the loading finished
var isRefreshingWorkaround by remember { mutableStateOf(refreshing) }
LaunchedEffect(key1 = refreshing) {
isRefreshingWorkaround = refreshing
}
val state = rememberPullRefreshState(isRefreshingWorkaround, onRefresh)
Box(
modifier = modifier.pullRefresh(state),
) {
content()
PullRefreshIndicator(
modifier = Modifier.align(Alignment.TopCenter),
refreshing = isRefreshingWorkaround,
state = state,
contentColor = MaterialTheme.colorScheme.primary,
)
}
}
jo...@gmail.com <jo...@gmail.com> #14
lp...@google.com <lp...@google.com> #15
I couldn't reproduce anything with the code provided, please file a new bug with a detailed reproduction, with the latest version of the material library.
ch...@gmail.com <ch...@gmail.com> #16
I can still reproduce the bug on compose version 1.4.0 without the workaround above, any update about this bug?
lp...@google.com <lp...@google.com> #17
Please file a new bug with a standalone sample project that reproduces this issue, I cannot reproduce on my end so it might be specific to your setup.
ma...@astropay.com <ma...@astropay.com> #18
hi...@gmail.com <hi...@gmail.com> #19
ma...@arsaga.jp <ma...@arsaga.jp> #20
WorkAround
if (state.progress > 0 || isRefreshing) PullRefreshIndicator(
refreshing = isRefreshing,
state = state,
modifier = Modifier.align(Alignment.TopCenter)
)
ne...@appsfactory.de <ne...@appsfactory.de> #21
lp...@google.com <lp...@google.com> #22
Could you share some sample code to reproduce the issue? Thanks
Description
Jetpack Compose version: 1.3.0-beta03 Jetpack Compose component used: PullRefresh Android Studio Build: Dolphin Kotlin version: 1.7.10
Steps to Reproduce or Code Sample to Reproduce:
delay()
inrefresh()
. The indicator continues to be visible (with just white circle) after refresh (see attached screenshot).Stack trace (if applicable):