diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentsFragment.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentsFragment.kt index 6e20e1425..2c6898d7a 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentsFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentsFragment.kt @@ -3,8 +3,6 @@ package org.schabi.newpipe.fragments.list.comments import android.os.Bundle import android.view.LayoutInflater import android.view.ViewGroup -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Surface import androidx.core.os.bundleOf import androidx.fragment.app.Fragment import androidx.fragment.compose.content @@ -20,9 +18,7 @@ class CommentsFragment : Fragment() { savedInstanceState: Bundle? ) = content { AppTheme { - Surface(color = MaterialTheme.colorScheme.background) { - CommentSection() - } + CommentSection() } } diff --git a/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentSection.kt b/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentSection.kt index a47848750..ed4f50dd0 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentSection.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentSection.kt @@ -50,33 +50,35 @@ fun CommentSection( val nestedScrollInterop = rememberNestedScrollInteropConnection() val state = rememberLazyListState() - LazyColumnScrollbar(state = state) { - LazyColumn(modifier = Modifier.nestedScroll(nestedScrollInterop), state = state) { - if (parentComment != null) { - item { - CommentRepliesHeader(comment = parentComment) - HorizontalDivider(thickness = 1.dp) - } - } - - if (itemCount == 0) { - item { - val refresh = comments.loadState.refresh - if (refresh is LoadState.Loading) { - LoadingIndicator(modifier = Modifier.padding(top = 8.dp)) - } else { - val error = (refresh as? LoadState.Error)?.error - val message = if (error is CommentsDisabledException) { - R.string.comments_are_disabled - } else { - R.string.no_comments - } - NoItemsMessage(message) + Surface(color = MaterialTheme.colorScheme.background) { + LazyColumnScrollbar(state = state) { + LazyColumn(modifier = Modifier.nestedScroll(nestedScrollInterop), state = state) { + if (parentComment != null) { + item { + CommentRepliesHeader(comment = parentComment) + HorizontalDivider(thickness = 1.dp) } } - } else { - items(itemCount) { - Comment(comment = comments[it]!!) + + if (itemCount == 0) { + item { + val refresh = comments.loadState.refresh + if (refresh is LoadState.Loading) { + LoadingIndicator(modifier = Modifier.padding(top = 8.dp)) + } else { + val error = (refresh as? LoadState.Error)?.error + val message = if (error is CommentsDisabledException) { + R.string.comments_are_disabled + } else { + R.string.no_comments + } + NoItemsMessage(message) + } + } + } else { + items(itemCount) { + Comment(comment = comments[it]!!) + } } } } @@ -116,9 +118,7 @@ private fun CommentSectionPreview( @PreviewParameter(CommentDataProvider::class) pagingData: PagingData ) { AppTheme { - Surface(color = MaterialTheme.colorScheme.background) { - CommentSection(commentsFlow = flowOf(pagingData)) - } + CommentSection(commentsFlow = flowOf(pagingData)) } } @@ -142,8 +142,6 @@ private fun CommentRepliesPreview() { val flow = flowOf(PagingData.from(replies)) AppTheme { - Surface(color = MaterialTheme.colorScheme.background) { - CommentSection(parentComment = comment, commentsFlow = flow) - } + CommentSection(parentComment = comment, commentsFlow = flow) } }