Skip to content

Commit

Permalink
Actually support basic theme changing
Browse files Browse the repository at this point in the history
  • Loading branch information
kuba2k2 committed Jun 28, 2024
1 parent 5fdc05e commit a903561
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ class ThemeChooserDialog(
if (app.uiManager.themeColor.ordinal != themeId) {
app.config.ui.themeConfig = Theme.Config(
color = enumValues<Theme>()[themeId],
type = app.config.ui.themeConfig.type,
mode = app.config.ui.themeConfig.mode,
nightMode = app.config.ui.themeConfig.nightMode,
)
activity.recreate()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ class UiManager(val app: App) {
val themeNightMode
get() = app.config.ui.themeConfig.nightMode

private val themeStyleRes by lazy {
val res = themeColor.styleRes[themeType to themeMode]
if (res != null)
return@lazy res
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S)
return@lazy BLUE.styleRes[Theme.Type.M3 to Theme.Mode.DAYNIGHT]!!
return@lazy DEFAULT.styleRes[Theme.Type.M3 to Theme.Mode.DAYNIGHT]!!
}
private val themeStyleRes: Int
get() {
val res = themeColor.styleRes[themeType to themeMode]
if (res != null)
return res
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S)
return BLUE.styleRes[Theme.Type.M3 to Theme.Mode.DAYNIGHT]!!
return DEFAULT.styleRes[Theme.Type.M3 to Theme.Mode.DAYNIGHT]!!
}

val isDark: Boolean
get() {
Expand Down

0 comments on commit a903561

Please sign in to comment.