diff --git a/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift b/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift index 4ca9d8c2ab..72d9f65c3a 100644 --- a/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift @@ -663,10 +663,11 @@ public func makeDefaultDarkPresentationTheme(extendingThemeReference: Presentati ) let inputButtonPanel = PresentationThemeInputButtonPanel( - panelSeparatorColor: UIColor(rgb: 0x545458, alpha: 0.55), - panelBackgroundColor: UIColor(rgb: 0x141414), - buttonFillColor: UIColor(rgb: 0x5a5a5a), - buttonStrokeColor: UIColor(rgb: 0x0c0c0c), + panelSeparatorColor: UIColor(rgb: 0x545458, alpha: 0.3), + panelBackgroundColor: UIColor(rgb: 0x141414, alpha: 0.6), + buttonFillColor: UIColor(rgb: 0xe9e9e9, alpha: 0.85), + buttonHighlightColor: UIColor(rgb: 0xffffff, alpha: 0.1), + buttonStrokeColor: UIColor(rgb: 0x000000, alpha: 0.85), buttonHighlightedFillColor: UIColor(rgb: 0x5a5a5a, alpha: 0.7), buttonHighlightedStrokeColor: UIColor(rgb: 0x0c0c0c), buttonTextColor: UIColor(rgb: 0xffffff) diff --git a/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift b/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift index 7aa97959c7..f0d6ab8816 100644 --- a/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift @@ -880,6 +880,7 @@ public func makeDefaultDarkTintedPresentationTheme(extendingThemeReference: Pres panelSeparatorColor: mainBackgroundColor, panelBackgroundColor: accentColor.withMultiplied(hue: 1.048, saturation: 0.378, brightness: 0.13), buttonFillColor: accentColor.withMultiplied(hue: 1.0, saturation: 0.085, brightness: 0.38), + buttonHighlightColor: UIColor(rgb: 0xffffff, alpha: 0.2), buttonStrokeColor: accentColor.withMultiplied(hue: 1.019, saturation: 0.39, brightness: 0.07), buttonHighlightedFillColor: accentColor.withMultiplied(hue: 1.0, saturation: 0.085, brightness: 0.38).withAlphaComponent(0.7), buttonHighlightedStrokeColor: accentColor.withMultiplied(hue: 1.019, saturation: 0.39, brightness: 0.07), diff --git a/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift b/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift index 75df504744..2d027d39cc 100644 --- a/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift @@ -912,10 +912,11 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio ) let inputButtonPanel = PresentationThemeInputButtonPanel( - panelSeparatorColor: UIColor(rgb: 0xbec2c6), - panelBackgroundColor: UIColor(rgb: 0xdee2e6), + panelSeparatorColor: UIColor(rgb: 0xb2b2b2), + panelBackgroundColor: UIColor(rgb: 0xdddfd7, alpha: 0.8), buttonFillColor: UIColor(rgb: 0xffffff), - buttonStrokeColor: UIColor(rgb: 0xc3c7c9), + buttonHighlightColor: UIColor(rgb: 0xffffff, alpha: 0.2), + buttonStrokeColor: UIColor(rgb: 0x353535, alpha: 0.2), buttonHighlightedFillColor: UIColor(rgb: 0xa8b3c0), buttonHighlightedStrokeColor: UIColor(rgb: 0xc3c7c9), buttonTextColor: UIColor(rgb: 0x000000) diff --git a/submodules/TelegramPresentationData/Sources/PresentationTheme.swift b/submodules/TelegramPresentationData/Sources/PresentationTheme.swift index 62091d16bc..ca0f78f2e2 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationTheme.swift @@ -1254,23 +1254,25 @@ public final class PresentationThemeInputButtonPanel { public let panelSeparatorColor: UIColor public let panelBackgroundColor: UIColor public let buttonFillColor: UIColor + public let buttonHighlightColor: UIColor public let buttonStrokeColor: UIColor public let buttonHighlightedFillColor: UIColor public let buttonHighlightedStrokeColor: UIColor public let buttonTextColor: UIColor - public init(panelSeparatorColor: UIColor, panelBackgroundColor: UIColor, buttonFillColor: UIColor, buttonStrokeColor: UIColor, buttonHighlightedFillColor: UIColor, buttonHighlightedStrokeColor: UIColor, buttonTextColor: UIColor) { + public init(panelSeparatorColor: UIColor, panelBackgroundColor: UIColor, buttonFillColor: UIColor, buttonHighlightColor: UIColor, buttonStrokeColor: UIColor, buttonHighlightedFillColor: UIColor, buttonHighlightedStrokeColor: UIColor, buttonTextColor: UIColor) { self.panelSeparatorColor = panelSeparatorColor self.panelBackgroundColor = panelBackgroundColor self.buttonFillColor = buttonFillColor + self.buttonHighlightColor = buttonHighlightColor self.buttonStrokeColor = buttonStrokeColor self.buttonHighlightedFillColor = buttonHighlightedFillColor self.buttonHighlightedStrokeColor = buttonHighlightedStrokeColor self.buttonTextColor = buttonTextColor } - public func withUpdated(panelSeparatorColor: UIColor? = nil, panelBackgroundColor: UIColor? = nil, buttonFillColor: UIColor? = nil, buttonStrokeColor: UIColor? = nil, buttonHighlightedFillColor: UIColor? = nil, buttonHighlightedStrokeColor: UIColor? = nil, buttonTextColor: UIColor? = nil) -> PresentationThemeInputButtonPanel { - return PresentationThemeInputButtonPanel(panelSeparatorColor: panelSeparatorColor ?? self.panelSeparatorColor, panelBackgroundColor: panelBackgroundColor ?? self.panelBackgroundColor, buttonFillColor: buttonFillColor ?? self.buttonFillColor, buttonStrokeColor: buttonStrokeColor ?? self.buttonStrokeColor, buttonHighlightedFillColor: buttonHighlightedFillColor ?? self.buttonHighlightedFillColor, buttonHighlightedStrokeColor: buttonHighlightedStrokeColor ?? self.buttonHighlightedStrokeColor, buttonTextColor: buttonTextColor ?? self.buttonTextColor) + public func withUpdated(panelSeparatorColor: UIColor? = nil, panelBackgroundColor: UIColor? = nil, buttonFillColor: UIColor? = nil, buttonHighlightColor: UIColor? = nil, buttonStrokeColor: UIColor? = nil, buttonHighlightedFillColor: UIColor? = nil, buttonHighlightedStrokeColor: UIColor? = nil, buttonTextColor: UIColor? = nil) -> PresentationThemeInputButtonPanel { + return PresentationThemeInputButtonPanel(panelSeparatorColor: panelSeparatorColor ?? self.panelSeparatorColor, panelBackgroundColor: panelBackgroundColor ?? self.panelBackgroundColor, buttonFillColor: buttonFillColor ?? self.buttonFillColor, buttonHighlightColor: buttonHighlightColor ?? self.buttonHighlightColor, buttonStrokeColor: buttonStrokeColor ?? self.buttonStrokeColor, buttonHighlightedFillColor: buttonHighlightedFillColor ?? self.buttonHighlightedFillColor, buttonHighlightedStrokeColor: buttonHighlightedStrokeColor ?? self.buttonHighlightedStrokeColor, buttonTextColor: buttonTextColor ?? self.buttonTextColor) } } diff --git a/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift b/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift index df9ee92b2b..fac8cfa68e 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift @@ -1711,6 +1711,7 @@ extension PresentationThemeInputButtonPanel: Codable { case panelBg case panelSeparator case buttonBg + case buttonHighlight case buttonStroke case buttonHighlightedBg case buttonHighlightedStroke @@ -1722,6 +1723,7 @@ extension PresentationThemeInputButtonPanel: Codable { self.init(panelSeparatorColor: try decodeColor(values, .panelSeparator), panelBackgroundColor: try decodeColor(values, .panelBg), buttonFillColor: try decodeColor(values, .buttonBg), + buttonHighlightColor: try decodeColor(values, .buttonHighlight), buttonStrokeColor: try decodeColor(values, .buttonStroke), buttonHighlightedFillColor: try decodeColor(values, .buttonHighlightedBg), buttonHighlightedStrokeColor: try decodeColor(values, .buttonHighlightedStroke), @@ -1733,6 +1735,7 @@ extension PresentationThemeInputButtonPanel: Codable { try encodeColor(&values, self.panelBackgroundColor, .panelBg) try encodeColor(&values, self.panelSeparatorColor, .panelSeparator) try encodeColor(&values, self.buttonFillColor, .buttonBg) + try encodeColor(&values, self.buttonHighlightColor, .buttonHighlight) try encodeColor(&values, self.buttonStrokeColor, .buttonStroke) try encodeColor(&values, self.buttonHighlightedFillColor, .buttonHighlightedBg) try encodeColor(&values, self.buttonHighlightedStrokeColor, .buttonHighlightedStroke) diff --git a/submodules/TelegramPresentationData/Sources/Resources/PresentationResourceKey.swift b/submodules/TelegramPresentationData/Sources/Resources/PresentationResourceKey.swift index ae5d02bd5d..f2b40eef86 100644 --- a/submodules/TelegramPresentationData/Sources/Resources/PresentationResourceKey.swift +++ b/submodules/TelegramPresentationData/Sources/Resources/PresentationResourceKey.swift @@ -176,8 +176,8 @@ public enum PresentationResourceKey: Int32 { case chatInputMediaPanelStickersModeIcon case chatInputMediaPanelPremiumIcon - case chatInputButtonPanelButtonImage - case chatInputButtonPanelButtonHighlightedImage + case chatInputButtonPanelButtonHighlightImage + case chatInputButtonPanelButtonShadowImage case chatInputTextFieldBackgroundImage case chatInputTextFieldClearImage diff --git a/submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesChat.swift b/submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesChat.swift index ec200e13fb..e5df3d2385 100644 --- a/submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesChat.swift +++ b/submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesChat.swift @@ -45,15 +45,19 @@ private func generateActionPhotoBackground(fillColor: UIColor, strokeColor: UICo }) } -private func generateInputPanelButtonBackgroundImage(fillColor: UIColor, strokeColor: UIColor) -> UIImage? { - let radius: CGFloat = 5.0 - let shadowSize: CGFloat = 1.0 - return generateImage(CGSize(width: radius * 2.0, height: radius * 2.0 + shadowSize), contextGenerator: { size, context in +private func generateInputPanelButtonStrokeImage(color: UIColor, offset: CGFloat) -> UIImage? { + let radius: CGFloat = 4.0 + return generateImage(CGSize(width: radius * 2.0 + 1.0, height: radius * 2.0 + 1.0), contextGenerator: { size, context in context.clear(CGRect(origin: CGPoint(), size: size)) - context.setFillColor(strokeColor.cgColor) - context.fillEllipse(in: CGRect(x: 0.0, y: 0.0, width: radius * 2.0, height: radius * 2.0)) - context.setFillColor(fillColor.cgColor) - context.fillEllipse(in: CGRect(x: 0.0, y: shadowSize, width: radius * 2.0, height: radius * 2.0)) + + var path = UIBezierPath(roundedRect: CGRect(origin: .zero, size: CGSize(width: size.width, height: size.height)), cornerRadius: radius) + context.addPath(path.cgPath) + context.setFillColor(color.cgColor) + context.fillPath() + path = UIBezierPath(roundedRect: CGRect(origin: CGPoint(x: 0.0, y: offset), size: CGSize(width: size.width, height: size.height)), cornerRadius: radius) + context.setBlendMode(.clear) + context.addPath(path.cgPath) + context.fillPath() })?.stretchableImage(withLeftCapWidth: Int(radius), topCapHeight: Int(radius)) } @@ -405,18 +409,18 @@ public struct PresentationResourcesChat { }) } - public static func chatInputButtonPanelButtonImage(_ theme: PresentationTheme) -> UIImage? { - return theme.image(PresentationResourceKey.chatInputButtonPanelButtonImage.rawValue, { theme in - return generateInputPanelButtonBackgroundImage(fillColor: theme.chat.inputButtonPanel.buttonFillColor, strokeColor: theme.chat.inputButtonPanel.buttonStrokeColor) + public static func chatInputButtonPanelButtonHighlightImage(_ theme: PresentationTheme) -> UIImage? { + return theme.image(PresentationResourceKey.chatInputButtonPanelButtonHighlightImage.rawValue, { theme in + return generateInputPanelButtonStrokeImage(color: theme.chat.inputButtonPanel.buttonHighlightColor, offset: -1.0) }) } - public static func chatInputButtonPanelButtonHighlightedImage(_ theme: PresentationTheme) -> UIImage? { - return theme.image(PresentationResourceKey.chatInputButtonPanelButtonHighlightedImage.rawValue, { theme in - return generateInputPanelButtonBackgroundImage(fillColor: theme.chat.inputButtonPanel.buttonHighlightedFillColor, strokeColor: theme.chat.inputButtonPanel.buttonHighlightedStrokeColor) + public static func chatInputButtonPanelButtonShadowImage(_ theme: PresentationTheme) -> UIImage? { + return theme.image(PresentationResourceKey.chatInputButtonPanelButtonShadowImage.rawValue, { theme in + return generateInputPanelButtonStrokeImage(color: theme.chat.inputButtonPanel.buttonStrokeColor, offset: 1.0) }) } - + public static func chatInputTextFieldBackgroundImage(_ theme: PresentationTheme) -> UIImage? { return theme.image(PresentationResourceKey.chatInputTextFieldBackgroundImage.rawValue, { theme in let diameter: CGFloat = 35.0 diff --git a/submodules/TelegramUI/Sources/ChatButtonKeyboardInputNode.swift b/submodules/TelegramUI/Sources/ChatButtonKeyboardInputNode.swift index 7023f872d3..fa08c95905 100644 --- a/submodules/TelegramUI/Sources/ChatButtonKeyboardInputNode.swift +++ b/submodules/TelegramUI/Sources/ChatButtonKeyboardInputNode.swift @@ -8,21 +8,103 @@ import SwiftSignalKit import TelegramPresentationData import AccountContext import ChatPresentationInterfaceState +import WallpaperBackgroundNode -private final class ChatButtonKeyboardInputButtonNode: ASButtonNode { +private final class ChatButtonKeyboardInputButtonNode: HighlightTrackingButtonNode { var button: ReplyMarkupButton? { didSet { self.updateIcon() } } - var iconNode: ASImageNode? + + private let backgroundContainerNode: ASDisplayNode + private var backgroundNode: WallpaperBubbleBackgroundNode? + private let backgroundColorNode: ASDisplayNode + private let backgroundAdditionalColorNode: ASDisplayNode + + private let shadowNode: ASImageNode + private let highlightNode: ASImageNode + + private let textNode: ImmediateTextNode + private var iconNode: ASImageNode? private var theme: PresentationTheme? - init(theme: PresentationTheme) { + init() { + self.backgroundContainerNode = ASDisplayNode() + self.backgroundContainerNode.clipsToBounds = true + self.backgroundContainerNode.allowsGroupOpacity = true + self.backgroundContainerNode.isUserInteractionEnabled = false + self.backgroundContainerNode.cornerRadius = 5.0 + if #available(iOS 13.0, *) { + self.backgroundContainerNode.layer.cornerCurve = .continuous + } + + self.backgroundColorNode = ASDisplayNode() + self.backgroundColorNode.cornerRadius = 5.0 + if #available(iOS 13.0, *) { + self.backgroundColorNode.layer.cornerCurve = .continuous + } + + self.backgroundAdditionalColorNode = ASDisplayNode() + self.backgroundAdditionalColorNode.backgroundColor = UIColor(rgb: 0xffffff, alpha: 0.1) + self.backgroundAdditionalColorNode.isHidden = true + + self.shadowNode = ASImageNode() + self.shadowNode.isUserInteractionEnabled = false + + self.highlightNode = ASImageNode() + self.highlightNode.isUserInteractionEnabled = false + + self.textNode = ImmediateTextNode() + self.textNode.isUserInteractionEnabled = false + self.textNode.textAlignment = .center + self.textNode.maximumNumberOfLines = 2 + super.init() - self.updateTheme(theme: theme) + self.addSubnode(self.backgroundContainerNode) + + self.backgroundContainerNode.addSubnode(self.backgroundColorNode) + self.backgroundContainerNode.addSubnode(self.backgroundAdditionalColorNode) + self.addSubnode(self.textNode) + + self.backgroundContainerNode.addSubnode(self.shadowNode) + self.backgroundContainerNode.addSubnode(self.highlightNode) + + self.highligthedChanged = { [weak self] highlighted in + if let strongSelf = self { + if highlighted, !strongSelf.bounds.width.isZero { + let scale = (strongSelf.bounds.width - 10.0) / strongSelf.bounds.width + + strongSelf.layer.animateScale(from: 1.0, to: scale, duration: 0.15, removeOnCompletion: false) + + strongSelf.backgroundContainerNode.layer.removeAnimation(forKey: "opacity") + strongSelf.backgroundContainerNode.alpha = 0.6 + } else if let presentationLayer = strongSelf.layer.presentation() { + strongSelf.layer.animateScale(from: CGFloat((presentationLayer.value(forKeyPath: "transform.scale.y") as? NSNumber)?.floatValue ?? 1.0), to: 1.0, duration: 0.25, removeOnCompletion: false) + + strongSelf.backgroundContainerNode.alpha = 1.0 + strongSelf.backgroundContainerNode.layer.animateAlpha(from: 0.6, to: 1.0, duration: 0.2) + } + } + } + } + + override func setAttributedTitle(_ title: NSAttributedString, for state: UIControl.State) { + self.textNode.attributedText = title + } + + private var absoluteRect: (CGRect, CGSize)? + func update(rect: CGRect, within containerSize: CGSize, transition: ContainedViewLayoutTransition) { + self.absoluteRect = (rect, containerSize) + + if let backgroundNode = self.backgroundNode { + var backgroundFrame = backgroundNode.frame + backgroundFrame.origin.x += rect.minX + backgroundFrame.origin.y += rect.minY + backgroundNode.update(rect: backgroundFrame, within: containerSize, transition: transition) + } } private func updateIcon() { @@ -55,32 +137,71 @@ private final class ChatButtonKeyboardInputButtonNode: ASButtonNode { self.setNeedsLayout() } - func updateTheme(theme: PresentationTheme) { + func updateTheme(theme: PresentationTheme, wallpaperBackgroundNode: WallpaperBackgroundNode?) { if theme !== self.theme { self.theme = theme - - self.setBackgroundImage(PresentationResourcesChat.chatInputButtonPanelButtonImage(theme), for: []) - self.setBackgroundImage(PresentationResourcesChat.chatInputButtonPanelButtonHighlightedImage(theme), for: [.highlighted]) + + self.highlightNode.image = PresentationResourcesChat.chatInputButtonPanelButtonHighlightImage(theme) + self.shadowNode.image = PresentationResourcesChat.chatInputButtonPanelButtonShadowImage(theme) self.updateIcon() } + + self.backgroundColorNode.backgroundColor = theme.chat.inputButtonPanel.buttonFillColor + if let alpha = self.backgroundColorNode.backgroundColor?.alpha, alpha < 1.0 { + self.backgroundColorNode.layer.compositingFilter = "softLightBlendMode" + self.backgroundAdditionalColorNode.isHidden = false + } else { + self.backgroundColorNode.layer.compositingFilter = nil + self.backgroundAdditionalColorNode.isHidden = true + } + + if wallpaperBackgroundNode?.hasExtraBubbleBackground() == true { + if self.backgroundNode == nil, let backgroundContent = wallpaperBackgroundNode?.makeBubbleBackground(for: .free) { + self.backgroundNode = backgroundContent + self.backgroundContainerNode.insertSubnode(backgroundContent, at: 0) + + self.setNeedsLayout() + } + } else { + self.backgroundNode?.removeFromSupernode() + self.backgroundNode = nil + } } override func layout() { super.layout() + self.backgroundContainerNode.frame = self.bounds + self.backgroundColorNode.frame = CGRect(origin: .zero, size: CGSize(width: self.bounds.width, height: self.bounds.height - 1.0)) + self.backgroundAdditionalColorNode.frame = self.backgroundColorNode.frame + self.backgroundNode?.frame = self.backgroundColorNode.frame + + self.highlightNode.frame = self.bounds + self.shadowNode.frame = self.bounds + + if let (rect, containerSize) = self.absoluteRect { + self.update(rect: rect, within: containerSize, transition: .immediate) + } + if let iconNode = self.iconNode { iconNode.frame = CGRect(x: self.frame.width - 16.0, y: 4.0, width: 12.0, height: 12.0) } + + let textSize = self.textNode.updateLayout(CGSize(width: self.bounds.width - 16.0, height: self.bounds.height)) + self.textNode.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((self.bounds.width - textSize.width) / 2.0), y: floorToScreenPixels((self.bounds.height - textSize.height) / 2.0)), size: textSize) } } final class ChatButtonKeyboardInputNode: ChatInputNode { private let context: AccountContext private let controllerInteraction: ChatControllerInteraction - + private let separatorNode: ASDisplayNode private let scrollNode: ASScrollNode + + private var backgroundNode: WallpaperBubbleBackgroundNode? + private let backgroundColorNode: ASDisplayNode private var buttonNodes: [ChatButtonKeyboardInputButtonNode] = [] private var message: Message? @@ -93,11 +214,15 @@ final class ChatButtonKeyboardInputNode: ChatInputNode { self.scrollNode = ASScrollNode() + self.backgroundColorNode = ASDisplayNode() + self.separatorNode = ASDisplayNode() self.separatorNode.isLayerBacked = true super.init() + self.addSubnode(self.backgroundColorNode) + self.addSubnode(self.scrollNode) self.scrollNode.view.delaysContentTouches = false self.scrollNode.view.canCancelContentTouches = true @@ -115,15 +240,41 @@ final class ChatButtonKeyboardInputNode: ChatInputNode { } } + private var absoluteRect: (CGRect, CGSize)? + override func updateAbsoluteRect(_ rect: CGRect, within containerSize: CGSize, transition: ContainedViewLayoutTransition) { + self.absoluteRect = (rect, containerSize) + + if let backgroundNode = self.backgroundNode { + var backgroundFrame = backgroundNode.frame + backgroundFrame.origin.x += rect.minX + backgroundFrame.origin.y += rect.minY + backgroundNode.update(rect: backgroundFrame, within: containerSize, transition: transition) + } + + for buttonNode in self.buttonNodes { + var buttonFrame = buttonNode.frame + buttonFrame.origin.x += rect.minX + buttonFrame.origin.y += rect.minY + buttonNode.update(rect: buttonFrame, within: containerSize, transition: transition) + } + } + override func updateLayout(width: CGFloat, leftInset: CGFloat, rightInset: CGFloat, bottomInset: CGFloat, standardInputHeight: CGFloat, inputHeight: CGFloat, maximumHeight: CGFloat, inputPanelHeight: CGFloat, transition: ContainedViewLayoutTransition, interfaceState: ChatPresentationInterfaceState, deviceMetrics: DeviceMetrics, isVisible: Bool, isExpanded: Bool) -> (CGFloat, CGFloat) { transition.updateFrame(node: self.separatorNode, frame: CGRect(origin: CGPoint(), size: CGSize(width: width, height: UIScreenPixel))) + if self.backgroundNode == nil { + if let backgroundNode = self.controllerInteraction.presentationContext.backgroundNode?.makeBubbleBackground(for: .free) { + self.backgroundNode = backgroundNode + self.insertSubnode(backgroundNode, at: 0) + } + } + let updatedTheme = self.theme !== interfaceState.theme if updatedTheme { self.theme = interfaceState.theme self.separatorNode.backgroundColor = interfaceState.theme.chat.inputButtonPanel.panelSeparatorColor - self.backgroundColor = interfaceState.theme.chat.inputButtonPanel.panelBackgroundColor + self.backgroundColorNode.backgroundColor = interfaceState.theme.chat.inputButtonPanel.panelBackgroundColor } var validatedMarkup: ReplyMarkupMessageAttribute? @@ -165,14 +316,14 @@ final class ChatButtonKeyboardInputNode: ChatInputNode { let buttonNode: ChatButtonKeyboardInputButtonNode if buttonIndex < self.buttonNodes.count { buttonNode = self.buttonNodes[buttonIndex] - buttonNode.updateTheme(theme: interfaceState.theme) } else { - buttonNode = ChatButtonKeyboardInputButtonNode(theme: interfaceState.theme) + buttonNode = ChatButtonKeyboardInputButtonNode() buttonNode.titleNode.maximumNumberOfLines = 2 buttonNode.addTarget(self, action: #selector(self.buttonPressed(_:)), forControlEvents: [.touchUpInside]) self.scrollNode.addSubnode(buttonNode) self.buttonNodes.append(buttonNode) } + buttonNode.updateTheme(theme: interfaceState.theme, wallpaperBackgroundNode: self.controllerInteraction.presentationContext.backgroundNode) buttonIndex += 1 if buttonNode.button != button || updatedTheme { buttonNode.button = button @@ -200,6 +351,15 @@ final class ChatButtonKeyboardInputNode: ChatInputNode { self.scrollNode.view.setContentOffset(CGPoint(), animated: false) } + if let backgroundNode = self.backgroundNode { + backgroundNode.frame = CGRect(origin: .zero, size: CGSize(width: width, height: panelHeight)) + } + self.backgroundColorNode.frame = CGRect(origin: .zero, size: CGSize(width: width, height: panelHeight)) + + if let (rect, containerSize) = self.absoluteRect { + self.updateAbsoluteRect(rect, within: containerSize, transition: transition) + } + return (panelHeight, 0.0) } else { return (0.0, 0.0) diff --git a/submodules/TelegramUI/Sources/ChatControllerNode.swift b/submodules/TelegramUI/Sources/ChatControllerNode.swift index 291e1f046d..c1e06fa9f0 100644 --- a/submodules/TelegramUI/Sources/ChatControllerNode.swift +++ b/submodules/TelegramUI/Sources/ChatControllerNode.swift @@ -1862,6 +1862,8 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { inputNode.frame = adjustedForPreviousInputHeightFrame transition.updateFrame(node: inputNode, frame: inputNodeFrame) + inputNode.updateAbsoluteRect(inputNodeFrame, within: layout.size, transition: transition) + if let externalTopPanelContainer = inputNode.externalTopPanelContainer { externalTopPanelContainer.frame = CGRect(origin: adjustedForPreviousInputHeightFrame.offsetBy(dx: 0.0, dy: externalTopPanelContainerOffset).origin, size: CGSize(width: adjustedForPreviousInputHeightFrame.width, height: 0.0)) transition.updateFrame(view: externalTopPanelContainer, frame: CGRect(origin: inputNodeFrame.origin, size: CGSize(width: inputNodeFrame.width, height: 0.0))) diff --git a/submodules/TelegramUI/Sources/ChatInputNode.swift b/submodules/TelegramUI/Sources/ChatInputNode.swift index 1aa38814f0..bc62c8c9a0 100644 --- a/submodules/TelegramUI/Sources/ChatInputNode.swift +++ b/submodules/TelegramUI/Sources/ChatInputNode.swift @@ -24,6 +24,10 @@ class ChatInputNode: ASDisplayNode { var followsDefaultHeight: Bool = false + func updateAbsoluteRect(_ rect: CGRect, within containerSize: CGSize, transition: ContainedViewLayoutTransition) { + + } + func updateLayout(width: CGFloat, leftInset: CGFloat, rightInset: CGFloat, bottomInset: CGFloat, standardInputHeight: CGFloat, inputHeight: CGFloat, maximumHeight: CGFloat, inputPanelHeight: CGFloat, transition: ContainedViewLayoutTransition, interfaceState: ChatPresentationInterfaceState, deviceMetrics: DeviceMetrics, isVisible: Bool, isExpanded: Bool) -> (CGFloat, CGFloat) { return (0.0, 0.0) } diff --git a/submodules/TelegramUI/Sources/ChatMessageBubbleItemNode.swift b/submodules/TelegramUI/Sources/ChatMessageBubbleItemNode.swift index 82e1245dcd..dbe19b64e6 100644 --- a/submodules/TelegramUI/Sources/ChatMessageBubbleItemNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageBubbleItemNode.swift @@ -4400,7 +4400,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode private var backgroundMaskMode: Bool { let hasWallpaper = self.item?.presentationData.theme.wallpaper.hasWallpaper ?? false let isPreview = self.item?.presentationData.isPreview ?? false - return self.mainContextSourceNode.isExtractedToContextPreview || hasWallpaper || isPreview + return self.mainContextSourceNode.isExtractedToContextPreview || hasWallpaper || isPreview || !self.disablesComments } override func openMessageContextMenu() {