@@ -177,7 +177,12 @@ fun RefreshHeader(
177177
178178 val textAlpha = when (pullToRefreshState.refreshState) {
179179 RefreshState .Pulling -> {
180- if (pullToRefreshState.pullProgress > 0.5f ) (pullToRefreshState.pullProgress - 0.5f ) * 2 else 0f
180+ if (pullToRefreshState.pullProgress > 0.5f ) (pullToRefreshState.pullProgress - 0.5f ) else 0f
181+ }
182+
183+ RefreshState .RefreshComplete -> {
184+ println (1f - refreshCompleteAnimProgress * 0.6f )
185+ 1f - refreshCompleteAnimProgress * 1.2f
181186 }
182187
183188 else -> 1f
@@ -189,7 +194,7 @@ fun RefreshHeader(
189194 RefreshState .Pulling -> circleSize * pullProgress
190195 RefreshState .ThresholdReached -> circleSize + (dragOffset - thresholdOffset).toDp()
191196 RefreshState .Refreshing -> circleSize
192- RefreshState .RefreshComplete -> circleSize
197+ RefreshState .RefreshComplete -> circleSize.coerceIn( 0 .dp, circleSize - circleSize * refreshCompleteAnimProgress)
193198 }.coerceAtMost(maxDrag.toDp())
194199 }
195200
@@ -198,14 +203,12 @@ fun RefreshHeader(
198203 horizontalAlignment = Alignment .CenterHorizontally
199204 ) {
200205 RefreshContent (
201- modifier = Modifier
202- .height(headerHeight)
203- .padding(top = 6 .dp),
206+ modifier = Modifier .height(headerHeight),
204207 circleSize = circleSize
205208 ) {
206- val ringStrokeWidthPx = circleSize.toPx() / 10
209+ val ringStrokeWidthPx = circleSize.toPx() / 11
207210 val indicatorRadiusPx = size.minDimension / 2
208- val center = Offset (size.width / 2 , size.height / 2 )
211+ val center = Offset (size.width / 2 , size.height / 1.8f )
209212
210213 when (pullToRefreshState.refreshState) {
211214 RefreshState .Idle -> return @RefreshContent
@@ -251,15 +254,17 @@ fun RefreshHeader(
251254 }
252255
253256 AnimatedVisibility (
254- visible = pullToRefreshState.refreshState != RefreshState .Idle
257+ visible = pullProgress >= 0.5f
258+ && pullToRefreshState.refreshState != RefreshState .Idle
259+ && pullToRefreshState.refreshState != RefreshState .RefreshComplete
255260 ) {
256261 Text (
257262 text = refreshText,
258263 style = refreshTextStyle,
259264 color = color,
260265 modifier = Modifier
261- .padding(top = 12 .dp)
262266 .alpha(textAlpha)
267+ .padding(top = 6 .dp)
263268 )
264269 }
265270 }
@@ -423,9 +428,11 @@ private fun DrawScope.drawRefreshCompleteState(
423428 refreshCompleteProgress : Float
424429) {
425430 val animatedRadius = radius * (1f - refreshCompleteProgress)
431+ val alphaColor = color.copy(alpha = 1f - refreshCompleteProgress)
432+
426433 if (animatedRadius > 0 ) {
427434 drawCircle(
428- color = color ,
435+ color = alphaColor ,
429436 radius = animatedRadius,
430437 center = center,
431438 style = Stroke (strokeWidth, cap = StrokeCap .Round )
0 commit comments