From c75bde7573afbaff629a65be53620a7578e5e784 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Tue, 24 Dec 2019 14:05:54 +0400 Subject: [PATCH] Alter chat elements to match flat themes --- .../DefaultDarkPresentationTheme.swift | 1 + .../DefaultDarkTintedPresentationTheme.swift | 1 + .../Sources/DefaultDayPresentationTheme.swift | 1 + .../Sources/PresentationTheme.swift | 8 ++-- .../Sources/PresentationThemeCodable.swift | 6 ++- .../TelegramUI/ChatController.swift | 20 ++++++-- .../TelegramUI/ChatControllerNode.swift | 47 +++++++++++++++++-- .../TelegramUI/ChatInterfaceInputNodes.swift | 2 +- .../TelegramUI/ChatMediaInputNode.swift | 20 ++++++-- .../ChatMessageAnimatedStickerItemNode.swift | 2 +- .../ChatMessageBubbleItemNode.swift | 2 +- .../ChatMessageInstantVideoItemNode.swift | 2 +- .../TelegramUI/ChatMessageSelectionNode.swift | 13 ++++- .../ChatMessageStickerItemNode.swift | 2 +- .../TelegramUI/ChatTextInputPanelNode.swift | 10 +++- 15 files changed, 113 insertions(+), 24 deletions(-) diff --git a/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift b/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift index 9dc9e64c13..885370fd52 100644 --- a/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift @@ -420,6 +420,7 @@ public func makeDefaultDarkPresentationTheme(preview: Bool) -> PresentationTheme let inputPanel = PresentationThemeChatInputPanel( panelBackgroundColor: UIColor(rgb: 0x1c1c1d), + panelBackgroundColorNoWallpaper: UIColor(rgb: 0x000000), panelSeparatorColor: UIColor(rgb: 0x3d3d40), panelControlAccentColor: UIColor(rgb: 0xffffff), panelControlColor: UIColor(rgb: 0x808080), diff --git a/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift b/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift index 4bf012314e..18483b9b9d 100644 --- a/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift @@ -676,6 +676,7 @@ public func makeDefaultDarkTintedPresentationTheme(preview: Bool) -> Presentatio let inputPanel = PresentationThemeChatInputPanel( panelBackgroundColor: mainBackgroundColor, + panelBackgroundColorNoWallpaper: accentColor.withMultiplied(hue: 1.024, saturation: 0.573, brightness: 0.18), panelSeparatorColor: mainSeparatorColor, panelControlAccentColor: accentColor, panelControlColor: mainSecondaryTextColor.withAlphaComponent(0.5), diff --git a/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift b/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift index 8c130bd90d..5a8d14a491 100644 --- a/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift @@ -629,6 +629,7 @@ public func makeDefaultDayPresentationTheme(serviceBackgroundColor: UIColor?, da let inputPanel = PresentationThemeChatInputPanel( panelBackgroundColor: UIColor(rgb: 0xf7f7f7), + panelBackgroundColorNoWallpaper: UIColor(rgb: 0xffffff), panelSeparatorColor: UIColor(rgb: 0xb2b2b2), panelControlAccentColor: UIColor(rgb: 0x007ee5), panelControlColor: UIColor(rgb: 0x858e99), diff --git a/submodules/TelegramPresentationData/Sources/PresentationTheme.swift b/submodules/TelegramPresentationData/Sources/PresentationTheme.swift index c35dc24047..1b45d6a192 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationTheme.swift @@ -847,6 +847,7 @@ public final class PresentationThemeChatInputPanelMediaRecordingControl { public final class PresentationThemeChatInputPanel { public let panelBackgroundColor: UIColor + public let panelBackgroundColorNoWallpaper: UIColor public let panelSeparatorColor: UIColor public let panelControlAccentColor: UIColor public let panelControlColor: UIColor @@ -864,8 +865,9 @@ public final class PresentationThemeChatInputPanel { public let mediaRecordingDotColor: UIColor public let mediaRecordingControl: PresentationThemeChatInputPanelMediaRecordingControl - public init(panelBackgroundColor: UIColor, panelSeparatorColor: UIColor, panelControlAccentColor: UIColor, panelControlColor: UIColor, panelControlDisabledColor: UIColor, panelControlDestructiveColor: UIColor, inputBackgroundColor: UIColor, inputStrokeColor: UIColor, inputPlaceholderColor: UIColor, inputTextColor: UIColor, inputControlColor: UIColor, actionControlFillColor: UIColor, actionControlForegroundColor: UIColor, primaryTextColor: UIColor, secondaryTextColor: UIColor, mediaRecordingDotColor: UIColor, mediaRecordingControl: PresentationThemeChatInputPanelMediaRecordingControl) { + public init(panelBackgroundColor: UIColor, panelBackgroundColorNoWallpaper: UIColor, panelSeparatorColor: UIColor, panelControlAccentColor: UIColor, panelControlColor: UIColor, panelControlDisabledColor: UIColor, panelControlDestructiveColor: UIColor, inputBackgroundColor: UIColor, inputStrokeColor: UIColor, inputPlaceholderColor: UIColor, inputTextColor: UIColor, inputControlColor: UIColor, actionControlFillColor: UIColor, actionControlForegroundColor: UIColor, primaryTextColor: UIColor, secondaryTextColor: UIColor, mediaRecordingDotColor: UIColor, mediaRecordingControl: PresentationThemeChatInputPanelMediaRecordingControl) { self.panelBackgroundColor = panelBackgroundColor + self.panelBackgroundColorNoWallpaper = panelBackgroundColorNoWallpaper self.panelSeparatorColor = panelSeparatorColor self.panelControlAccentColor = panelControlAccentColor self.panelControlColor = panelControlColor @@ -884,8 +886,8 @@ public final class PresentationThemeChatInputPanel { self.mediaRecordingControl = mediaRecordingControl } - public func withUpdated(panelBackgroundColor: UIColor? = nil, panelSeparatorColor: UIColor? = nil, panelControlAccentColor: UIColor? = nil, panelControlColor: UIColor? = nil, panelControlDisabledColor: UIColor? = nil, panelControlDestructiveColor: UIColor? = nil, inputBackgroundColor: UIColor? = nil, inputStrokeColor: UIColor? = nil, inputPlaceholderColor: UIColor? = nil, inputTextColor: UIColor? = nil, inputControlColor: UIColor? = nil, actionControlFillColor: UIColor? = nil, actionControlForegroundColor: UIColor? = nil, primaryTextColor: UIColor? = nil, secondaryTextColor: UIColor? = nil, mediaRecordingDotColor: UIColor? = nil, mediaRecordingControl: PresentationThemeChatInputPanelMediaRecordingControl? = nil) -> PresentationThemeChatInputPanel { - return PresentationThemeChatInputPanel(panelBackgroundColor: panelBackgroundColor ?? self.panelBackgroundColor, panelSeparatorColor: panelSeparatorColor ?? self.panelSeparatorColor, panelControlAccentColor: panelControlAccentColor ?? self.panelControlAccentColor, panelControlColor: panelControlColor ?? self.panelControlColor, panelControlDisabledColor: panelControlDisabledColor ?? self.panelControlDisabledColor, panelControlDestructiveColor: panelControlDestructiveColor ?? self.panelControlDestructiveColor, inputBackgroundColor: inputBackgroundColor ?? self.inputBackgroundColor, inputStrokeColor: inputStrokeColor ?? self.inputStrokeColor, inputPlaceholderColor: inputPlaceholderColor ?? self.inputPlaceholderColor, inputTextColor: inputTextColor ?? self.inputTextColor, inputControlColor: inputControlColor ?? self.inputControlColor, actionControlFillColor: actionControlFillColor ?? self.actionControlFillColor, actionControlForegroundColor: actionControlForegroundColor ?? self.actionControlForegroundColor, primaryTextColor: primaryTextColor ?? self.primaryTextColor, secondaryTextColor: secondaryTextColor ?? self.secondaryTextColor, mediaRecordingDotColor: mediaRecordingDotColor ?? self.mediaRecordingDotColor, mediaRecordingControl: mediaRecordingControl ?? self.mediaRecordingControl) + public func withUpdated(panelBackgroundColor: UIColor? = nil, panelBackgroundColorNoWallpaper: UIColor? = nil, panelSeparatorColor: UIColor? = nil, panelControlAccentColor: UIColor? = nil, panelControlColor: UIColor? = nil, panelControlDisabledColor: UIColor? = nil, panelControlDestructiveColor: UIColor? = nil, inputBackgroundColor: UIColor? = nil, inputStrokeColor: UIColor? = nil, inputPlaceholderColor: UIColor? = nil, inputTextColor: UIColor? = nil, inputControlColor: UIColor? = nil, actionControlFillColor: UIColor? = nil, actionControlForegroundColor: UIColor? = nil, primaryTextColor: UIColor? = nil, secondaryTextColor: UIColor? = nil, mediaRecordingDotColor: UIColor? = nil, mediaRecordingControl: PresentationThemeChatInputPanelMediaRecordingControl? = nil) -> PresentationThemeChatInputPanel { + return PresentationThemeChatInputPanel(panelBackgroundColor: panelBackgroundColor ?? self.panelBackgroundColor, panelBackgroundColorNoWallpaper: panelBackgroundColorNoWallpaper ?? self.panelBackgroundColorNoWallpaper, panelSeparatorColor: panelSeparatorColor ?? self.panelSeparatorColor, panelControlAccentColor: panelControlAccentColor ?? self.panelControlAccentColor, panelControlColor: panelControlColor ?? self.panelControlColor, panelControlDisabledColor: panelControlDisabledColor ?? self.panelControlDisabledColor, panelControlDestructiveColor: panelControlDestructiveColor ?? self.panelControlDestructiveColor, inputBackgroundColor: inputBackgroundColor ?? self.inputBackgroundColor, inputStrokeColor: inputStrokeColor ?? self.inputStrokeColor, inputPlaceholderColor: inputPlaceholderColor ?? self.inputPlaceholderColor, inputTextColor: inputTextColor ?? self.inputTextColor, inputControlColor: inputControlColor ?? self.inputControlColor, actionControlFillColor: actionControlFillColor ?? self.actionControlFillColor, actionControlForegroundColor: actionControlForegroundColor ?? self.actionControlForegroundColor, primaryTextColor: primaryTextColor ?? self.primaryTextColor, secondaryTextColor: secondaryTextColor ?? self.secondaryTextColor, mediaRecordingDotColor: mediaRecordingDotColor ?? self.mediaRecordingDotColor, mediaRecordingControl: mediaRecordingControl ?? self.mediaRecordingControl) } } diff --git a/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift b/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift index ce6be6b708..60753ba0f2 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift @@ -1318,6 +1318,7 @@ extension PresentationThemeChatInputPanelMediaRecordingControl: Codable { extension PresentationThemeChatInputPanel: Codable { enum CodingKeys: String, CodingKey { case panelBg + case panelBgNoWallpaper case panelSeparator case panelControlAccent case panelControl @@ -1338,7 +1339,10 @@ extension PresentationThemeChatInputPanel: Codable { public convenience init(from decoder: Decoder) throws { let values = try decoder.container(keyedBy: CodingKeys.self) - self.init(panelBackgroundColor: try decodeColor(values, .panelBg), + let panelBackgroundColor = try decodeColor(values, .panelBg) + let panelBackgroundColorNoWallpaper = try decodeColor(values, .panelBgNoWallpaper) + self.init(panelBackgroundColor: panelBackgroundColor, + panelBackgroundColorNoWallpaper: panelBackgroundColorNoWallpaper ?? panelBackgroundColor, panelSeparatorColor: try decodeColor(values, .panelSeparator), panelControlAccentColor: try decodeColor(values, .panelControlAccent), panelControlColor: try decodeColor(values, .panelControl), diff --git a/submodules/TelegramUI/TelegramUI/ChatController.swift b/submodules/TelegramUI/TelegramUI/ChatController.swift index ab34384fad..02ad46c4c2 100644 --- a/submodules/TelegramUI/TelegramUI/ChatController.swift +++ b/submodules/TelegramUI/TelegramUI/ChatController.swift @@ -2687,6 +2687,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G self.chatDisplayNode.historyNode.contentPositionChanged = { [weak self] offset in if let strongSelf = self { let offsetAlpha: CGFloat + let plainInputSeparatorAlpha: CGFloat switch offset { case let .known(offset): if offset < 40.0 { @@ -2694,13 +2695,21 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } else { offsetAlpha = 1.0 } + if offset < 4.0 { + plainInputSeparatorAlpha = 0.0 + } else { + plainInputSeparatorAlpha = 1.0 + } case .unknown: offsetAlpha = 1.0 + plainInputSeparatorAlpha = 1.0 case .none: offsetAlpha = 0.0 + plainInputSeparatorAlpha = 0.0 } strongSelf.chatDisplayNode.navigateButtons.displayDownButton = !offsetAlpha.isZero + strongSelf.chatDisplayNode.updatePlainInputSeparatorAlpha(plainInputSeparatorAlpha, animated: true) } } @@ -5079,14 +5088,17 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G statusText = strongSelf.presentationData.strings.Undo_ChatCleared } - strongSelf.present(UndoOverlayController(presentationData: strongSelf.context.sharedContext.currentPresentationData.with { $0 }, content: .removedChat(text: statusText), elevatedLayout: true, action: { shouldCommit in - if shouldCommit { + strongSelf.present(UndoOverlayController(presentationData: strongSelf.context.sharedContext.currentPresentationData.with { $0 }, content: .removedChat(text: statusText), elevatedLayout: true, action: { value in + if value == .commit { let _ = clearHistoryInteractively(postbox: account.postbox, peerId: peerId, type: type).start(completed: { self?.chatDisplayNode.historyNode.historyAppearsCleared = false }) - } else { + return true + } else if value == .undo { self?.chatDisplayNode.historyNode.historyAppearsCleared = false + return true } + return false }), in: .current) } @@ -5349,7 +5361,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G disposable.set((signal |> deliverOnMainQueue).start(completed: { [weak self] in if let strongSelf = self, let layout = strongSelf.validLayout { - strongSelf.present(UndoOverlayController(presentationData: presentationData, content: .succeed(text: presentationData.strings.ClearCache_Success("\(dataSizeString(selectedSize, decimalSeparator: presentationData.dateTimeFormat.decimalSeparator))", stringForDeviceType()).0), elevatedLayout: true, action: { _ in }), in: .current) + strongSelf.present(UndoOverlayController(presentationData: presentationData, content: .succeed(text: presentationData.strings.ClearCache_Success("\(dataSizeString(selectedSize, decimalSeparator: presentationData.dateTimeFormat.decimalSeparator))", stringForDeviceType()).0), elevatedLayout: true, action: { _ in return false }), in: .current) } })) diff --git a/submodules/TelegramUI/TelegramUI/ChatControllerNode.swift b/submodules/TelegramUI/TelegramUI/ChatControllerNode.swift index fdd2f87c54..9c5b7846d5 100644 --- a/submodules/TelegramUI/TelegramUI/ChatControllerNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatControllerNode.swift @@ -92,6 +92,8 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { private let inputPanelBackgroundNode: ASDisplayNode private let inputPanelBackgroundSeparatorNode: ASDisplayNode + private var plainInputSeparatorAlpha: CGFloat? + private var usePlainInputSeparator: Bool private let titleAccessoryPanelContainer: ChatControllerTitlePanelNodeContainer private var titleAccessoryPanelNode: ChatTitleAccessoryPanelNode? @@ -225,7 +227,14 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { self.loadingNode = ChatLoadingNode(theme: self.chatPresentationInterfaceState.theme, chatWallpaper: self.chatPresentationInterfaceState.chatWallpaper) self.inputPanelBackgroundNode = ASDisplayNode() - self.inputPanelBackgroundNode.backgroundColor = self.chatPresentationInterfaceState.theme.chat.inputPanel.panelBackgroundColor + if self.chatPresentationInterfaceState.chatWallpaper == self.chatPresentationInterfaceState.theme.chat.defaultWallpaper, case .color = self.chatPresentationInterfaceState.chatWallpaper { + self.inputPanelBackgroundNode.backgroundColor = self.chatPresentationInterfaceState.theme.chat.inputPanel.panelBackgroundColorNoWallpaper + self.usePlainInputSeparator = true + } else { + self.inputPanelBackgroundNode.backgroundColor = self.chatPresentationInterfaceState.theme.chat.inputPanel.panelBackgroundColor + self.usePlainInputSeparator = false + self.plainInputSeparatorAlpha = nil + } self.inputPanelBackgroundNode.isLayerBacked = true self.inputPanelBackgroundSeparatorNode = ASDisplayNode() @@ -1443,7 +1452,17 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { self.navigateButtons.updateTheme(theme: chatPresentationInterfaceState.theme) if themeUpdated { - self.inputPanelBackgroundNode.backgroundColor = chatPresentationInterfaceState.theme.chat.inputPanel.panelBackgroundColor + if self.chatPresentationInterfaceState.chatWallpaper == self.chatPresentationInterfaceState.theme.chat.defaultWallpaper, case .color = self.chatPresentationInterfaceState.chatWallpaper { + self.inputPanelBackgroundNode.backgroundColor = self.chatPresentationInterfaceState.theme.chat.inputPanel.panelBackgroundColorNoWallpaper + self.usePlainInputSeparator = true + } else { + self.inputPanelBackgroundNode.backgroundColor = self.chatPresentationInterfaceState.theme.chat.inputPanel.panelBackgroundColor + self.usePlainInputSeparator = false + self.plainInputSeparatorAlpha = nil + } + if let plainInputSeparatorAlpha = self.plainInputSeparatorAlpha { + self.updatePlainInputSeparatorAlpha(plainInputSeparatorAlpha, animated: false) + } self.inputPanelBackgroundSeparatorNode.backgroundColor = self.chatPresentationInterfaceState.theme.chat.inputPanel.panelSeparatorColor } @@ -1657,7 +1676,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { if case let .peer(id) = self.chatPresentationInterfaceState.chatLocation { peerId = id } - let inputNode = ChatMediaInputNode(context: self.context, peerId: peerId, controllerInteraction: self.controllerInteraction, theme: theme, strings: strings, fontSize: fontSize, gifPaneIsActiveUpdated: { [weak self] value in + let inputNode = ChatMediaInputNode(context: self.context, peerId: peerId, controllerInteraction: self.controllerInteraction, chatWallpaper: self.chatPresentationInterfaceState.chatWallpaper, theme: theme, strings: strings, fontSize: fontSize, gifPaneIsActiveUpdated: { [weak self] value in if let strongSelf = self, let interfaceInteraction = strongSelf.interfaceInteraction { interfaceInteraction.updateInputModeAndDismissedButtonKeyboardMessageId { state in if case let .media(_, expanded) = state.inputMode { @@ -2275,4 +2294,26 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { func setEnablePredictiveTextInput(_ value: Bool) { self.textInputPanelNode?.enablePredictiveInput = value } + + func updatePlainInputSeparatorAlpha(_ value: CGFloat, animated: Bool) { + if self.usePlainInputSeparator { + if let plainInputSeparatorAlpha = self.plainInputSeparatorAlpha { + if plainInputSeparatorAlpha != value { + self.plainInputSeparatorAlpha = value + if animated { + let transition: ContainedViewLayoutTransition = .animated(duration: 0.2, curve: .easeInOut) + transition.updateAlpha(node: self.inputPanelBackgroundSeparatorNode, alpha: value, beginWithCurrentState: true) + } else { + self.inputPanelBackgroundSeparatorNode.alpha = value + } + } + } else { + self.plainInputSeparatorAlpha = value + self.inputPanelBackgroundSeparatorNode.alpha = value + } + } else if self.updatePlainInputSeparatorAlpha != nil { + self.plainInputSeparatorAlpha = nil + self.inputPanelBackgroundSeparatorNode.alpha = 1.0 + } + } } diff --git a/submodules/TelegramUI/TelegramUI/ChatInterfaceInputNodes.swift b/submodules/TelegramUI/TelegramUI/ChatInterfaceInputNodes.swift index 27389e1cba..0440046386 100644 --- a/submodules/TelegramUI/TelegramUI/ChatInterfaceInputNodes.swift +++ b/submodules/TelegramUI/TelegramUI/ChatInterfaceInputNodes.swift @@ -21,7 +21,7 @@ func inputNodeForChatPresentationIntefaceState(_ chatPresentationInterfaceState: if case let .peer(id) = chatPresentationInterfaceState.chatLocation { peerId = id } - let inputNode = ChatMediaInputNode(context: context, peerId: peerId, controllerInteraction: controllerInteraction, theme: chatPresentationInterfaceState.theme, strings: chatPresentationInterfaceState.strings, fontSize: chatPresentationInterfaceState.fontSize, gifPaneIsActiveUpdated: { [weak interfaceInteraction] value in + let inputNode = ChatMediaInputNode(context: context, peerId: peerId, controllerInteraction: controllerInteraction, chatWallpaper: chatPresentationInterfaceState.chatWallpaper, theme: chatPresentationInterfaceState.theme, strings: chatPresentationInterfaceState.strings, fontSize: chatPresentationInterfaceState.fontSize, gifPaneIsActiveUpdated: { [weak interfaceInteraction] value in if let interfaceInteraction = interfaceInteraction { interfaceInteraction.updateInputModeAndDismissedButtonKeyboardMessageId { state in if case let .media(_, expanded) = state.inputMode { diff --git a/submodules/TelegramUI/TelegramUI/ChatMediaInputNode.swift b/submodules/TelegramUI/TelegramUI/ChatMediaInputNode.swift index fb60abc52b..1af629375e 100644 --- a/submodules/TelegramUI/TelegramUI/ChatMediaInputNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatMediaInputNode.swift @@ -446,7 +446,7 @@ final class ChatMediaInputNode: ChatInputNode { return self._ready.get() } - init(context: AccountContext, peerId: PeerId?, controllerInteraction: ChatControllerInteraction, theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize, gifPaneIsActiveUpdated: @escaping (Bool) -> Void) { + init(context: AccountContext, peerId: PeerId?, controllerInteraction: ChatControllerInteraction, chatWallpaper: TelegramWallpaper, theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize, gifPaneIsActiveUpdated: @escaping (Bool) -> Void) { self.context = context self.peerId = peerId self.controllerInteraction = controllerInteraction @@ -459,7 +459,12 @@ final class ChatMediaInputNode: ChatInputNode { self.collectionListPanel = ASDisplayNode() self.collectionListPanel.clipsToBounds = true - self.collectionListPanel.backgroundColor = theme.chat.inputPanel.panelBackgroundColor + + if chatWallpaper == theme.chat.defaultWallpaper, case .color = chatWallpaper { + self.collectionListPanel.backgroundColor = theme.chat.inputPanel.panelBackgroundColorNoWallpaper + } else { + self.collectionListPanel.backgroundColor = theme.chat.inputPanel.panelBackgroundColor + } self.collectionListSeparator = ASDisplayNode() self.collectionListSeparator.isLayerBacked = true @@ -913,12 +918,17 @@ final class ChatMediaInputNode: ChatInputNode { self.searchContainerNodeLoadedDisposable.dispose() } - private func updateThemeAndStrings(theme: PresentationTheme, strings: PresentationStrings) { + private func updateThemeAndStrings(chatWallpaper: TelegramWallpaper, theme: PresentationTheme, strings: PresentationStrings) { if self.theme !== theme || self.strings !== strings { self.theme = theme self.strings = strings - self.collectionListPanel.backgroundColor = theme.chat.inputPanel.panelBackgroundColor + if chatWallpaper == theme.chat.defaultWallpaper, case .color = chatWallpaper { + self.collectionListPanel.backgroundColor = theme.chat.inputPanel.panelBackgroundColorNoWallpaper + } else { + self.collectionListPanel.backgroundColor = theme.chat.inputPanel.panelBackgroundColor + } + self.collectionListSeparator.backgroundColor = theme.chat.inputMediaPanel.panelSeparatorColor self.backgroundColor = theme.chat.inputMediaPanel.stickersBackgroundColor @@ -1332,7 +1342,7 @@ final class ChatMediaInputNode: ChatInputNode { self.validLayout = (width, leftInset, rightInset, bottomInset, standardInputHeight, inputHeight, maximumHeight, inputPanelHeight, interfaceState, deviceMetrics, isVisible) if self.theme !== interfaceState.theme || self.strings !== interfaceState.strings { - self.updateThemeAndStrings(theme: interfaceState.theme, strings: interfaceState.strings) + self.updateThemeAndStrings(chatWallpaper: interfaceState.chatWallpaper, theme: interfaceState.theme, strings: interfaceState.strings) } var displaySearch = false diff --git a/submodules/TelegramUI/TelegramUI/ChatMessageAnimatedStickerItemNode.swift b/submodules/TelegramUI/TelegramUI/ChatMessageAnimatedStickerItemNode.swift index 01f7ce55e7..d52457021e 100644 --- a/submodules/TelegramUI/TelegramUI/ChatMessageAnimatedStickerItemNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatMessageAnimatedStickerItemNode.swift @@ -1015,7 +1015,7 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView { selectionNode.updateLayout(size: selectionFrame.size) self.subnodeTransform = CATransform3DMakeTranslation(offset, 0.0, 0.0); } else { - let selectionNode = ChatMessageSelectionNode(theme: item.presentationData.theme.theme, toggle: { [weak self] value in + let selectionNode = ChatMessageSelectionNode(wallpaper: item.presentationData.theme.wallpaper, theme: item.presentationData.theme.theme, toggle: { [weak self] value in if let strongSelf = self, let item = strongSelf.item { item.controllerInteraction.toggleMessagesSelection([item.message.id], value) } diff --git a/submodules/TelegramUI/TelegramUI/ChatMessageBubbleItemNode.swift b/submodules/TelegramUI/TelegramUI/ChatMessageBubbleItemNode.swift index 9a3a8a8bb3..36e8429945 100644 --- a/submodules/TelegramUI/TelegramUI/ChatMessageBubbleItemNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatMessageBubbleItemNode.swift @@ -2661,7 +2661,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePrevewItemNode selectionNode.updateLayout(size: selectionFrame.size) self.subnodeTransform = CATransform3DMakeTranslation(offset, 0.0, 0.0); } else { - let selectionNode = ChatMessageSelectionNode(theme: item.presentationData.theme.theme, toggle: { [weak self] value in + let selectionNode = ChatMessageSelectionNode(wallpaper: item.presentationData.theme.wallpaper, theme: item.presentationData.theme.theme, toggle: { [weak self] value in if let strongSelf = self, let item = strongSelf.item { switch item.content { case let .message(message, _, _, _): diff --git a/submodules/TelegramUI/TelegramUI/ChatMessageInstantVideoItemNode.swift b/submodules/TelegramUI/TelegramUI/ChatMessageInstantVideoItemNode.swift index 357286e43c..c2136f81d2 100644 --- a/submodules/TelegramUI/TelegramUI/ChatMessageInstantVideoItemNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatMessageInstantVideoItemNode.swift @@ -770,7 +770,7 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView { selectionNode.updateSelected(selected, animated: animated) self.subnodeTransform = CATransform3DMakeTranslation(offset, 0.0, 0.0); } else { - let selectionNode = ChatMessageSelectionNode(theme: item.presentationData.theme.theme, toggle: { [weak self] value in + let selectionNode = ChatMessageSelectionNode(wallpaper: item.presentationData.theme.wallpaper, theme: item.presentationData.theme.theme, toggle: { [weak self] value in if let strongSelf = self, let item = strongSelf.item { item.controllerInteraction.toggleMessagesSelection([item.message.id], value) } diff --git a/submodules/TelegramUI/TelegramUI/ChatMessageSelectionNode.swift b/submodules/TelegramUI/TelegramUI/ChatMessageSelectionNode.swift index df711333ef..ab47b38038 100644 --- a/submodules/TelegramUI/TelegramUI/ChatMessageSelectionNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatMessageSelectionNode.swift @@ -3,6 +3,7 @@ import UIKit import AsyncDisplayKit import TelegramPresentationData import CheckNode +import SyncCore final class ChatMessageSelectionNode: ASDisplayNode { private let toggle: (Bool) -> Void @@ -10,9 +11,17 @@ final class ChatMessageSelectionNode: ASDisplayNode { private(set) var selected = false private let checkNode: CheckNode - init(theme: PresentationTheme, toggle: @escaping (Bool) -> Void) { + init(wallpaper: TelegramWallpaper, theme: PresentationTheme, toggle: @escaping (Bool) -> Void) { self.toggle = toggle - self.checkNode = CheckNode(strokeColor: theme.list.itemCheckColors.strokeColor, fillColor: theme.list.itemCheckColors.fillColor, foregroundColor: theme.list.itemCheckColors.foregroundColor, style: .overlay) + + let style: CheckNodeStyle + if wallpaper == theme.chat.defaultWallpaper, case .color = wallpaper { + style = .plain + } else { + style = .overlay + } + + self.checkNode = CheckNode(strokeColor: theme.list.itemCheckColors.strokeColor, fillColor: theme.list.itemCheckColors.fillColor, foregroundColor: theme.list.itemCheckColors.foregroundColor, style: style) self.checkNode.isUserInteractionEnabled = false super.init() diff --git a/submodules/TelegramUI/TelegramUI/ChatMessageStickerItemNode.swift b/submodules/TelegramUI/TelegramUI/ChatMessageStickerItemNode.swift index faae1d4db2..d9c2e3c55d 100644 --- a/submodules/TelegramUI/TelegramUI/ChatMessageStickerItemNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatMessageStickerItemNode.swift @@ -796,7 +796,7 @@ class ChatMessageStickerItemNode: ChatMessageItemView { selectionNode.updateSelected(selected, animated: animated) self.subnodeTransform = CATransform3DMakeTranslation(offset, 0.0, 0.0); } else { - let selectionNode = ChatMessageSelectionNode(theme: item.presentationData.theme.theme, toggle: { [weak self] value in + let selectionNode = ChatMessageSelectionNode(wallpaper: item.presentationData.theme.wallpaper, theme: item.presentationData.theme.theme, toggle: { [weak self] value in if let strongSelf = self, let item = strongSelf.item { item.controllerInteraction.toggleMessagesSelection([item.message.id], value) } diff --git a/submodules/TelegramUI/TelegramUI/ChatTextInputPanelNode.swift b/submodules/TelegramUI/TelegramUI/ChatTextInputPanelNode.swift index 6a36ceb492..af4e03d72f 100644 --- a/submodules/TelegramUI/TelegramUI/ChatTextInputPanelNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatTextInputPanelNode.swift @@ -724,7 +724,15 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { let textFieldMinHeight = calclulateTextFieldMinHeight(interfaceState, metrics: metrics) let minimalInputHeight: CGFloat = 2.0 + textFieldMinHeight - self.textInputBackgroundNode.image = textInputBackgroundImage(backgroundColor: interfaceState.theme.chat.inputPanel.panelBackgroundColor, strokeColor: interfaceState.theme.chat.inputPanel.inputStrokeColor, diameter: minimalInputHeight) + + let backgroundColor: UIColor + if interfaceState.theme.chat.defaultWallpaper == interfaceState.chatWallpaper, case .color = interfaceState.chatWallpaper { + backgroundColor = interfaceState.theme.chat.inputPanel.panelBackgroundColorNoWallpaper + } else { + backgroundColor = interfaceState.theme.chat.inputPanel.panelBackgroundColor + } + + self.textInputBackgroundNode.image = textInputBackgroundImage(backgroundColor: backgroundColor, strokeColor: interfaceState.theme.chat.inputPanel.inputStrokeColor, diameter: minimalInputHeight) self.searchLayoutClearButton.setImage(PresentationResourcesChat.chatInputTextFieldClearImage(interfaceState.theme), for: [])