1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2025-02-02 04:09:13 +00:00

Merge pull request #11539 from Isira-Seneviratne/Compose-theme-improvements

Compose theme improvements
This commit is contained in:
Stypox 2025-01-28 14:02:50 +01:00 committed by GitHub
commit 407d2d768d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 251 additions and 252 deletions

View File

@ -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()
} }
} }

View File

@ -3,7 +3,6 @@ package org.schabi.newpipe.fragments.list.videos
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
@ -21,7 +20,7 @@ class RelatedItemsFragment : Fragment() {
savedInstanceState: Bundle? savedInstanceState: Bundle?
) = content { ) = content {
AppTheme { AppTheme {
Surface(color = MaterialTheme.colorScheme.background) { Surface {
RelatedItems(requireArguments().serializable<StreamInfo>(KEY_INFO)!!) RelatedItems(requireArguments().serializable<StreamInfo>(KEY_INFO)!!)
} }
} }

View File

@ -13,7 +13,6 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.SearchBar import androidx.compose.material3.SearchBar
import androidx.compose.material3.SearchBarDefaults
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@ -91,14 +90,7 @@ fun Toolbar(
active = true, active = true,
onActiveChange = { onActiveChange = {
isSearchActive = it isSearchActive = it
}, }
colors = SearchBarDefaults.colors(
containerColor = MaterialTheme.colorScheme.background,
inputFieldColors = SearchBarDefaults.inputFieldColors(
focusedTextColor = MaterialTheme.colorScheme.onBackground,
unfocusedTextColor = MaterialTheme.colorScheme.onBackground
)
)
) { ) {
onSearchQueryChange?.invoke(query)?.takeIf { it.isNotEmpty() } onSearchQueryChange?.invoke(query)?.takeIf { it.isNotEmpty() }
?.map { suggestionText -> SearchSuggestionItem(text = suggestionText) } ?.map { suggestionText -> SearchSuggestionItem(text = suggestionText) }

View File

@ -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,
)
} }

View File

@ -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,

View File

