diff --git a/v4/platformUI/src/main/java/exchange/dydx/platformui/designSystem/theme/ThemeConfig.kt b/v4/platformUI/src/main/java/exchange/dydx/platformui/designSystem/theme/ThemeConfig.kt index 1ea60bb0..6365b8f9 100644 --- a/v4/platformUI/src/main/java/exchange/dydx/platformui/designSystem/theme/ThemeConfig.kt +++ b/v4/platformUI/src/main/java/exchange/dydx/platformui/designSystem/theme/ThemeConfig.kt @@ -1,6 +1,8 @@ package exchange.dydx.platformui.designSystem.theme import android.content.Context +import android.content.res.Configuration +import android.content.res.Configuration.UI_MODE_NIGHT_YES import android.util.Log import exchange.dydx.utilities.utils.JsonUtils import exchange.dydx.utilities.utils.SharedPreferencesStore @@ -47,6 +49,7 @@ data class ThemeConfig( "dark" -> dark(context) "light" -> light(context) "classic_dark" -> classicDark(context) + "system" -> if (context.isDarkThemeOn()) dark(context) else light(context) else -> null } @@ -57,6 +60,11 @@ data class ThemeConfig( config } } + + private fun Context.isDarkThemeOn(): Boolean { + return resources.configuration.uiMode and + Configuration.UI_MODE_NIGHT_MASK == UI_MODE_NIGHT_YES + } } }