From dc31b6e3d8cbe233f2499128dbdb07ec2f0cc3cc Mon Sep 17 00:00:00 2001 From: Ali <> Date: Fri, 11 Jun 2021 15:19:52 +0400 Subject: [PATCH] Allow disabling service message blur for certain wallpapers --- submodules/Display/Source/NavigationBar.swift | 24 ++++++++----------- submodules/Display/Source/TabBarNode.swift | 2 +- submodules/Display/Source/ToolbarNode.swift | 2 +- .../SearchBarNode/Sources/SearchBarNode.swift | 2 +- .../ThemeAccentColorControllerNode.swift | 2 +- .../Themes/WallpaperColorPanelNode.swift | 2 +- .../Sources/Themes/WallpaperGalleryItem.swift | 2 +- .../Themes/WallpaperGalleryToolbarNode.swift | 2 +- .../Themes/WallpaperOptionButtonNode.swift | 2 +- .../Themes/WallpaperPatternPanelNode.swift | 2 +- .../Sources/DefaultDayPresentationTheme.swift | 10 ++++++++ .../Sources/ChatControllerNode.swift | 4 ++-- .../TelegramUI/Sources/ChatEmptyNode.swift | 3 +-- .../ChatHistoryNavigationButtonNode.swift | 2 +- .../TelegramUI/Sources/ChatLoadingNode.swift | 2 +- .../ChatMessageActionButtonsNode.swift | 2 +- .../ChatMessageAnimatedStickerItemNode.swift | 10 ++++---- .../ChatMessageDateAndStatusNode.swift | 10 ++++---- .../Sources/ChatMessageDateHeader.swift | 8 +++---- ...atMessageInteractiveInstantVideoNode.swift | 8 +++---- .../Sources/ChatMessageStickerItemNode.swift | 4 ++-- .../ChatRecentActionsControllerNode.swift | 2 +- .../Sources/PeerInfo/PeerInfoHeaderNode.swift | 2 +- .../PeerInfo/PeerInfoPaneContainerNode.swift | 2 +- .../Sources/PeerSelectionControllerNode.swift | 2 +- 25 files changed, 59 insertions(+), 54 deletions(-) diff --git a/submodules/Display/Source/NavigationBar.swift b/submodules/Display/Source/NavigationBar.swift index 04bcb0c451..0a64eb4339 100644 --- a/submodules/Display/Source/NavigationBar.swift +++ b/submodules/Display/Source/NavigationBar.swift @@ -121,15 +121,8 @@ private var sharedIsReduceTransparencyEnabled = UIAccessibility.isReduceTranspar public final class NavigationBackgroundNode: ASDisplayNode { private var _color: UIColor - public var color: UIColor { - get { - return self._color - } set(value) { - self.updateColor(color: value, transition: .immediate) - } - } - private let enableBlur: Bool + private var enableBlur: Bool private var effectView: UIVisualEffectView? private let backgroundNode: ASDisplayNode @@ -150,7 +143,7 @@ public final class NavigationBackgroundNode: ASDisplayNode { } private func updateBackgroundBlur(forceKeepBlur: Bool) { - if self.enableBlur && !sharedIsReduceTransparencyEnabled && ((self.color.alpha > .ulpOfOne && self.color.alpha < 0.95) || forceKeepBlur) { + if self.enableBlur && !sharedIsReduceTransparencyEnabled && ((self._color.alpha > .ulpOfOne && self._color.alpha < 0.95) || forceKeepBlur) { if self.effectView == nil { let effectView = UIVisualEffectView(effect: UIBlurEffect(style: .light)) @@ -193,16 +186,19 @@ public final class NavigationBackgroundNode: ASDisplayNode { } } - public func updateColor(color: UIColor, forceKeepBlur: Bool = false, transition: ContainedViewLayoutTransition) { - if self._color.isEqual(color) { + public func updateColor(color: UIColor, enableBlur: Bool? = nil, forceKeepBlur: Bool = false, transition: ContainedViewLayoutTransition) { + let effectiveEnableBlur = enableBlur ?? self.enableBlur + + if self._color.isEqual(color) && self.enableBlur == effectiveEnableBlur { return } self._color = color + self.enableBlur = effectiveEnableBlur if sharedIsReduceTransparencyEnabled { - transition.updateBackgroundColor(node: self.backgroundNode, color: self.color.withAlphaComponent(1.0)) + transition.updateBackgroundColor(node: self.backgroundNode, color: self._color.withAlphaComponent(1.0)) } else { - transition.updateBackgroundColor(node: self.backgroundNode, color: self.color) + transition.updateBackgroundColor(node: self.backgroundNode, color: self._color) } self.updateBackgroundBlur(forceKeepBlur: forceKeepBlur) @@ -906,7 +902,7 @@ open class NavigationBar: ASDisplayNode { if presentationData.theme !== self.presentationData.theme || presentationData.strings !== self.presentationData.strings { self.presentationData = presentationData - self.backgroundNode.color = self.presentationData.theme.backgroundColor + self.backgroundNode.updateColor(color: self.presentationData.theme.backgroundColor, transition: .immediate) self.backButtonNode.color = self.presentationData.theme.buttonColor self.backButtonNode.disabledColor = self.presentationData.theme.disabledButtonColor diff --git a/submodules/Display/Source/TabBarNode.swift b/submodules/Display/Source/TabBarNode.swift index 86c371a17b..291333a8e4 100644 --- a/submodules/Display/Source/TabBarNode.swift +++ b/submodules/Display/Source/TabBarNode.swift @@ -393,7 +393,7 @@ class TabBarNode: ASDisplayNode { self.theme = theme self.separatorNode.backgroundColor = theme.tabBarSeparatorColor - self.backgroundNode.color = theme.tabBarBackgroundColor + self.backgroundNode.updateColor(color: theme.tabBarBackgroundColor, transition: .immediate) self.badgeImage = generateStretchableFilledCircleImage(diameter: 18.0, color: theme.tabBarBadgeBackgroundColor, strokeColor: theme.tabBarBadgeStrokeColor, strokeWidth: 1.0, backgroundColor: nil)! for container in self.tabBarNodeContainers { diff --git a/submodules/Display/Source/ToolbarNode.swift b/submodules/Display/Source/ToolbarNode.swift index 9da7b467c0..775fe381bd 100644 --- a/submodules/Display/Source/ToolbarNode.swift +++ b/submodules/Display/Source/ToolbarNode.swift @@ -102,7 +102,7 @@ public final class ToolbarNode: ASDisplayNode { public func updateTheme(_ theme: TabBarControllerTheme) { self.separatorNode.backgroundColor = theme.tabBarSeparatorColor - self.backgroundNode.color = theme.tabBarBackgroundColor + self.backgroundNode.updateColor(color: theme.tabBarBackgroundColor, transition: .immediate) } public func updateLayout(size: CGSize, leftInset: CGFloat, rightInset: CGFloat, additionalSideInsets: UIEdgeInsets, bottomInset: CGFloat, toolbar: Toolbar, transition: ContainedViewLayoutTransition) { diff --git a/submodules/SearchBarNode/Sources/SearchBarNode.swift b/submodules/SearchBarNode/Sources/SearchBarNode.swift index b54e9be64c..2756d839c7 100644 --- a/submodules/SearchBarNode/Sources/SearchBarNode.swift +++ b/submodules/SearchBarNode/Sources/SearchBarNode.swift @@ -887,7 +887,7 @@ public class SearchBarNode: ASDisplayNode, UITextFieldDelegate { self.cancelButton.setAttributedTitle(NSAttributedString(string: self.cancelText ?? strings.Common_Cancel, font: self.cancelText != nil ? Font.semibold(17.0) : Font.regular(17.0), textColor: theme.accent), for: []) } if self.theme != theme { - self.backgroundNode.color = theme.background + self.backgroundNode.updateColor(color: theme.background, transition: .immediate) if self.fieldStyle != .modern || self.forceSeparator { self.separatorNode.backgroundColor = theme.separator } diff --git a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift index 56edc12897..f0412b421c 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift @@ -573,7 +573,7 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate strongSelf.pageControlBackgroundNode.backgroundColor = color strongSelf.patternButtonNode.buttonColor = color strongSelf.colorsButtonNode.buttonColor = color - strongSelf.playButtonBackgroundNode.color = color + strongSelf.playButtonBackgroundNode.updateColor(color: color, transition: .immediate) } }) } diff --git a/submodules/SettingsUI/Sources/Themes/WallpaperColorPanelNode.swift b/submodules/SettingsUI/Sources/Themes/WallpaperColorPanelNode.swift index 2a0858fb80..db6370b49b 100644 --- a/submodules/SettingsUI/Sources/Themes/WallpaperColorPanelNode.swift +++ b/submodules/SettingsUI/Sources/Themes/WallpaperColorPanelNode.swift @@ -508,7 +508,7 @@ final class WallpaperColorPanelNode: ASDisplayNode { func updateTheme(_ theme: PresentationTheme) { self.theme = theme - self.backgroundNode.color = self.theme.chat.inputPanel.panelBackgroundColor + self.backgroundNode.updateColor(color: self.theme.chat.inputPanel.panelBackgroundColor, transition: .immediate) self.topSeparatorNode.backgroundColor = self.theme.chat.inputPanel.panelSeparatorColor self.bottomSeparatorNode.backgroundColor = self.theme.chat.inputPanel.panelSeparatorColor self.multiColorFieldNode.updateTheme(theme) diff --git a/submodules/SettingsUI/Sources/Themes/WallpaperGalleryItem.swift b/submodules/SettingsUI/Sources/Themes/WallpaperGalleryItem.swift index 164e6f2558..43d62ae361 100644 --- a/submodules/SettingsUI/Sources/Themes/WallpaperGalleryItem.swift +++ b/submodules/SettingsUI/Sources/Themes/WallpaperGalleryItem.swift @@ -642,7 +642,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode { strongSelf.motionButtonNode.buttonColor = color strongSelf.colorsButtonNode.buttonColor = color - strongSelf.playButtonBackgroundNode.color = color + strongSelf.playButtonBackgroundNode.updateColor(color: color, transition: .immediate) })) } else if self.arguments.patternEnabled != previousArguments.patternEnabled { self.patternButtonNode.isSelected = self.arguments.patternEnabled diff --git a/submodules/SettingsUI/Sources/Themes/WallpaperGalleryToolbarNode.swift b/submodules/SettingsUI/Sources/Themes/WallpaperGalleryToolbarNode.swift index 834d519073..ae64944748 100644 --- a/submodules/SettingsUI/Sources/Themes/WallpaperGalleryToolbarNode.swift +++ b/submodules/SettingsUI/Sources/Themes/WallpaperGalleryToolbarNode.swift @@ -98,7 +98,7 @@ final class WallpaperGalleryToolbarNode: ASDisplayNode { func updateThemeAndStrings(theme: PresentationTheme, strings: PresentationStrings) { self.theme = theme - self.backgroundNode.color = theme.rootController.tabBar.backgroundColor + self.backgroundNode.updateColor(color: theme.rootController.tabBar.backgroundColor, transition: .immediate) self.separatorNode.backgroundColor = theme.rootController.tabBar.separatorColor self.topSeparatorNode.backgroundColor = theme.rootController.tabBar.separatorColor self.cancelHighlightBackgroundNode.backgroundColor = theme.list.itemHighlightedBackgroundColor diff --git a/submodules/SettingsUI/Sources/Themes/WallpaperOptionButtonNode.swift b/submodules/SettingsUI/Sources/Themes/WallpaperOptionButtonNode.swift index 5ef4731c73..b0ebf964cb 100644 --- a/submodules/SettingsUI/Sources/Themes/WallpaperOptionButtonNode.swift +++ b/submodules/SettingsUI/Sources/Themes/WallpaperOptionButtonNode.swift @@ -132,7 +132,7 @@ final class WallpaperOptionButtonNode: HighlightTrackingButtonNode { var buttonColor: UIColor = UIColor(rgb: 0x000000, alpha: 0.3) { didSet { - self.backgroundNode.color = self.buttonColor + self.backgroundNode.updateColor(color: self.buttonColor, transition: .immediate) } } diff --git a/submodules/SettingsUI/Sources/Themes/WallpaperPatternPanelNode.swift b/submodules/SettingsUI/Sources/Themes/WallpaperPatternPanelNode.swift index c90534837c..e0760e6eca 100644 --- a/submodules/SettingsUI/Sources/Themes/WallpaperPatternPanelNode.swift +++ b/submodules/SettingsUI/Sources/Themes/WallpaperPatternPanelNode.swift @@ -386,7 +386,7 @@ final class WallpaperPatternPanelNode: ASDisplayNode { func updateTheme(_ theme: PresentationTheme) { self.theme = theme - self.backgroundNode.color = self.theme.chat.inputPanel.panelBackgroundColor + self.backgroundNode.updateColor(color: self.theme.chat.inputPanel.panelBackgroundColor, transition: .immediate) self.topSeparatorNode.backgroundColor = self.theme.chat.inputPanel.panelSeparatorColor self.sliderView?.backColor = self.theme.list.disclosureArrowColor diff --git a/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift b/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift index ee75c5cf9e..ee7a3fecdb 100644 --- a/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift @@ -8,11 +8,21 @@ import Postbox public func selectDateFillStaticColor(theme: PresentationTheme, wallpaper: TelegramWallpaper) -> UIColor { if case .color(0xffffff) = wallpaper { return theme.chat.serviceMessage.components.withDefaultWallpaper.dateFillStatic + } else if case .builtin = wallpaper { + return UIColor(rgb: 0x748391, alpha: 0.45) } else { return theme.chat.serviceMessage.components.withCustomWallpaper.dateFillStatic } } +public func dateFillNeedsBlur(theme: PresentationTheme, wallpaper: TelegramWallpaper) -> Bool { + if case .builtin = wallpaper { + return false + } else { + return true + } +} + public let defaultServiceBackgroundColor = UIColor(rgb: 0x000000, alpha: 0.2) public let defaultPresentationTheme = makeDefaultDayPresentationTheme(serviceBackgroundColor: defaultServiceBackgroundColor, day: false, preview: false) public let defaultDayAccentColor = UIColor(rgb: 0x007ee5) diff --git a/submodules/TelegramUI/Sources/ChatControllerNode.swift b/submodules/TelegramUI/Sources/ChatControllerNode.swift index a0fbcf528b..e4b4b1d122 100644 --- a/submodules/TelegramUI/Sources/ChatControllerNode.swift +++ b/submodules/TelegramUI/Sources/ChatControllerNode.swift @@ -1608,10 +1608,10 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { if themeUpdated { if case let .color(color) = self.chatPresentationInterfaceState.chatWallpaper, UIColor(rgb: color).isEqual(self.chatPresentationInterfaceState.theme.chat.inputPanel.panelBackgroundColorNoWallpaper) { - self.inputPanelBackgroundNode.color = self.chatPresentationInterfaceState.theme.chat.inputPanel.panelBackgroundColorNoWallpaper + self.inputPanelBackgroundNode.updateColor(color: self.chatPresentationInterfaceState.theme.chat.inputPanel.panelBackgroundColorNoWallpaper, transition: .immediate) self.usePlainInputSeparator = true } else { - self.inputPanelBackgroundNode.color = self.chatPresentationInterfaceState.theme.chat.inputPanel.panelBackgroundColor + self.inputPanelBackgroundNode.updateColor(color: self.chatPresentationInterfaceState.theme.chat.inputPanel.panelBackgroundColor, transition: .immediate) self.usePlainInputSeparator = false self.plainInputSeparatorAlpha = nil } diff --git a/submodules/TelegramUI/Sources/ChatEmptyNode.swift b/submodules/TelegramUI/Sources/ChatEmptyNode.swift index 2da3230fdf..e5ea648a42 100644 --- a/submodules/TelegramUI/Sources/ChatEmptyNode.swift +++ b/submodules/TelegramUI/Sources/ChatEmptyNode.swift @@ -796,8 +796,7 @@ final class ChatEmptyNode: ASDisplayNode { self.currentTheme = interfaceState.theme self.currentStrings = interfaceState.strings - - self.backgroundNode.color = selectDateFillStaticColor(theme: interfaceState.theme, wallpaper: interfaceState.chatWallpaper) + self.backgroundNode.updateColor(color: selectDateFillStaticColor(theme: interfaceState.theme, wallpaper: interfaceState.chatWallpaper), enableBlur: dateFillNeedsBlur(theme: interfaceState.theme, wallpaper: interfaceState.chatWallpaper), transition: .immediate) } var isScheduledMessages = false diff --git a/submodules/TelegramUI/Sources/ChatHistoryNavigationButtonNode.swift b/submodules/TelegramUI/Sources/ChatHistoryNavigationButtonNode.swift index 48cf046548..ed35ecf4e2 100644 --- a/submodules/TelegramUI/Sources/ChatHistoryNavigationButtonNode.swift +++ b/submodules/TelegramUI/Sources/ChatHistoryNavigationButtonNode.swift @@ -86,7 +86,7 @@ class ChatHistoryNavigationButtonNode: ASControlNode { if self.theme !== theme { self.theme = theme - self.backgroundNode.color = theme.chat.inputPanel.panelBackgroundColor + self.backgroundNode.updateColor(color: theme.chat.inputPanel.panelBackgroundColor, transition: .immediate) switch self.type { case .down: self.imageNode.image = PresentationResourcesChat.chatHistoryNavigationButtonImage(theme) diff --git a/submodules/TelegramUI/Sources/ChatLoadingNode.swift b/submodules/TelegramUI/Sources/ChatLoadingNode.swift index 4445d8a3f2..fac49f4b8b 100644 --- a/submodules/TelegramUI/Sources/ChatLoadingNode.swift +++ b/submodules/TelegramUI/Sources/ChatLoadingNode.swift @@ -13,7 +13,7 @@ final class ChatLoadingNode: ASDisplayNode { private let offset: CGPoint init(theme: PresentationTheme, chatWallpaper: TelegramWallpaper, bubbleCorners: PresentationChatBubbleCorners) { - self.backgroundNode = NavigationBackgroundNode(color: selectDateFillStaticColor(theme: theme, wallpaper: chatWallpaper)) + self.backgroundNode = NavigationBackgroundNode(color: selectDateFillStaticColor(theme: theme, wallpaper: chatWallpaper), enableBlur: dateFillNeedsBlur(theme: theme, wallpaper: chatWallpaper)) let serviceColor = serviceMessageColorComponents(theme: theme, wallpaper: chatWallpaper) self.activityIndicator = ActivityIndicator(type: .custom(serviceColor.primaryText, 22.0, 2.0, false), speed: .regular) diff --git a/submodules/TelegramUI/Sources/ChatMessageActionButtonsNode.swift b/submodules/TelegramUI/Sources/ChatMessageActionButtonsNode.swift index b0639aa492..30586e68cb 100644 --- a/submodules/TelegramUI/Sources/ChatMessageActionButtonsNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageActionButtonsNode.swift @@ -163,7 +163,7 @@ private final class ChatMessageActionButtonNode: ASDisplayNode { node.backgroundBlurNode.frame = CGRect(origin: CGPoint(), size: CGSize(width: max(0.0, width), height: 42.0)) node.backgroundBlurNode.update(size: node.backgroundBlurNode.bounds.size, transition: .immediate) - node.backgroundBlurNode.color = selectDateFillStaticColor(theme: theme.theme, wallpaper: theme.wallpaper) + node.backgroundBlurNode.updateColor(color: selectDateFillStaticColor(theme: theme.theme, wallpaper: theme.wallpaper), enableBlur: dateFillNeedsBlur(theme: theme.theme, wallpaper: theme.wallpaper), transition: .immediate) if iconImage != nil { if node.iconNode == nil { diff --git a/submodules/TelegramUI/Sources/ChatMessageAnimatedStickerItemNode.swift b/submodules/TelegramUI/Sources/ChatMessageAnimatedStickerItemNode.swift index b1e971089d..8a6e1ce63d 100644 --- a/submodules/TelegramUI/Sources/ChatMessageAnimatedStickerItemNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageAnimatedStickerItemNode.swift @@ -109,7 +109,7 @@ class ChatMessageShareButton: HighlightableButtonNode { } else { updatedIconImage = PresentationResourcesChat.chatFreeShareButtonIcon(presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper) } - self.backgroundNode.color = selectDateFillStaticColor(theme: presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper) + self.backgroundNode.updateColor(color: selectDateFillStaticColor(theme: presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper), enableBlur: dateFillNeedsBlur(theme: presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper), transition: .immediate) self.iconNode.image = updatedIconImage } var size = CGSize(width: 30.0, height: 30.0) @@ -1065,9 +1065,9 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView { if needsReplyBackground { if let replyBackgroundNode = strongSelf.replyBackgroundNode { - replyBackgroundNode.color = selectDateFillStaticColor(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper) + replyBackgroundNode.updateColor(color: selectDateFillStaticColor(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper), enableBlur: dateFillNeedsBlur(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper), transition: .immediate) } else { - let replyBackgroundNode = NavigationBackgroundNode(color: selectDateFillStaticColor(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper)) + let replyBackgroundNode = NavigationBackgroundNode(color: selectDateFillStaticColor(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper), enableBlur: dateFillNeedsBlur(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper)) strongSelf.replyBackgroundNode = replyBackgroundNode strongSelf.contextSourceNode.contentNode.addSubnode(replyBackgroundNode) } @@ -1157,9 +1157,9 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView { if needsForwardBackground { if let forwardBackgroundNode = strongSelf.forwardBackgroundNode { - forwardBackgroundNode.color = selectDateFillStaticColor(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper) + forwardBackgroundNode.updateColor(color: selectDateFillStaticColor(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper), enableBlur: dateFillNeedsBlur(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper), transition: .immediate) } else { - let forwardBackgroundNode = NavigationBackgroundNode(color: selectDateFillStaticColor(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper)) + let forwardBackgroundNode = NavigationBackgroundNode(color: selectDateFillStaticColor(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper), enableBlur: dateFillNeedsBlur(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper)) strongSelf.forwardBackgroundNode = forwardBackgroundNode strongSelf.addSubnode(forwardBackgroundNode) } diff --git a/submodules/TelegramUI/Sources/ChatMessageDateAndStatusNode.swift b/submodules/TelegramUI/Sources/ChatMessageDateAndStatusNode.swift index 0e373c4564..d7856d1496 100644 --- a/submodules/TelegramUI/Sources/ChatMessageDateAndStatusNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageDateAndStatusNode.swift @@ -228,7 +228,7 @@ class ChatMessageDateAndStatusNode: ASDisplayNode { return { context, presentationData, edited, impressionCount, dateText, type, constrainedSize, reactions, replyCount, isPinned, hasAutoremove in let dateColor: UIColor var backgroundImage: UIImage? - var blurredBackgroundColor: UIColor? + var blurredBackgroundColor: (UIColor, Bool)? var outgoingStatus: ChatMessageDateAndStatusOutgoingType? var leftInset: CGFloat @@ -328,7 +328,7 @@ class ChatMessageDateAndStatusNode: ASDisplayNode { let serviceColor = serviceMessageColorComponents(theme: presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper) dateColor = serviceColor.primaryText - blurredBackgroundColor = selectDateFillStaticColor(theme: presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper) + blurredBackgroundColor = (selectDateFillStaticColor(theme: presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper), dateFillNeedsBlur(theme: presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper)) leftInset = 0.0 loadedCheckFullImage = PresentationResourcesChat.chatFreeFullCheck(presentationData.theme.theme, size: checkSize, isDefaultWallpaper: isDefaultWallpaper) loadedCheckPartialImage = PresentationResourcesChat.chatFreePartialCheck(presentationData.theme.theme, size: checkSize, isDefaultWallpaper: isDefaultWallpaper) @@ -350,7 +350,7 @@ class ChatMessageDateAndStatusNode: ASDisplayNode { dateColor = serviceColor.primaryText outgoingStatus = status //backgroundImage = graphics.dateAndStatusFreeBackground - blurredBackgroundColor = selectDateFillStaticColor(theme: presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper) + blurredBackgroundColor = (selectDateFillStaticColor(theme: presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper), dateFillNeedsBlur(theme: presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper)) leftInset = 0.0 loadedCheckFullImage = PresentationResourcesChat.chatFreeFullCheck(presentationData.theme.theme, size: checkSize, isDefaultWallpaper: isDefaultWallpaper) loadedCheckPartialImage = PresentationResourcesChat.chatFreePartialCheck(presentationData.theme.theme, size: checkSize, isDefaultWallpaper: isDefaultWallpaper) @@ -611,7 +611,7 @@ class ChatMessageDateAndStatusNode: ASDisplayNode { if let blurredBackgroundColor = blurredBackgroundColor { if let blurredBackgroundNode = strongSelf.blurredBackgroundNode { - blurredBackgroundNode.color = blurredBackgroundColor + blurredBackgroundNode.updateColor(color: blurredBackgroundColor.0, enableBlur: blurredBackgroundColor.1, transition: .immediate) let transition: ContainedViewLayoutTransition = animated ? .animated(duration: 0.4, curve: .spring) : .immediate if let previousLayoutSize = previousLayoutSize { blurredBackgroundNode.frame = blurredBackgroundNode.frame.offsetBy(dx: layoutSize.width - previousLayoutSize.width, dy: 0.0) @@ -619,7 +619,7 @@ class ChatMessageDateAndStatusNode: ASDisplayNode { transition.updateFrame(node: blurredBackgroundNode, frame: CGRect(origin: CGPoint(), size: layoutSize)) blurredBackgroundNode.update(size: blurredBackgroundNode.bounds.size, cornerRadius: blurredBackgroundNode.bounds.height / 2.0, transition: transition) } else { - let blurredBackgroundNode = NavigationBackgroundNode(color: blurredBackgroundColor) + let blurredBackgroundNode = NavigationBackgroundNode(color: blurredBackgroundColor.0, enableBlur: blurredBackgroundColor.1) strongSelf.blurredBackgroundNode = blurredBackgroundNode strongSelf.insertSubnode(blurredBackgroundNode, at: 0) blurredBackgroundNode.frame = CGRect(origin: CGPoint(), size: layoutSize) diff --git a/submodules/TelegramUI/Sources/ChatMessageDateHeader.swift b/submodules/TelegramUI/Sources/ChatMessageDateHeader.swift index 8f4450aee0..e04373ff50 100644 --- a/submodules/TelegramUI/Sources/ChatMessageDateHeader.swift +++ b/submodules/TelegramUI/Sources/ChatMessageDateHeader.swift @@ -166,7 +166,7 @@ final class ChatMessageDateHeaderNode: ListViewItemHeaderNode { let graphics = PresentationResourcesChat.principalGraphics(theme: presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper, bubbleCorners: presentationData.chatBubbleCorners) //self.backgroundNode.image = graphics.dateStaticBackground - self.backgroundNode.color = selectDateFillStaticColor(theme: presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper) + self.backgroundNode.updateColor(color: selectDateFillStaticColor(theme: presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper), enableBlur: dateFillNeedsBlur(theme: presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper), transition: .immediate) self.stickBackgroundNode.image = graphics.dateFloatingBackground self.stickBackgroundNode.alpha = 0.0 //self.backgroundNode.addSubnode(self.stickBackgroundNode) @@ -200,7 +200,7 @@ final class ChatMessageDateHeaderNode: ListViewItemHeaderNode { let graphics = PresentationResourcesChat.principalGraphics(theme: presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper, bubbleCorners: presentationData.chatBubbleCorners) //self.backgroundNode.image = graphics.dateStaticBackground - self.backgroundNode.color = selectDateFillStaticColor(theme: presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper) + self.backgroundNode.updateColor(color: selectDateFillStaticColor(theme: presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper), enableBlur: dateFillNeedsBlur(theme: presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper), transition: .immediate) self.stickBackgroundNode.image = graphics.dateFloatingBackground let titleFont = Font.medium(min(18.0, floor(presentationData.fontSize.baseDisplaySize * 13.0 / 17.0))) @@ -218,8 +218,8 @@ final class ChatMessageDateHeaderNode: ListViewItemHeaderNode { self.setNeedsLayout() } - func updateBackgroundColor(_ color: UIColor) { - self.backgroundNode.color = color + func updateBackgroundColor(color: UIColor, enableBlur: Bool) { + self.backgroundNode.updateColor(color: color, enableBlur: enableBlur, transition: .immediate) /*let chatDateSize: CGFloat = 20.0 self.backgroundNode.image = generateImage(CGSize(width: chatDateSize, height: chatDateSize), contextGenerator: { size, context -> Void in context.clear(CGRect(origin: CGPoint(), size: size)) diff --git a/submodules/TelegramUI/Sources/ChatMessageInteractiveInstantVideoNode.swift b/submodules/TelegramUI/Sources/ChatMessageInteractiveInstantVideoNode.swift index 5596b4410e..43a8dbb043 100644 --- a/submodules/TelegramUI/Sources/ChatMessageInteractiveInstantVideoNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageInteractiveInstantVideoNode.swift @@ -359,12 +359,12 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode { if let telegramFile = updatedFile { if updatedMedia { let durationTextColor: UIColor - let durationBlurColor: UIColor? + let durationBlurColor: (UIColor, Bool)? switch statusDisplayType { case .free: let serviceColor = serviceMessageColorComponents(theme: theme.theme, wallpaper: theme.wallpaper) durationTextColor = serviceColor.primaryText - durationBlurColor = selectDateFillStaticColor(theme: theme.theme, wallpaper: theme.wallpaper) + durationBlurColor = (selectDateFillStaticColor(theme: theme.theme, wallpaper: theme.wallpaper), dateFillNeedsBlur(theme: theme.theme, wallpaper: theme.wallpaper)) case .bubble: durationBlurColor = nil if item.message.effectivelyIncoming(item.context.account.peerId) { @@ -376,9 +376,9 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode { if let durationBlurColor = durationBlurColor { if let durationBackgroundNode = strongSelf.durationBackgroundNode { - durationBackgroundNode.color = durationBlurColor + durationBackgroundNode.updateColor(color: durationBlurColor.0, enableBlur: durationBlurColor.1, transition: .immediate) } else { - let durationBackgroundNode = NavigationBackgroundNode(color: durationBlurColor) + let durationBackgroundNode = NavigationBackgroundNode(color: durationBlurColor.0, enableBlur: durationBlurColor.1) strongSelf.durationBackgroundNode = durationBackgroundNode strongSelf.addSubnode(durationBackgroundNode) } diff --git a/submodules/TelegramUI/Sources/ChatMessageStickerItemNode.swift b/submodules/TelegramUI/Sources/ChatMessageStickerItemNode.swift index 4f8c23d220..e105a800e7 100644 --- a/submodules/TelegramUI/Sources/ChatMessageStickerItemNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageStickerItemNode.swift @@ -705,9 +705,9 @@ class ChatMessageStickerItemNode: ChatMessageItemView { if needsReplyBackground { if let replyBackgroundNode = strongSelf.replyBackgroundNode { - replyBackgroundNode.color = selectDateFillStaticColor(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper) + replyBackgroundNode.updateColor(color: selectDateFillStaticColor(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper), enableBlur: dateFillNeedsBlur(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper), transition: .immediate) } else { - let replyBackgroundNode = NavigationBackgroundNode(color: selectDateFillStaticColor(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper)) + let replyBackgroundNode = NavigationBackgroundNode(color: selectDateFillStaticColor(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper), enableBlur: dateFillNeedsBlur(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper)) strongSelf.replyBackgroundNode = replyBackgroundNode strongSelf.contextSourceNode.contentNode.addSubnode(replyBackgroundNode) } diff --git a/submodules/TelegramUI/Sources/ChatRecentActionsControllerNode.swift b/submodules/TelegramUI/Sources/ChatRecentActionsControllerNode.swift index b67b076227..276d311384 100644 --- a/submodules/TelegramUI/Sources/ChatRecentActionsControllerNode.swift +++ b/submodules/TelegramUI/Sources/ChatRecentActionsControllerNode.swift @@ -632,7 +632,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode { } func updateThemeAndStrings(theme: PresentationTheme, strings: PresentationStrings) { - self.panelBackgroundNode.color = theme.chat.inputPanel.panelBackgroundColor + self.panelBackgroundNode.updateColor(color: theme.chat.inputPanel.panelBackgroundColor, transition: .immediate) self.panelSeparatorNode.backgroundColor = theme.chat.inputPanel.panelSeparatorColor self.panelButtonNode.setTitle(presentationData.strings.Channel_AdminLog_InfoPanelTitle, with: Font.regular(17.0), with: theme.chat.inputPanel.panelControlAccentColor, for: []) } diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift index 3bab194973..b3ba163f13 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift @@ -1951,7 +1951,7 @@ final class PeerInfoHeaderNode: ASDisplayNode { var transitionSourceTitleFrame = CGRect() var transitionSourceSubtitleFrame = CGRect() - self.backgroundNode.color = presentationData.theme.rootController.navigationBar.blurredBackgroundColor + self.backgroundNode.updateColor(color: presentationData.theme.rootController.navigationBar.blurredBackgroundColor, transition: .immediate) if let navigationTransition = self.navigationTransition, let sourceAvatarNode = (navigationTransition.sourceNavigationBar.rightButtonNode.singleCustomNode as? ChatAvatarNavigationNode)?.avatarNode { transitionSourceHeight = navigationTransition.sourceNavigationBar.backgroundNode.bounds.height diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoPaneContainerNode.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoPaneContainerNode.swift index 7bdc48aae2..22b50b5d73 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoPaneContainerNode.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoPaneContainerNode.swift @@ -692,7 +692,7 @@ final class PeerInfoPaneContainerNode: ASDisplayNode, UIGestureRecognizerDelegat transition.updateAlpha(node: self.coveringBackgroundNode, alpha: expansionFraction) self.backgroundColor = presentationData.theme.list.itemBlocksBackgroundColor - self.coveringBackgroundNode.color = presentationData.theme.rootController.navigationBar.opaqueBackgroundColor + self.coveringBackgroundNode.updateColor(color: presentationData.theme.rootController.navigationBar.opaqueBackgroundColor, transition: .immediate) self.separatorNode.backgroundColor = presentationData.theme.list.itemBlocksSeparatorColor self.tabsSeparatorNode.backgroundColor = presentationData.theme.list.itemBlocksSeparatorColor diff --git a/submodules/TelegramUI/Sources/PeerSelectionControllerNode.swift b/submodules/TelegramUI/Sources/PeerSelectionControllerNode.swift index 37f95e9e7a..74f1d5d7bf 100644 --- a/submodules/TelegramUI/Sources/PeerSelectionControllerNode.swift +++ b/submodules/TelegramUI/Sources/PeerSelectionControllerNode.swift @@ -176,7 +176,7 @@ final class PeerSelectionControllerNode: ASDisplayNode { self.searchDisplayController?.updatePresentationData(self.presentationData) self.chatListNode.updateThemeAndStrings(theme: self.presentationData.theme, fontSize: self.presentationData.listsFontSize, strings: self.presentationData.strings, dateTimeFormat: self.presentationData.dateTimeFormat, nameSortOrder: self.presentationData.nameSortOrder, nameDisplayOrder: self.presentationData.nameDisplayOrder, disableAnimations: true) - self.toolbarBackgroundNode?.color = self.presentationData.theme.rootController.navigationBar.blurredBackgroundColor + self.toolbarBackgroundNode?.updateColor(color: self.presentationData.theme.rootController.navigationBar.blurredBackgroundColor, transition: .immediate) self.toolbarSeparatorNode?.backgroundColor = self.presentationData.theme.rootController.navigationBar.separatorColor self.segmentedControlNode?.updateTheme(SegmentedControlTheme(theme: self.presentationData.theme)) }