From 1abe14aab76caeb36c516516837348bfcf647f21 Mon Sep 17 00:00:00 2001 From: Avently <7953703+avently@users.noreply.github.com> Date: Tue, 7 May 2024 19:27:18 +0700 Subject: [PATCH] don't drop customization in same cases --- .../kotlin/chat/simplex/common/ui/theme/ThemeManager.kt | 6 ++++-- .../chat/simplex/common/views/usersettings/Appearance.kt | 3 --- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/ui/theme/ThemeManager.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/ui/theme/ThemeManager.kt index 95b8132bac..434c316407 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/ui/theme/ThemeManager.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/ui/theme/ThemeManager.kt @@ -138,9 +138,11 @@ object ThemeManager { fun saveAndApplyBackgroundImage(baseTheme: DefaultTheme, type: BackgroundImageType?, pref: SharedPreference> = appPrefs.themeOverrides) { val nonSystemThemeName = baseTheme.name val overrides = pref.get().toMutableMap() - // val prevValue = overrides.getOrDefault(nonSystemThemeName, ThemeOverrides()) + var prevValue = overrides.getOrDefault(nonSystemThemeName, ThemeOverrides()) // Overriding the whole theme on type change - val prevValue = ThemeOverrides() + if (prevValue.wallpaper.imageFile != type?.filename && prevValue.wallpaper.preset != type?.filename) { + prevValue = ThemeOverrides() + } overrides[nonSystemThemeName] = prevValue.copy(wallpaper = if (type != null) ThemeWallpaper.from(type, prevValue.wallpaper.background, prevValue.wallpaper.tint) else ThemeWallpaper()) pref.set(overrides) CurrentColors.value = currentColors(!CurrentColors.value.colors.isLight, appPrefs.themeOverrides.get()) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/Appearance.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/Appearance.kt index 7838844776..89ee351ebe 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/Appearance.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/Appearance.kt @@ -118,9 +118,6 @@ object AppearanceScope { val cornerRadius = 22 fun setBackground(type: BackgroundImageType?) { - if (type is BackgroundImageType.Static || CurrentColors.value.wallpaper.type is BackgroundImageType.Static) { - resetColors() - } onTypeChange(type) }