Align load comments button and progress indicator

This commit is contained in:
FooIbar committed 2024-04-06 15:24:54 +08:00
1 parent d84e948352
commit 8e45014e3f
1 file changed
+21 -19
@@ -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))
}
}
}
}
}