mirror of
https://github.com/TeamNewPipe/NewPipe.git
synced 2024-11-25 04:22:30 +01:00
Clean up unnecessary manual color specification in Compose code
This commit is contained in:
parent
a56debfce6
commit
6ea715a18d
@ -3,7 +3,6 @@ package org.schabi.newpipe.fragments.list.comments
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.compose.material3.MaterialTheme
|
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
@ -20,7 +19,7 @@ class CommentsFragment : Fragment() {
|
|||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
) = content {
|
) = content {
|
||||||
AppTheme {
|
AppTheme {
|
||||||
Surface(color = MaterialTheme.colorScheme.background) {
|
Surface {
|
||||||
CommentSection()
|
CommentSection()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,16 +3,11 @@ package org.schabi.newpipe.ui.components.common
|
|||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.wrapContentSize
|
import androidx.compose.foundation.layout.wrapContentSize
|
||||||
import androidx.compose.material3.CircularProgressIndicator
|
import androidx.compose.material3.CircularProgressIndicator
|
||||||
import androidx.compose.material3.MaterialTheme
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun LoadingIndicator(modifier: Modifier = Modifier) {
|
fun LoadingIndicator(modifier: Modifier = Modifier) {
|
||||||
CircularProgressIndicator(
|
CircularProgressIndicator(modifier = modifier.fillMaxSize().wrapContentSize(Alignment.Center))
|
||||||
modifier = modifier.fillMaxSize().wrapContentSize(Alignment.Center),
|
|
||||||
color = MaterialTheme.colorScheme.primary,
|
|
||||||
trackColor = MaterialTheme.colorScheme.surfaceVariant,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import androidx.compose.foundation.lazy.LazyListState
|
|||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import my.nanihadesuka.compose.LazyColumnScrollbar
|
||||||
import my.nanihadesuka.compose.ScrollbarSettings
|
import my.nanihadesuka.compose.ScrollbarSettings
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@ -20,7 +21,7 @@ fun LazyColumnThemedScrollbar(
|
|||||||
indicatorContent: (@Composable (index: Int, isThumbSelected: Boolean) -> Unit)? = null,
|
indicatorContent: (@Composable (index: Int, isThumbSelected: Boolean) -> Unit)? = null,
|
||||||
content: @Composable () -> Unit
|
content: @Composable () -> Unit
|
||||||
) {
|
) {
|
||||||
my.nanihadesuka.compose.LazyColumnScrollbar(
|
LazyColumnScrollbar(
|
||||||
state = state,
|
state = state,
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
settings = settings,
|
settings = settings,
|
||||||
|
@ -16,16 +16,15 @@ import androidx.compose.ui.platform.rememberNestedScrollInteropConnection
|
|||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import androidx.window.core.layout.WindowWidthSizeClass
|
import androidx.window.core.layout.WindowWidthSizeClass
|
||||||
import my.nanihadesuka.compose.LazyColumnScrollbar
|
|
||||||
import org.schabi.newpipe.R
|
import org.schabi.newpipe.R
|
||||||
import org.schabi.newpipe.extractor.InfoItem
|
import org.schabi.newpipe.extractor.InfoItem
|
||||||
import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem
|
import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem
|
||||||
import org.schabi.newpipe.info_list.ItemViewMode
|
import org.schabi.newpipe.info_list.ItemViewMode
|
||||||
import org.schabi.newpipe.ktx.findFragmentActivity
|
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.playlist.PlaylistListItem
|
||||||
import org.schabi.newpipe.ui.components.items.stream.StreamListItem
|
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.DependentPreferenceHelper
|
||||||
import org.schabi.newpipe.util.NavigationHelper
|
import org.schabi.newpipe.util.NavigationHelper
|
||||||
|
|
||||||
@ -73,7 +72,7 @@ fun ItemList(
|
|||||||
} else {
|
} else {
|
||||||
val state = rememberLazyListState()
|
val state = rememberLazyListState()
|
||||||
|
|
||||||
LazyColumnScrollbar(state = state, settings = NewPipeScrollbarSettings) {
|
LazyColumnThemedScrollbar(state = state) {
|
||||||
LazyColumn(modifier = nestedScrollModifier, state = state) {
|
LazyColumn(modifier = nestedScrollModifier, state = state) {
|
||||||
listHeader()
|
listHeader()
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ private fun CommentPreview(
|
|||||||
@PreviewParameter(CommentPreviewProvider::class) commentsInfoItem: CommentsInfoItem
|
@PreviewParameter(CommentPreviewProvider::class) commentsInfoItem: CommentsInfoItem
|
||||||
) {
|
) {
|
||||||
AppTheme {
|
AppTheme {
|
||||||
Surface(color = MaterialTheme.colorScheme.background) {
|
Surface {
|
||||||
Comment(commentsInfoItem) {}
|
Comment(commentsInfoItem) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -267,7 +267,7 @@ private fun CommentPreview(
|
|||||||
@Composable
|
@Composable
|
||||||
private fun CommentListPreview() {
|
private fun CommentListPreview() {
|
||||||
AppTheme {
|
AppTheme {
|
||||||
Surface(color = MaterialTheme.colorScheme.background) {
|
Surface {
|
||||||
Column {
|
Column {
|
||||||
for (comment in CommentPreviewProvider().values) {
|
for (comment in CommentPreviewProvider().values) {
|
||||||
Comment(comment) {}
|
Comment(comment) {}
|
||||||
|
@ -6,14 +6,11 @@ import androidx.compose.foundation.lazy.LazyColumn
|
|||||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.HorizontalDivider
|
import androidx.compose.material3.HorizontalDivider
|
||||||
import androidx.compose.material3.LocalContentColor
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.ModalBottomSheet
|
import androidx.compose.material3.ModalBottomSheet
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.contentColorFor
|
|
||||||
import androidx.compose.material3.rememberModalBottomSheetState
|
import androidx.compose.material3.rememberModalBottomSheetState
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.CompositionLocalProvider
|
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
@ -84,12 +81,6 @@ private fun CommentRepliesDialog(
|
|||||||
ModalBottomSheet(
|
ModalBottomSheet(
|
||||||
sheetState = sheetState,
|
sheetState = sheetState,
|
||||||
onDismissRequest = onDismissRequest,
|
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) {
|
LazyColumnThemedScrollbar(state = listState) {
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
@ -150,7 +141,6 @@ private fun CommentRepliesDialog(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Preview(name = "Light mode", uiMode = Configuration.UI_MODE_NIGHT_NO)
|
@Preview(name = "Light mode", uiMode = Configuration.UI_MODE_NIGHT_NO)
|
||||||
|
@ -143,7 +143,7 @@ fun CommentRepliesHeaderPreview() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
AppTheme {
|
AppTheme {
|
||||||
Surface(color = MaterialTheme.colorScheme.background) {
|
Surface {
|
||||||
CommentRepliesHeader(comment) {}
|
CommentRepliesHeader(comment) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ private fun CommentSection(
|
|||||||
@Composable
|
@Composable
|
||||||
private fun CommentSectionLoadingPreview() {
|
private fun CommentSectionLoadingPreview() {
|
||||||
AppTheme {
|
AppTheme {
|
||||||
Surface(color = MaterialTheme.colorScheme.background) {
|
Surface {
|
||||||
CommentSection(uiState = Resource.Loading, commentsFlow = flowOf())
|
CommentSection(uiState = Resource.Loading, commentsFlow = flowOf())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -151,7 +151,7 @@ private fun CommentSectionSuccessPreview() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AppTheme {
|
AppTheme {
|
||||||
Surface(color = MaterialTheme.colorScheme.background) {
|
Surface {
|
||||||
CommentSection(
|
CommentSection(
|
||||||
uiState = Resource.Success(
|
uiState = Resource.Success(
|
||||||
CommentInfo(
|
CommentInfo(
|
||||||
@ -170,7 +170,7 @@ private fun CommentSectionSuccessPreview() {
|
|||||||
@Composable
|
@Composable
|
||||||
private fun CommentSectionErrorPreview() {
|
private fun CommentSectionErrorPreview() {
|
||||||
AppTheme {
|
AppTheme {
|
||||||
Surface(color = MaterialTheme.colorScheme.background) {
|
Surface {
|
||||||
CommentSection(uiState = Resource.Error(RuntimeException()), commentsFlow = flowOf())
|
CommentSection(uiState = Resource.Error(RuntimeException()), commentsFlow = flowOf())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import androidx.compose.runtime.Composable
|
|||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import my.nanihadesuka.compose.ScrollbarSettings
|
|
||||||
|
|
||||||
private val lightScheme = lightColorScheme(
|
private val lightScheme = lightColorScheme(
|
||||||
primary = primaryLight,
|
primary = primaryLight,
|
||||||
@ -88,11 +87,6 @@ private val darkScheme = darkColorScheme(
|
|||||||
|
|
||||||
private val blackScheme = darkScheme.copy(surface = Color.Black)
|
private val blackScheme = darkScheme.copy(surface = Color.Black)
|
||||||
|
|
||||||
val NewPipeScrollbarSettings = ScrollbarSettings(
|
|
||||||
thumbSelectedColor = primaryDark,
|
|
||||||
thumbUnselectedColor = primaryLight
|
|
||||||
)
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun AppTheme(useDarkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
|
fun AppTheme(useDarkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
|
||||||
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(LocalContext.current)
|
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(LocalContext.current)
|
||||||
|
Loading…
Reference in New Issue
Block a user