From 8e45014e3f0ee47d83ae011307cf54f38da66086 Mon Sep 17 00:00:00 2001 From: FooIbar <118464521+FooIbar@users.noreply.github.com> Date: Sat, 6 Apr 2024 12:28:05 +0800 Subject: [PATCH] Align load comments button and progress indicator --- .../ui/screen/GalleryCommentsScreen.kt | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/GalleryCommentsScreen.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/GalleryCommentsScreen.kt index 4416bc5b1..b69719caf 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/GalleryCommentsScreen.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/GalleryCommentsScreen.kt @@ -7,7 +7,7 @@ import android.text.style.ForegroundColorSpan import android.text.style.RelativeSizeSpan import android.text.style.StyleSpan import android.widget.TextView -import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.Crossfade import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column @@ -377,25 +377,27 @@ fun GalleryCommentsScreen(gid: Long, navigator: DestinationsNavigator) = composi } if (comments.hasMore) { item { - AnimatedVisibility(refreshing) { - Box(modifier = Modifier.fillMaxWidth()) { - CircularProgressIndicator( - modifier = Modifier.align(Alignment.Center).padding(keylineMargin), - ) - } - } - AnimatedVisibility(!refreshing) { - TextButton( - onClick = { - launchIO { - refreshing = true - runSuspendCatching { refreshComment(true) } - refreshing = false - } - }, - modifier = Modifier.fillMaxWidth().padding(keylineMargin), + Crossfade(targetState = refreshing, modifier = Modifier.padding(keylineMargin), label = "refreshing") { + Box( + modifier = Modifier.fillMaxWidth().height(40.dp), + contentAlignment = Alignment.Center, ) { - Text(text = stringResource(id = R.string.click_more_comments)) + if (it) { + CircularProgressIndicator() + } else { + TextButton( + onClick = { + launchIO { + refreshing = true + runSuspendCatching { refreshComment(true) } + refreshing = false + } + }, + modifier = Modifier.fillMaxWidth(), + ) { + Text(text = stringResource(id = R.string.click_more_comments)) + } + } } } }