From a7f9e0fed69d558aa78ab532b7e524e04f24cf9f Mon Sep 17 00:00:00 2001 From: Ali <> Date: Fri, 13 Oct 2023 17:10:33 +0400 Subject: [PATCH] Refactoring --- submodules/TelegramUI/BUILD | 2 + .../ChatMessageInteractiveMediaNode/BUILD | 46 +++++++++ .../ChatMessageInteractiveMediaNode.swift | 95 +++++++++++-------- .../Components/WallpaperPreviewMedia/BUILD | 19 ++++ .../Sources/WallpaperPreviewMedia.swift | 24 +++-- .../ChatMessageActionButtonsNode.swift | 50 ++++++++++ .../ChatMessageAttachedContentNode.swift | 2 + .../ChatMessageMediaBubbleContentNode.swift | 1 + ...hatMessageWallpaperBubbleContentNode.swift | 1 + .../ChatMessageWebpageBubbleContentNode.swift | 2 + .../Sources/InChatPrefetchManager.swift | 1 + .../TelegramUI/Sources/PrefetchManager.swift | 1 + 12 files changed, 198 insertions(+), 46 deletions(-) create mode 100644 submodules/TelegramUI/Components/Chat/ChatMessageInteractiveMediaNode/BUILD rename submodules/TelegramUI/{ => Components/Chat/ChatMessageInteractiveMediaNode}/Sources/ChatMessageInteractiveMediaNode.swift (97%) create mode 100644 submodules/TelegramUI/Components/WallpaperPreviewMedia/BUILD rename submodules/TelegramUI/{ => Components/WallpaperPreviewMedia}/Sources/WallpaperPreviewMedia.swift (70%) diff --git a/submodules/TelegramUI/BUILD b/submodules/TelegramUI/BUILD index 47ef7d3a94..050828d08f 100644 --- a/submodules/TelegramUI/BUILD +++ b/submodules/TelegramUI/BUILD @@ -365,6 +365,8 @@ swift_library( "//submodules/TelegramUI/Components/Chat/InstantVideoRadialStatusNode", "//submodules/TelegramUI/Components/Chat/ChatMessageInteractiveFileNode", "//submodules/TelegramUI/Components/Chat/ChatMessageFileBubbleContentNode", + "//submodules/TelegramUI/Components/Chat/ChatMessageInteractiveMediaNode", + "//submodules/TelegramUI/Components/WallpaperPreviewMedia", ] + select({ "@build_bazel_rules_apple//apple:ios_arm64": appcenter_targets, "//build-system:ios_sim_arm64": [], diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveMediaNode/BUILD b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveMediaNode/BUILD new file mode 100644 index 0000000000..1e1cb0ffcd --- /dev/null +++ b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveMediaNode/BUILD @@ -0,0 +1,46 @@ +load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") + +swift_library( + name = "ChatMessageInteractiveMediaNode", + module_name = "ChatMessageInteractiveMediaNode", + srcs = glob([ + "Sources/**/*.swift", + ]), + copts = [ + "-warnings-as-errors", + ], + deps = [ + "//submodules/AsyncDisplayKit", + "//submodules/Postbox", + "//submodules/SSignalKit/SwiftSignalKit", + "//submodules/Display", + "//submodules/TelegramCore", + "//submodules/TelegramPresentationData", + "//submodules/TelegramUIPreferences", + "//submodules/MediaPlayer:UniversalMediaPlayer", + "//submodules/TextFormat", + "//submodules/AccountContext", + "//submodules/RadialStatusNode", + "//submodules/StickerResources", + "//submodules/PhotoResources", + "//submodules/TelegramUniversalVideoContent", + "//submodules/TelegramStringFormatting", + "//submodules/GalleryUI", + "//submodules/AnimatedStickerNode", + "//submodules/TelegramAnimatedStickerNode", + "//submodules/LocalMediaResources", + "//submodules/WallpaperResources", + "//submodules/ChatMessageInteractiveMediaBadge", + "//submodules/ContextUI", + "//submodules/InvisibleInkDustNode", + "//submodules/TelegramUI/Components/ChatControllerInteraction", + "//submodules/TelegramUI/Components/Stories/StoryContainerScreen", + "//submodules/TelegramUI/Components/Chat/ChatMessageDateAndStatusNode", + "//submodules/TelegramUI/Components/Chat/ChatHistoryEntry", + "//submodules/TelegramUI/Components/Chat/ChatMessageItemCommon", + "//submodules/TelegramUI/Components/WallpaperPreviewMedia", + ], + visibility = [ + "//visibility:public", + ], +) diff --git a/submodules/TelegramUI/Sources/ChatMessageInteractiveMediaNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveMediaNode/Sources/ChatMessageInteractiveMediaNode.swift similarity index 97% rename from submodules/TelegramUI/Sources/ChatMessageInteractiveMediaNode.swift rename to submodules/TelegramUI/Components/Chat/ChatMessageInteractiveMediaNode/Sources/ChatMessageInteractiveMediaNode.swift index 576446ac90..330aed1c88 100644 --- a/submodules/TelegramUI/Sources/ChatMessageInteractiveMediaNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveMediaNode/Sources/ChatMessageInteractiveMediaNode.swift @@ -28,22 +28,23 @@ import StoryContainerScreen import ChatMessageDateAndStatusNode import ChatHistoryEntry import ChatMessageItemCommon +import WallpaperPreviewMedia private struct FetchControls { let fetch: (Bool) -> Void let cancel: () -> Void } -enum InteractiveMediaNodeSizeCalculation { +public enum InteractiveMediaNodeSizeCalculation { case constrained(CGSize) case unconstrained } -enum InteractiveMediaNodeContentMode { +public enum InteractiveMediaNodeContentMode { case aspectFit case aspectFill - var bubbleVideoDecorationContentMode: ChatBubbleVideoDecorationContentMode { + public var bubbleVideoDecorationContentMode: ChatBubbleVideoDecorationContentMode { switch self { case .aspectFit: return .aspectFit @@ -53,32 +54,52 @@ enum InteractiveMediaNodeContentMode { } } -enum InteractiveMediaNodeActivateContent { +public enum InteractiveMediaNodeActivateContent { case `default` case stream case automaticPlayback } -enum InteractiveMediaNodeAutodownloadMode { +public enum InteractiveMediaNodeAutodownloadMode { case none case prefetch case full } -enum InteractiveMediaNodePlayWithSoundMode { +public enum InteractiveMediaNodePlayWithSoundMode { case single case loop } -struct ChatMessageDateAndStatus { - var type: ChatMessageDateAndStatusType - var edited: Bool - var viewCount: Int? - var dateReactions: [MessageReaction] - var dateReactionPeers: [(MessageReaction.Reaction, EnginePeer)] - var dateReplies: Int - var isPinned: Bool - var dateText: String +public struct ChatMessageDateAndStatus { + public var type: ChatMessageDateAndStatusType + public var edited: Bool + public var viewCount: Int? + public var dateReactions: [MessageReaction] + public var dateReactionPeers: [(MessageReaction.Reaction, EnginePeer)] + public var dateReplies: Int + public var isPinned: Bool + public var dateText: String + + public init( + type: ChatMessageDateAndStatusType, + edited: Bool, + viewCount: Int?, + dateReactions: [MessageReaction], + dateReactionPeers: [(MessageReaction.Reaction, EnginePeer)], + dateReplies: Int, + isPinned: Bool, + dateText: String + ) { + self.type = type + self.edited = edited + self.viewCount = viewCount + self.dateReactions = dateReactions + self.dateReactionPeers = dateReactionPeers + self.dateReplies = dateReplies + self.isPinned = isPinned + self.dateText = dateText + } } public func roundedRectCgPath(roundRect rect: CGRect, topLeftRadius: CGFloat = 0.0, topRightRadius: CGFloat = 0.0, bottomLeftRadius: CGFloat = 0.0, bottomRightRadius: CGFloat = 0.0) -> CGPath { @@ -348,7 +369,7 @@ private class ExtendedMediaOverlayNode: ASDisplayNode { } } -final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitionNode { +public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitionNode { private let pinchContainerNode: PinchSourceContainerNode private let imageNode: TransformImageNode private var currentImageArguments: TransformImageArguments? @@ -360,11 +381,11 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio private var videoContent: NativeVideoContent? private var animatedStickerNode: AnimatedStickerNode? private var statusNode: RadialStatusNode? - var videoNodeDecoration: ChatBubbleVideoDecoration? - var decoration: UniversalVideoDecoration? { + public var videoNodeDecoration: ChatBubbleVideoDecoration? + public var decoration: UniversalVideoDecoration? { return self.videoNodeDecoration } - let dateAndStatusNode: ChatMessageDateAndStatusNode + public let dateAndStatusNode: ChatMessageDateAndStatusNode private var badgeNode: ChatMessageInteractiveMediaBadge? private var extendedMediaOverlayNode: ExtendedMediaOverlayNode? @@ -377,7 +398,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio private var sizeCalculation: InteractiveMediaNodeSizeCalculation? private var wideLayout: Bool? private var automaticDownload: InteractiveMediaNodeAutodownloadMode? - var automaticPlayback: Bool? + public var automaticPlayback: Bool? private let statusDisposable = MetaDisposable() private let fetchControls = Atomic(value: nil) @@ -404,8 +425,8 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio private var secretTimer: SwiftSignalKit.Timer? - var visibilityPromise = ValuePromise(false, ignoreRepeated: true) - var visibility: Bool = false { + public var visibilityPromise = ValuePromise(false, ignoreRepeated: true) + public var visibility: Bool = false { didSet { self.updateVisibility() } @@ -431,11 +452,11 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio self.visibilityPromise.set(visibility) } - var activateLocalContent: (InteractiveMediaNodeActivateContent) -> Void = { _ in } - var activatePinch: ((PinchSourceContainerNode) -> Void)? - var updateMessageReaction: ((Message, ChatControllerInteractionReaction) -> Void)? + public var activateLocalContent: (InteractiveMediaNodeActivateContent) -> Void = { _ in } + public var activatePinch: ((PinchSourceContainerNode) -> Void)? + public var updateMessageReaction: ((Message, ChatControllerInteractionReaction) -> Void)? - override init() { + override public init() { self.pinchContainerNode = PinchSourceContainerNode() self.dateAndStatusNode = ChatMessageDateAndStatusNode() @@ -541,15 +562,15 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio self.secretTimer?.invalidate() } - func isAvailableForGalleryTransition() -> Bool { + public func isAvailableForGalleryTransition() -> Bool { return self.automaticPlayback ?? false } - func isAvailableForInstantPageTransition() -> Bool { + public func isAvailableForInstantPageTransition() -> Bool { return false } - override func didLoad() { + override public func didLoad() { super.didLoad() self.imageNode.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.imageTap(_:)))) @@ -615,7 +636,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio } } - @objc func imageTap(_ recognizer: UITapGestureRecognizer) { + @objc private func imageTap(_ recognizer: UITapGestureRecognizer) { if case .ended = recognizer.state { let point = recognizer.location(in: self.imageNode.view) if let _ = self.attributes?.updatingMedia { @@ -660,7 +681,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio } } - func asyncLayout() -> (_ context: AccountContext, _ presentationData: ChatPresentationData, _ dateTimeFormat: PresentationDateTimeFormat, _ message: Message, _ associatedData: ChatMessageItemAssociatedData, _ attributes: ChatMessageEntryAttributes, _ media: Media, _ dateAndStatus: ChatMessageDateAndStatus?, _ automaticDownload: InteractiveMediaNodeAutodownloadMode, _ peerType: MediaAutoDownloadPeerType, _ peerId: EnginePeer.Id?, _ sizeCalculation: InteractiveMediaNodeSizeCalculation, _ layoutConstants: ChatMessageItemLayoutConstants, _ contentMode: InteractiveMediaNodeContentMode, _ presentationContext: ChatPresentationContext) -> (CGSize, CGFloat, (CGSize, Bool, Bool, ImageCorners) -> (CGFloat, (CGFloat) -> (CGSize, (ListViewItemUpdateAnimation, Bool) -> Void))) { + public func asyncLayout() -> (_ context: AccountContext, _ presentationData: ChatPresentationData, _ dateTimeFormat: PresentationDateTimeFormat, _ message: Message, _ associatedData: ChatMessageItemAssociatedData, _ attributes: ChatMessageEntryAttributes, _ media: Media, _ dateAndStatus: ChatMessageDateAndStatus?, _ automaticDownload: InteractiveMediaNodeAutodownloadMode, _ peerType: MediaAutoDownloadPeerType, _ peerId: EnginePeer.Id?, _ sizeCalculation: InteractiveMediaNodeSizeCalculation, _ layoutConstants: ChatMessageItemLayoutConstants, _ contentMode: InteractiveMediaNodeContentMode, _ presentationContext: ChatPresentationContext) -> (CGSize, CGFloat, (CGSize, Bool, Bool, ImageCorners) -> (CGFloat, (CGFloat) -> (CGSize, (ListViewItemUpdateAnimation, Bool) -> Void))) { let currentMessage = self.message let currentMedia = self.media let imageLayout = self.imageNode.asyncLayout() @@ -2200,7 +2221,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio } } - static func asyncLayout(_ node: ChatMessageInteractiveMediaNode?) -> (_ context: AccountContext, _ presentationData: ChatPresentationData, _ dateTimeFormat: PresentationDateTimeFormat, _ message: Message, _ associatedData: ChatMessageItemAssociatedData, _ attributes: ChatMessageEntryAttributes, _ media: Media, _ dateAndStatus: ChatMessageDateAndStatus?, _ automaticDownload: InteractiveMediaNodeAutodownloadMode, _ peerType: MediaAutoDownloadPeerType, _ peerId: EnginePeer.Id?, _ sizeCalculation: InteractiveMediaNodeSizeCalculation, _ layoutConstants: ChatMessageItemLayoutConstants, _ contentMode: InteractiveMediaNodeContentMode, _ presentationContext: ChatPresentationContext) -> (CGSize, CGFloat, (CGSize, Bool, Bool, ImageCorners) -> (CGFloat, (CGFloat) -> (CGSize, (ListViewItemUpdateAnimation, Bool) -> ChatMessageInteractiveMediaNode))) { + public static func asyncLayout(_ node: ChatMessageInteractiveMediaNode?) -> (_ context: AccountContext, _ presentationData: ChatPresentationData, _ dateTimeFormat: PresentationDateTimeFormat, _ message: Message, _ associatedData: ChatMessageItemAssociatedData, _ attributes: ChatMessageEntryAttributes, _ media: Media, _ dateAndStatus: ChatMessageDateAndStatus?, _ automaticDownload: InteractiveMediaNodeAutodownloadMode, _ peerType: MediaAutoDownloadPeerType, _ peerId: EnginePeer.Id?, _ sizeCalculation: InteractiveMediaNodeSizeCalculation, _ layoutConstants: ChatMessageItemLayoutConstants, _ contentMode: InteractiveMediaNodeContentMode, _ presentationContext: ChatPresentationContext) -> (CGSize, CGFloat, (CGSize, Bool, Bool, ImageCorners) -> (CGFloat, (CGFloat) -> (CGSize, (ListViewItemUpdateAnimation, Bool) -> ChatMessageInteractiveMediaNode))) { let currentAsyncLayout = node?.asyncLayout() return { context, presentationData, dateTimeFormat, message, associatedData, attributes, media, dateAndStatus, automaticDownload, peerType, peerId, sizeCalculation, layoutConstants, contentMode, presentationContext in @@ -2232,11 +2253,11 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio } } - func setOverlayColor(_ color: UIColor?, animated: Bool) { + public func setOverlayColor(_ color: UIColor?, animated: Bool) { self.imageNode.setOverlayColor(color, animated: animated) } - func isReadyForInteractivePreview() -> Bool { + public func isReadyForInteractivePreview() -> Bool { if let fetchStatus = self.fetchStatus, case .Local = fetchStatus { return true } else { @@ -2244,7 +2265,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio } } - func updateIsHidden(_ isHidden: Bool) { + public func updateIsHidden(_ isHidden: Bool) { if isHidden && !self.internallyVisible { self.internallyVisible = true self.updateVisibility() @@ -2278,7 +2299,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio } } - func transitionNode(adjustRect: Bool) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? { + public func transitionNode(adjustRect: Bool) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? { var bounds: CGRect if let currentImageArguments = self.currentImageArguments { if adjustRect { @@ -2336,7 +2357,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio }) } - func playMediaWithSound() -> (action: (Double?) -> Void, soundEnabled: Bool, isVideoMessage: Bool, isUnread: Bool, badgeNode: ASDisplayNode?)? { + public func playMediaWithSound() -> (action: (Double?) -> Void, soundEnabled: Bool, isVideoMessage: Bool, isUnread: Bool, badgeNode: ASDisplayNode?)? { var isAnimated = false if let file = self.media as? TelegramMediaFile, file.isAnimated { isAnimated = true diff --git a/submodules/TelegramUI/Components/WallpaperPreviewMedia/BUILD b/submodules/TelegramUI/Components/WallpaperPreviewMedia/BUILD new file mode 100644 index 0000000000..2bbdb275af --- /dev/null +++ b/submodules/TelegramUI/Components/WallpaperPreviewMedia/BUILD @@ -0,0 +1,19 @@ +load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") + +swift_library( + name = "WallpaperPreviewMedia", + module_name = "WallpaperPreviewMedia", + srcs = glob([ + "Sources/**/*.swift", + ]), + copts = [ + "-warnings-as-errors", + ], + deps = [ + "//submodules/Postbox", + "//submodules/TelegramCore", + ], + visibility = [ + "//visibility:public", + ], +) diff --git a/submodules/TelegramUI/Sources/WallpaperPreviewMedia.swift b/submodules/TelegramUI/Components/WallpaperPreviewMedia/Sources/WallpaperPreviewMedia.swift similarity index 70% rename from submodules/TelegramUI/Sources/WallpaperPreviewMedia.swift rename to submodules/TelegramUI/Components/WallpaperPreviewMedia/Sources/WallpaperPreviewMedia.swift index 0a232c2355..7903e414e8 100644 --- a/submodules/TelegramUI/Sources/WallpaperPreviewMedia.swift +++ b/submodules/TelegramUI/Components/WallpaperPreviewMedia/Sources/WallpaperPreviewMedia.swift @@ -3,7 +3,7 @@ import UIKit import Postbox import TelegramCore -enum WallpaperPreviewMediaContent: Equatable { +public enum WallpaperPreviewMediaContent: Equatable { case file(file: TelegramMediaFile, colors: [UInt32], rotation: Int32?, intensity: Int32?, Bool, Bool) case image(representations: [TelegramMediaImageRepresentation]) case color(UIColor) @@ -11,23 +11,23 @@ enum WallpaperPreviewMediaContent: Equatable { case themeSettings(TelegramThemeSettings) } -final class WallpaperPreviewMedia: Media { - var id: MediaId? { +public final class WallpaperPreviewMedia: Media { + public var id: MediaId? { return nil } - let peerIds: [PeerId] = [] + public let peerIds: [PeerId] = [] - let content: WallpaperPreviewMediaContent + public let content: WallpaperPreviewMediaContent - init(content: WallpaperPreviewMediaContent) { + public init(content: WallpaperPreviewMediaContent) { self.content = content } - init(decoder: PostboxDecoder) { + public init(decoder: PostboxDecoder) { self.content = .color(.clear) } - func encode(_ encoder: PostboxEncoder) { + public func encode(_ encoder: PostboxEncoder) { } public func isEqual(to other: Media) -> Bool { @@ -47,7 +47,13 @@ final class WallpaperPreviewMedia: Media { } } -extension WallpaperPreviewMedia { +private extension UIColor { + convenience init(rgb: UInt32) { + self.init(red: CGFloat((rgb >> 16) & 0xff) / 255.0, green: CGFloat((rgb >> 8) & 0xff) / 255.0, blue: CGFloat(rgb & 0xff) / 255.0, alpha: 1.0) + } +} + +public extension WallpaperPreviewMedia { convenience init?(wallpaper: TelegramWallpaper) { switch wallpaper { case let .color(color): diff --git a/submodules/TelegramUI/Sources/ChatMessageActionButtonsNode.swift b/submodules/TelegramUI/Sources/ChatMessageActionButtonsNode.swift index bbbda3cf3b..0b99c2e7fa 100644 --- a/submodules/TelegramUI/Sources/ChatMessageActionButtonsNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageActionButtonsNode.swift @@ -10,6 +10,56 @@ import WallpaperBackgroundNode private let titleFont = Font.medium(16.0) +private extension UIBezierPath { + convenience init(roundRect rect: CGRect, topLeftRadius: CGFloat = 0.0, topRightRadius: CGFloat = 0.0, bottomLeftRadius: CGFloat = 0.0, bottomRightRadius: CGFloat = 0.0) { + self.init() + + let path = CGMutablePath() + + let topLeft = rect.origin + let topRight = CGPoint(x: rect.maxX, y: rect.minY) + let bottomRight = CGPoint(x: rect.maxX, y: rect.maxY) + let bottomLeft = CGPoint(x: rect.minX, y: rect.maxY) + + if topLeftRadius != .zero { + path.move(to: CGPoint(x: topLeft.x+topLeftRadius, y: topLeft.y)) + } else { + path.move(to: CGPoint(x: topLeft.x, y: topLeft.y)) + } + + if topRightRadius != .zero { + path.addLine(to: CGPoint(x: topRight.x-topRightRadius, y: topRight.y)) + path.addCurve(to: CGPoint(x: topRight.x, y: topRight.y+topRightRadius), control1: CGPoint(x: topRight.x, y: topRight.y), control2:CGPoint(x: topRight.x, y: topRight.y + topRightRadius)) + } else { + path.addLine(to: CGPoint(x: topRight.x, y: topRight.y)) + } + + if bottomRightRadius != .zero { + path.addLine(to: CGPoint(x: bottomRight.x, y: bottomRight.y-bottomRightRadius)) + path.addCurve(to: CGPoint(x: bottomRight.x-bottomRightRadius, y: bottomRight.y), control1: CGPoint(x: bottomRight.x, y: bottomRight.y), control2: CGPoint(x: bottomRight.x-bottomRightRadius, y: bottomRight.y)) + } else { + path.addLine(to: CGPoint(x: bottomRight.x, y: bottomRight.y)) + } + + if bottomLeftRadius != .zero { + path.addLine(to: CGPoint(x: bottomLeft.x+bottomLeftRadius, y: bottomLeft.y)) + path.addCurve(to: CGPoint(x: bottomLeft.x, y: bottomLeft.y-bottomLeftRadius), control1: CGPoint(x: bottomLeft.x, y: bottomLeft.y), control2: CGPoint(x: bottomLeft.x, y: bottomLeft.y-bottomLeftRadius)) + } else { + path.addLine(to: CGPoint(x: bottomLeft.x, y: bottomLeft.y)) + } + + if topLeftRadius != .zero { + path.addLine(to: CGPoint(x: topLeft.x, y: topLeft.y+topLeftRadius)) + path.addCurve(to: CGPoint(x: topLeft.x+topLeftRadius, y: topLeft.y) , control1: CGPoint(x: topLeft.x, y: topLeft.y) , control2: CGPoint(x: topLeft.x+topLeftRadius, y: topLeft.y)) + } else { + path.addLine(to: CGPoint(x: topLeft.x, y: topLeft.y)) + } + + path.closeSubpath() + self.cgPath = path + } +} + private final class ChatMessageActionButtonNode: ASDisplayNode { //private let backgroundBlurNode: NavigationBackgroundNode private var backgroundBlurView: PortalView? diff --git a/submodules/TelegramUI/Sources/ChatMessageAttachedContentNode.swift b/submodules/TelegramUI/Sources/ChatMessageAttachedContentNode.swift index a7bc74a250..e1750ea5cf 100644 --- a/submodules/TelegramUI/Sources/ChatMessageAttachedContentNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageAttachedContentNode.swift @@ -25,6 +25,8 @@ import ChatMessageItemCommon import ChatMessageBubbleContentNode import ChatMessageInteractiveInstantVideoNode import ChatMessageInteractiveFileNode +import ChatMessageInteractiveMediaNode +import WallpaperPreviewMedia private let buttonFont = Font.semibold(13.0) diff --git a/submodules/TelegramUI/Sources/ChatMessageMediaBubbleContentNode.swift b/submodules/TelegramUI/Sources/ChatMessageMediaBubbleContentNode.swift index 71e31e9705..bfab3b790c 100644 --- a/submodules/TelegramUI/Sources/ChatMessageMediaBubbleContentNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageMediaBubbleContentNode.swift @@ -13,6 +13,7 @@ import ChatControllerInteraction import ChatMessageDateAndStatusNode import ChatMessageBubbleContentNode import ChatMessageItemCommon +import ChatMessageInteractiveMediaNode class ChatMessageMediaBubbleContentNode: ChatMessageBubbleContentNode { override var supportsMosaic: Bool { diff --git a/submodules/TelegramUI/Sources/ChatMessageWallpaperBubbleContentNode.swift b/submodules/TelegramUI/Sources/ChatMessageWallpaperBubbleContentNode.swift index c430d8606d..22aeb4ae0c 100644 --- a/submodules/TelegramUI/Sources/ChatMessageWallpaperBubbleContentNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageWallpaperBubbleContentNode.swift @@ -20,6 +20,7 @@ import ComponentFlow import AudioTranscriptionPendingIndicatorComponent import ChatMessageBubbleContentNode import ChatMessageItemCommon +import WallpaperPreviewMedia class ChatMessageWallpaperBubbleContentNode: ChatMessageBubbleContentNode { private var mediaBackgroundContent: WallpaperBubbleBackgroundNode? diff --git a/submodules/TelegramUI/Sources/ChatMessageWebpageBubbleContentNode.swift b/submodules/TelegramUI/Sources/ChatMessageWebpageBubbleContentNode.swift index e4667301dd..a54b812b10 100644 --- a/submodules/TelegramUI/Sources/ChatMessageWebpageBubbleContentNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageWebpageBubbleContentNode.swift @@ -15,6 +15,8 @@ import GalleryData import TelegramPresentationData import ChatMessageBubbleContentNode import ChatMessageItemCommon +import WallpaperPreviewMedia +import ChatMessageInteractiveMediaNode private let titleFont: UIFont = Font.semibold(15.0) diff --git a/submodules/TelegramUI/Sources/InChatPrefetchManager.swift b/submodules/TelegramUI/Sources/InChatPrefetchManager.swift index d87ae27290..b0c86c381c 100644 --- a/submodules/TelegramUI/Sources/InChatPrefetchManager.swift +++ b/submodules/TelegramUI/Sources/InChatPrefetchManager.swift @@ -6,6 +6,7 @@ import TelegramUIPreferences import AccountContext import PhotoResources import UniversalMediaPlayer +import ChatMessageInteractiveMediaNode private final class PrefetchMediaContext { let fetchDisposable = MetaDisposable() diff --git a/submodules/TelegramUI/Sources/PrefetchManager.swift b/submodules/TelegramUI/Sources/PrefetchManager.swift index 2398ada772..52f34f9601 100644 --- a/submodules/TelegramUI/Sources/PrefetchManager.swift +++ b/submodules/TelegramUI/Sources/PrefetchManager.swift @@ -7,6 +7,7 @@ import PhotoResources import StickerResources import Emoji import UniversalMediaPlayer +import ChatMessageInteractiveMediaNode private final class PrefetchMediaContext { let fetchDisposable = MetaDisposable()