Avoid drawing surface background twice for comments fragment
This commit is contained in:
parent
62ab9bd740
commit
13585ca0be
|
@ -48,71 +48,69 @@ private fun CommentSection(
|
||||||
val nestedScrollInterop = rememberNestedScrollInteropConnection()
|
val nestedScrollInterop = rememberNestedScrollInteropConnection()
|
||||||
val state = rememberLazyListState()
|
val state = rememberLazyListState()
|
||||||
|
|
||||||
Surface(color = MaterialTheme.colorScheme.background) {
|
LazyColumnThemedScrollbar(state = state) {
|
||||||
LazyColumnThemedScrollbar(state = state) {
|
LazyColumn(
|
||||||
LazyColumn(
|
modifier = Modifier.nestedScroll(nestedScrollInterop),
|
||||||
modifier = Modifier.nestedScroll(nestedScrollInterop),
|
state = state
|
||||||
state = state
|
) {
|
||||||
) {
|
when (uiState) {
|
||||||
when (uiState) {
|
is Resource.Loading -> {
|
||||||
is Resource.Loading -> {
|
item {
|
||||||
item {
|
LoadingIndicator(modifier = Modifier.padding(top = 8.dp))
|
||||||
LoadingIndicator(modifier = Modifier.padding(top = 8.dp))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
is Resource.Success -> {
|
is Resource.Success -> {
|
||||||
val commentInfo = uiState.data
|
val commentInfo = uiState.data
|
||||||
val count = commentInfo.commentCount
|
val count = commentInfo.commentCount
|
||||||
|
|
||||||
if (commentInfo.isCommentsDisabled) {
|
if (commentInfo.isCommentsDisabled) {
|
||||||
|
item {
|
||||||
|
NoItemsMessage(R.string.comments_are_disabled)
|
||||||
|
}
|
||||||
|
} else if (count == 0) {
|
||||||
|
item {
|
||||||
|
NoItemsMessage(R.string.no_comments)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// do not show anything if the comment count is unknown
|
||||||
|
if (count >= 0) {
|
||||||
item {
|
item {
|
||||||
NoItemsMessage(R.string.comments_are_disabled)
|
Text(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(start = 12.dp, end = 12.dp, bottom = 4.dp),
|
||||||
|
text = pluralStringResource(R.plurals.comments, count, count),
|
||||||
|
maxLines = 1,
|
||||||
|
style = MaterialTheme.typography.titleMedium
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} else if (count == 0) {
|
}
|
||||||
item {
|
|
||||||
NoItemsMessage(R.string.no_comments)
|
when (comments.loadState.refresh) {
|
||||||
}
|
is LoadState.Loading -> {
|
||||||
} else {
|
|
||||||
// do not show anything if the comment count is unknown
|
|
||||||
if (count >= 0) {
|
|
||||||
item {
|
item {
|
||||||
Text(
|
LoadingIndicator(modifier = Modifier.padding(top = 8.dp))
|
||||||
modifier = Modifier
|
|
||||||
.padding(start = 12.dp, end = 12.dp, bottom = 4.dp),
|
|
||||||
text = pluralStringResource(R.plurals.comments, count, count),
|
|
||||||
maxLines = 1,
|
|
||||||
style = MaterialTheme.typography.titleMedium
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
when (comments.loadState.refresh) {
|
is LoadState.Error -> {
|
||||||
is LoadState.Loading -> {
|
item {
|
||||||
item {
|
NoItemsMessage(R.string.error_unable_to_load_comments)
|
||||||
LoadingIndicator(modifier = Modifier.padding(top = 8.dp))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
is LoadState.Error -> {
|
else -> {
|
||||||
item {
|
items(comments.itemCount) {
|
||||||
NoItemsMessage(R.string.error_unable_to_load_comments)
|
Comment(comment = comments[it]!!) {}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> {
|
|
||||||
items(comments.itemCount) {
|
|
||||||
Comment(comment = comments[it]!!) {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
is Resource.Error -> {
|
is Resource.Error -> {
|
||||||
item {
|
item {
|
||||||
NoItemsMessage(R.string.error_unable_to_load_comments)
|
NoItemsMessage(R.string.error_unable_to_load_comments)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue