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..26bfa7728 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,7 +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 @@ -20,7 +19,7 @@ class CommentsFragment : Fragment() { savedInstanceState: Bundle? ) = content { AppTheme { - Surface(color = MaterialTheme.colorScheme.background) { + Surface { CommentSection() } } diff --git a/app/src/main/java/org/schabi/newpipe/ui/components/common/LoadingIndicator.kt b/app/src/main/java/org/schabi/newpipe/ui/components/common/LoadingIndicator.kt index 3bfe1dee4..94a0489d0 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/components/common/LoadingIndicator.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/components/common/LoadingIndicator.kt @@ -3,16 +3,11 @@ package org.schabi.newpipe.ui.components.common import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.material3.CircularProgressIndicator -import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @Composable fun LoadingIndicator(modifier: Modifier = Modifier) { - CircularProgressIndicator( - modifier = modifier.fillMaxSize().wrapContentSize(Alignment.Center), - color = MaterialTheme.colorScheme.primary, - trackColor = MaterialTheme.colorScheme.surfaceVariant, - ) + CircularProgressIndicator(modifier = modifier.fillMaxSize().wrapContentSize(Alignment.Center)) } diff --git a/app/src/main/java/org/schabi/newpipe/ui/components/common/Scrollbar.kt b/app/src/main/java/org/schabi/newpipe/ui/components/common/Scrollbar.kt index eb1595467..1e619f32a 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/components/common/Scrollbar.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/components/common/Scrollbar.kt @@ -4,6 +4,7 @@ import androidx.compose.foundation.lazy.LazyListState import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import my.nanihadesuka.compose.LazyColumnScrollbar import my.nanihadesuka.compose.ScrollbarSettings @Composable @@ -20,7 +21,7 @@ fun LazyColumnThemedScrollbar( indicatorContent: (@Composable (index: Int, isThumbSelected: Boolean) -> Unit)? = null, content: @Composable () -> Unit ) { - my.nanihadesuka.compose.LazyColumnScrollbar( + LazyColumnScrollbar( state = state, modifier = modifier, settings = settings, diff --git a/app/src/main/java/org/schabi/newpipe/ui/components/items/ItemList.kt b/app/src/main/java/org/schabi/newpipe/ui/components/items/ItemList.kt index 3ede9dcdf..4562e17af 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/components/items/ItemList.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/components/items/ItemList.kt @@ -16,16 +16,15 @@ import androidx.compose.ui.platform.rememberNestedScrollInteropConnection import androidx.compose.ui.res.stringResource import androidx.preference.PreferenceManager import androidx.window.core.layout.WindowWidthSizeClass -import my.nanihadesuka.compose.LazyColumnScrollbar import org.schabi.newpipe.R import org.schabi.newpipe.extractor.InfoItem import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem import org.schabi.newpipe.extractor.stream.StreamInfoItem import org.schabi.newpipe.info_list.ItemViewMode import org.schabi.newpipe.ktx.findFragmentActivity +import org.schabi.newpipe.ui.components.common.LazyColumnThemedScrollbar import org.schabi.newpipe.ui.components.items.playlist.PlaylistListItem import org.schabi.newpipe.ui.components.items.stream.StreamListItem -import org.schabi.newpipe.ui.theme.NewPipeScrollbarSettings import org.schabi.newpipe.util.DependentPreferenceHelper import org.schabi.newpipe.util.NavigationHelper @@ -73,7 +72,7 @@ fun ItemList( } else { val state = rememberLazyListState() - LazyColumnScrollbar(state = state, settings = NewPipeScrollbarSettings) { + LazyColumnThemedScrollbar(state = state) { LazyColumn(modifier = nestedScrollModifier, state = state) { listHeader() diff --git a/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/Comment.kt b/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/Comment.kt index 7f29269d1..076fcc707 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/Comment.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/Comment.kt @@ -257,7 +257,7 @@ private fun CommentPreview( @PreviewParameter(CommentPreviewProvider::class) commentsInfoItem: CommentsInfoItem ) { AppTheme { - Surface(color = MaterialTheme.colorScheme.background) { + Surface { Comment(commentsInfoItem) {} } } @@ -267,7 +267,7 @@ private fun CommentPreview( @Composable private fun CommentListPreview() { AppTheme { - Surface(color = MaterialTheme.colorScheme.background) { + Surface { Column { for (comment in CommentPreviewProvider().values) { Comment(comment) {} diff --git a/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentRepliesDialog.kt b/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentRepliesDialog.kt index 17ea900a5..eb31d15eb 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentRepliesDialog.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentRepliesDialog.kt @@ -6,14 +6,11 @@ import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.HorizontalDivider -import androidx.compose.material3.LocalContentColor import androidx.compose.material3.MaterialTheme import androidx.compose.material3.ModalBottomSheet import androidx.compose.material3.Text -import androidx.compose.material3.contentColorFor import androidx.compose.material3.rememberModalBottomSheetState import androidx.compose.runtime.Composable -import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier @@ -85,67 +82,60 @@ private fun CommentRepliesDialog( sheetState = sheetState, onDismissRequest = onDismissRequest, ) { - CompositionLocalProvider( - // contentColorFor(MaterialTheme.colorScheme.containerColor), i.e. ModalBottomSheet's - // default background color, does not resolve correctly, so need to manually set the - // content color for MaterialTheme.colorScheme.background instead - LocalContentColor provides contentColorFor(MaterialTheme.colorScheme.background) - ) { - LazyColumnThemedScrollbar(state = listState) { - LazyColumn( - modifier = Modifier.nestedScroll(nestedScrollInterop), - state = listState - ) { + LazyColumnThemedScrollbar(state = listState) { + LazyColumn( + modifier = Modifier.nestedScroll(nestedScrollInterop), + state = listState + ) { + item { + CommentRepliesHeader( + comment = parentComment, + onCommentAuthorOpened = nestedOnCommentAuthorOpened, + ) + HorizontalDivider( + thickness = 1.dp, + modifier = Modifier.padding(start = 16.dp, end = 16.dp, bottom = 8.dp) + ) + } + + if (parentComment.replyCount >= 0) { item { - CommentRepliesHeader( - comment = parentComment, + Text( + modifier = Modifier.padding( + horizontal = 12.dp, + vertical = 4.dp + ), + text = pluralStringResource( + R.plurals.replies, + parentComment.replyCount, + parentComment.replyCount, + ), + maxLines = 1, + style = MaterialTheme.typography.titleMedium + ) + } + } + + if (comments.itemCount == 0) { + item { + val refresh = comments.loadState.refresh + if (refresh is LoadState.Loading) { + LoadingIndicator(modifier = Modifier.padding(top = 8.dp)) + } else { + val message = if (refresh is LoadState.Error) { + R.string.error_unable_to_load_comments + } else { + R.string.no_comments + } + NoItemsMessage(message) + } + } + } else { + items(comments.itemCount) { + Comment( + comment = comments[it]!!, onCommentAuthorOpened = nestedOnCommentAuthorOpened, ) - HorizontalDivider( - thickness = 1.dp, - modifier = Modifier.padding(start = 16.dp, end = 16.dp, bottom = 8.dp) - ) - } - - if (parentComment.replyCount >= 0) { - item { - Text( - modifier = Modifier.padding( - horizontal = 12.dp, - vertical = 4.dp - ), - text = pluralStringResource( - R.plurals.replies, - parentComment.replyCount, - parentComment.replyCount, - ), - maxLines = 1, - style = MaterialTheme.typography.titleMedium - ) - } - } - - if (comments.itemCount == 0) { - item { - val refresh = comments.loadState.refresh - if (refresh is LoadState.Loading) { - LoadingIndicator(modifier = Modifier.padding(top = 8.dp)) - } else { - val message = if (refresh is LoadState.Error) { - R.string.error_unable_to_load_comments - } else { - R.string.no_comments - } - NoItemsMessage(message) - } - } - } else { - items(comments.itemCount) { - Comment( - comment = comments[it]!!, - onCommentAuthorOpened = nestedOnCommentAuthorOpened, - ) - } } } } diff --git a/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentRepliesHeader.kt b/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentRepliesHeader.kt index 95542092e..a35e2ea2f 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentRepliesHeader.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentRepliesHeader.kt @@ -143,7 +143,7 @@ fun CommentRepliesHeaderPreview() { ) AppTheme { - Surface(color = MaterialTheme.colorScheme.background) { + Surface { CommentRepliesHeader(comment) {} } } 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 33c4e2139..cf92ac4a0 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 @@ -123,7 +123,7 @@ private fun CommentSection( @Composable private fun CommentSectionLoadingPreview() { AppTheme { - Surface(color = MaterialTheme.colorScheme.background) { + Surface { CommentSection(uiState = Resource.Loading, commentsFlow = flowOf()) } } @@ -151,7 +151,7 @@ private fun CommentSectionSuccessPreview() { } AppTheme { - Surface(color = MaterialTheme.colorScheme.background) { + Surface { CommentSection( uiState = Resource.Success( CommentInfo( @@ -170,7 +170,7 @@ private fun CommentSectionSuccessPreview() { @Composable private fun CommentSectionErrorPreview() { AppTheme { - Surface(color = MaterialTheme.colorScheme.background) { + Surface { CommentSection(uiState = Resource.Error(RuntimeException()), commentsFlow = flowOf()) } } diff --git a/app/src/main/java/org/schabi/newpipe/ui/theme/Theme.kt b/app/src/main/java/org/schabi/newpipe/ui/theme/Theme.kt index 4cf9c5c64..d436b35a2 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/theme/Theme.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/theme/Theme.kt @@ -8,7 +8,6 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext import androidx.preference.PreferenceManager -import my.nanihadesuka.compose.ScrollbarSettings private val lightScheme = lightColorScheme( primary = primaryLight, @@ -88,11 +87,6 @@ private val darkScheme = darkColorScheme( private val blackScheme = darkScheme.copy(surface = Color.Black) -val NewPipeScrollbarSettings = ScrollbarSettings( - thumbSelectedColor = primaryDark, - thumbUnselectedColor = primaryLight -) - @Composable fun AppTheme(useDarkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) { val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(LocalContext.current)