Add black theme (#15)
This commit is contained in:
@@ -40,10 +40,7 @@ import it.vfsfitvnm.vimusic.ui.components.BottomSheetMenu
|
|||||||
import it.vfsfitvnm.vimusic.ui.components.LocalMenuState
|
import it.vfsfitvnm.vimusic.ui.components.LocalMenuState
|
||||||
import it.vfsfitvnm.vimusic.ui.components.rememberMenuState
|
import it.vfsfitvnm.vimusic.ui.components.rememberMenuState
|
||||||
import it.vfsfitvnm.vimusic.ui.screens.HomeScreen
|
import it.vfsfitvnm.vimusic.ui.screens.HomeScreen
|
||||||
import it.vfsfitvnm.vimusic.ui.styling.LocalColorPalette
|
import it.vfsfitvnm.vimusic.ui.styling.*
|
||||||
import it.vfsfitvnm.vimusic.ui.styling.LocalTypography
|
|
||||||
import it.vfsfitvnm.vimusic.ui.styling.rememberColorPalette
|
|
||||||
import it.vfsfitvnm.vimusic.ui.styling.rememberTypography
|
|
||||||
import it.vfsfitvnm.vimusic.utils.*
|
import it.vfsfitvnm.vimusic.utils.*
|
||||||
|
|
||||||
private val Context.dataStore by preferencesDataStore(name = "preferences")
|
private val Context.dataStore by preferencesDataStore(name = "preferences")
|
||||||
@@ -64,14 +61,16 @@ class MainActivity : ComponentActivity() {
|
|||||||
val preferences by rememberPreferences(dataStore)
|
val preferences by rememberPreferences(dataStore)
|
||||||
val systemUiController = rememberSystemUiController()
|
val systemUiController = rememberSystemUiController()
|
||||||
|
|
||||||
val isDarkTheme = when (preferences.colorPaletteMode) {
|
val (isDarkTheme, colorPalette) = when (preferences.colorPaletteMode) {
|
||||||
ColorPaletteMode.Light -> false
|
ColorPaletteMode.Light -> false to LightColorPalette
|
||||||
ColorPaletteMode.Dark -> true
|
ColorPaletteMode.Dark -> true to DarkColorPalette
|
||||||
ColorPaletteMode.System -> isSystemInDarkTheme()
|
ColorPaletteMode.Black -> true to BlackColorPalette
|
||||||
|
ColorPaletteMode.System -> when (isSystemInDarkTheme()) {
|
||||||
|
true -> true to DarkColorPalette
|
||||||
|
false -> false to LightColorPalette
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val colorPalette = rememberColorPalette(isDarkTheme)
|
|
||||||
|
|
||||||
val rippleTheme = remember(colorPalette.text, isDarkTheme) {
|
val rippleTheme = remember(colorPalette.text, isDarkTheme) {
|
||||||
object : RippleTheme {
|
object : RippleTheme {
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
@@ -3,5 +3,6 @@ package it.vfsfitvnm.vimusic.enums
|
|||||||
enum class ColorPaletteMode {
|
enum class ColorPaletteMode {
|
||||||
Light,
|
Light,
|
||||||
Dark,
|
Dark,
|
||||||
|
Black,
|
||||||
System
|
System
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package it.vfsfitvnm.vimusic.ui.styling
|
package it.vfsfitvnm.vimusic.ui.styling
|
||||||
|
|
||||||
import androidx.compose.foundation.isSystemInDarkTheme
|
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
|
||||||
@@ -45,6 +44,12 @@ val DarkColorPalette = ColorPalette(
|
|||||||
iconOnPrimaryContainer = Color.White,
|
iconOnPrimaryContainer = Color.White,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val BlackColorPalette = DarkColorPalette.copy(
|
||||||
|
background = Color.Black,
|
||||||
|
lightBackground = Color(0xff0d0d12),
|
||||||
|
elevatedBackground = Color(0xff0d0d12),
|
||||||
|
)
|
||||||
|
|
||||||
val LightColorPalette = ColorPalette(
|
val LightColorPalette = ColorPalette(
|
||||||
background = Color(0xfffdfdfe),
|
background = Color(0xfffdfdfe),
|
||||||
lightBackground = Color(0xFFf8f8fc),
|
lightBackground = Color(0xFFf8f8fc),
|
||||||
@@ -69,10 +74,3 @@ val LightColorPalette = ColorPalette(
|
|||||||
)
|
)
|
||||||
|
|
||||||
val LocalColorPalette = staticCompositionLocalOf { LightColorPalette }
|
val LocalColorPalette = staticCompositionLocalOf { LightColorPalette }
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun rememberColorPalette(isDarkTheme: Boolean = isSystemInDarkTheme()): ColorPalette {
|
|
||||||
return remember(isDarkTheme) {
|
|
||||||
if (isDarkTheme) DarkColorPalette else LightColorPalette
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user