From 6a12f2dec8a41a34166c4607aaa1dd27d6abdc66 Mon Sep 17 00:00:00 2001 From: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com> Date: Mon, 12 Aug 2024 20:57:04 +0000 Subject: [PATCH] ios: fix updating chat wallpaper while app is in background (#4661) --- apps/ios/Shared/Views/Helpers/ChatWallpaper.swift | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/ios/Shared/Views/Helpers/ChatWallpaper.swift b/apps/ios/Shared/Views/Helpers/ChatWallpaper.swift index 35bb21354d..9eea278d4e 100644 --- a/apps/ios/Shared/Views/Helpers/ChatWallpaper.swift +++ b/apps/ios/Shared/Views/Helpers/ChatWallpaper.swift @@ -11,13 +11,22 @@ import SwiftUI import SimpleXChat struct ChatViewBackground: ViewModifier { - @EnvironmentObject var theme: AppTheme + @Environment(\.colorScheme) var colorScheme var image: Image var imageType: WallpaperType var background: Color var tint: Color func body(content: Content) -> some View { + // Workaround a problem (SwiftUI bug?) when wallpaper is not updated when user changes global theme in iOS settings from dark to light and vice versa + if colorScheme == .light { + back(content) + } else { + back(content) + } + } + + func back(_ content: Content) -> some View { content.background( Canvas { context, size in var image = context.resolve(image)