From ecfe436a24fcbe05a551825c79f2ec445621ed12 Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Sat, 27 Sep 2025 01:01:29 +0800 Subject: [PATCH] Various improvements --- .../Sources/ChatListContainerItemNode.swift | 1 + .../Sources/ChatTextInputPanelNode.swift | 2 +- .../Sources/ChatControllerNode.swift | 104 +++++------------- .../Sources/ChatTagSearchInputPanelNode.swift | 7 +- .../HashtagChatInputContextPanelNode.swift | 14 ++- 5 files changed, 42 insertions(+), 86 deletions(-) diff --git a/submodules/ChatListUI/Sources/ChatListContainerItemNode.swift b/submodules/ChatListUI/Sources/ChatListContainerItemNode.swift index 68fdcfd80e..9b6974a7ba 100644 --- a/submodules/ChatListUI/Sources/ChatListContainerItemNode.swift +++ b/submodules/ChatListUI/Sources/ChatListContainerItemNode.swift @@ -454,6 +454,7 @@ final class ChatListContainerItemNode: ASDisplayNode { let edgeEffectFrame = CGRect(origin: CGPoint(x: 0.0, y: size.height - edgeEffectHeight), size: CGSize(width: size.width, height: edgeEffectHeight)) transition.updateFrame(view: self.edgeEffectView, frame: edgeEffectFrame) self.edgeEffectView.update(content: self.presentationData.theme.list.plainBackgroundColor, rect: edgeEffectFrame, edge: .bottom, edgeSize: edgeEffectFrame.height, transition: ComponentTransition(transition)) + transition.updateAlpha(layer: self.edgeEffectView.layer, alpha: edgeEffectHeight > 21.0 ? 1.0 : 0.0) } func updateScrollingOffset(navigationHeight: CGFloat, offset: CGFloat, transition: ContainedViewLayoutTransition) { diff --git a/submodules/TelegramUI/Components/Chat/ChatTextInputPanelNode/Sources/ChatTextInputPanelNode.swift b/submodules/TelegramUI/Components/Chat/ChatTextInputPanelNode/Sources/ChatTextInputPanelNode.swift index 7fa6f39b28..b6533f1f02 100644 --- a/submodules/TelegramUI/Components/Chat/ChatTextInputPanelNode/Sources/ChatTextInputPanelNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatTextInputPanelNode/Sources/ChatTextInputPanelNode.swift @@ -502,7 +502,7 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg self.textInputNodeClippingContainer.clipsToBounds = true self.textInputSeparator = GlassBackgroundView.ContentColorView() - self.textInputContainerBackgroundView.contentView.addSubview(self.textInputSeparator) + //self.textInputContainerBackgroundView.contentView.addSubview(self.textInputSeparator) self.textInputBackgroundNode = ASImageNode() self.textInputBackgroundNode.displaysAsynchronously = false diff --git a/submodules/TelegramUI/Sources/ChatControllerNode.swift b/submodules/TelegramUI/Sources/ChatControllerNode.swift index ebd0b85e24..e4ee18890e 100644 --- a/submodules/TelegramUI/Sources/ChatControllerNode.swift +++ b/submodules/TelegramUI/Sources/ChatControllerNode.swift @@ -239,9 +239,6 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate { private var bottomBackgroundEdgeEffectNode: WallpaperEdgeEffectNode? - private var inputPanelBackgroundBlurMask: UIImageView? - private var inputPanelBackgroundBlurView: VariableBlurView? - private(set) var inputPanelNode: ChatInputPanelNode? private weak var currentDismissedInputPanelNode: ChatInputPanelNode? private(set) var secondaryInputPanelNode: ChatInputPanelNode? @@ -2144,11 +2141,15 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate { var inputPanelHideOffset: CGFloat = 0.0 if let inputNode = self.inputNode, inputNode.hideInput { + var additionalOffset: CGFloat = 0.0 + if case let .media(_, expanded, _) = self.chatPresentationInterfaceState.inputMode, expanded != nil { + additionalOffset = 80.0 + } if let inputPanelSize = inputPanelSize { - inputPanelHideOffset += -inputPanelSize.height - 80.0 + inputPanelHideOffset += -inputPanelSize.height - additionalOffset } if let accessoryPanelSize = accessoryPanelSize { - inputPanelHideOffset += -accessoryPanelSize.height - 80.0 + inputPanelHideOffset += -accessoryPanelSize.height - additionalOffset } } @@ -2203,82 +2204,27 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate { } } - if "".isEmpty { - var bottomBackgroundEdgeEffectNode: WallpaperEdgeEffectNode? - if let current = self.bottomBackgroundEdgeEffectNode { - bottomBackgroundEdgeEffectNode = current - } else { - if let value = self.backgroundNode.makeEdgeEffectNode() { - bottomBackgroundEdgeEffectNode = value - self.bottomBackgroundEdgeEffectNode = value - self.historyNodeContainer.view.superview?.insertSubview(value.view, aboveSubview: self.historyNodeContainer.view) - } - } - - if let bottomBackgroundEdgeEffectNode { - var blurFrame = inputBackgroundFrame - blurFrame.origin.y -= 26.0 - blurFrame.size.height += 100.0 - transition.updateFrame(node: bottomBackgroundEdgeEffectNode, frame: blurFrame) - bottomBackgroundEdgeEffectNode.update( - rect: blurFrame, - edge: WallpaperEdgeEffectEdge(edge: .bottom, size: 80.0), - containerSize: wallpaperBounds.size, - transition: transition - ) + var bottomBackgroundEdgeEffectNode: WallpaperEdgeEffectNode? + if let current = self.bottomBackgroundEdgeEffectNode { + bottomBackgroundEdgeEffectNode = current + } else { + if let value = self.backgroundNode.makeEdgeEffectNode() { + bottomBackgroundEdgeEffectNode = value + self.bottomBackgroundEdgeEffectNode = value + self.historyNodeContainer.view.superview?.insertSubview(value.view, aboveSubview: self.historyNodeContainer.view) } } - - if !"".isEmpty { - let blurView: VariableBlurView - let blurMask: UIImageView - if let current = self.inputPanelBackgroundBlurMask { - blurMask = current - } else { - blurMask = UIImageView() - self.inputPanelBackgroundBlurMask = blurMask - - blurMask.image = generateGradientImage(size: CGSize(width: 8.0, height: 16.0), colors: [UIColor(white: 1.0, alpha: 0.0), UIColor(white: 1.0, alpha: 0.0), UIColor(white: 1.0, alpha: 1.0)], locations: [0.0, 0.5, 1.0])?.stretchableImage(withLeftCapWidth: 0, topCapHeight: 16) - } - - if let current = self.inputPanelBackgroundBlurView { - blurView = current - } else { - let baseGradientAlpha: CGFloat = 0.5 - let numSteps = 8 - let firstStep = 1 - let firstLocation = 0.5 - let colors = (0 ..< numSteps).map { i -> UIColor in - if i < firstStep { - return UIColor(white: 1.0, alpha: 1.0) - } else { - let step: CGFloat = CGFloat(i - firstStep) / CGFloat(numSteps - firstStep - 1) - let value: CGFloat = 1.0 - bezierPoint(0.42, 0.0, 0.58, 1.0, step) - return UIColor(white: 1.0, alpha: baseGradientAlpha * value) - } - } - let locations = (0 ..< numSteps).map { i -> CGFloat in - if i < firstStep { - return 0.0 - } else { - let step: CGFloat = CGFloat(i - firstStep) / CGFloat(numSteps - firstStep - 1) - return (firstLocation + (1.0 - firstLocation) * step) - } - } - - let backgroundBlurImage = generateGradientImage(size: CGSize(width: 8.0, height: 100.0), colors: colors.reversed(), locations: locations.reversed().map { 1.0 - $0 })! - blurView = VariableBlurView(gradientMask: backgroundBlurImage, maxBlurRadius: 15.0) - self.inputPanelBackgroundBlurView = blurView - self.historyNodeContainer.view.superview?.insertSubview(blurView, aboveSubview: self.historyNodeContainer.view) - - blurView.mask = blurMask - } - + if let bottomBackgroundEdgeEffectNode { var blurFrame = inputBackgroundFrame - blurFrame.origin.y -= 18.0 - blurFrame.size.height += 100.0 - transition.updateFrame(view: blurView, frame: blurFrame) - transition.updateFrame(view: blurMask, frame: CGRect(origin: CGPoint(), size: blurFrame.size)) + blurFrame.origin.y -= 26.0 + blurFrame.size.height = max(100.0, layout.size.height - blurFrame.origin.y) + transition.updateFrame(node: bottomBackgroundEdgeEffectNode, frame: blurFrame) + bottomBackgroundEdgeEffectNode.update( + rect: blurFrame, + edge: WallpaperEdgeEffectEdge(edge: .bottom, size: 80.0), + containerSize: wallpaperBounds.size, + transition: transition + ) } let additionalScrollDistance: CGFloat = 0.0 @@ -3400,6 +3346,8 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate { inlineSearchResultsView.layer.allowsGroupOpacity = true if let emptyNode = self.emptyNode { self.contentContainerNode.contentNode.view.insertSubview(inlineSearchResultsView, aboveSubview: emptyNode.view) + } else if let bottomBackgroundEdgeEffectNode = self.bottomBackgroundEdgeEffectNode { + self.contentContainerNode.contentNode.view.insertSubview(inlineSearchResultsView, aboveSubview: bottomBackgroundEdgeEffectNode.view) } else { self.contentContainerNode.contentNode.view.insertSubview(inlineSearchResultsView, aboveSubview: self.historyNodeContainer.view) } diff --git a/submodules/TelegramUI/Sources/ChatTagSearchInputPanelNode.swift b/submodules/TelegramUI/Sources/ChatTagSearchInputPanelNode.swift index d361288fc4..952ecd5d74 100644 --- a/submodules/TelegramUI/Sources/ChatTagSearchInputPanelNode.swift +++ b/submodules/TelegramUI/Sources/ChatTagSearchInputPanelNode.swift @@ -332,7 +332,7 @@ final class ChatTagSearchInputPanelNode: ChatInputPanelNode { buttonView.alpha = 0.0 self.view.addSubview(buttonView) } - let listModeFrame = CGRect(origin: CGPoint(x: size.width - params.rightInset - 20.0 - 8.0 - buttonSize.width, y: floor((size.height - buttonSize.height) * 0.5)), size: buttonSize) + let listModeFrame = CGRect(origin: CGPoint(x: params.width - params.rightInset - 20.0 - 8.0 - buttonSize.width, y: floor((size.height - buttonSize.height) * 0.5)), size: buttonSize) listModeButtonFrameValue = listModeFrame listModeButtonTransition.setPosition(view: buttonView, position: CGPoint(x: listModeFrame.minX + listModeFrame.width * buttonView.layer.anchorPoint.x, y: listModeFrame.minY + listModeFrame.height * buttonView.layer.anchorPoint.y)) listModeButtonTransition.setBounds(view: buttonView, bounds: CGRect(origin: CGPoint(), size: listModeFrame.size)) @@ -499,7 +499,10 @@ final class ChatTagSearchInputPanelNode: ChatInputPanelNode { environment: {}, containerSize: CGSize(width: 200.0, height: 100.0) ) - let resultsTextFrame = CGRect(origin: CGPoint(x: nextLeftX - 3.0, y: floor((size.height - resultsTextSize.height) * 0.5)), size: resultsTextSize) + var resultsTextFrame = CGRect(origin: CGPoint(x: nextLeftX - 3.0, y: floor((size.height - resultsTextSize.height) * 0.5)), size: resultsTextSize) + if !displaySearchMembers && !(!self.alwaysShowTotalMessagesCount && self.externalSearchResultsCount == nil) { + resultsTextFrame.origin.x += 8.0 + } resultsTextFrameValue = resultsTextFrame if let resultsTextView = resultsText.view { if resultsTextView.superview == nil { diff --git a/submodules/TelegramUI/Sources/HashtagChatInputContextPanelNode.swift b/submodules/TelegramUI/Sources/HashtagChatInputContextPanelNode.swift index 29e0daafe3..cff6806590 100644 --- a/submodules/TelegramUI/Sources/HashtagChatInputContextPanelNode.swift +++ b/submodules/TelegramUI/Sources/HashtagChatInputContextPanelNode.swift @@ -118,18 +118,22 @@ final class HashtagChatInputContextPanelNode: ChatInputContextPanelNode { guard let self else { return } - var topOffset: CGFloat = 0.0 + var topOffset: CGFloat? switch offset { case let .known(offset): topOffset = max(0.0, -offset + self.listView.insets.top) case .unknown: - break + topOffset = 0.0 case .none: break } - self.backgroundView.isHidden = false - self.backgroundView.layer.position = CGPoint(x: 0.0, y: topOffset) + if let topOffset { + self.backgroundView.isHidden = false + self.backgroundView.layer.position = CGPoint(x: 0.0, y: topOffset) + } else { + self.backgroundView.isHidden = true + } } } @@ -269,7 +273,7 @@ final class HashtagChatInputContextPanelNode: ChatInputContextPanelNode { self.enqueuedTransitions.remove(at: 0) var options = ListViewDeleteAndInsertOptions() - if firstTime { + if firstTime || "".isEmpty { //options.insert(.Synchronous) //options.insert(.LowLatency) } else {