From c92ce1c1dc603dac6e084a19af82c3d7d76bb60e Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sun, 11 Aug 2024 01:19:25 +0200 Subject: [PATCH] Various improvements --- .../Display/Source/PresentationContext.swift | 8 ++++++-- submodules/Display/Source/StatusBar.swift | 2 +- submodules/GalleryUI/BUILD | 1 + .../Sources/ChatItemGalleryFooterContentNode.swift | 14 ++++++++++++++ .../ChatMessageWebpageBubbleContentNode.swift | 3 +++ submodules/TelegramUI/Sources/ChatController.swift | 12 +++++++++--- 6 files changed, 34 insertions(+), 6 deletions(-) diff --git a/submodules/Display/Source/PresentationContext.swift b/submodules/Display/Source/PresentationContext.swift index 6a0d378f02..57b6a5f091 100644 --- a/submodules/Display/Source/PresentationContext.swift +++ b/submodules/Display/Source/PresentationContext.swift @@ -52,8 +52,12 @@ public final class PresentationContext { return self.view != nil && self.layout != nil } - public private(set) var controllers: [(ContainableController, PresentationSurfaceLevel)] = [] - public var controllersUpdated: ([ContainableController]) -> Void = { _ in } + public private(set) var controllers: [(ContainableController, PresentationSurfaceLevel)] = [] { + didSet { + self.controllersUpdated(self.controllers) + } + } + public var controllersUpdated: ([(ContainableController, PresentationSurfaceLevel)]) -> Void = { _ in } private var presentationDisposables = DisposableSet() diff --git a/submodules/Display/Source/StatusBar.swift b/submodules/Display/Source/StatusBar.swift index e74ef187c3..abd031a5e7 100644 --- a/submodules/Display/Source/StatusBar.swift +++ b/submodules/Display/Source/StatusBar.swift @@ -81,7 +81,7 @@ public final class StatusBar: ASDisplayNode { } } - var alphaUpdated: ((ContainedViewLayoutTransition) -> Void)? + public var alphaUpdated: ((ContainedViewLayoutTransition) -> Void)? public func updateAlpha(_ alpha: CGFloat, transition: ContainedViewLayoutTransition) { self.alpha = alpha diff --git a/submodules/GalleryUI/BUILD b/submodules/GalleryUI/BUILD index 601f15eb8f..40fc66c24f 100644 --- a/submodules/GalleryUI/BUILD +++ b/submodules/GalleryUI/BUILD @@ -52,6 +52,7 @@ swift_library( "//submodules/AdUI", "//submodules/TelegramUI/Components/Ads/AdsInfoScreen", "//submodules/TelegramUI/Components/Ads/AdsReportScreen", + "//submodules/UrlHandling", ], visibility = [ "//visibility:public", diff --git a/submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift b/submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift index f9b7d2065d..c73e666e38 100644 --- a/submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift +++ b/submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift @@ -30,6 +30,7 @@ import Speak import TranslateUI import TelegramNotices import SolidRoundedButtonNode +import UrlHandling private let deleteImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Input/Accessory Panels/MessageSelectionTrash"), color: .white) private let actionImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Input/Accessory Panels/MessageSelectionForward"), color: .white) @@ -147,6 +148,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, ASScroll private var spoilerTextNode: ImmediateTextNodeWithEntities? private var dustNode: InvisibleInkDustNode? private var buttonNode: SolidRoundedButtonNode? + private var buttonIconNode: ASImageNode? private var textSelectionNode: TextSelectionNode? @@ -1069,6 +1071,14 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, ASScroll } self.contentNode.addSubnode(buttonNode) self.buttonNode = buttonNode + + if !isTelegramMeLink(adAttribute.url) { + let buttonIconNode = ASImageNode() + buttonIconNode.displaysAsynchronously = false + buttonIconNode.image = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotLink"), color: .white) + buttonNode.addSubnode(buttonIconNode) + self.buttonIconNode = buttonIconNode + } } } else if let buttonNode = self.buttonNode { buttonNode.removeFromSupernode() @@ -1227,6 +1237,10 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, ASScroll let buttonHeight = buttonNode.updateLayout(width: constrainSize.width, transition: transition) transition.updateFrame(node: buttonNode, frame: CGRect(origin: CGPoint(x: sideInset, y: scrollWrapperNodeFrame.maxY + 8.0), size: CGSize(width: constrainSize.width, height: buttonHeight))) + if let buttonIconNode = self.buttonIconNode, let icon = buttonIconNode.image { + transition.updateFrame(node: buttonIconNode, frame: CGRect(origin: CGPoint(x: constrainSize.width - icon.size.width - 9.0, y: 9.0), size: icon.size)) + } + if let _ = self.scrubberView { panelHeight += 68.0 } else { diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageWebpageBubbleContentNode/Sources/ChatMessageWebpageBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageWebpageBubbleContentNode/Sources/ChatMessageWebpageBubbleContentNode.swift index 27ce00d8f0..49875649c4 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageWebpageBubbleContentNode/Sources/ChatMessageWebpageBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageWebpageBubbleContentNode/Sources/ChatMessageWebpageBubbleContentNode.swift @@ -513,6 +513,9 @@ public final class ChatMessageWebpageBubbleContentNode: ChatMessageBubbleContent } actionTitle = adAttribute.buttonText.uppercased() + if !isTelegramMeLink(adAttribute.url) { + actionIcon = .link + } displayLine = true } diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 2ed6f6ed89..ae1164d0db 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -1278,6 +1278,12 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G }, present: { c, a, i in if case .current = i { c.presentationArguments = a + c.statusBar.alphaUpdated = { [weak self] transition in + guard let self else { + return + } + self.updateStatusBarPresentation(animated: transition.isAnimated) + } self?.galleryPresentationContext.present(c, on: PresentationSurfaceLevel(rawValue: 0), blockInteraction: true, completion: {}) } else { self?.present(c, in: .window(.root), with: a, blockInteraction: true) @@ -6803,9 +6809,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } } - func updateStatusBarPresentation() { - if !self.galleryPresentationContext.controllers.isEmpty { - self.statusBar.statusBarStyle = .White + func updateStatusBarPresentation(animated: Bool = false) { + if !self.galleryPresentationContext.controllers.isEmpty, let statusBarStyle = (self.galleryPresentationContext.controllers.last?.0 as? ViewController)?.statusBar.statusBarStyle { + self.statusBar.updateStatusBarStyle(statusBarStyle, animated: animated) } else { switch self.presentationInterfaceState.mode { case let .standard(standardMode):