mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
Monoforums
This commit is contained in:
parent
77e21b4047
commit
4c423437a3
@ -1519,7 +1519,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
|||||||
if let threadId = threadId {
|
if let threadId = threadId {
|
||||||
let source: ContextContentSource
|
let source: ContextContentSource
|
||||||
let chatController = strongSelf.context.sharedContext.makeChatController(context: strongSelf.context, chatLocation: .replyThread(message: ChatReplyThreadMessage(
|
let chatController = strongSelf.context.sharedContext.makeChatController(context: strongSelf.context, chatLocation: .replyThread(message: ChatReplyThreadMessage(
|
||||||
peerId: peer.peerId, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: !channel.isMonoForum, isMonoforumPost: channel.isMonoForum, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false
|
peerId: peer.peerId, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: channel.isForumOrMonoForum, isMonoforumPost: channel.isMonoForum, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false
|
||||||
)), subject: nil, botStart: nil, mode: .standard(.previewing), params: nil)
|
)), subject: nil, botStart: nil, mode: .standard(.previewing), params: nil)
|
||||||
chatController.canReadHistory.set(false)
|
chatController.canReadHistory.set(false)
|
||||||
source = .controller(ContextControllerContentSourceImpl(controller: chatController, sourceNode: node, navigationController: strongSelf.navigationController as? NavigationController))
|
source = .controller(ContextControllerContentSourceImpl(controller: chatController, sourceNode: node, navigationController: strongSelf.navigationController as? NavigationController))
|
||||||
|
@ -995,6 +995,7 @@ public class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||||||
final class TopicItemNode: ASDisplayNode {
|
final class TopicItemNode: ASDisplayNode {
|
||||||
let topicTitleNode: TextNode
|
let topicTitleNode: TextNode
|
||||||
let titleTopicIconView: ComponentHostView<Empty>?
|
let titleTopicIconView: ComponentHostView<Empty>?
|
||||||
|
var titleTopicAvatarNode: AvatarNode?
|
||||||
var titleTopicIconComponent: EmojiStatusComponent?
|
var titleTopicIconComponent: EmojiStatusComponent?
|
||||||
|
|
||||||
var visibilityStatus: Bool = false {
|
var visibilityStatus: Bool = false {
|
||||||
@ -1012,30 +1013,34 @@ public class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private init(topicTitleNode: TextNode, titleTopicIconView: ComponentHostView<Empty>?, titleTopicIconComponent: EmojiStatusComponent?) {
|
private init(topicTitleNode: TextNode, titleTopicIconView: ComponentHostView<Empty>?, titleTopicAvatarNode: AvatarNode?, titleTopicIconComponent: EmojiStatusComponent?) {
|
||||||
self.topicTitleNode = topicTitleNode
|
self.topicTitleNode = topicTitleNode
|
||||||
self.titleTopicIconView = titleTopicIconView
|
self.titleTopicIconView = titleTopicIconView
|
||||||
|
self.titleTopicAvatarNode = titleTopicAvatarNode
|
||||||
self.titleTopicIconComponent = titleTopicIconComponent
|
self.titleTopicIconComponent = titleTopicIconComponent
|
||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
self.addSubnode(self.topicTitleNode)
|
self.addSubnode(self.topicTitleNode)
|
||||||
|
if let titleTopicAvatarNode = self.titleTopicAvatarNode {
|
||||||
|
self.view.addSubview(titleTopicAvatarNode.view)
|
||||||
|
}
|
||||||
if let titleTopicIconView = self.titleTopicIconView {
|
if let titleTopicIconView = self.titleTopicIconView {
|
||||||
self.view.addSubview(titleTopicIconView)
|
self.view.addSubview(titleTopicIconView)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static func asyncLayout(_ currentNode: TopicItemNode?) -> (_ constrainedWidth: CGFloat, _ context: AccountContext, _ theme: PresentationTheme, _ threadId: Int64, _ title: NSAttributedString, _ iconId: Int64?, _ iconColor: Int32?) -> (CGSize, () -> TopicItemNode) {
|
static func asyncLayout(_ currentNode: TopicItemNode?) -> (_ constrainedWidth: CGFloat, _ context: AccountContext, _ theme: PresentationTheme, _ threadId: Int64, _ threadPeer: EnginePeer?, _ title: NSAttributedString, _ iconId: Int64?, _ iconColor: Int32?) -> (CGSize, () -> TopicItemNode) {
|
||||||
let makeTopicTitleLayout = TextNode.asyncLayout(currentNode?.topicTitleNode)
|
let makeTopicTitleLayout = TextNode.asyncLayout(currentNode?.topicTitleNode)
|
||||||
|
|
||||||
return { constrainedWidth, context, theme, threadId, title, iconId, iconColor in
|
return { constrainedWidth, context, theme, threadId, threadPeer, title, iconId, iconColor in
|
||||||
let remainingWidth = max(1.0, constrainedWidth - (((iconId == nil && iconColor == nil) ? 1.0 : 18.0) + 2.0))
|
let remainingWidth = max(1.0, constrainedWidth - (((iconId == nil && iconColor == nil && threadPeer == nil) ? 1.0 : 18.0) + 2.0))
|
||||||
|
|
||||||
let topicTitleArguments = TextNodeLayoutArguments(attributedString: title, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: remainingWidth, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets(top: 2.0, left: 1.0, bottom: 2.0, right: 1.0))
|
let topicTitleArguments = TextNodeLayoutArguments(attributedString: title, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: remainingWidth, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets(top: 2.0, left: 1.0, bottom: 2.0, right: 1.0))
|
||||||
|
|
||||||
let topicTitleLayout = makeTopicTitleLayout(topicTitleArguments)
|
let topicTitleLayout = makeTopicTitleLayout(topicTitleArguments)
|
||||||
|
|
||||||
return (CGSize(width: ((iconId == nil && iconColor == nil) ? 1.0 : 18.0) + 2.0 + topicTitleLayout.0.size.width, height: topicTitleLayout.0.size.height), {
|
return (CGSize(width: ((iconId == nil && iconColor == nil && threadPeer == nil) ? 1.0 : 18.0) + 2.0 + topicTitleLayout.0.size.width, height: topicTitleLayout.0.size.height), {
|
||||||
let topicTitleNode = topicTitleLayout.1()
|
let topicTitleNode = topicTitleLayout.1()
|
||||||
|
|
||||||
let titleTopicIconContent: EmojiStatusComponent.Content?
|
let titleTopicIconContent: EmojiStatusComponent.Content?
|
||||||
@ -1069,7 +1074,16 @@ public class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let targetNode = currentNode ?? TopicItemNode(topicTitleNode: topicTitleNode, titleTopicIconView: titleTopicIconView, titleTopicIconComponent: titleTopicIconComponent)
|
var titleTopicAvatarNode: AvatarNode?
|
||||||
|
if let _ = threadPeer {
|
||||||
|
if let current = currentNode?.titleTopicAvatarNode {
|
||||||
|
titleTopicAvatarNode = current
|
||||||
|
} else {
|
||||||
|
titleTopicAvatarNode = AvatarNode(font: avatarPlaceholderFont(size: 8.0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let targetNode = currentNode ?? TopicItemNode(topicTitleNode: topicTitleNode, titleTopicIconView: titleTopicIconView, titleTopicAvatarNode: titleTopicAvatarNode, titleTopicIconComponent: titleTopicIconComponent)
|
||||||
|
|
||||||
targetNode.titleTopicIconComponent = titleTopicIconComponent
|
targetNode.titleTopicIconComponent = titleTopicIconComponent
|
||||||
|
|
||||||
@ -1082,6 +1096,18 @@ public class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||||||
)
|
)
|
||||||
titleTopicIconView.frame = CGRect(origin: CGPoint(x: 0.0, y: 2.0), size: iconSize)
|
titleTopicIconView.frame = CGRect(origin: CGPoint(x: 0.0, y: 2.0), size: iconSize)
|
||||||
|
|
||||||
|
topicTitleNode.frame = CGRect(origin: CGPoint(x: 18.0 + 2.0, y: 0.0), size: topicTitleLayout.0.size)
|
||||||
|
} else if let titleTopicAvatarNode, let threadPeer {
|
||||||
|
let iconSize = CGSize(width: 18.0, height: 18.0)
|
||||||
|
|
||||||
|
titleTopicAvatarNode.frame = CGRect(origin: CGPoint(x: 0.0, y: 2.0), size: iconSize)
|
||||||
|
titleTopicAvatarNode.updateSize(size: iconSize)
|
||||||
|
if threadPeer.smallProfileImage != nil {
|
||||||
|
titleTopicAvatarNode.setPeerV2(context: context, theme: theme, peer: threadPeer, overrideImage: nil, emptyColor: theme.list.mediaPlaceholderColor, clipStyle: .round, synchronousLoad: false, displayDimensions: iconSize)
|
||||||
|
} else {
|
||||||
|
titleTopicAvatarNode.setPeer(context: context, theme: theme, peer: threadPeer, overrideImage: nil, emptyColor: theme.list.mediaPlaceholderColor, clipStyle: .round, synchronousLoad: false, displayDimensions: iconSize)
|
||||||
|
}
|
||||||
|
|
||||||
topicTitleNode.frame = CGRect(origin: CGPoint(x: 18.0 + 2.0, y: 0.0), size: topicTitleLayout.0.size)
|
topicTitleNode.frame = CGRect(origin: CGPoint(x: 18.0 + 2.0, y: 0.0), size: topicTitleLayout.0.size)
|
||||||
} else {
|
} else {
|
||||||
topicTitleNode.frame = CGRect(origin: CGPoint(x: 1.0, y: 0.0), size: topicTitleLayout.0.size)
|
topicTitleNode.frame = CGRect(origin: CGPoint(x: 1.0, y: 0.0), size: topicTitleLayout.0.size)
|
||||||
@ -1145,9 +1171,9 @@ public class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func asyncLayout() -> (_ context: AccountContext, _ constrainedWidth: CGFloat, _ theme: PresentationTheme, _ authorTitle: NSAttributedString?, _ topics: [(id: Int64, title: NSAttributedString, iconId: Int64?, iconColor: Int32?)]) -> (CGSize, () -> CGRect?) {
|
func asyncLayout() -> (_ context: AccountContext, _ constrainedWidth: CGFloat, _ theme: PresentationTheme, _ authorTitle: NSAttributedString?, _ topics: [(id: Int64, threadPeer: EnginePeer?, title: NSAttributedString, iconId: Int64?, iconColor: Int32?)]) -> (CGSize, () -> CGRect?) {
|
||||||
let makeAuthorLayout = TextNode.asyncLayout(self.authorNode)
|
let makeAuthorLayout = TextNode.asyncLayout(self.authorNode)
|
||||||
var makeExistingTopicLayouts: [Int64: (_ constrainedWidth: CGFloat, _ context: AccountContext, _ theme: PresentationTheme, _ threadId: Int64, _ title: NSAttributedString, _ iconId: Int64?, _ iconColor: Int32?) -> (CGSize, () -> TopicItemNode)] = [:]
|
var makeExistingTopicLayouts: [Int64: (_ constrainedWidth: CGFloat, _ context: AccountContext, _ theme: PresentationTheme, _ threadId: Int64, _ threadPeer: EnginePeer?, _ title: NSAttributedString, _ iconId: Int64?, _ iconColor: Int32?) -> (CGSize, () -> TopicItemNode)] = [:]
|
||||||
for (topicId, topicNode) in self.topicNodes {
|
for (topicId, topicNode) in self.topicNodes {
|
||||||
makeExistingTopicLayouts[topicId] = TopicItemNode.asyncLayout(topicNode)
|
makeExistingTopicLayouts[topicId] = TopicItemNode.asyncLayout(topicNode)
|
||||||
}
|
}
|
||||||
@ -1179,7 +1205,7 @@ public class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let makeTopicLayout = makeExistingTopicLayouts[topic.id] ?? TopicItemNode.asyncLayout(nil)
|
let makeTopicLayout = makeExistingTopicLayouts[topic.id] ?? TopicItemNode.asyncLayout(nil)
|
||||||
let (topicSize, topicApply) = makeTopicLayout(remainingWidth, context, theme, topic.id, topic.title, topic.iconId, topic.iconColor)
|
let (topicSize, topicApply) = makeTopicLayout(remainingWidth, context, theme, topic.id, topic.threadPeer, topic.title, topic.iconId, topic.iconColor)
|
||||||
topicsSizeAndApply.append((topic.id, topicSize, topicApply))
|
topicsSizeAndApply.append((topic.id, topicSize, topicApply))
|
||||||
|
|
||||||
remainingWidth -= topicSize.width + 4.0
|
remainingWidth -= topicSize.width + 4.0
|
||||||
@ -3338,17 +3364,17 @@ public class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||||||
let isSearching = item.interaction.searchTextHighightState != nil
|
let isSearching = item.interaction.searchTextHighightState != nil
|
||||||
|
|
||||||
var isFirstForumThreadSelectable = false
|
var isFirstForumThreadSelectable = false
|
||||||
var forumThreads: [(id: Int64, title: NSAttributedString, iconId: Int64?, iconColor: Int32?)] = []
|
var forumThreads: [(id: Int64, threadPeer: EnginePeer?, title: NSAttributedString, iconId: Int64?, iconColor: Int32?)] = []
|
||||||
if case .savedMessagesChats = item.chatListLocation {
|
if case .savedMessagesChats = item.chatListLocation {
|
||||||
} else if case let .peer(peer) = item.content, case let .channel(channel) = peer.peer.peer, channel.flags.contains(.isMonoforum) {
|
} else if case let .peer(peer) = item.content, case let .channel(channel) = peer.peer.peer, channel.flags.contains(.isMonoforum) {
|
||||||
if forumThread != nil || !topForumTopicItems.isEmpty {
|
if forumThread != nil || !topForumTopicItems.isEmpty {
|
||||||
if let forumThread {
|
if let forumThread {
|
||||||
isFirstForumThreadSelectable = forumThread.isUnread
|
isFirstForumThreadSelectable = forumThread.isUnread
|
||||||
forumThreads.append((id: forumThread.id, title: NSAttributedString(string: forumThread.threadPeer?.compactDisplayTitle ?? " ", font: textFont, textColor: forumThread.isUnread || isSearching ? theme.authorNameColor : theme.messageTextColor), iconId: nil, iconColor: nil))
|
forumThreads.append((id: forumThread.id, threadPeer: forumThread.threadPeer, title: NSAttributedString(string: forumThread.threadPeer?.compactDisplayTitle ?? " ", font: textFont, textColor: forumThread.isUnread || isSearching ? theme.authorNameColor : theme.messageTextColor), iconId: nil, iconColor: nil))
|
||||||
}
|
}
|
||||||
for topicItem in topForumTopicItems {
|
for topicItem in topForumTopicItems {
|
||||||
if forumThread?.id != topicItem.id {
|
if forumThread?.id != topicItem.id {
|
||||||
forumThreads.append((id: topicItem.id, title: NSAttributedString(string: topicItem.threadPeer?.compactDisplayTitle ?? " ", font: textFont, textColor: topicItem.isUnread || isSearching ? theme.authorNameColor : theme.messageTextColor), iconId: nil, iconColor: nil))
|
forumThreads.append((id: topicItem.id, threadPeer: topicItem.threadPeer, title: NSAttributedString(string: topicItem.threadPeer?.compactDisplayTitle ?? " ", font: textFont, textColor: topicItem.isUnread || isSearching ? theme.authorNameColor : theme.messageTextColor), iconId: nil, iconColor: nil))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3365,13 +3391,13 @@ public class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||||||
} else if forumThread != nil || !topForumTopicItems.isEmpty {
|
} else if forumThread != nil || !topForumTopicItems.isEmpty {
|
||||||
if let forumThread = forumThread {
|
if let forumThread = forumThread {
|
||||||
isFirstForumThreadSelectable = forumThread.isUnread
|
isFirstForumThreadSelectable = forumThread.isUnread
|
||||||
forumThreads.append((id: forumThread.id, title: NSAttributedString(string: forumThread.title, font: textFont, textColor: forumThread.isUnread || isSearching ? theme.authorNameColor : theme.messageTextColor), iconId: forumThread.iconId, iconColor: forumThread.iconColor))
|
forumThreads.append((id: forumThread.id, threadPeer: forumThread.threadPeer, title: NSAttributedString(string: forumThread.title, font: textFont, textColor: forumThread.isUnread || isSearching ? theme.authorNameColor : theme.messageTextColor), iconId: forumThread.iconId, iconColor: forumThread.iconColor))
|
||||||
}
|
}
|
||||||
for topicItem in topForumTopicItems {
|
for topicItem in topForumTopicItems {
|
||||||
if case let .peer(peer) = item.content, peer.peer.peerId.id._internalGetInt64Value() == topicItem.id {
|
if case let .peer(peer) = item.content, peer.peer.peerId.id._internalGetInt64Value() == topicItem.id {
|
||||||
|
|
||||||
} else if forumThread?.id != topicItem.id {
|
} else if forumThread?.id != topicItem.id {
|
||||||
forumThreads.append((id: topicItem.id, title: NSAttributedString(string: topicItem.title, font: textFont, textColor: topicItem.isUnread || isSearching ? theme.authorNameColor : theme.messageTextColor), iconId: topicItem.iconFileId, iconColor: topicItem.iconColor))
|
forumThreads.append((id: topicItem.id, threadPeer: topicItem.threadPeer, title: NSAttributedString(string: topicItem.title, font: textFont, textColor: topicItem.isUnread || isSearching ? theme.authorNameColor : theme.messageTextColor), iconId: topicItem.iconFileId, iconColor: topicItem.iconColor))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,8 +125,12 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
|
|||||||
let compactAuthorName = message.author?.compactDisplayTitle ?? ""
|
let compactAuthorName = message.author?.compactDisplayTitle ?? ""
|
||||||
|
|
||||||
var isChannel = false
|
var isChannel = false
|
||||||
if message.id.peerId.namespace == Namespaces.Peer.CloudChannel, let peer = message.peers[message.id.peerId] as? TelegramChannel, case .broadcast = peer.info {
|
var isMonoforum = false
|
||||||
isChannel = true
|
if message.id.peerId.namespace == Namespaces.Peer.CloudChannel, let peer = message.peers[message.id.peerId] as? TelegramChannel {
|
||||||
|
if case .broadcast = peer.info {
|
||||||
|
isChannel = true
|
||||||
|
}
|
||||||
|
isMonoforum = peer.isMonoForum
|
||||||
}
|
}
|
||||||
|
|
||||||
switch action.action {
|
switch action.action {
|
||||||
@ -135,7 +139,12 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
|
|||||||
attributedString = NSAttributedString(string: strings.Notification_CreatedChannel, font: titleFont, textColor: primaryTextColor)
|
attributedString = NSAttributedString(string: strings.Notification_CreatedChannel, font: titleFont, textColor: primaryTextColor)
|
||||||
} else {
|
} else {
|
||||||
if forChatList {
|
if forChatList {
|
||||||
attributedString = NSAttributedString(string: strings.Notification_CreatedGroup, font: titleFont, textColor: primaryTextColor)
|
if isMonoforum {
|
||||||
|
//TODO:Localize
|
||||||
|
attributedString = NSAttributedString(string: "No messages here yet...", font: titleFont, textColor: primaryTextColor)
|
||||||
|
} else {
|
||||||
|
attributedString = NSAttributedString(string: strings.Notification_CreatedGroup, font: titleFont, textColor: primaryTextColor)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
attributedString = addAttributesToStringWithRanges(strings.Notification_CreatedChatWithTitle(authorName, title)._tuple, body: bodyAttributes, argumentAttributes: peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: [(0, message.author?.id)]))
|
attributedString = addAttributesToStringWithRanges(strings.Notification_CreatedChatWithTitle(authorName, title)._tuple, body: bodyAttributes, argumentAttributes: peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: [(0, message.author?.id)]))
|
||||||
}
|
}
|
||||||
|
@ -1816,7 +1816,7 @@ public final class ChatEmptyNode: ASDisplayNode {
|
|||||||
contentType = .secret
|
contentType = .secret
|
||||||
} else if let group = peer as? TelegramGroup, case .creator = group.role {
|
} else if let group = peer as? TelegramGroup, case .creator = group.role {
|
||||||
contentType = .group
|
contentType = .group
|
||||||
} else if let channel = peer as? TelegramChannel, case .group = channel.info, channel.flags.contains(.isCreator) && !channel.flags.contains(.isGigagroup) {
|
} else if let channel = peer as? TelegramChannel, case .group = channel.info, channel.flags.contains(.isCreator) && !channel.flags.contains(.isGigagroup) && !channel.isMonoForum {
|
||||||
contentType = .group
|
contentType = .group
|
||||||
} else if let _ = interfaceState.peerNearbyData {
|
} else if let _ = interfaceState.peerNearbyData {
|
||||||
contentType = .peerNearby
|
contentType = .peerNearby
|
||||||
@ -1835,6 +1835,8 @@ public final class ChatEmptyNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if let channel = peer as? TelegramChannel, channel.isMonoForum, let sendPaidMessageStars = interfaceState.sendPaidMessageStars {
|
||||||
|
contentType = .starsRequired(sendPaidMessageStars.value)
|
||||||
} else {
|
} else {
|
||||||
contentType = .regular
|
contentType = .regular
|
||||||
}
|
}
|
||||||
|
@ -2429,6 +2429,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
|
|||||||
var mediaInfoSizeApply: (CGSize, (Bool) -> ChatMessageStarsMediaInfoNode?) = (CGSize(), { _ in nil })
|
var mediaInfoSizeApply: (CGSize, (Bool) -> ChatMessageStarsMediaInfoNode?) = (CGSize(), { _ in nil })
|
||||||
|
|
||||||
var hasTitleAvatar = false
|
var hasTitleAvatar = false
|
||||||
|
var hasTitleTopicNavigation = false
|
||||||
|
|
||||||
if displayHeader {
|
if displayHeader {
|
||||||
let bubbleWidthInsets: CGFloat = mosaicRange == nil ? layoutConstants.text.bubbleInsets.left + layoutConstants.text.bubbleInsets.right : 0.0
|
let bubbleWidthInsets: CGFloat = mosaicRange == nil ? layoutConstants.text.bubbleInsets.left + layoutConstants.text.bubbleInsets.right : 0.0
|
||||||
@ -2439,6 +2440,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
|
|||||||
|
|
||||||
if isSidePanelOpen && incoming {
|
if isSidePanelOpen && incoming {
|
||||||
hasTitleAvatar = true
|
hasTitleAvatar = true
|
||||||
|
hasTitleTopicNavigation = item.chatLocation.threadId == nil
|
||||||
}
|
}
|
||||||
|
|
||||||
let inlineBotNameColor = messageTheme.accentTextColor
|
let inlineBotNameColor = messageTheme.accentTextColor
|
||||||
@ -2544,7 +2546,10 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
|
|||||||
var nameAvatarSpaceWidth: CGFloat = 0.0
|
var nameAvatarSpaceWidth: CGFloat = 0.0
|
||||||
if hasTitleAvatar {
|
if hasTitleAvatar {
|
||||||
headerSize.height += 12.0
|
headerSize.height += 12.0
|
||||||
nameAvatarSpaceWidth += 26.0 + 5.0 + 4.0 + 26.0
|
nameAvatarSpaceWidth += 26.0 + 5.0
|
||||||
|
if hasTitleTopicNavigation {
|
||||||
|
nameAvatarSpaceWidth += 4.0 + 26.0
|
||||||
|
}
|
||||||
nameNodeOriginY += 5.0
|
nameNodeOriginY += 5.0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3285,6 +3290,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
|
|||||||
contentOrigin: contentOrigin,
|
contentOrigin: contentOrigin,
|
||||||
nameNodeOriginY: nameNodeOriginY + detachedContentNodesHeight + additionalTopHeight,
|
nameNodeOriginY: nameNodeOriginY + detachedContentNodesHeight + additionalTopHeight,
|
||||||
hasTitleAvatar: hasTitleAvatar,
|
hasTitleAvatar: hasTitleAvatar,
|
||||||
|
hasTitleTopicNavigation: hasTitleTopicNavigation,
|
||||||
authorNameColor: authorNameColor,
|
authorNameColor: authorNameColor,
|
||||||
layoutConstants: layoutConstants,
|
layoutConstants: layoutConstants,
|
||||||
currentCredibilityIcon: currentCredibilityIcon,
|
currentCredibilityIcon: currentCredibilityIcon,
|
||||||
@ -3348,6 +3354,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
|
|||||||
contentOrigin: CGPoint,
|
contentOrigin: CGPoint,
|
||||||
nameNodeOriginY: CGFloat,
|
nameNodeOriginY: CGFloat,
|
||||||
hasTitleAvatar: Bool,
|
hasTitleAvatar: Bool,
|
||||||
|
hasTitleTopicNavigation: Bool,
|
||||||
authorNameColor: UIColor?,
|
authorNameColor: UIColor?,
|
||||||
layoutConstants: ChatMessageItemLayoutConstants,
|
layoutConstants: ChatMessageItemLayoutConstants,
|
||||||
currentCredibilityIcon: (EmojiStatusComponent.Content, UIColor?)?,
|
currentCredibilityIcon: (EmojiStatusComponent.Content, UIColor?)?,
|
||||||
@ -3538,21 +3545,6 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
|
|||||||
strongSelf.clippingNode.addSubnode(nameAvatarNode)
|
strongSelf.clippingNode.addSubnode(nameAvatarNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
let nameNavigateButton: NameNavigateButton
|
|
||||||
if let current = strongSelf.nameNavigateButton {
|
|
||||||
nameNavigateButton = current
|
|
||||||
} else {
|
|
||||||
nameNavigateButton = NameNavigateButton(frame: CGRect())
|
|
||||||
strongSelf.nameNavigateButton = nameNavigateButton
|
|
||||||
strongSelf.clippingNode.view.addSubview(nameNavigateButton)
|
|
||||||
nameNavigateButton.action = { [weak strongSelf] in
|
|
||||||
guard let strongSelf, let item = strongSelf.item else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
item.controllerInteraction.updateChatLocationThread(item.content.firstMessage.threadId, nil)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let nameAvatarFrame = CGRect(origin: CGPoint(x: nameNodeFrame.minX, y: nameNodeFrame.minY - 4.0), size: CGSize(width: 26.0, height: 26.0))
|
let nameAvatarFrame = CGRect(origin: CGPoint(x: nameNodeFrame.minX, y: nameNodeFrame.minY - 4.0), size: CGSize(width: 26.0, height: 26.0))
|
||||||
let nameNavigateFrame = CGRect(origin: CGPoint(x: nameNodeFrame.maxX + 4.0 + nameNavigateButtonOffset, y: nameNodeFrame.minY - 4.0), size: CGSize(width: 26.0, height: 26.0))
|
let nameNavigateFrame = CGRect(origin: CGPoint(x: nameNodeFrame.maxX + 4.0 + nameNavigateButtonOffset, y: nameNodeFrame.minY - 4.0), size: CGSize(width: 26.0, height: 26.0))
|
||||||
|
|
||||||
@ -3563,11 +3555,38 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
|
|||||||
}
|
}
|
||||||
nameAvatarNode.updateSize(size: nameAvatarFrame.size)
|
nameAvatarNode.updateSize(size: nameAvatarFrame.size)
|
||||||
|
|
||||||
nameNavigateButton.update(size: nameNavigateFrame.size, color: authorNameColor ?? item.presentationData.theme.theme.chat.message.incoming.accentTextColor)
|
if hasTitleTopicNavigation {
|
||||||
|
let nameNavigateButton: NameNavigateButton
|
||||||
|
if let current = strongSelf.nameNavigateButton {
|
||||||
|
nameNavigateButton = current
|
||||||
|
} else {
|
||||||
|
nameNavigateButton = NameNavigateButton(frame: CGRect())
|
||||||
|
strongSelf.nameNavigateButton = nameNavigateButton
|
||||||
|
strongSelf.clippingNode.view.addSubview(nameNavigateButton)
|
||||||
|
nameNavigateButton.action = { [weak strongSelf] in
|
||||||
|
guard let strongSelf, let item = strongSelf.item else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
item.controllerInteraction.updateChatLocationThread(item.content.firstMessage.threadId, nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nameNavigateButton.update(size: nameNavigateFrame.size, color: authorNameColor ?? item.presentationData.theme.theme.chat.message.incoming.accentTextColor)
|
||||||
|
} else {
|
||||||
|
if let nameNavigateButton = strongSelf.nameNavigateButton {
|
||||||
|
strongSelf.nameNavigateButton = nil
|
||||||
|
nameNavigateButton.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.1, removeOnCompletion: false, completion: { [weak nameNavigateButton] _ in
|
||||||
|
nameNavigateButton?.removeFromSuperview()
|
||||||
|
})
|
||||||
|
animation.animator.updateFrame(layer: nameNavigateButton.layer, frame: CGRect(origin: CGPoint(x: nameNodeFrame.maxX + nameNavigateButtonOffset - 26.0 * 0.5, y: nameNodeFrame.minY - 4.0), size: CGSize(width: 26.0, height: 26.0)), completion: nil)
|
||||||
|
animation.transition.updateTransformScale(layer: nameNavigateButton.layer, scale: CGPoint(x: 0.001, y: 0.001))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if animateNameAvatar {
|
if animateNameAvatar {
|
||||||
animation.animator.updateFrame(layer: nameAvatarNode.layer, frame: nameAvatarFrame, completion: nil)
|
animation.animator.updateFrame(layer: nameAvatarNode.layer, frame: nameAvatarFrame, completion: nil)
|
||||||
animation.animator.updateFrame(layer: nameNavigateButton.layer, frame: nameNavigateFrame, completion: nil)
|
if let nameNavigateButton = strongSelf.nameNavigateButton {
|
||||||
|
animation.animator.updateFrame(layer: nameNavigateButton.layer, frame: nameNavigateFrame, completion: nil)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
nameAvatarNode.frame = CGRect(origin: CGPoint(x: previousNameNodeFrame.minX - 26.0 * 0.5, y: previousNameNodeFrame.minY - 4.0), size: CGSize(width: 26.0, height: 26.0))
|
nameAvatarNode.frame = CGRect(origin: CGPoint(x: previousNameNodeFrame.minX - 26.0 * 0.5, y: previousNameNodeFrame.minY - 4.0), size: CGSize(width: 26.0, height: 26.0))
|
||||||
animation.animator.updateFrame(layer: nameAvatarNode.layer, frame: nameAvatarFrame, completion: nil)
|
animation.animator.updateFrame(layer: nameAvatarNode.layer, frame: nameAvatarFrame, completion: nil)
|
||||||
@ -3576,11 +3595,13 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
|
|||||||
nameAvatarNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.1)
|
nameAvatarNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.1)
|
||||||
}
|
}
|
||||||
|
|
||||||
nameNavigateButton.frame = CGRect(origin: CGPoint(x: previousNameNodeFrame.maxX + nameNavigateButtonOffset - 26.0 * 0.5, y: previousNameNodeFrame.minY - 4.0), size: CGSize(width: 26.0, height: 26.0))
|
if let nameNavigateButton = strongSelf.nameNavigateButton {
|
||||||
animation.animator.updateFrame(layer: nameNavigateButton.layer, frame: nameNavigateFrame, completion: nil)
|
nameNavigateButton.frame = CGRect(origin: CGPoint(x: previousNameNodeFrame.maxX + nameNavigateButtonOffset - 26.0 * 0.5, y: previousNameNodeFrame.minY - 4.0), size: CGSize(width: 26.0, height: 26.0))
|
||||||
if animation.isAnimated {
|
animation.animator.updateFrame(layer: nameNavigateButton.layer, frame: nameNavigateFrame, completion: nil)
|
||||||
animation.transition.animateTransformScale(view: nameNavigateButton, from: 0.001)
|
if animation.isAnimated {
|
||||||
nameNavigateButton.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.1)
|
animation.transition.animateTransformScale(view: nameNavigateButton, from: 0.001)
|
||||||
|
nameNavigateButton.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1857,8 +1857,6 @@ extension ChatControllerImpl {
|
|||||||
}
|
}
|
||||||
if globalRemainingUnreadChatCount > 0 {
|
if globalRemainingUnreadChatCount > 0 {
|
||||||
strongSelf.initialNavigationBadge = "\(globalRemainingUnreadChatCount)"
|
strongSelf.initialNavigationBadge = "\(globalRemainingUnreadChatCount)"
|
||||||
} else {
|
|
||||||
strongSelf.initialNavigationBadge = ""
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1409,11 +1409,11 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG
|
/*#if DEBUG
|
||||||
if "".isEmpty {
|
if "".isEmpty {
|
||||||
hasTranslationPanel = true
|
hasTranslationPanel = true
|
||||||
}
|
}
|
||||||
#endif
|
#endif*/
|
||||||
|
|
||||||
if hasTranslationPanel {
|
if hasTranslationPanel {
|
||||||
let translationPanelNode: ChatTranslationPanelNode
|
let translationPanelNode: ChatTranslationPanelNode
|
||||||
|
@ -135,6 +135,20 @@ func chatHistoryEntriesForView(
|
|||||||
continue loop
|
continue loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if case .peer = location {
|
||||||
|
for media in message.media {
|
||||||
|
if let action = media as? TelegramMediaAction, case .groupCreated = action.action {
|
||||||
|
var chatPeer: Peer?
|
||||||
|
for entry in view.additionalData {
|
||||||
|
if case let .peer(_, peer) = entry {
|
||||||
|
chatPeer = peer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let channel = chatPeer as? TelegramChannel, channel.isMonoForum {
|
||||||
|
continue loop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
count += 1
|
count += 1
|
||||||
|
@ -167,7 +167,7 @@ final class ChatTranslationPanelNode: ASDisplayNode {
|
|||||||
let buttonTextSize = self.buttonTextNode.updateLayout(CGSize(width: width - contentRightInset - moreButtonSize.width, height: panelHeight))
|
let buttonTextSize = self.buttonTextNode.updateLayout(CGSize(width: width - contentRightInset - moreButtonSize.width, height: panelHeight))
|
||||||
if let icon = self.buttonIconNode.image {
|
if let icon = self.buttonIconNode.image {
|
||||||
let buttonSize = CGSize(width: buttonTextSize.width + icon.size.width + buttonSpacing + buttonPadding * 2.0, height: panelHeight)
|
let buttonSize = CGSize(width: buttonTextSize.width + icon.size.width + buttonSpacing + buttonPadding * 2.0, height: panelHeight)
|
||||||
transition.updateFrame(node: self.button, frame: CGRect(origin: CGPoint(x: floorToScreenPixels((width - buttonSize.width) / 2.0), y: 0.0), size: buttonSize))
|
transition.updateFrame(node: self.button, frame: CGRect(origin: CGPoint(x: leftInset + floorToScreenPixels((width - leftInset - rightInset - buttonSize.width) / 2.0), y: 0.0), size: buttonSize))
|
||||||
|
|
||||||
transition.updateFrame(node: self.buttonIconNode, frame: CGRect(origin: CGPoint(x: buttonPadding, y: floorToScreenPixels((buttonSize.height - icon.size.height) / 2.0)), size: icon.size))
|
transition.updateFrame(node: self.buttonIconNode, frame: CGRect(origin: CGPoint(x: buttonPadding, y: floorToScreenPixels((buttonSize.height - icon.size.height) / 2.0)), size: icon.size))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user