mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-03-30 18:35:49 +00:00
android: more checks for colors in customized theme (#2343)
* android: more checks for colors in customized theme * code style * refactor --------- Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
c254b33753
commit
607f77d432
@@ -21,21 +21,26 @@ enum class DefaultTheme {
|
||||
SYSTEM, LIGHT, DARK, SIMPLEX;
|
||||
|
||||
// Call it only with base theme, not SYSTEM
|
||||
fun hasChangedAnyColor(colors: Colors): Boolean {
|
||||
fun hasChangedAnyColor(colors: Colors, appColors: AppColors): Boolean {
|
||||
val palette = when (this) {
|
||||
SYSTEM -> return false
|
||||
LIGHT -> LightColorPalette
|
||||
DARK -> DarkColorPalette
|
||||
SIMPLEX -> SimplexColorPalette
|
||||
}
|
||||
return with(palette) {
|
||||
colors.primary != primary ||
|
||||
colors.primaryVariant != primaryVariant ||
|
||||
colors.secondary != secondary ||
|
||||
colors.secondaryVariant != secondaryVariant ||
|
||||
colors.background != background ||
|
||||
colors.surface != surface
|
||||
val appPalette = when (this) {
|
||||
SYSTEM -> return false
|
||||
LIGHT -> LightColorPaletteApp
|
||||
DARK -> DarkColorPaletteApp
|
||||
SIMPLEX -> SimplexColorPaletteApp
|
||||
}
|
||||
return colors.primary != palette.primary ||
|
||||
colors.primaryVariant != palette.primaryVariant ||
|
||||
colors.secondary != palette.secondary ||
|
||||
colors.secondaryVariant != palette.secondaryVariant ||
|
||||
colors.background != palette.background ||
|
||||
colors.surface != palette.surface ||
|
||||
appColors != appPalette
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -229,14 +229,14 @@ fun CustomizeThemeView(editColor: (ThemeColor, Color) -> Unit) {
|
||||
}
|
||||
}
|
||||
val isInDarkTheme = isInDarkTheme()
|
||||
if (currentTheme.base.hasChangedAnyColor(currentTheme.colors)) {
|
||||
if (currentTheme.base.hasChangedAnyColor(currentTheme.colors, currentTheme.appColors)) {
|
||||
SectionItemView({ ThemeManager.resetAllThemeColors(darkForSystemTheme = isInDarkTheme) }) {
|
||||
Text(generalGetString(R.string.reset_color), color = colors.primary)
|
||||
}
|
||||
}
|
||||
SectionSpacer()
|
||||
SectionView {
|
||||
if (currentTheme.base.hasChangedAnyColor(currentTheme.colors)) {
|
||||
if (currentTheme.base.hasChangedAnyColor(currentTheme.colors, currentTheme.appColors)) {
|
||||
val context = LocalContext.current
|
||||
val theme = remember { mutableStateOf(null as String?) }
|
||||
val exportThemeLauncher = rememberSaveThemeLauncher(context, theme)
|
||||
|
||||
Reference in New Issue
Block a user