@ -64,7 +64,7 @@ private fun PlaylistListItemPreview() {
playlist.uploaderName = "Uploader" playlist.uploaderName = "Uploader"
AppTheme { AppTheme {
Surface(color = MaterialTheme.colorScheme.background) { Surface {
PlaylistListItem(playlist) PlaylistListItem(playlist)
} }
} }

View File

@ -78,7 +78,7 @@ private fun StreamListItemPreview(
@PreviewParameter(StreamItemPreviewProvider::class) stream: StreamInfoItem @PreviewParameter(StreamItemPreviewProvider::class) stream: StreamInfoItem
) { ) {
AppTheme { AppTheme {
Surface(color = MaterialTheme.colorScheme.background) { Surface {
StreamListItem(stream, showProgress = false, isSelected = false) StreamListItem(stream, showProgress = false, isSelected = false)
} }
} }

View File

@ -1,9 +1,7 @@
package org.schabi.newpipe.ui.components.items.stream package org.schabi.newpipe.ui.components.items.stream
import androidx.annotation.StringRes
import androidx.compose.material3.DropdownMenu import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
@ -34,8 +32,8 @@ fun StreamMenu(
DropdownMenu(expanded = expanded, onDismissRequest = onDismissRequest) { DropdownMenu(expanded = expanded, onDismissRequest = onDismissRequest) {
if (playerHolder.isPlayQueueReady) { if (playerHolder.isPlayQueueReady) {
StreamMenuItem( DropdownMenuItem(
text = R.string.enqueue_stream, text = { Text(text = stringResource(R.string.enqueue_stream)) },
onClick = { onClick = {
onDismissRequest() onDismissRequest()
SparseItemUtil.fetchItemInfoIfSparse(context, stream) { SparseItemUtil.fetchItemInfoIfSparse(context, stream) {
@ -45,8 +43,8 @@ fun StreamMenu(
) )
if (playerHolder.queuePosition < playerHolder.queueSize - 1) { if (playerHolder.queuePosition < playerHolder.queueSize - 1) {
StreamMenuItem( DropdownMenuItem(
text = R.string.enqueue_next_stream, text = { Text(text = stringResource(R.string.enqueue_next_stream)) },
onClick = { onClick = {
onDismissRequest() onDismissRequest()
SparseItemUtil.fetchItemInfoIfSparse(context, stream) { SparseItemUtil.fetchItemInfoIfSparse(context, stream) {
@ -57,8 +55,8 @@ fun StreamMenu(
} }
} }
StreamMenuItem( DropdownMenuItem(
text = R.string.start_here_on_background, text = { Text(text = stringResource(R.string.start_here_on_background)) },
onClick = { onClick = {
onDismissRequest() onDismissRequest()
SparseItemUtil.fetchItemInfoIfSparse(context, stream) { SparseItemUtil.fetchItemInfoIfSparse(context, stream) {
@ -66,8 +64,8 @@ fun StreamMenu(
} }
} }
) )
StreamMenuItem( DropdownMenuItem(
text = R.string.start_here_on_popup, text = { Text(text = stringResource(R.string.start_here_on_popup)) },
onClick = { onClick = {
onDismissRequest() onDismissRequest()
SparseItemUtil.fetchItemInfoIfSparse(context, stream) { SparseItemUtil.fetchItemInfoIfSparse(context, stream) {
@ -75,8 +73,8 @@ fun StreamMenu(
} }
} }
) )
StreamMenuItem( DropdownMenuItem(
text = R.string.download, text = { Text(text = stringResource(R.string.download)) },
onClick = { onClick = {
onDismissRequest() onDismissRequest()
SparseItemUtil.fetchStreamInfoAndSaveToDatabase( SparseItemUtil.fetchStreamInfoAndSaveToDatabase(
@ -89,8 +87,8 @@ fun StreamMenu(
} }
} }
) )
StreamMenuItem( DropdownMenuItem(
text = R.string.add_to_playlist, text = { Text(text = stringResource(R.string.add_to_playlist)) },
onClick = { onClick = {
onDismissRequest() onDismissRequest()
val list = listOf(StreamEntity(stream)) val list = listOf(StreamEntity(stream))
@ -103,29 +101,29 @@ fun StreamMenu(
} }
} }
) )
StreamMenuItem( DropdownMenuItem(
text = R.string.share, text = { Text(text = stringResource(R.string.share)) },
onClick = { onClick = {
onDismissRequest() onDismissRequest()
ShareUtils.shareText(context, stream.name, stream.url, stream.thumbnails) ShareUtils.shareText(context, stream.name, stream.url, stream.thumbnails)
} }
) )
StreamMenuItem( DropdownMenuItem(
text = R.string.open_in_browser, text = { Text(text = stringResource(R.string.open_in_browser)) },
onClick = { onClick = {
onDismissRequest() onDismissRequest()
ShareUtils.openUrlInBrowser(context, stream.url) ShareUtils.openUrlInBrowser(context, stream.url)
} }
) )
StreamMenuItem( DropdownMenuItem(
text = R.string.mark_as_watched, text = { Text(text = stringResource(R.string.mark_as_watched)) },
onClick = { onClick = {
onDismissRequest() onDismissRequest()
streamViewModel.markAsWatched(stream) streamViewModel.markAsWatched(stream)
} }
) )
StreamMenuItem( DropdownMenuItem(
text = R.string.show_channel_details, text = { Text(text = stringResource(R.string.show_channel_details)) },
onClick = { onClick = {
onDismissRequest() onDismissRequest()
SparseItemUtil.fetchUploaderUrlIfSparse( SparseItemUtil.fetchUploaderUrlIfSparse(
@ -138,16 +136,3 @@ fun StreamMenu(
) )
} }
} }
@Composable
private fun StreamMenuItem(
@StringRes text: Int,
onClick: () -> Unit
) {
DropdownMenuItem(
text = {
Text(text = stringResource(text), color = MaterialTheme.colorScheme.onBackground)
},
onClick = onClick
)
}

View File

@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface import androidx.compose.material3.Surface
import androidx.compose.material3.Switch import androidx.compose.material3.Switch
import androidx.compose.material3.Text import androidx.compose.material3.Text
@ -94,7 +93,7 @@ private fun RelatedItemsPreview() {
) )
AppTheme { AppTheme {
Surface(color = MaterialTheme.colorScheme.background) { Surface {
RelatedItems(info) RelatedItems(info)
} }
} }

View File

@ -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) {}

View File

@ -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
@ -86,12 +83,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(
@ -138,8 +129,8 @@ private fun CommentRepliesDialog(
EmptyStateSpec.DisabledComments.copy( EmptyStateSpec.DisabledComments.copy(
descriptionText = { descriptionText = {
stringResource(R.string.error_unable_to_load_comments) stringResource(R.string.error_unable_to_load_comments)
} },
) ),
) )
} else { } else {
EmptyStateComposable(EmptyStateSpec.NoComments) EmptyStateComposable(EmptyStateSpec.NoComments)
@ -156,7 +147,6 @@ private fun CommentRepliesDialog(
} }
} }
} }
}
} }
@Preview(name = "Light mode", uiMode = Configuration.UI_MODE_NIGHT_NO) @Preview(name = "Light mode", uiMode = Configuration.UI_MODE_NIGHT_NO)

View File

@ -143,7 +143,7 @@ fun CommentRepliesHeaderPreview() {
) )
AppTheme { AppTheme {
Surface(color = MaterialTheme.colorScheme.background) { Surface {
CommentRepliesHeader(comment) {} CommentRepliesHeader(comment) {}
} }
} }

View File

@ -139,7 +139,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())
} }
} }
@ -167,7 +167,7 @@ private fun CommentSectionSuccessPreview() {
} }
AppTheme { AppTheme {
Surface(color = MaterialTheme.colorScheme.background) { Surface {
CommentSection( CommentSection(
uiState = Resource.Success( uiState = Resource.Success(
CommentInfo( CommentInfo(
@ -186,7 +186,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())
} }
} }

View File

@ -2,62 +2,74 @@ package org.schabi.newpipe.ui.theme
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
val md_theme_light_primary = Color(0xFFBB171C) val primaryLight = Color(0xFF904A45)
val md_theme_light_onPrimary = Color(0xFFFFFFFF) val onPrimaryLight = Color(0xFFFFFFFF)
val md_theme_light_primaryContainer = Color(0xFFFFDAD6) val primaryContainerLight = Color(0xFFFFDAD6)
val md_theme_light_onPrimaryContainer = Color(0xFF410002) val onPrimaryContainerLight = Color(0xFF3B0908)
val md_theme_light_secondary = Color(0xFF984061) val secondaryLight = Color(0xFF775653)
val md_theme_light_onSecondary = Color(0xFFFFFFFF) val onSecondaryLight = Color(0xFFFFFFFF)
val md_theme_light_secondaryContainer = Color(0xFFFFD9E2) val secondaryContainerLight = Color(0xFFFFDAD6)
val md_theme_light_onSecondaryContainer = Color(0xFF3E001D) val onSecondaryContainerLight = Color(0xFF2C1513)
val md_theme_light_tertiary = Color(0xFF006874) val tertiaryLight = Color(0xFF725B2E)
val md_theme_light_onTertiary = Color(0xFFFFFFFF) val onTertiaryLight = Color(0xFFFFFFFF)
val md_theme_light_tertiaryContainer = Color(0xFF97F0FF) val tertiaryContainerLight = Color(0xFFFEDEA6)
val md_theme_light_onTertiaryContainer = Color(0xFF001F24) val onTertiaryContainerLight = Color(0xFF261900)
val md_theme_light_error = Color(0xFFBA1A1A) val errorLight = Color(0xFFBA1A1A)
val md_theme_light_errorContainer = Color(0xFFFFDAD6) val onErrorLight = Color(0xFFFFFFFF)
val md_theme_light_onError = Color(0xFFFFFFFF) val errorContainerLight = Color(0xFFFFDAD6)
val md_theme_light_onErrorContainer = Color(0xFF410002) val onErrorContainerLight = Color(0xFF410002)
val md_theme_light_background = Color(0xFFEEEEEE) val backgroundLight = Color(0xFFFFF8F7)
val md_theme_light_onBackground = Color(0xFF1B1B1B) val onBackgroundLight = Color(0xFF231918)
val md_theme_light_surface = Color(0xFFE53835) val surfaceLight = Color(0xFFFFF8F7)
val md_theme_light_onSurface = Color(0xFFFFFFFF) val onSurfaceLight = Color(0xFF231918)
val md_theme_light_surfaceVariant = Color(0xFFF5DDDB) val surfaceVariantLight = Color(0xFFF5DDDB)
val md_theme_light_onSurfaceVariant = Color(0xFF534341) val onSurfaceVariantLight = Color(0xFF534342)
val md_theme_light_outline = Color(0xFF857371) val outlineLight = Color(0xFF857371)
val md_theme_light_inverseOnSurface = Color(0xFFD6F6FF) val outlineVariantLight = Color(0xFFD8C2BF)
val md_theme_light_inverseSurface = Color(0xFF00363F) val scrimLight = Color(0xFF000000)
val md_theme_light_inversePrimary = Color(0xFFFFB4AC) val inverseSurfaceLight = Color(0xFF392E2D)
val md_theme_light_surfaceTint = Color(0xFFBB171C) val inverseOnSurfaceLight = Color(0xFFFFEDEB)
val md_theme_light_outlineVariant = Color(0xFFD8C2BF) val inversePrimaryLight = Color(0xFFFFB3AC)
val md_theme_light_scrim = Color(0xFF000000) val surfaceDimLight = Color(0xFFE8D6D4)
val surfaceBrightLight = Color(0xFFFFF8F7)
val surfaceContainerLowestLight = Color(0xFFFFFFFF)
val surfaceContainerLowLight = Color(0xFFFFF0EF)
val surfaceContainerLight = Color(0xFFFCEAE8)
val surfaceContainerHighLight = Color(0xFFF6E4E2)
val surfaceContainerHighestLight = Color(0xFFF1DEDC)
val md_theme_dark_primary = Color(0xFFFFB4AC) val primaryDark = Color(0xFFFFB3AC)
val md_theme_dark_onPrimary = Color(0xFF690006) val onPrimaryDark = Color(0xFF571E1B)
val md_theme_dark_primaryContainer = Color(0xFF93000D) val primaryContainerDark = Color(0xFF73332F)
val md_theme_dark_onPrimaryContainer = Color(0xFFFFDAD6) val onPrimaryContainerDark = Color(0xFFFFDAD6)
val md_theme_dark_secondary = Color(0xFFFFB1C8) val secondaryDark = Color(0xFFE7BDB8)
val md_theme_dark_onSecondary = Color(0xFF5E1133) val onSecondaryDark = Color(0xFF442927)
val md_theme_dark_secondaryContainer = Color(0xFF7B2949) val secondaryContainerDark = Color(0xFF5D3F3C)
val md_theme_dark_onSecondaryContainer = Color(0xFFFFD9E2) val onSecondaryContainerDark = Color(0xFFFFDAD6)
val md_theme_dark_tertiary = Color(0xFF4FD8EB) val tertiaryDark = Color(0xFFE1C38C)
val md_theme_dark_onTertiary = Color(0xFF00363D) val onTertiaryDark = Color(0xFF402D04)
val md_theme_dark_tertiaryContainer = Color(0xFF004F58) val tertiaryContainerDark = Color(0xFF584419)
val md_theme_dark_onTertiaryContainer = Color(0xFF97F0FF) val onTertiaryContainerDark = Color(0xFFFEDEA6)
val md_theme_dark_error = Color(0xFFFFB4AB) val errorDark = Color(0xFFFFB4AB)
val md_theme_dark_errorContainer = Color(0xFF93000A) val onErrorDark = Color(0xFF690005)
val md_theme_dark_onError = Color(0xFF690005) val errorContainerDark = Color(0xFF93000A)
val md_theme_dark_onErrorContainer = Color(0xFFFFDAD6) val onErrorContainerDark = Color(0xFFFFDAD6)
val md_theme_dark_background = Color(0xFF212121) val backgroundDark = Color(0xFF1A1110)
val md_theme_dark_onBackground = Color(0xFFFFFFFF) val onBackgroundDark = Color(0xFFF1DEDC)
val md_theme_dark_surface = Color(0xFF992521) val surfaceDark = Color(0xFF1A1110)
val md_theme_dark_onSurface = Color(0xFFFFFFFF) val onSurfaceDark = Color(0xFFF1DEDC)
val md_theme_dark_surfaceVariant = Color(0xFF534341) val surfaceVariantDark = Color(0xFF534342)
val md_theme_dark_onSurfaceVariant = Color(0xFFD8C2BF) val onSurfaceVariantDark = Color(0xFFD8C2BF)
val md_theme_dark_outline = Color(0xFFA08C8A) val outlineDark = Color(0xFFA08C8A)
val md_theme_dark_inverseOnSurface = Color(0xFF001F25) val outlineVariantDark = Color(0xFF534342)
val md_theme_dark_inverseSurface = Color(0xFFA6EEFF) val scrimDark = Color(0xFF000000)
val md_theme_dark_inversePrimary = Color(0xFFBB171C) val inverseSurfaceDark = Color(0xFFF1DEDC)
val md_theme_dark_surfaceTint = Color(0xFFFFB4AC) val inverseOnSurfaceDark = Color(0xFF392E2D)
val md_theme_dark_outlineVariant = Color(0xFF534341) val inversePrimaryDark = Color(0xFF904A45)
val md_theme_dark_scrim = Color(0xFF000000) val surfaceDimDark = Color(0xFF1A1110)
val surfaceBrightDark = Color(0xFF423735)
val surfaceContainerLowestDark = Color(0xFF140C0B)
val surfaceContainerLowDark = Color(0xFF231918)
val surfaceContainerDark = Color(0xFF271D1C)
val surfaceContainerHighDark = Color(0xFF322827)
val surfaceContainerHighestDark = Color(0xFF3D3231)

View File

@ -5,75 +5,102 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.preference.PreferenceManager
private val LightColors = lightColorScheme( private val lightScheme = lightColorScheme(
primary = md_theme_light_primary, primary = primaryLight,
onPrimary = md_theme_light_onPrimary, onPrimary = onPrimaryLight,
primaryContainer = md_theme_light_primaryContainer, primaryContainer = primaryContainerLight,
onPrimaryContainer = md_theme_light_onPrimaryContainer, onPrimaryContainer = onPrimaryContainerLight,
secondary = md_theme_light_secondary, secondary = secondaryLight,
onSecondary = md_theme_light_onSecondary, onSecondary = onSecondaryLight,
secondaryContainer = md_theme_light_secondaryContainer, secondaryContainer = secondaryContainerLight,
onSecondaryContainer = md_theme_light_onSecondaryContainer, onSecondaryContainer = onSecondaryContainerLight,
tertiary = md_theme_light_tertiary, tertiary = tertiaryLight,
onTertiary = md_theme_light_onTertiary, onTertiary = onTertiaryLight,
tertiaryContainer = md_theme_light_tertiaryContainer, tertiaryContainer = tertiaryContainerLight,
onTertiaryContainer = md_theme_light_onTertiaryContainer, onTertiaryContainer = onTertiaryContainerLight,
error = md_theme_light_error, error = errorLight,
errorContainer = md_theme_light_errorContainer, onError = onErrorLight,
onError = md_theme_light_onError, errorContainer = errorContainerLight,
onErrorContainer = md_theme_light_onErrorContainer, onErrorContainer = onErrorContainerLight,
background = md_theme_light_background, background = backgroundLight,
onBackground = md_theme_light_onBackground, onBackground = onBackgroundLight,
surface = md_theme_light_surface, surface = surfaceLight,
onSurface = md_theme_light_onSurface, onSurface = onSurfaceLight,
surfaceVariant = md_theme_light_surfaceVariant, surfaceVariant = surfaceVariantLight,
onSurfaceVariant = md_theme_light_onSurfaceVariant, onSurfaceVariant = onSurfaceVariantLight,
outline = md_theme_light_outline, outline = outlineLight,
inverseOnSurface = md_theme_light_inverseOnSurface, outlineVariant = outlineVariantLight,
inverseSurface = md_theme_light_inverseSurface, scrim = scrimLight,
inversePrimary = md_theme_light_inversePrimary, inverseSurface = inverseSurfaceLight,
surfaceTint = md_theme_light_surfaceTint, inverseOnSurface = inverseOnSurfaceLight,
outlineVariant = md_theme_light_outlineVariant, inversePrimary = inversePrimaryLight,
scrim = md_theme_light_scrim, surfaceDim = surfaceDimLight,
surfaceBright = surfaceBrightLight,
surfaceContainerLowest = surfaceContainerLowestLight,
surfaceContainerLow = surfaceContainerLowLight,
surfaceContainer = surfaceContainerLight,
surfaceContainerHigh = surfaceContainerHighLight,
surfaceContainerHighest = surfaceContainerHighestLight,
) )
private val DarkColors = darkColorScheme( private val darkScheme = darkColorScheme(
primary = md_theme_dark_primary, primary = primaryDark,
onPrimary = md_theme_dark_onPrimary, onPrimary = onPrimaryDark,
primaryContainer = md_theme_dark_primaryContainer, primaryContainer = primaryContainerDark,
onPrimaryContainer = md_theme_dark_onPrimaryContainer, onPrimaryContainer = onPrimaryContainerDark,
secondary = md_theme_dark_secondary, secondary = secondaryDark,
onSecondary = md_theme_dark_onSecondary, onSecondary = onSecondaryDark,
secondaryContainer = md_theme_dark_secondaryContainer, secondaryContainer = secondaryContainerDark,
onSecondaryContainer = md_theme_dark_onSecondaryContainer, onSecondaryContainer = onSecondaryContainerDark,
tertiary = md_theme_dark_tertiary, tertiary = tertiaryDark,
onTertiary = md_theme_dark_onTertiary, onTertiary = onTertiaryDark,
tertiaryContainer = md_theme_dark_tertiaryContainer, tertiaryContainer = tertiaryContainerDark,
onTertiaryContainer = md_theme_dark_onTertiaryContainer, onTertiaryContainer = onTertiaryContainerDark,
error = md_theme_dark_error, error = errorDark,
errorContainer = md_theme_dark_errorContainer, onError = onErrorDark,
onError = md_theme_dark_onError, errorContainer = errorContainerDark,
onErrorContainer = md_theme_dark_onErrorContainer, onErrorContainer = onErrorContainerDark,
background = md_theme_dark_background, background = backgroundDark,
onBackground = md_theme_dark_onBackground, onBackground = onBackgroundDark,
surface = md_theme_dark_surface, surface = surfaceDark,
onSurface = md_theme_dark_onSurface, onSurface = onSurfaceDark,
surfaceVariant = md_theme_dark_surfaceVariant, surfaceVariant = surfaceVariantDark,
onSurfaceVariant = md_theme_dark_onSurfaceVariant, onSurfaceVariant = onSurfaceVariantDark,
outline = md_theme_dark_outline, outline = outlineDark,
inverseOnSurface = md_theme_dark_inverseOnSurface, outlineVariant = outlineVariantDark,
inverseSurface = md_theme_dark_inverseSurface, scrim = scrimDark,
inversePrimary = md_theme_dark_inversePrimary, inverseSurface = inverseSurfaceDark,
surfaceTint = md_theme_dark_surfaceTint, inverseOnSurface = inverseOnSurfaceDark,
outlineVariant = md_theme_dark_outlineVariant, inversePrimary = inversePrimaryDark,
scrim = md_theme_dark_scrim, surfaceDim = surfaceDimDark,
surfaceBright = surfaceBrightDark,
surfaceContainerLowest = surfaceContainerLowestDark,
surfaceContainerLow = surfaceContainerLowDark,
surfaceContainer = surfaceContainerDark,
surfaceContainerHigh = surfaceContainerHighDark,
surfaceContainerHighest = surfaceContainerHighestDark,
) )
private val blackScheme = darkScheme.copy(surface = Color.Black)
@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 theme = sharedPreferences.getString("theme", "auto_device_theme")
val nightTheme = sharedPreferences.getString("night_theme", "dark_theme")
MaterialTheme( MaterialTheme(
colorScheme = if (useDarkTheme) DarkColors else LightColors, colorScheme = if (!useDarkTheme) {
lightScheme
} else if (theme == "black_theme" || nightTheme == "black_theme") {
blackScheme
} else {
darkScheme
},
content = content content = content
) )
} }

View File

@ -10,8 +10,8 @@
<color name="placeholder_foreground">#6C6C6C</color> <color name="placeholder_foreground">#6C6C6C</color>
<!-- Light Theme --> <!-- Light Theme -->
<color name="light_background_color">#EEEEEE</color> <color name="light_background_color">#FFFFF8F7</color>
<color name="light_dialog_background_color">#EEEEEE</color> <color name="light_dialog_background_color">#FFFFF8F7</color>
<color name="light_settings_accent_color">#e53935</color> <color name="light_settings_accent_color">#e53935</color>
<color name="light_separator_color">#32000000</color> <color name="light_separator_color">#32000000</color>
<color name="light_ripple_color">#48868686</color> <color name="light_ripple_color">#48868686</color>
@ -25,7 +25,7 @@
<color name="light_border_color">#33000000</color> <color name="light_border_color">#33000000</color>
<!-- Dark Theme --> <!-- Dark Theme -->
<color name="dark_background_color">#222222</color> <color name="dark_background_color">#FF1A1110</color>
<color name="dark_dialog_background_color">#424242</color> <color name="dark_dialog_background_color">#424242</color>
<color name="dark_settings_accent_color">#ff5252</color> <color name="dark_settings_accent_color">#ff5252</color>
<color name="dark_separator_color">#0affffff</color> <color name="dark_separator_color">#0affffff</color>