mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-05 19:28:46 +02:00
Consolidates 137 wave commits + 31 supporting commits (CLAUDE.md bump, typealias additions, AnyObject→EngineMedia restoration) into one squashed commit. Migrates dozens of consumer-side public APIs, struct fields, protocol methods, and enum payloads from Postbox protocols/structs to TelegramEngine engine wrappers and typealiases. Drops `import Postbox` from many files. Adds new TelegramCore typealiases and one TelegramEngineUnauthorized facade. Notable changes by category: **TelegramCore typealias additions** (rule 2 — narrow utility typealiases): - EngineChatListIndex, EngineTempBoxFile, EngineItemCollectionItemIndex, EngineItemCollectionViewEntryIndex, EngineValueBoxEncryptionParameters, EngineMessageAndThreadId, EnginePeerStoryStats, EngineMessageHistoryAnchorIndex, EngineChatListTotalUnreadStateCategory, EngineChatListTotalUnreadStateStats, EnginePeerSummaryCounterTags, EngineChatListTotalUnreadState, EngineItemCacheEntryId, EngineHashFunctions, EngineCachedMediaResourceRepresentationResult, EngineMediaResourceDataFetchResult, EngineMediaResourceDataFetchError, EngineMediaResourceStatus, EngineCachedPeerData **TelegramCore engine extensions/forwarders**: - EngineMessage.engineMedia, EngineMessage.enginePeers, EngineMessage.adAttribute, EngineMessage.effectivelyIncoming - engineFileSize forwarder - TelegramEngine.Resources.clearCachedMediaResources(mediaResourceIds: Set<EngineMediaResource.Id>) - TelegramEngine.Resources.fetchStatus(id:resourceSize:) - TelegramEngineUnauthorized.UnauthorizedResources facade with storeResourceData **Public API/struct migrations to engine types**: - ChatAvailableMessageActions.banAuthor/banAuthors → EnginePeer?/[EnginePeer] - WebSessionsContextState.peers → [EnginePeer.Id: EnginePeer] - CacheUsageStats.peers → [EnginePeer.Id: EnginePeer] - PeerCommand.peer → EnginePeer - PeerInfoControllerMode.calls(messages:) → [EngineMessage] - CallControllerNodeProtocol.updatePeer → EnginePeer params - ChatHistoryListNode.messageInCurrentHistoryView (and 4 variants) → EngineMessage? - ChatHistorySearchContainerNode.messageForGallery → EngineMessage? - PeerInfoPaneNode.findLoadedMessage / ensureMessageIsVisible / transitionNodeForGallery → engine-typed - GalleryHiddenMediaTarget.getTransitionInfo / GalleryHiddenMediaManager.findTarget → engine-typed - ChatPanelInterfaceInteraction.presentReactionDeletionOptions / presentBan*MessageOptions → EnginePeer - DrawingMessageRenderer.messages → [EngineMessage] - ChatVideoGalleryItemScrubberView.setFetchStatusSignal → EngineMediaResource.FetchStatus - ChannelDiscussionGroupActionSheetItem.peer, VoiceChatPeerEntry.peer, VoiceChatFullscreenParticipantItem.peer, MediaStreamComponent.chatPeer, MediaStreamVideoComponent.callPeer, ChatMessageContactBubbleContentNode.contactPeer, ChatMessageForwardInfoNode.peer, ChatMessageCommentFooterContentNode.replyPeers, ChatReportPeerTitlePanelNode.peer, ChatMessageActionUrlAuthController.bot, PeerMediaCollectionInterfaceState.peer, ChatMessageCallBubbleContentNode.peopleAvatars, ChatLoadingNode.renderedPeer (→ EngineRenderedPeer) — all to engine types **Wave-71-shadow stored-field migrations** (Postbox Peer/Message → Engine wrapper): - LegacyCallControllerNode.peer - CallStatusBarNode.currentPeer **Dead-code / dead-field removals**: - CallController.peer, CallControllerNodeV2.account, ContactMultiselectionController PeerNameIndex fields, preparedChatListNodeViewTransition account: Account param, FetchResource.swift entirely (unused function) **Module-level Postbox import drops**: 30+ files including TelegramRootController, EditStories, GiftViewScreen, AnimatedStickerUtils, FetchPhotoLibraryImageResource, PeerInfoGiftsPaneNode, PeerInfoPaneContainerNode, PresentAddMembers, PeerInfoProfileItems, ChatControllerAdminBanUsers, PresentationData typealiases, DefaultDayPresentationTheme, ChatListViewTransition, GalleryHiddenMediaManager, RecentSessionsController, GifContext, AuthorizationSequenceController, PeerInfoHeaderEditingContentNode, PeerInfoHeaderNode, PeerAllowedReactionListController, CallControllerNodeV2, and 6 PeerInfo pane files. **AnyObject restoration**: rule 8 added (never substitute Postbox protocols with Any/AnyObject) — undid previous AnyObject substitutions in waves 141/143 back to EngineMedia. Doc maintenance: CLAUDE.md updated to reflect new typealiases and forwarders. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
111 lines
5.5 KiB
Swift
111 lines
5.5 KiB
Swift
import Foundation
|
|
import UIKit
|
|
import AsyncDisplayKit
|
|
import UIKit
|
|
import Display
|
|
import TelegramCore
|
|
import TelegramPresentationData
|
|
import TelegramUIPreferences
|
|
import AvatarNode
|
|
import AccountContext
|
|
|
|
final class ChannelDiscussionGroupActionSheetItem: ActionSheetItem {
|
|
let context: AccountContext
|
|
let channelPeer: EnginePeer
|
|
let groupPeer: EnginePeer
|
|
let strings: PresentationStrings
|
|
let nameDisplayOrder: PresentationPersonNameOrder
|
|
|
|
init(context: AccountContext, channelPeer: EnginePeer, groupPeer: EnginePeer, strings: PresentationStrings, nameDisplayOrder: PresentationPersonNameOrder) {
|
|
self.context = context
|
|
self.channelPeer = channelPeer
|
|
self.groupPeer = groupPeer
|
|
self.strings = strings
|
|
self.nameDisplayOrder = nameDisplayOrder
|
|
}
|
|
|
|
func node(theme: ActionSheetControllerTheme) -> ActionSheetItemNode {
|
|
return ChannelDiscussionGroupActionSheetItemNode(theme: theme, context: self.context, channelPeer: self.channelPeer, groupPeer: self.groupPeer, strings: self.strings, nameDisplayOrder: self.nameDisplayOrder)
|
|
}
|
|
|
|
func updateNode(_ node: ActionSheetItemNode) {
|
|
}
|
|
}
|
|
|
|
private let avatarFont = avatarPlaceholderFont(size: 26.0)
|
|
|
|
private final class ChannelDiscussionGroupActionSheetItemNode: ActionSheetItemNode {
|
|
private let theme: ActionSheetControllerTheme
|
|
|
|
private let channelAvatarNode: AvatarNode
|
|
private let channelAvatarOverlay: ASImageNode
|
|
private let groupAvatarNode: AvatarNode
|
|
private let textNode: ImmediateTextNode
|
|
|
|
init(theme: ActionSheetControllerTheme, context: AccountContext, channelPeer: EnginePeer, groupPeer: EnginePeer, strings: PresentationStrings, nameDisplayOrder: PresentationPersonNameOrder) {
|
|
self.theme = theme
|
|
|
|
self.channelAvatarNode = AvatarNode(font: avatarFont)
|
|
self.groupAvatarNode = AvatarNode(font: avatarFont)
|
|
self.channelAvatarOverlay = ASImageNode()
|
|
self.channelAvatarOverlay.displayWithoutProcessing = true
|
|
self.channelAvatarOverlay.displaysAsynchronously = false
|
|
self.channelAvatarOverlay.image = generateFilledCircleImage(diameter: 66.0, color: theme.itemBackgroundColor.withAlphaComponent(1.0))
|
|
|
|
self.textNode = ImmediateTextNode()
|
|
self.textNode.displaysAsynchronously = false
|
|
self.textNode.maximumNumberOfLines = 0
|
|
self.textNode.textAlignment = .center
|
|
|
|
super.init(theme: theme)
|
|
|
|
self.addSubnode(self.groupAvatarNode)
|
|
self.addSubnode(self.channelAvatarOverlay)
|
|
self.addSubnode(self.channelAvatarNode)
|
|
self.addSubnode(self.textNode)
|
|
|
|
self.channelAvatarNode.setPeer(context: context, theme: (context.sharedContext.currentPresentationData.with { $0 }).theme, peer: channelPeer)
|
|
self.groupAvatarNode.setPeer(context: context, theme: (context.sharedContext.currentPresentationData.with { $0 }).theme, peer: groupPeer)
|
|
|
|
let text: PresentationStrings.FormattedString
|
|
if case let .channel(channel) = channelPeer, let addressName = channel.addressName, !addressName.isEmpty {
|
|
text = strings.Channel_DiscussionGroup_PublicChannelLink(groupPeer.displayTitle(strings: strings, displayOrder: nameDisplayOrder), channelPeer.displayTitle(strings: strings, displayOrder: nameDisplayOrder))
|
|
} else {
|
|
text = strings.Channel_DiscussionGroup_PrivateChannelLink(groupPeer.displayTitle(strings: strings, displayOrder: nameDisplayOrder), channelPeer.displayTitle(strings: strings, displayOrder: nameDisplayOrder))
|
|
}
|
|
|
|
let textFont = Font.regular(floor(theme.baseFontSize * 14.0 / 17.0))
|
|
let boldFont = Font.semibold(floor(theme.baseFontSize * 14.0 / 17.0))
|
|
|
|
let attributedText = NSMutableAttributedString(attributedString: NSAttributedString(string: text.string, font: textFont, textColor: theme.primaryTextColor))
|
|
for range in text.ranges {
|
|
attributedText.addAttribute(.font, value: boldFont, range: range.range)
|
|
}
|
|
|
|
self.textNode.attributedText = attributedText
|
|
}
|
|
|
|
public override func updateLayout(constrainedSize: CGSize, transition: ContainedViewLayoutTransition) -> CGSize {
|
|
let textSize = self.textNode.updateLayout(CGSize(width: constrainedSize.width - 20.0, height: .greatestFiniteMagnitude))
|
|
|
|
let topInset: CGFloat = 16.0
|
|
let avatarSize: CGFloat = 60.0
|
|
let textSpacing: CGFloat = 12.0
|
|
let bottomInset: CGFloat = 15.0
|
|
|
|
let avatarOverlap: CGFloat = 10.0
|
|
let avatarsWidth = avatarSize * 2.0 - avatarOverlap
|
|
|
|
let channelAvatarFrame = CGRect(origin: CGPoint(x: floor((constrainedSize.width - avatarsWidth) / 2.0), y: topInset), size: CGSize(width: avatarSize, height: avatarSize))
|
|
self.channelAvatarNode.frame = channelAvatarFrame
|
|
self.groupAvatarNode.frame = channelAvatarFrame.offsetBy(dx: avatarSize - avatarOverlap, dy: 0.0)
|
|
self.channelAvatarOverlay.frame = CGRect(origin: CGPoint(x: channelAvatarFrame.minX - 3.0, y: channelAvatarFrame.minY - 3.0), size: CGSize(width: 66.0, height: 66.0))
|
|
|
|
self.textNode.frame = CGRect(origin: CGPoint(x: floor((constrainedSize.width - textSize.width) / 2.0), y: topInset + avatarSize + textSpacing), size: textSize)
|
|
|
|
let size = CGSize(width: constrainedSize.width, height: topInset + avatarSize + textSpacing + textSize.height + bottomInset)
|
|
|
|
self.updateInternalLayout(size, constrainedSize: constrainedSize)
|
|
return size
|
|
}
|
|
}
|