mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-10 06:42:05 +01:00
Add support for detecting the system theme
This commit is contained in:
@@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
enum class ThemeMode {
|
||||
/*System,*/
|
||||
System,
|
||||
Light,
|
||||
Dark,
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
package ca.gosyer.ui.base.theme
|
||||
|
||||
import androidx.compose.desktop.DesktopMaterialTheme
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.material.Colors
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
@@ -83,11 +84,11 @@ private class AppThemeViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
return when (themeMode) {
|
||||
/*ThemeMode.System -> if (!isSystemInDarkTheme()) {
|
||||
getTheme(lightTheme, true)
|
||||
ThemeMode.System -> if (!isSystemInDarkTheme()) {
|
||||
getTheme(lightTheme, true)
|
||||
} else {
|
||||
getTheme(darkTheme, false)
|
||||
}*/
|
||||
getTheme(darkTheme, false)
|
||||
}
|
||||
ThemeMode.Light -> getTheme(lightTheme, true)
|
||||
ThemeMode.Dark -> getTheme(darkTheme, false)
|
||||
}
|
||||
|
||||
@@ -46,6 +46,8 @@ import com.github.zsoltk.compose.savedinstancestate.Bundle
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import org.jetbrains.skiko.SystemTheme
|
||||
import org.jetbrains.skiko.currentSystemTheme
|
||||
import toothpick.configuration.Configuration
|
||||
import toothpick.ktp.KTP
|
||||
import toothpick.ktp.extension.getInstance
|
||||
@@ -98,6 +100,10 @@ suspend fun main() {
|
||||
return@getAsFlow
|
||||
}
|
||||
val theme = when (it) {
|
||||
ThemeMode.System -> when (currentSystemTheme) {
|
||||
SystemTheme.LIGHT, SystemTheme.UNKNOWN -> IntelliJTheme()
|
||||
SystemTheme.DARK -> DarculaTheme()
|
||||
}
|
||||
ThemeMode.Light -> IntelliJTheme()
|
||||
ThemeMode.Dark -> DarculaTheme()
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ fun SettingsAppearance(navController: BackStack<Route>) {
|
||||
ChoicePreference(
|
||||
preference = vm.themeMode,
|
||||
choices = mapOf(
|
||||
// ThemeMode.System to R.string.follow_system_settings,
|
||||
ThemeMode.System to stringResource("theme_follow_system"),
|
||||
ThemeMode.Light to stringResource("theme_light"),
|
||||
ThemeMode.Dark to stringResource("theme_dark")
|
||||
),
|
||||
|
||||
@@ -110,6 +110,7 @@
|
||||
|
||||
<!-- Appearance Settings -->
|
||||
<string name="theme">Theme</string>
|
||||
<string name="theme_follow_system">Follow system settings</string>
|
||||
<string name="theme_light">Light</string>
|
||||
<string name="theme_dark">Dark</string>
|
||||
<string name="theme_text">Text</string>
|
||||
|
||||
Reference in New Issue
Block a user