Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 44 additions & 19 deletions app/src/main/kotlin/com/aliucord/manager/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,27 @@ fun ManagerTheme(
dynamicColor: Boolean = true,
content: @Composable () -> Unit,
) {
val context = LocalContext.current
val dynamicColor = dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
val darkTheme = when (theme) {

val isBlack = theme == Theme.Black
val isDark = when (theme) {
Theme.System -> isSystemInDarkTheme()
Theme.Dark -> true
Theme.Light -> false
Theme.Dark, Theme.Black -> true
}
val colorScheme = when {
dynamicColor && darkTheme -> dynamicDarkColorScheme(LocalContext.current)
dynamicColor && !darkTheme -> dynamicLightColorScheme(LocalContext.current)
darkTheme -> darkColorScheme()

val baseScheme = when {
dynamicColor && isDark -> dynamicDarkColorScheme(context)
dynamicColor -> dynamicLightColorScheme(context)
isDark -> darkColorScheme()
else -> lightColorScheme()
}
val customColors = when (darkTheme) {
val colorScheme = when (isBlack) {
true -> baseScheme.toPitchBlack()
false -> baseScheme
}
val customColors = when (isDark) {
true -> DarkCustomColors
false -> LightCustomColors
}
Expand All @@ -47,7 +55,7 @@ fun ManagerTheme(
SideEffect {
systemUiController.setSystemBarsColor(
color = colorScheme.background,
darkIcons = !darkTheme,
darkIcons = !isDark,
)
systemUiController.setNavigationBarColor(
color = Color.Transparent,
Expand All @@ -66,19 +74,36 @@ fun ManagerTheme(
enum class Theme {
System,
Light,
Dark;
Dark,
Black;

@Composable
fun toDisplayName() = when (this) {
System -> stringResource(R.string.theme_system)
Light -> stringResource(R.string.theme_light)
Dark -> stringResource(R.string.theme_dark)
}
fun toDisplayName() = stringResource(
when (this) {
System -> R.string.theme_system
Light -> R.string.theme_light
Dark -> R.string.theme_dark
Black -> R.string.theme_black
}
)

@Composable
fun toPainter() = when (this) {
System -> painterResource(R.drawable.ic_sync)
Light -> painterResource(R.drawable.ic_light)
Dark -> painterResource(R.drawable.ic_night)
}
fun toPainter() = painterResource(
when (this) {
System -> R.drawable.ic_sync
Light -> R.drawable.ic_light
Dark -> R.drawable.ic_night
Black -> R.drawable.ic_brightness_empty
}
)
}

private fun ColorScheme.toPitchBlack(): ColorScheme {
return this.copy(
background = Color.Black,
surface = Color.Black,
surfaceVariant = Color.Black,
onBackground = Color.White,
onSurface = Color.White
)
}
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_brightness_empty.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="#e3e3e3"
android:pathData="M480,932 L346,800L160,800v-186L28,480l132,-134v-186h186l134,-132 134,132h186v186l132,134 -132,134v186L614,800L480,932ZM480,820 L580,720h140v-140l100,-100 -100,-100v-140L580,240L480,140 380,240L240,240v140L140,480l100,100v140h140l100,100ZM480,480Z" />
</vector>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
<string name="theme_system">System</string>
<string name="theme_dark">Dark</string>
<string name="theme_light">Light</string>
<string name="theme_black">Black</string>

<string name="plugins_title">Plugins</string>
<string name="plugins_view_changelog">View changelog</string>
Expand Down
Loading