mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-06 17:00:13 +00:00
Fix monoforum search
This commit is contained in:
parent
b1371bf1ee
commit
2ca01d18eb
@ -2154,7 +2154,11 @@ public class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||||||
topForumTopicItems = topForumTopicItemsValue
|
topForumTopicItems = topForumTopicItemsValue
|
||||||
|
|
||||||
if item.interaction.searchTextHighightState != nil, threadInfo == nil, topForumTopicItems.isEmpty, let message = messagesValue.first, let threadId = message.threadId, let associatedThreadInfo = message.associatedThreadInfo {
|
if item.interaction.searchTextHighightState != nil, threadInfo == nil, topForumTopicItems.isEmpty, let message = messagesValue.first, let threadId = message.threadId, let associatedThreadInfo = message.associatedThreadInfo {
|
||||||
topForumTopicItems = [EngineChatList.ForumTopicData(id: threadId, title: associatedThreadInfo.title, iconFileId: associatedThreadInfo.icon, iconColor: associatedThreadInfo.iconColor, maxOutgoingReadMessageId: message.id, isUnread: false, threadPeer: nil)]
|
var threadPeer: EnginePeer?
|
||||||
|
if case let .channel(channel) = peerValue.peer, channel.isMonoForum {
|
||||||
|
threadPeer = message.peers[EnginePeer.Id(threadId)].flatMap(EnginePeer.init)
|
||||||
|
}
|
||||||
|
topForumTopicItems = [EngineChatList.ForumTopicData(id: threadId, title: associatedThreadInfo.title, iconFileId: associatedThreadInfo.icon, iconColor: associatedThreadInfo.iconColor, maxOutgoingReadMessageId: message.id, isUnread: false, threadPeer: threadPeer)]
|
||||||
}
|
}
|
||||||
|
|
||||||
switch peerValue.peer {
|
switch peerValue.peer {
|
||||||
|
|||||||
@ -452,6 +452,7 @@ public class ContactsPeerItemNode: ItemListRevealOptionsItemNode {
|
|||||||
private var avatarIconView: ComponentHostView<Empty>?
|
private var avatarIconView: ComponentHostView<Empty>?
|
||||||
private var avatarIconComponent: EmojiStatusComponent?
|
private var avatarIconComponent: EmojiStatusComponent?
|
||||||
public let titleNode: TextNode
|
public let titleNode: TextNode
|
||||||
|
private var titleBadge: (backgroundView: UIImageView, textNode: TextNode)?
|
||||||
private var credibilityIconView: ComponentHostView<Empty>?
|
private var credibilityIconView: ComponentHostView<Empty>?
|
||||||
private var credibilityIconComponent: EmojiStatusComponent?
|
private var credibilityIconComponent: EmojiStatusComponent?
|
||||||
private var verifiedIconView: ComponentHostView<Empty>?
|
private var verifiedIconView: ComponentHostView<Empty>?
|
||||||
@ -735,6 +736,7 @@ public class ContactsPeerItemNode: ItemListRevealOptionsItemNode {
|
|||||||
|
|
||||||
public func asyncLayout() -> (_ item: ContactsPeerItem, _ params: ListViewItemLayoutParams, _ first: Bool, _ last: Bool, _ firstWithHeader: Bool, _ neighbors: ItemListNeighbors) -> (ListViewItemNodeLayout, () -> (Signal<Void, NoError>?, (Bool, Bool) -> Void)) {
|
public func asyncLayout() -> (_ item: ContactsPeerItem, _ params: ListViewItemLayoutParams, _ first: Bool, _ last: Bool, _ firstWithHeader: Bool, _ neighbors: ItemListNeighbors) -> (ListViewItemNodeLayout, () -> (Signal<Void, NoError>?, (Bool, Bool) -> Void)) {
|
||||||
let makeTitleLayout = TextNode.asyncLayout(self.titleNode)
|
let makeTitleLayout = TextNode.asyncLayout(self.titleNode)
|
||||||
|
let titleBadgeLayout = TextNode.asyncLayout(self.titleBadge?.textNode)
|
||||||
let makeStatusLayout = TextNodeWithEntities.asyncLayout(self.statusNode)
|
let makeStatusLayout = TextNodeWithEntities.asyncLayout(self.statusNode)
|
||||||
let currentSelectionNode = self.selectionNode
|
let currentSelectionNode = self.selectionNode
|
||||||
|
|
||||||
@ -933,11 +935,7 @@ public class ContactsPeerItemNode: ItemListRevealOptionsItemNode {
|
|||||||
} else if case let .legacyGroup(group) = peer {
|
} else if case let .legacyGroup(group) = peer {
|
||||||
titleAttributedString = NSAttributedString(string: group.title, font: titleBoldFont, textColor: item.presentationData.theme.list.itemPrimaryTextColor)
|
titleAttributedString = NSAttributedString(string: group.title, font: titleBoldFont, textColor: item.presentationData.theme.list.itemPrimaryTextColor)
|
||||||
} else if case let .channel(channel) = peer {
|
} else if case let .channel(channel) = peer {
|
||||||
if case let .channel(mainChannel) = chatPeer, mainChannel.isMonoForum {
|
titleAttributedString = NSAttributedString(string: channel.title, font: titleBoldFont, textColor: item.presentationData.theme.list.itemPrimaryTextColor)
|
||||||
titleAttributedString = NSAttributedString(string: item.presentationData.strings.Monoforum_NameFormat(channel.title).string, font: titleBoldFont, textColor: item.presentationData.theme.list.itemPrimaryTextColor)
|
|
||||||
} else {
|
|
||||||
titleAttributedString = NSAttributedString(string: channel.title, font: titleBoldFont, textColor: item.presentationData.theme.list.itemPrimaryTextColor)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch item.status {
|
switch item.status {
|
||||||
@ -1120,7 +1118,21 @@ public class ContactsPeerItemNode: ItemListRevealOptionsItemNode {
|
|||||||
additionalTitleInset += rightLabelTextLayoutAndApply.0.size.width + 36.0
|
additionalTitleInset += rightLabelTextLayoutAndApply.0.size.width + 36.0
|
||||||
}
|
}
|
||||||
|
|
||||||
let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: titleAttributedString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: max(0.0, params.width - leftInset - rightInset - additionalTitleInset), height: CGFloat.infinity), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
var titleBadgeText: String?
|
||||||
|
if case let .peer(_, chatPeer) = item.peer, case let .channel(channel) = chatPeer, channel.isMonoForum {
|
||||||
|
titleBadgeText = item.presentationData.strings.ChatList_MonoforumLabel
|
||||||
|
}
|
||||||
|
|
||||||
|
var maxTextWidth: CGFloat = params.width - leftInset - rightInset - additionalTitleInset
|
||||||
|
|
||||||
|
var titleBadgeLayoutAndApply: (TextNodeLayout, () -> TextNode)?
|
||||||
|
if let titleBadgeText {
|
||||||
|
let titleBadgeLayoutAndApplyValue = titleBadgeLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: titleBadgeText, font: Font.semibold(11.0), textColor: item.presentationData.theme.chatList.titleColor.withMultipliedAlpha(0.4)), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: maxTextWidth, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||||
|
titleBadgeLayoutAndApply = titleBadgeLayoutAndApplyValue
|
||||||
|
maxTextWidth = max(0.0, maxTextWidth - titleBadgeLayoutAndApplyValue.0.size.width - 8.0)
|
||||||
|
}
|
||||||
|
|
||||||
|
let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: titleAttributedString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: max(0.0, maxTextWidth), height: CGFloat.infinity), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||||
|
|
||||||
var maxStatusWidth: CGFloat = params.width - leftInset - rightInset - badgeSize
|
var maxStatusWidth: CGFloat = params.width - leftInset - rightInset - badgeSize
|
||||||
if let _ = statusIcon {
|
if let _ = statusIcon {
|
||||||
@ -1565,6 +1577,37 @@ public class ContactsPeerItemNode: ItemListRevealOptionsItemNode {
|
|||||||
strongSelf.credibilityIconView = nil
|
strongSelf.credibilityIconView = nil
|
||||||
credibilityIconView.removeFromSuperview()
|
credibilityIconView.removeFromSuperview()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let (titleBadgeLayout, titleBadgeApply) = titleBadgeLayoutAndApply {
|
||||||
|
let titleBadgeNode = titleBadgeApply()
|
||||||
|
let backgroundView: UIImageView
|
||||||
|
if let current = strongSelf.titleBadge {
|
||||||
|
backgroundView = current.backgroundView
|
||||||
|
} else {
|
||||||
|
backgroundView = UIImageView(image: generateStretchableFilledCircleImage(radius: 4.0, color: .white)?.withRenderingMode(.alwaysTemplate))
|
||||||
|
strongSelf.titleBadge = (backgroundView, titleBadgeNode)
|
||||||
|
|
||||||
|
strongSelf.offsetContainerNode.view.addSubview(backgroundView)
|
||||||
|
strongSelf.offsetContainerNode.addSubnode(titleBadgeNode)
|
||||||
|
}
|
||||||
|
nextIconX += 10.0
|
||||||
|
let titleBadgeFrame = CGRect(origin: CGPoint(x: nextIconX, y: titleFrame.minY + floor((titleFrame.height - titleBadgeLayout.size.height) * 0.5)), size: titleBadgeLayout.size)
|
||||||
|
nextIconX += titleBadgeLayout.size.width + 4.0
|
||||||
|
titleBadgeNode.frame = titleBadgeFrame
|
||||||
|
|
||||||
|
var titleBadgeBackgroundFrame = titleBadgeFrame.insetBy(dx: -4.0, dy: -2.0)
|
||||||
|
titleBadgeBackgroundFrame.size.height -= 1.0
|
||||||
|
backgroundView.frame = titleBadgeBackgroundFrame
|
||||||
|
if item.presentationData.theme.overallDarkAppearance {
|
||||||
|
backgroundView.tintColor = item.presentationData.theme.chatList.titleColor.withMultipliedAlpha(0.1)
|
||||||
|
} else {
|
||||||
|
backgroundView.tintColor = item.presentationData.theme.chatList.titleColor.withMultipliedAlpha(0.05)
|
||||||
|
}
|
||||||
|
} else if let titleBadge = strongSelf.titleBadge {
|
||||||
|
strongSelf.titleBadge = nil
|
||||||
|
titleBadge.backgroundView.removeFromSuperview()
|
||||||
|
titleBadge.textNode.removeFromSupernode()
|
||||||
|
}
|
||||||
|
|
||||||
var additionalRightInset: CGFloat = 0.0
|
var additionalRightInset: CGFloat = 0.0
|
||||||
if let (titleLayout, titleApply) = actionButtonTitleLayoutAndApply {
|
if let (titleLayout, titleApply) = actionButtonTitleLayoutAndApply {
|
||||||
|
|||||||
@ -234,6 +234,18 @@ func locallyRenderedMessage(message: StoreMessage, peers: [PeerId: Peer], associ
|
|||||||
messagePeers[channelPeer.id] = channelPeer
|
messagePeers[channelPeer.id] = channelPeer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let channel = peer as? TelegramChannel, channel.isMonoForum, let linkedMonoforumId = channel.linkedMonoforumId {
|
||||||
|
if let channelPeer = peers[linkedMonoforumId] {
|
||||||
|
messagePeers[channelPeer.id] = channelPeer
|
||||||
|
}
|
||||||
|
|
||||||
|
if let threadId = message.threadId {
|
||||||
|
if let threadPeer = peers[PeerId(threadId)] {
|
||||||
|
messagePeers[threadPeer.id] = threadPeer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for media in message.media {
|
for media in message.media {
|
||||||
|
|||||||
@ -485,6 +485,10 @@ public extension RenderedPeer {
|
|||||||
if let regularPeer = message.peers[peer.regularPeerId] {
|
if let regularPeer = message.peers[peer.regularPeerId] {
|
||||||
peers[regularPeer.id] = regularPeer
|
peers[regularPeer.id] = regularPeer
|
||||||
}
|
}
|
||||||
|
} else if let peer = peer as? TelegramChannel, peer.isMonoForum, let linkedMonoforumId = peer.linkedMonoforumId {
|
||||||
|
if let regularPeer = message.peers[linkedMonoforumId] {
|
||||||
|
peers[regularPeer.id] = regularPeer
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.init(peerId: message.id.peerId, peers: peers, associatedMedia: [:])
|
self.init(peerId: message.id.peerId, peers: peers, associatedMedia: [:])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user