Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOB-363: Android: "System" theme setting not working #32

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
}

Expand All @@ -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
}
}
}

Expand Down
Loading