From e451881c7903331b13a55c59f15a9cc4e0fe49da Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Mon, 27 Nov 2023 18:14:04 +0400 Subject: [PATCH 1/3] Fix calls title tabs --- submodules/CallListUI/Sources/CallListController.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/submodules/CallListUI/Sources/CallListController.swift b/submodules/CallListUI/Sources/CallListController.swift index 583d63023a..98f1cec192 100644 --- a/submodules/CallListUI/Sources/CallListController.swift +++ b/submodules/CallListUI/Sources/CallListController.swift @@ -122,6 +122,7 @@ public final class CallListController: TelegramBaseController { self.segmentedTitleView.indexUpdated = { [weak self] index in if let strongSelf = self { + strongSelf.segmentedTitleView.index = index strongSelf.controllerNode.updateType(index == 0 ? .all : .missed) } } From 92043f024172e0c4a67adaaaeafc20c3061479fc Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Mon, 27 Nov 2023 18:35:41 +0400 Subject: [PATCH 2/3] Fix tint colors --- submodules/Display/Source/TextNode.swift | 47 ++++++++++++++++++- .../Sources/PeerInfoAvatarListNode.swift | 1 + .../Sources/EmojiStatusComponent.swift | 2 +- .../Sources/MultiScaleTextNode.swift | 34 +++++++++----- 4 files changed, 70 insertions(+), 14 deletions(-) diff --git a/submodules/Display/Source/TextNode.swift b/submodules/Display/Source/TextNode.swift index 60fac84e77..cabd9cb729 100644 --- a/submodules/Display/Source/TextNode.swift +++ b/submodules/Display/Source/TextNode.swift @@ -1158,7 +1158,33 @@ private func addAttachment(attachment: UIImage, line: TextNodeLine, ascent: CGFl } open class TextNode: ASDisplayNode { + public struct RenderContentTypes: OptionSet { + public var rawValue: Int + + public init(rawValue: Int) { + self.rawValue = rawValue + } + + public static let text = RenderContentTypes(rawValue: 1 << 0) + public static let emoji = RenderContentTypes(rawValue: 1 << 1) + + public static let all: RenderContentTypes = [.text, .emoji] + } + + private final class DrawingParameters: NSObject { + let cachedLayout: TextNodeLayout? + let renderContentTypes: RenderContentTypes + + init(cachedLayout: TextNodeLayout?, renderContentTypes: RenderContentTypes) { + self.cachedLayout = cachedLayout + self.renderContentTypes = renderContentTypes + + super.init() + } + } + public internal(set) var cachedLayout: TextNodeLayout? + public var renderContentTypes: RenderContentTypes = .all override public init() { super.init() @@ -2169,7 +2195,7 @@ open class TextNode: ASDisplayNode { } override public func drawParameters(forAsyncLayer layer: _ASDisplayLayer) -> NSObjectProtocol? { - return self.cachedLayout + return DrawingParameters(cachedLayout: self.cachedLayout, renderContentTypes: self.renderContentTypes) } @objc override public class func draw(_ bounds: CGRect, withParameters parameters: Any?, isCancelled: () -> Bool, isRasterizing: Bool) { @@ -2192,8 +2218,13 @@ open class TextNode: ASDisplayNode { var blendMode: CGBlendMode = .normal + var renderContentTypes: RenderContentTypes = .all + if let parameters = parameters as? DrawingParameters { + renderContentTypes = parameters.renderContentTypes + } + var clearRects: [CGRect] = [] - if let layout = parameters as? TextNodeLayout { + if let layout = (parameters as? DrawingParameters)?.cachedLayout { if !isRasterizing || layout.backgroundColor != nil { context.setBlendMode(.copy) blendMode = .copy @@ -2409,6 +2440,18 @@ open class TextNode: ASDisplayNode { continue } + if renderContentTypes != .all { + if let font = attributes["NSFont"] as? UIFont, font.fontName.contains("ColorEmoji") { + if !renderContentTypes.contains(.emoji) { + continue + } + } else { + if !renderContentTypes.contains(.text) { + continue + } + } + } + var fixDoubleEmoji = false if glyphCount == 2, let font = attributes["NSFont"] as? UIFont, font.fontName.contains("ColorEmoji"), let string = layout.attributedString { let range = CTRunGetStringRange(run) diff --git a/submodules/PeerInfoAvatarListNode/Sources/PeerInfoAvatarListNode.swift b/submodules/PeerInfoAvatarListNode/Sources/PeerInfoAvatarListNode.swift index aec1905662..0c1089fb1a 100644 --- a/submodules/PeerInfoAvatarListNode/Sources/PeerInfoAvatarListNode.swift +++ b/submodules/PeerInfoAvatarListNode/Sources/PeerInfoAvatarListNode.swift @@ -662,6 +662,7 @@ public final class AvatarListContentNode: ASDisplayNode { if value { replicatorLayer.instanceAlphaOffset = -1.0 + replicatorLayer.animate(from: 0.0 as NSNumber, to: -1.0 as NSNumber, keyPath: "instanceAlphaOffset", timingFunction: CAMediaTimingFunctionName.linear.rawValue, duration: 0.3) } else { replicatorLayer.instanceAlphaOffset = 0.0 replicatorLayer.animate(from: -1.0 as NSNumber, to: 1.0 as NSNumber, keyPath: "instanceAlphaOffset", timingFunction: CAMediaTimingFunctionName.linear.rawValue, duration: 0.3) diff --git a/submodules/TelegramUI/Components/EmojiStatusComponent/Sources/EmojiStatusComponent.swift b/submodules/TelegramUI/Components/EmojiStatusComponent/Sources/EmojiStatusComponent.swift index 5ccd91b090..e204821d54 100644 --- a/submodules/TelegramUI/Components/EmojiStatusComponent/Sources/EmojiStatusComponent.swift +++ b/submodules/TelegramUI/Components/EmojiStatusComponent/Sources/EmojiStatusComponent.swift @@ -418,7 +418,7 @@ public final class EmojiStatusComponent: Component { if transition.animation.isImmediate { iconView.tintColor = iconTintColor } else { - transition.setTintColor(layer: iconView.layer, color: iconTintColor) + transition.setTintColor(view: iconView, color: iconTintColor) } } else { iconView.tintColor = nil diff --git a/submodules/TelegramUI/Components/MultiScaleTextNode/Sources/MultiScaleTextNode.swift b/submodules/TelegramUI/Components/MultiScaleTextNode/Sources/MultiScaleTextNode.swift index ab4b31c4fb..4036237092 100644 --- a/submodules/TelegramUI/Components/MultiScaleTextNode/Sources/MultiScaleTextNode.swift +++ b/submodules/TelegramUI/Components/MultiScaleTextNode/Sources/MultiScaleTextNode.swift @@ -4,17 +4,24 @@ import AsyncDisplayKit import Display private final class MultiScaleTextStateNode: ASDisplayNode { - let textNode: ImmediateTextNode + let tintTextNode: ImmediateTextNode + let noTintTextNode: ImmediateTextNode var currentLayout: MultiScaleTextLayout? override init() { - self.textNode = ImmediateTextNode() - self.textNode.displaysAsynchronously = false + self.tintTextNode = ImmediateTextNode() + self.tintTextNode.displaysAsynchronously = false + self.tintTextNode.renderContentTypes = TextNode.RenderContentTypes.all.subtracting(TextNode.RenderContentTypes.emoji) + + self.noTintTextNode = ImmediateTextNode() + self.noTintTextNode.displaysAsynchronously = false + self.noTintTextNode.renderContentTypes = .emoji super.init() - self.addSubnode(self.textNode) + self.addSubnode(self.tintTextNode) + self.addSubnode(self.noTintTextNode) } } @@ -60,12 +67,12 @@ public final class MultiScaleTextNode: ASDisplayNode { } public func stateNode(forKey key: AnyHashable) -> ASDisplayNode? { - return self.stateNodes[key]?.textNode + return self.stateNodes[key]?.tintTextNode } public func updateTintColor(color: UIColor, transition: ContainedViewLayoutTransition) { for (_, node) in self.stateNodes { - transition.updateTintColor(layer: node.textNode.layer, color: color) + transition.updateTintColor(layer: node.tintTextNode.layer, color: color) } } @@ -77,10 +84,13 @@ public final class MultiScaleTextNode: ASDisplayNode { var mainLayout: MultiScaleTextLayout? for (key, state) in states { if let node = self.stateNodes[key] { - node.textNode.attributedText = NSAttributedString(string: text, font: state.attributes.font, textColor: state.attributes.color) - node.textNode.isAccessibilityElement = true - node.textNode.accessibilityLabel = text - let nodeSize = node.textNode.updateLayout(state.constrainedSize) + node.tintTextNode.attributedText = NSAttributedString(string: text, font: state.attributes.font, textColor: state.attributes.color) + node.noTintTextNode.attributedText = NSAttributedString(string: text, font: state.attributes.font, textColor: state.attributes.color) + node.tintTextNode.isAccessibilityElement = true + node.tintTextNode.accessibilityLabel = text + node.noTintTextNode.isAccessibilityElement = false + let nodeSize = node.tintTextNode.updateLayout(state.constrainedSize) + let _ = node.noTintTextNode.updateLayout(state.constrainedSize) let nodeLayout = MultiScaleTextLayout(size: nodeSize) if key == mainState { mainLayout = nodeLayout @@ -93,7 +103,9 @@ public final class MultiScaleTextNode: ASDisplayNode { let mainBounds = CGRect(origin: CGPoint(x: -mainLayout.size.width / 2.0, y: -mainLayout.size.height / 2.0), size: mainLayout.size) for (key, _) in states { if let node = self.stateNodes[key], let nodeLayout = result[key] { - node.textNode.frame = CGRect(origin: CGPoint(x: mainBounds.minX, y: mainBounds.minY + floor((mainBounds.height - nodeLayout.size.height) / 2.0)), size: nodeLayout.size) + let textFrame = CGRect(origin: CGPoint(x: mainBounds.minX, y: mainBounds.minY + floor((mainBounds.height - nodeLayout.size.height) / 2.0)), size: nodeLayout.size) + node.tintTextNode.frame = textFrame + node.noTintTextNode.frame = textFrame } } } From c2c042ea484585e4658d06b2096e55860c6a54fe Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Mon, 27 Nov 2023 19:20:22 +0400 Subject: [PATCH 3/3] Adjust blur --- .../Sources/PeerInfoAvatarListNode.swift | 3 ++- .../PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderNode.swift | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/submodules/PeerInfoAvatarListNode/Sources/PeerInfoAvatarListNode.swift b/submodules/PeerInfoAvatarListNode/Sources/PeerInfoAvatarListNode.swift index 0c1089fb1a..4c8aaf55d6 100644 --- a/submodules/PeerInfoAvatarListNode/Sources/PeerInfoAvatarListNode.swift +++ b/submodules/PeerInfoAvatarListNode/Sources/PeerInfoAvatarListNode.swift @@ -600,7 +600,8 @@ public final class PeerAvatarBottomShadowNode: ASDisplayNode { return UIColor(white: 1.0, alpha: 1.0).cgColor } else { let step: CGFloat = CGFloat(i - firstStep) / CGFloat(numSteps - firstStep - 1) - return UIColor(white: 1.0, alpha: baseGradientAlpha * (1.0 - pow(step, 3.0))).cgColor + let value: CGFloat = 1.0 - bezierPoint(0.42, 0.0, 0.58, 1.0, step) + return UIColor(white: 1.0, alpha: baseGradientAlpha * value).cgColor } } self.backgroundGradientMaskLayer.locations = (0 ..< numSteps).map { i -> NSNumber in diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderNode.swift index 97d0f1ca7e..43670b697c 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderNode.swift @@ -1106,7 +1106,7 @@ final class PeerInfoHeaderNode: ASDisplayNode { var bottomShadowHeight: CGFloat = 88.0 if !self.isSettings { - bottomShadowHeight += 90.0 + bottomShadowHeight += 110.0 } let bottomShadowFrame = CGRect(origin: CGPoint(x: 0.0, y: expandedAvatarHeight - bottomShadowHeight), size: CGSize(width: width, height: bottomShadowHeight)) transition.updateFrame(node: self.avatarListNode.listContainerNode.bottomShadowNode, frame: bottomShadowFrame, beginWithCurrentState: true)