Various improvements

This commit is contained in:
Ilya Laktyushin 2024-08-11 01:19:25 +02:00
parent 6109477015
commit c92ce1c1dc
6 changed files with 34 additions and 6 deletions

View File

@ -52,8 +52,12 @@ public final class PresentationContext {
return self.view != nil && self.layout != nil return self.view != nil && self.layout != nil
} }
public private(set) var controllers: [(ContainableController, PresentationSurfaceLevel)] = [] public private(set) var controllers: [(ContainableController, PresentationSurfaceLevel)] = [] {
public var controllersUpdated: ([ContainableController]) -> Void = { _ in } didSet {
self.controllersUpdated(self.controllers)
}
}
public var controllersUpdated: ([(ContainableController, PresentationSurfaceLevel)]) -> Void = { _ in }
private var presentationDisposables = DisposableSet() private var presentationDisposables = DisposableSet()

View File

@ -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) { public func updateAlpha(_ alpha: CGFloat, transition: ContainedViewLayoutTransition) {
self.alpha = alpha self.alpha = alpha

View File

@ -52,6 +52,7 @@ swift_library(
"//submodules/AdUI", "//submodules/AdUI",
"//submodules/TelegramUI/Components/Ads/AdsInfoScreen", "//submodules/TelegramUI/Components/Ads/AdsInfoScreen",
"//submodules/TelegramUI/Components/Ads/AdsReportScreen", "//submodules/TelegramUI/Components/Ads/AdsReportScreen",
"//submodules/UrlHandling",
], ],
visibility = [ visibility = [
"//visibility:public", "//visibility:public",

View File

@ -30,6 +30,7 @@ import Speak
import TranslateUI import TranslateUI
import TelegramNotices import TelegramNotices
import SolidRoundedButtonNode import SolidRoundedButtonNode
import UrlHandling
private let deleteImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Input/Accessory Panels/MessageSelectionTrash"), color: .white) 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) 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 spoilerTextNode: ImmediateTextNodeWithEntities?
private var dustNode: InvisibleInkDustNode? private var dustNode: InvisibleInkDustNode?
private var buttonNode: SolidRoundedButtonNode? private var buttonNode: SolidRoundedButtonNode?
private var buttonIconNode: ASImageNode?
private var textSelectionNode: TextSelectionNode? private var textSelectionNode: TextSelectionNode?
@ -1069,6 +1071,14 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, ASScroll
} }
self.contentNode.addSubnode(buttonNode) self.contentNode.addSubnode(buttonNode)
self.buttonNode = 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 { } else if let buttonNode = self.buttonNode {
buttonNode.removeFromSupernode() buttonNode.removeFromSupernode()
@ -1227,6 +1237,10 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, ASScroll
let buttonHeight = buttonNode.updateLayout(width: constrainSize.width, transition: transition) 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))) 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 { if let _ = self.scrubberView {
panelHeight += 68.0 panelHeight += 68.0
} else { } else {

View File

@ -513,6 +513,9 @@ public final class ChatMessageWebpageBubbleContentNode: ChatMessageBubbleContent
} }
actionTitle = adAttribute.buttonText.uppercased() actionTitle = adAttribute.buttonText.uppercased()
if !isTelegramMeLink(adAttribute.url) {
actionIcon = .link
}
displayLine = true displayLine = true
} }

View File

@ -1278,6 +1278,12 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
}, present: { c, a, i in }, present: { c, a, i in
if case .current = i { if case .current = i {
c.presentationArguments = a 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: {}) self?.galleryPresentationContext.present(c, on: PresentationSurfaceLevel(rawValue: 0), blockInteraction: true, completion: {})
} else { } else {
self?.present(c, in: .window(.root), with: a, blockInteraction: true) self?.present(c, in: .window(.root), with: a, blockInteraction: true)
@ -6803,9 +6809,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
} }
} }
func updateStatusBarPresentation() { func updateStatusBarPresentation(animated: Bool = false) {
if !self.galleryPresentationContext.controllers.isEmpty { if !self.galleryPresentationContext.controllers.isEmpty, let statusBarStyle = (self.galleryPresentationContext.controllers.last?.0 as? ViewController)?.statusBar.statusBarStyle {
self.statusBar.statusBarStyle = .White self.statusBar.updateStatusBarStyle(statusBarStyle, animated: animated)
} else { } else {
switch self.presentationInterfaceState.mode { switch self.presentationInterfaceState.mode {
case let .standard(standardMode): case let .standard(standardMode):