mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Refactoring
This commit is contained in:
parent
3e8c111d6f
commit
8b7ca5f4f7
21 changed files with 71 additions and 23 deletions
|
|
@ -340,6 +340,7 @@ swift_library(
|
|||
"//submodules/TelegramUI/Components/Chat/AccessoryPanelNode",
|
||||
"//submodules/TelegramUI/Components/Chat/ForwardAccessoryPanelNode",
|
||||
"//submodules/TelegramUI/Components/LegacyMessageInputPanel",
|
||||
"//submodules/TelegramUI/Components/Chat/ChatMessageDateAndStatusNode",
|
||||
] + select({
|
||||
"@build_bazel_rules_apple//apple:ios_arm64": appcenter_targets,
|
||||
"//build-system:ios_sim_arm64": [],
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
|
||||
|
||||
swift_library(
|
||||
name = "ChatMessageDateAndStatusNode",
|
||||
module_name = "ChatMessageDateAndStatusNode",
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/AsyncDisplayKit",
|
||||
"//submodules/Postbox",
|
||||
"//submodules/TelegramCore",
|
||||
"//submodules/Display",
|
||||
"//submodules/SSignalKit/SwiftSignalKit",
|
||||
"//submodules/TelegramPresentationData",
|
||||
"//submodules/AccountContext",
|
||||
"//submodules/AppBundle",
|
||||
"//submodules/Components/ReactionButtonListComponent",
|
||||
"//submodules/Components/ReactionImageComponent",
|
||||
"//submodules/TelegramUI/Components/AnimationCache",
|
||||
"//submodules/TelegramUI/Components/MultiAnimationRenderer",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
],
|
||||
)
|
||||
|
|
@ -29,13 +29,13 @@ private func maybeAddRotationAnimation(_ layer: CALayer, duration: Double) {
|
|||
layer.add(basicAnimation, forKey: "clockFrameAnimation")
|
||||
}
|
||||
|
||||
enum ChatMessageDateAndStatusOutgoingType: Equatable {
|
||||
public enum ChatMessageDateAndStatusOutgoingType: Equatable {
|
||||
case Sent(read: Bool)
|
||||
case Sending
|
||||
case Failed
|
||||
}
|
||||
|
||||
enum ChatMessageDateAndStatusType: Equatable {
|
||||
public enum ChatMessageDateAndStatusType: Equatable {
|
||||
case BubbleIncoming
|
||||
case BubbleOutgoing(ChatMessageDateAndStatusOutgoingType)
|
||||
case ImageIncoming
|
||||
|
|
@ -176,27 +176,27 @@ private final class StatusReactionNode: ASDisplayNode {
|
|||
}
|
||||
}
|
||||
|
||||
class ChatMessageDateAndStatusNode: ASDisplayNode {
|
||||
struct TrailingReactionSettings {
|
||||
var displayInline: Bool
|
||||
var preferAdditionalInset: Bool
|
||||
public class ChatMessageDateAndStatusNode: ASDisplayNode {
|
||||
public struct TrailingReactionSettings {
|
||||
public var displayInline: Bool
|
||||
public var preferAdditionalInset: Bool
|
||||
|
||||
init(displayInline: Bool, preferAdditionalInset: Bool) {
|
||||
public init(displayInline: Bool, preferAdditionalInset: Bool) {
|
||||
self.displayInline = displayInline
|
||||
self.preferAdditionalInset = preferAdditionalInset
|
||||
}
|
||||
}
|
||||
|
||||
struct StandaloneReactionSettings {
|
||||
init() {
|
||||
public struct StandaloneReactionSettings {
|
||||
public init() {
|
||||
}
|
||||
}
|
||||
|
||||
enum LayoutInput {
|
||||
public enum LayoutInput {
|
||||
case trailingContent(contentWidth: CGFloat, reactionSettings: TrailingReactionSettings?)
|
||||
case standalone(reactionSettings: StandaloneReactionSettings?)
|
||||
|
||||
var displayInlineReactions: Bool {
|
||||
public var displayInlineReactions: Bool {
|
||||
switch self {
|
||||
case let .trailingContent(_, reactionSettings):
|
||||
if let reactionSettings = reactionSettings {
|
||||
|
|
@ -214,7 +214,7 @@ class ChatMessageDateAndStatusNode: ASDisplayNode {
|
|||
}
|
||||
}
|
||||
|
||||
struct Arguments {
|
||||
public struct Arguments {
|
||||
var context: AccountContext
|
||||
var presentationData: ChatPresentationData
|
||||
var edited: Bool
|
||||
|
|
@ -234,7 +234,7 @@ class ChatMessageDateAndStatusNode: ASDisplayNode {
|
|||
var animationCache: AnimationCache
|
||||
var animationRenderer: MultiAnimationRenderer
|
||||
|
||||
init(
|
||||
public init(
|
||||
context: AccountContext,
|
||||
presentationData: ChatPresentationData,
|
||||
edited: Bool,
|
||||
|
|
@ -297,8 +297,8 @@ class ChatMessageDateAndStatusNode: ASDisplayNode {
|
|||
|
||||
private var tapGestureRecognizer: UITapGestureRecognizer?
|
||||
|
||||
var openReplies: (() -> Void)?
|
||||
var pressed: (() -> Void)? {
|
||||
public var openReplies: (() -> Void)?
|
||||
public var pressed: (() -> Void)? {
|
||||
didSet {
|
||||
if self.pressed != nil {
|
||||
if self.tapGestureRecognizer == nil {
|
||||
|
|
@ -312,10 +312,10 @@ class ChatMessageDateAndStatusNode: ASDisplayNode {
|
|||
}
|
||||
}
|
||||
}
|
||||
var reactionSelected: ((MessageReaction.Reaction) -> Void)?
|
||||
var openReactionPreview: ((ContextGesture?, ContextExtractedContentContainingView, MessageReaction.Reaction) -> Void)?
|
||||
public var reactionSelected: ((MessageReaction.Reaction) -> Void)?
|
||||
public var openReactionPreview: ((ContextGesture?, ContextExtractedContentContainingView, MessageReaction.Reaction) -> Void)?
|
||||
|
||||
override init() {
|
||||
override public init() {
|
||||
self.dateNode = TextNode()
|
||||
self.dateNode.isUserInteractionEnabled = false
|
||||
self.dateNode.displaysAsynchronously = false
|
||||
|
|
@ -333,7 +333,7 @@ class ChatMessageDateAndStatusNode: ASDisplayNode {
|
|||
}
|
||||
}
|
||||
|
||||
func asyncLayout() -> (_ arguments: Arguments) -> (CGFloat, (CGFloat) -> (CGSize, (ListViewItemUpdateAnimation) -> Void)) {
|
||||
public func asyncLayout() -> (_ arguments: Arguments) -> (CGFloat, (CGFloat) -> (CGSize, (ListViewItemUpdateAnimation) -> Void)) {
|
||||
let dateLayout = TextNode.asyncLayout(self.dateNode)
|
||||
|
||||
var checkReadNode = self.checkReadNode
|
||||
|
|
@ -1310,7 +1310,7 @@ class ChatMessageDateAndStatusNode: ASDisplayNode {
|
|||
}
|
||||
}
|
||||
|
||||
static func asyncLayout(_ node: ChatMessageDateAndStatusNode?) -> (_ arguments: Arguments) -> (CGFloat, (CGFloat) -> (CGSize, (ListViewItemUpdateAnimation) -> ChatMessageDateAndStatusNode)) {
|
||||
public static func asyncLayout(_ node: ChatMessageDateAndStatusNode?) -> (_ arguments: Arguments) -> (CGFloat, (CGFloat) -> (CGSize, (ListViewItemUpdateAnimation) -> ChatMessageDateAndStatusNode)) {
|
||||
let currentLayout = node?.asyncLayout()
|
||||
return { arguments in
|
||||
let resultNode: ChatMessageDateAndStatusNode
|
||||
|
|
@ -1334,7 +1334,7 @@ class ChatMessageDateAndStatusNode: ASDisplayNode {
|
|||
}
|
||||
}
|
||||
|
||||
func reactionView(value: MessageReaction.Reaction) -> UIView? {
|
||||
public func reactionView(value: MessageReaction.Reaction) -> UIView? {
|
||||
for (id, node) in self.reactionNodes {
|
||||
if id == value {
|
||||
return node.iconView
|
||||
|
|
@ -1348,7 +1348,7 @@ class ChatMessageDateAndStatusNode: ASDisplayNode {
|
|||
return nil
|
||||
}
|
||||
|
||||
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
||||
override public func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
||||
for (_, button) in self.reactionButtonsContainer.buttons {
|
||||
if button.view.frame.contains(point) {
|
||||
if let result = button.view.hitTest(self.view.convert(point, to: button.view), with: event) {
|
||||
|
|
@ -1365,6 +1365,6 @@ class ChatMessageDateAndStatusNode: ASDisplayNode {
|
|||
}
|
||||
}
|
||||
|
||||
func shouldDisplayInlineDateReactions(message: Message, isPremium: Bool, forceInline: Bool) -> Bool {
|
||||
public func shouldDisplayInlineDateReactions(message: Message, isPremium: Bool, forceInline: Bool) -> Bool {
|
||||
return forceInline
|
||||
}
|
||||
|
|
@ -102,6 +102,7 @@ import ChatContextQuery
|
|||
import PeerReportScreen
|
||||
import PeerSelectionController
|
||||
import SaveToCameraRoll
|
||||
import ChatMessageDateAndStatusNode
|
||||
|
||||
#if DEBUG
|
||||
import os.signpost
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import ChatPresentationInterfaceState
|
|||
import TextNodeWithEntities
|
||||
import ChatControllerInteraction
|
||||
import ChatMessageForwardInfoNode
|
||||
import ChatMessageDateAndStatusNode
|
||||
|
||||
private let nameFont = Font.medium(14.0)
|
||||
private let inlineBotPrefixFont = Font.regular(14.0)
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import AnimationCache
|
|||
import MultiAnimationRenderer
|
||||
import ChatControllerInteraction
|
||||
import ShimmerEffect
|
||||
import ChatMessageDateAndStatusNode
|
||||
|
||||
private let buttonFont = Font.semibold(13.0)
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import ComponentFlow
|
|||
import EmojiStatusComponent
|
||||
import ChatControllerInteraction
|
||||
import ChatMessageForwardInfoNode
|
||||
import ChatMessageDateAndStatusNode
|
||||
|
||||
enum InternalBubbleTapAction {
|
||||
case action(() -> Void)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import TelegramPresentationData
|
|||
import AvatarNode
|
||||
import AccountContext
|
||||
import PhoneNumberFormat
|
||||
import ChatMessageDateAndStatusNode
|
||||
|
||||
private let avatarFont = avatarPlaceholderFont(size: 16.0)
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import TelegramCore
|
|||
import TelegramUIPreferences
|
||||
import ComponentFlow
|
||||
import AudioTranscriptionButtonComponent
|
||||
import ChatMessageDateAndStatusNode
|
||||
|
||||
class ChatMessageFileBubbleContentNode: ChatMessageBubbleContentNode {
|
||||
let interactiveFileNode: ChatMessageInteractiveFileNode
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import Markdown
|
|||
import ShimmerEffect
|
||||
import AnimatedStickerNode
|
||||
import TelegramAnimatedStickerNode
|
||||
import ChatMessageDateAndStatusNode
|
||||
|
||||
private let titleFont = Font.medium(15.0)
|
||||
private let textFont = Font.regular(13.0)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import TelegramCore
|
|||
import TelegramUIPreferences
|
||||
import ComponentFlow
|
||||
import AudioTranscriptionButtonComponent
|
||||
import ChatMessageDateAndStatusNode
|
||||
|
||||
class ChatMessageInstantVideoBubbleContentNode: ChatMessageBubbleContentNode {
|
||||
let interactiveFileNode: ChatMessageInteractiveFileNode
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import ContextUI
|
|||
import Markdown
|
||||
import ChatControllerInteraction
|
||||
import ChatMessageForwardInfoNode
|
||||
import ChatMessageDateAndStatusNode
|
||||
|
||||
private let nameFont = Font.medium(14.0)
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import AudioTranscriptionPendingIndicatorComponent
|
|||
import UndoUI
|
||||
import TelegramNotices
|
||||
import ChatControllerInteraction
|
||||
import ChatMessageDateAndStatusNode
|
||||
|
||||
private struct FetchControls {
|
||||
let fetch: (Bool) -> Void
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import TelegramNotices
|
|||
import Markdown
|
||||
import TextFormat
|
||||
import ChatMessageForwardInfoNode
|
||||
import ChatMessageDateAndStatusNode
|
||||
|
||||
struct ChatMessageInstantVideoItemLayoutResult {
|
||||
let contentSize: CGSize
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import ContextUI
|
|||
import InvisibleInkDustNode
|
||||
import ChatControllerInteraction
|
||||
import StoryContainerScreen
|
||||
import ChatMessageDateAndStatusNode
|
||||
|
||||
private struct FetchControls {
|
||||
let fetch: (Bool) -> Void
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import PhotoResources
|
|||
import MediaResources
|
||||
import LocationResources
|
||||
import LiveLocationPositionNode
|
||||
import ChatMessageDateAndStatusNode
|
||||
|
||||
private let titleFont = Font.medium(14.0)
|
||||
private let liveTitleFont = Font.medium(16.0)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import TelegramPresentationData
|
|||
import AccountContext
|
||||
import GridMessageSelectionNode
|
||||
import ChatControllerInteraction
|
||||
import ChatMessageDateAndStatusNode
|
||||
|
||||
class ChatMessageMediaBubbleContentNode: ChatMessageBubbleContentNode {
|
||||
override var supportsMosaic: Bool {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import AccountContext
|
|||
import AvatarNode
|
||||
import TelegramPresentationData
|
||||
import ChatMessageBackground
|
||||
import ChatMessageDateAndStatusNode
|
||||
|
||||
func isPollEffectivelyClosed(message: Message, poll: TelegramMediaPoll) -> Bool {
|
||||
if poll.isClosed {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import SwiftSignalKit
|
|||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import TextFormat
|
||||
import ChatMessageDateAndStatusNode
|
||||
|
||||
class ChatMessageRestrictedBubbleContentNode: ChatMessageBubbleContentNode {
|
||||
private let textNode: TextNode
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import ShimmerEffect
|
|||
import WallpaperBackgroundNode
|
||||
import ChatControllerInteraction
|
||||
import ChatMessageForwardInfoNode
|
||||
import ChatMessageDateAndStatusNode
|
||||
|
||||
private let nameFont = Font.medium(14.0)
|
||||
private let inlineBotPrefixFont = Font.regular(14.0)
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import LottieAnimationCache
|
|||
import MultiAnimationRenderer
|
||||
import EmojiTextAttachmentView
|
||||
import TextNodeWithEntities
|
||||
import ChatMessageDateAndStatusNode
|
||||
|
||||
private final class CachedChatMessageText {
|
||||
let text: String
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue