diff --git a/submodules/AccountContext/Sources/AccountContext.swift b/submodules/AccountContext/Sources/AccountContext.swift index a3f413e354..44762593d8 100644 --- a/submodules/AccountContext/Sources/AccountContext.swift +++ b/submodules/AccountContext/Sources/AccountContext.swift @@ -356,34 +356,27 @@ public enum ChatSearchDomain: Equatable { case everything case members case member(Peer) - case tag(String) public static func ==(lhs: ChatSearchDomain, rhs: ChatSearchDomain) -> Bool { switch lhs { - case .everything: - if case .everything = rhs { - return true - } else { - return false - } - case .members: - if case .members = rhs { - return true - } else { - return false - } - case let .member(lhsPeer): - if case let .member(rhsPeer) = rhs, lhsPeer.isEqual(rhsPeer) { - return true - } else { - return false - } - case let .tag(tag): - if case .tag(tag) = rhs { - return true - } else { - return false - } + case .everything: + if case .everything = rhs { + return true + } else { + return false + } + case .members: + if case .members = rhs { + return true + } else { + return false + } + case let .member(lhsPeer): + if case let .member(rhsPeer) = rhs, lhsPeer.isEqual(rhsPeer) { + return true + } else { + return false + } } } } diff --git a/submodules/AvatarNode/Sources/AvatarNode.swift b/submodules/AvatarNode/Sources/AvatarNode.swift index b9428f29a9..1f2b11790c 100644 --- a/submodules/AvatarNode/Sources/AvatarNode.swift +++ b/submodules/AvatarNode/Sources/AvatarNode.swift @@ -22,7 +22,6 @@ public let repostStoryIcon = generateTintedImage(image: UIImage(bundleImageName: private let archivedChatsIcon = UIImage(bundleImageName: "Avatar/ArchiveAvatarIcon")?.precomposed() private let repliesIcon = generateTintedImage(image: UIImage(bundleImageName: "Avatar/RepliesMessagesIcon"), color: .white) private let anonymousSavedMessagesIcon = generateTintedImage(image: UIImage(bundleImageName: "Avatar/AnonymousSenderIcon"), color: .white) -private let myNotesIcon = generateTintedImage(image: UIImage(bundleImageName: "Avatar/MyNotesIcon"), color: .white) public func avatarPlaceholderFont(size: CGFloat) -> UIFont { return Font.with(size: size, design: .round, weight: .bold) @@ -96,8 +95,6 @@ private func calculateColors(context: AccountContext?, explicitColorIndex: Int?, colors = AvatarNode.savedMessagesColors } else if case .anonymousSavedMessagesIcon = icon { colors = AvatarNode.savedMessagesColors - } else if case .myNotesIcon = icon { - colors = AvatarNode.savedMessagesColors } else if case .editAvatarIcon = icon, let theme { colors = [theme.list.itemAccentColor.withAlphaComponent(0.1), theme.list.itemAccentColor.withAlphaComponent(0.1)] } else if case let .archivedChatsIcon(hiddenByDefault) = icon, let theme = theme { @@ -179,7 +176,6 @@ private enum AvatarNodeIcon: Equatable { case savedMessagesIcon case repliesIcon case anonymousSavedMessagesIcon - case myNotesIcon case archivedChatsIcon(hiddenByDefault: Bool) case editAvatarIcon case deletedIcon @@ -193,7 +189,6 @@ public enum AvatarNodeImageOverride: Equatable { case savedMessagesIcon case repliesIcon case anonymousSavedMessagesIcon - case myNotesIcon case archivedChatsIcon(hiddenByDefault: Bool) case editAvatarIcon(forceNone: Bool) case deletedIcon @@ -497,9 +492,6 @@ public final class AvatarNode: ASDisplayNode { case .anonymousSavedMessagesIcon: representation = nil icon = .anonymousSavedMessagesIcon - case .myNotesIcon: - representation = nil - icon = .myNotesIcon case let .archivedChatsIcon(hiddenByDefault): representation = nil icon = .archivedChatsIcon(hiddenByDefault: hiddenByDefault) @@ -670,9 +662,6 @@ public final class AvatarNode: ASDisplayNode { case .anonymousSavedMessagesIcon: representation = nil icon = .anonymousSavedMessagesIcon - case .myNotesIcon: - representation = nil - icon = .myNotesIcon case let .archivedChatsIcon(hiddenByDefault): representation = nil icon = .archivedChatsIcon(hiddenByDefault: hiddenByDefault) @@ -912,15 +901,6 @@ public final class AvatarNode: ASDisplayNode { if let anonymousSavedMessagesIcon = anonymousSavedMessagesIcon { context.draw(anonymousSavedMessagesIcon.cgImage!, in: CGRect(origin: CGPoint(x: floor((bounds.size.width - anonymousSavedMessagesIcon.size.width) / 2.0), y: floor((bounds.size.height - anonymousSavedMessagesIcon.size.height) / 2.0)), size: anonymousSavedMessagesIcon.size)) } - } else if case .myNotesIcon = parameters.icon { - let factor = bounds.size.width / 60.0 - context.translateBy(x: bounds.size.width / 2.0, y: bounds.size.height / 2.0) - context.scaleBy(x: factor, y: -factor) - context.translateBy(x: -bounds.size.width / 2.0, y: -bounds.size.height / 2.0) - - if let myNotesIcon = myNotesIcon { - context.draw(myNotesIcon.cgImage!, in: CGRect(origin: CGPoint(x: floor((bounds.size.width - myNotesIcon.size.width) / 2.0), y: floor((bounds.size.height - myNotesIcon.size.height) / 2.0)), size: myNotesIcon.size)) - } } else if case .editAvatarIcon = parameters.icon, let theme = parameters.theme, !parameters.hasImage { context.translateBy(x: bounds.size.width / 2.0, y: bounds.size.height / 2.0) context.scaleBy(x: 1.0, y: -1.0) diff --git a/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift b/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift index 9911b6671e..16c58d9e39 100644 --- a/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift +++ b/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift @@ -217,7 +217,7 @@ private enum ChatListRecentEntry: Comparable, Identifiable { sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, - peerMode: .generalSearch(isSavedMessages: false), + peerMode: .generalSearch, peer: .peer(peer: primaryPeer, chatPeer: chatPeer), status: status, badge: badge, @@ -508,7 +508,7 @@ public enum ChatListSearchEntry: Comparable, Identifiable { toggleExpandGlobalResults() }) - return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: .firstLast, displayOrder: .firstLast, context: context, peerMode: .generalSearch(isSavedMessages: false), peer: .thread(peer: peer, title: threadInfo.info.title, icon: threadInfo.info.icon, color: threadInfo.info.iconColor), status: .none, badge: nil, enabled: true, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: header, action: { _ in + return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: .firstLast, displayOrder: .firstLast, context: context, peerMode: .generalSearch, peer: .thread(peer: peer, title: threadInfo.info.title, icon: threadInfo.info.icon, color: threadInfo.info.iconColor), status: .none, badge: nil, enabled: true, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: header, action: { _ in interaction.peerSelected(peer, nil, threadInfo.id, nil) }, contextAction: nil, animationCache: interaction.animationCache, animationRenderer: interaction.animationRenderer) case let .recentlySearchedPeer(peer, associatedPeer, unreadBadge, _, theme, strings, nameSortOrder, nameDisplayOrder, storyStats): @@ -572,7 +572,7 @@ public enum ChatListSearchEntry: Comparable, Identifiable { header = ChatListSearchItemHeader(type: headerType, theme: theme, strings: strings, actionTitle: nil, action: nil) } - return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .generalSearch(isSavedMessages: false), peer: .peer(peer: primaryPeer, chatPeer: chatPeer), status: .none, badge: badge, enabled: enabled, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: header, action: { contactPeer in + return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .generalSearch, peer: .peer(peer: primaryPeer, chatPeer: chatPeer), status: .none, badge: badge, enabled: enabled, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: header, action: { contactPeer in if case let .peer(maybePeer, maybeChatPeer) = contactPeer, let peer = maybePeer, let chatPeer = maybeChatPeer { interaction.peerSelected(chatPeer, peer, nil, nil) } else { @@ -671,12 +671,8 @@ public enum ChatListSearchEntry: Comparable, Identifiable { toggleExpandLocalResults() }) } - var isSavedMessages = false - if case .savedMessagesChats = location { - isSavedMessages = true - } - return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .generalSearch(isSavedMessages: isSavedMessages), peer: .peer(peer: primaryPeer, chatPeer: chatPeer), status: .none, badge: badge, enabled: enabled, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: header, action: { contactPeer in + return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .generalSearch, peer: .peer(peer: primaryPeer, chatPeer: chatPeer), status: .none, badge: badge, enabled: enabled, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: header, action: { contactPeer in if case let .peer(maybePeer, maybeChatPeer) = contactPeer, let peer = maybePeer, let chatPeer = maybeChatPeer { interaction.peerSelected(chatPeer, peer, nil, nil) } else { @@ -751,13 +747,8 @@ public enum ChatListSearchEntry: Comparable, Identifiable { toggleExpandGlobalResults() }) } - - var isSavedMessages = false - if case .savedMessagesChats = location { - isSavedMessages = true - } - return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .generalSearch(isSavedMessages: isSavedMessages), peer: .peer(peer: EnginePeer(peer.peer), chatPeer: EnginePeer(peer.peer)), status: .addressName(suffixString), badge: badge, enabled: enabled, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: header, action: { _ in + return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .generalSearch, peer: .peer(peer: EnginePeer(peer.peer), chatPeer: EnginePeer(peer.peer)), status: .addressName(suffixString), badge: badge, enabled: enabled, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: header, action: { _ in interaction.peerSelected(EnginePeer(peer.peer), nil, nil, nil) }, contextAction: peerContextAction.flatMap { peerContextAction in return { node, gesture, location in @@ -1423,9 +1414,8 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode { if let query { foundLocalPeers = context.engine.messages.searchLocalSavedMessagesPeers(query: query.lowercased(), indexNameMapping: [ context.account.peerId: [ - PeerIndexNameRepresentation.title(title: "my notes", addressNames: []), - //TODO:localize - PeerIndexNameRepresentation.title(title: "my notes".lowercased(), addressNames: []) + PeerIndexNameRepresentation.title(title: "saved messages", addressNames: []), + PeerIndexNameRepresentation.title(title: presentationData.strings.DialogList_SavedMessages.lowercased(), addressNames: []) ], PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(2666000)): [ PeerIndexNameRepresentation.title(title: presentationData.strings.ChatList_AuthorHidden.lowercased(), addressNames: []) diff --git a/submodules/ChatListUI/Sources/Node/ChatListItem.swift b/submodules/ChatListUI/Sources/Node/ChatListItem.swift index 77d1077e14..073dc6b043 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListItem.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListItem.swift @@ -1406,11 +1406,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { } else if peer.id.isAnonymousSavedMessages { overrideImage = .anonymousSavedMessagesIcon } else if peer.id == item.context.account.peerId && !displayAsMessage { - if case .savedMessagesChats = item.chatListLocation { - overrideImage = .myNotesIcon - } else { - overrideImage = .savedMessagesIcon - } + overrideImage = .savedMessagesIcon } else if peer.isDeleted { overrideImage = .deletedIcon } @@ -2306,12 +2302,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { } else if isPeerGroup { titleAttributedString = NSAttributedString(string: item.presentationData.strings.ChatList_ArchivedChatsTitle, font: titleFont, textColor: theme.titleColor) } else if itemPeer.chatMainPeer?.id == item.context.account.peerId { - if case .savedMessagesChats = item.chatListLocation { - //TODO:localize - titleAttributedString = NSAttributedString(string: "My Notes", font: titleFont, textColor: theme.titleColor) - } else { - titleAttributedString = NSAttributedString(string: item.presentationData.strings.DialogList_SavedMessages, font: titleFont, textColor: theme.titleColor) - } + titleAttributedString = NSAttributedString(string: item.presentationData.strings.DialogList_SavedMessages, font: titleFont, textColor: theme.titleColor) } else if let id = itemPeer.chatMainPeer?.id, id.isReplies { titleAttributedString = NSAttributedString(string: item.presentationData.strings.DialogList_Replies, font: titleFont, textColor: theme.titleColor) } else if let id = itemPeer.chatMainPeer?.id, id.isAnonymousSavedMessages { @@ -2617,8 +2608,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { var isFirstForumThreadSelectable = false var forumThreads: [(id: Int64, title: NSAttributedString, iconId: Int64?, iconColor: Int32)] = [] - if case .savedMessagesChats = item.chatListLocation { - } else if forumThread != nil || !topForumTopicItems.isEmpty { + if forumThread != nil || !topForumTopicItems.isEmpty { if let forumThread = forumThread { 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)) diff --git a/submodules/ChatListUI/Sources/Node/ChatListNode.swift b/submodules/ChatListUI/Sources/Node/ChatListNode.swift index 16dff19e41..9c74232736 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListNode.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListNode.swift @@ -580,7 +580,7 @@ private func mappedInsertEntries(context: AccountContext, nodeInteraction: ChatL sortOrder: presentationData.nameSortOrder, displayOrder: presentationData.nameDisplayOrder, context: context, - peerMode: .generalSearch(isSavedMessages: false), + peerMode: .generalSearch, peer: peerContent, status: status, enabled: enabled, @@ -619,7 +619,7 @@ private func mappedInsertEntries(context: AccountContext, nodeInteraction: ChatL sortOrder: presentationData.nameSortOrder, displayOrder: presentationData.nameDisplayOrder, context: context, - peerMode: .generalSearch(isSavedMessages: false), + peerMode: .generalSearch, peer: peerContent, status: status, enabled: true, @@ -681,7 +681,7 @@ private func mappedInsertEntries(context: AccountContext, nodeInteraction: ChatL sortOrder: presentationData.nameSortOrder, displayOrder: presentationData.nameDisplayOrder, context: context, - peerMode: .generalSearch(isSavedMessages: false), + peerMode: .generalSearch, peer: peerContent, status: status, enabled: true, @@ -899,7 +899,7 @@ private func mappedUpdateEntries(context: AccountContext, nodeInteraction: ChatL sortOrder: presentationData.nameSortOrder, displayOrder: presentationData.nameDisplayOrder, context: context, - peerMode: .generalSearch(isSavedMessages: false), + peerMode: .generalSearch, peer: peerContent, status: status, enabled: enabled, @@ -938,7 +938,7 @@ private func mappedUpdateEntries(context: AccountContext, nodeInteraction: ChatL sortOrder: presentationData.nameSortOrder, displayOrder: presentationData.nameDisplayOrder, context: context, - peerMode: .generalSearch(isSavedMessages: false), + peerMode: .generalSearch, peer: peerContent, status: status, enabled: true, @@ -1000,7 +1000,7 @@ private func mappedUpdateEntries(context: AccountContext, nodeInteraction: ChatL sortOrder: presentationData.nameSortOrder, displayOrder: presentationData.nameDisplayOrder, context: context, - peerMode: .generalSearch(isSavedMessages: false), + peerMode: .generalSearch, peer: peerContent, status: status, enabled: true, diff --git a/submodules/Components/ReactionButtonListComponent/BUILD b/submodules/Components/ReactionButtonListComponent/BUILD index f8167464d8..93fc5e91c1 100644 --- a/submodules/Components/ReactionButtonListComponent/BUILD +++ b/submodules/Components/ReactionButtonListComponent/BUILD @@ -24,7 +24,6 @@ swift_library( "//submodules/TelegramUI/Components/AnimationCache:AnimationCache", "//submodules/TelegramUI/Components/MultiAnimationRenderer:MultiAnimationRenderer", "//submodules/TextFormat:TextFormat", - "//submodules/AppBundle", ], visibility = [ "//visibility:public", diff --git a/submodules/Components/ReactionButtonListComponent/Sources/ReactionButtonListComponent.swift b/submodules/Components/ReactionButtonListComponent/Sources/ReactionButtonListComponent.swift index 64f9946729..f01e91d457 100644 --- a/submodules/Components/ReactionButtonListComponent/Sources/ReactionButtonListComponent.swift +++ b/submodules/Components/ReactionButtonListComponent/Sources/ReactionButtonListComponent.swift @@ -14,11 +14,6 @@ import AnimationCache import MultiAnimationRenderer import EmojiTextAttachmentView import TextFormat -import AppBundle - -private let tagImage: UIImage? = { - return generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/ReactionTagBackground"), color: .white)?.stretchableImage(withLeftCapWidth: 8, topCapHeight: 15) -}() public final class ReactionIconView: PortalSourceView { private var animationLayer: InlineStickerItemLayer? @@ -278,7 +273,6 @@ public final class ReactionButtonAsyncNode: ContextControllerSourceView { var colors: Colors var size: CGSize var counter: Counter? - var isTag: Bool } private struct AnimationState { @@ -372,116 +366,98 @@ public final class ReactionButtonAsyncNode: ContextControllerSourceView { let animationState = self.animationState DispatchQueue.global().async { [weak self] in - let image = generateImage(layout.size, rotatedContext: { size, context in - context.clear(CGRect(origin: CGPoint(), size: size)) - UIGraphicsPushContext(context) - - func drawContents(colors: Colors) { - let backgroundColor: UIColor - let foregroundColor: UIColor - if isExtracted { - backgroundColor = UIColor(argb: colors.extractedBackground) - foregroundColor = UIColor(argb: colors.extractedForeground) - } else { - backgroundColor = UIColor(argb: colors.background) - foregroundColor = UIColor(argb: colors.foreground) - } - - context.setBlendMode(.copy) + var image: UIImage? + + if true { + image = generateImage(layout.size, rotatedContext: { size, context in + context.clear(CGRect(origin: CGPoint(), size: size)) + UIGraphicsPushContext(context) - if layout.isTag { - if let tagImage { - let rect = CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: size.height)) - - context.setFillColor(UIColor(rgb: layout.colors.background).cgColor) - context.fill(rect) - - UIGraphicsPushContext(context) - tagImage.draw(in: rect, blendMode: .destinationIn, alpha: 1.0) - UIGraphicsPopContext() - - context.setBlendMode(.destinationIn) - context.setFillColor(UIColor(white: 1.0, alpha: 0.5).cgColor) - context.fillEllipse(in: CGRect(origin: CGPoint(x: rect.width - 6.0 - 6.0, y: floor((rect.height - 6.0) * 0.5)), size: CGSize(width: 6.0, height: 6.0))) - context.setBlendMode(.copy) + func drawContents(colors: Colors) { + let backgroundColor: UIColor + let foregroundColor: UIColor + if isExtracted { + backgroundColor = UIColor(argb: colors.extractedBackground) + foregroundColor = UIColor(argb: colors.extractedForeground) + } else { + backgroundColor = UIColor(argb: colors.background) + foregroundColor = UIColor(argb: colors.foreground) } - } else { + + context.setBlendMode(.copy) + context.setFillColor(backgroundColor.cgColor) context.fillEllipse(in: CGRect(origin: CGPoint(), size: CGSize(width: size.height, height: size.height))) context.fillEllipse(in: CGRect(origin: CGPoint(x: size.width - size.height, y: 0.0), size: CGSize(width: size.height, height: size.height))) context.fill(CGRect(origin: CGPoint(x: size.height / 2.0, y: 0.0), size: CGSize(width: size.width - size.height, height: size.height))) - } - - if let counter = layout.counter { - let isForegroundTransparent = foregroundColor.alpha < 1.0 - context.setBlendMode(isForegroundTransparent ? .copy : .normal) - - let textOrigin: CGFloat = 36.0 - - var rightTextOrigin = textOrigin + totalComponentWidth - - let animationFraction: CGFloat - if let animationState = animationState, animationState.fromCounter != nil { - animationFraction = max(0.0, min(1.0, (CACurrentMediaTime() - animationState.startTime) / animationState.duration)) - } else { - animationFraction = 1.0 - } - for i in (0 ..< counter.components.count).reversed() { - let component = counter.components[i] - var componentAlpha: CGFloat = 1.0 - var componentVerticalOffset: CGFloat = 0.0 + if let counter = layout.counter { + let isForegroundTransparent = foregroundColor.alpha < 1.0 + context.setBlendMode(isForegroundTransparent ? .copy : .normal) - if let animationState = animationState, let fromCounter = animationState.fromCounter { - let reverseIndex = counter.components.count - 1 - i - if reverseIndex < fromCounter.components.count { - let previousComponent = fromCounter.components[fromCounter.components.count - 1 - reverseIndex] - - if previousComponent != component { - componentAlpha = animationFraction - componentVerticalOffset = -(1.0 - animationFraction) * 8.0 - if previousComponent.string < component.string { - componentVerticalOffset = -componentVerticalOffset - } - - let previousComponentAlpha = 1.0 - componentAlpha - var previousComponentVerticalOffset = animationFraction * 8.0 - if previousComponent.string < component.string { - previousComponentVerticalOffset = -previousComponentVerticalOffset - } + let textOrigin: CGFloat = 36.0 + + var rightTextOrigin = textOrigin + totalComponentWidth + + let animationFraction: CGFloat + if let animationState = animationState, animationState.fromCounter != nil { + animationFraction = max(0.0, min(1.0, (CACurrentMediaTime() - animationState.startTime) / animationState.duration)) + } else { + animationFraction = 1.0 + } + + for i in (0 ..< counter.components.count).reversed() { + let component = counter.components[i] + var componentAlpha: CGFloat = 1.0 + var componentVerticalOffset: CGFloat = 0.0 + + if let animationState = animationState, let fromCounter = animationState.fromCounter { + let reverseIndex = counter.components.count - 1 - i + if reverseIndex < fromCounter.components.count { + let previousComponent = fromCounter.components[fromCounter.components.count - 1 - reverseIndex] - var componentOrigin = rightTextOrigin - previousComponent.bounds.width - componentOrigin = max(componentOrigin, layout.size.height / 2.0 + UIScreenPixel) - let previousColor: UIColor - if isForegroundTransparent { - previousColor = foregroundColor.mixedWith(backgroundColor, alpha: 1.0 - previousComponentAlpha) - } else { - previousColor = foregroundColor.withMultipliedAlpha(previousComponentAlpha) + if previousComponent != component { + componentAlpha = animationFraction + componentVerticalOffset = -(1.0 - animationFraction) * 8.0 + if previousComponent.string < component.string { + componentVerticalOffset = -componentVerticalOffset + } + + let previousComponentAlpha = 1.0 - componentAlpha + var previousComponentVerticalOffset = animationFraction * 8.0 + if previousComponent.string < component.string { + previousComponentVerticalOffset = -previousComponentVerticalOffset + } + + var componentOrigin = rightTextOrigin - previousComponent.bounds.width + componentOrigin = max(componentOrigin, layout.size.height / 2.0 + UIScreenPixel) + let previousColor: UIColor + if isForegroundTransparent { + previousColor = foregroundColor.mixedWith(backgroundColor, alpha: 1.0 - previousComponentAlpha) + } else { + previousColor = foregroundColor.withMultipliedAlpha(previousComponentAlpha) + } + let string = NSAttributedString(string: previousComponent.string, font: Font.medium(11.0), textColor: previousColor) + string.draw(at: previousComponent.bounds.origin.offsetBy(dx: componentOrigin, dy: floorToScreenPixels(size.height - previousComponent.bounds.height) / 2.0 + previousComponentVerticalOffset)) } - let string = NSAttributedString(string: previousComponent.string, font: Font.medium(11.0), textColor: previousColor) - string.draw(at: previousComponent.bounds.origin.offsetBy(dx: componentOrigin, dy: floorToScreenPixels(size.height - previousComponent.bounds.height) / 2.0 + previousComponentVerticalOffset)) } } + + let componentOrigin = rightTextOrigin - component.bounds.width + let currentColor: UIColor + if isForegroundTransparent { + currentColor = foregroundColor.mixedWith(backgroundColor, alpha: 1.0 - componentAlpha) + } else { + currentColor = foregroundColor.withMultipliedAlpha(componentAlpha) + } + let string = NSAttributedString(string: component.string, font: Font.medium(11.0), textColor: currentColor) + string.draw(at: component.bounds.origin.offsetBy(dx: componentOrigin, dy: floorToScreenPixels(size.height - component.bounds.height) / 2.0 + componentVerticalOffset)) + + rightTextOrigin -= component.bounds.width } - - let componentOrigin = rightTextOrigin - component.bounds.width - let currentColor: UIColor - if isForegroundTransparent { - currentColor = foregroundColor.mixedWith(backgroundColor, alpha: 1.0 - componentAlpha) - } else { - currentColor = foregroundColor.withMultipliedAlpha(componentAlpha) - } - let string = NSAttributedString(string: component.string, font: Font.medium(11.0), textColor: currentColor) - string.draw(at: component.bounds.origin.offsetBy(dx: componentOrigin, dy: floorToScreenPixels(size.height - component.bounds.height) / 2.0 + componentVerticalOffset)) - - rightTextOrigin -= component.bounds.width } } - } - - if layout.isTag { - drawContents(colors: layout.colors) - } else { + if let animationState = animationState, animationState.fromColors.isSelected != layout.colors.isSelected { var animationFraction: CGFloat = max(0.0, min(1.0, (CACurrentMediaTime() - animationState.startTime) / animationState.duration)) if !layout.colors.isSelected { @@ -497,7 +473,7 @@ public final class ReactionButtonAsyncNode: ContextControllerSourceView { drawContents(colors: layout.colors.isSelected ? layout.colors : animationState.fromColors) context.resetClip() - + context.beginPath() context.addRect(CGRect(origin: CGPoint(), size: size)) context.addEllipse(in: CGRect(origin: CGPoint(x: center.x - diameter / 2.0, y: center.y - diameter / 2.0), size: CGSize(width: diameter, height: diameter))) @@ -506,10 +482,10 @@ public final class ReactionButtonAsyncNode: ContextControllerSourceView { } else { drawContents(colors: layout.colors) } - } - - UIGraphicsPopContext() - }) + + UIGraphicsPopContext() + }) + } DispatchQueue.main.async { if let strongSelf = self, let image = image { @@ -665,13 +641,7 @@ public final class ReactionButtonAsyncNode: ContextControllerSourceView { let backgroundColor = spec.component.chosenOrder != nil ? spec.component.colors.selectedBackground : spec.component.colors.deselectedBackground - let imageFrame: CGRect - if spec.component.isTag { - imageFrame = CGRect(origin: CGPoint(x: 6.0 + floorToScreenPixels((boundingImageSize.width - imageSize.width) / 2.0), y: floorToScreenPixels((height - imageSize.height) / 2.0)), size: imageSize) - } else { - imageFrame = CGRect(origin: CGPoint(x: sideInsets + floorToScreenPixels((boundingImageSize.width - imageSize.width) / 2.0), y: floorToScreenPixels((height - imageSize.height) / 2.0)), size: imageSize) - } - + let imageFrame = CGRect(origin: CGPoint(x: sideInsets + floorToScreenPixels((boundingImageSize.width - imageSize.width) / 2.0), y: floorToScreenPixels((height - imageSize.height) / 2.0)), size: imageSize) var counterLayout: CounterLayout? @@ -683,8 +653,6 @@ public final class ReactionButtonAsyncNode: ContextControllerSourceView { } else { size.width -= 2.0 } - } else if spec.component.isTag { - size.width += 2.0 } else { let counterSpec = CounterLayout.Spec( stringComponents: counterComponents @@ -718,8 +686,7 @@ public final class ReactionButtonAsyncNode: ContextControllerSourceView { let backgroundLayout = ContainerButtonNode.Layout( colors: backgroundColors, size: size, - counter: backgroundCounter, - isTag: spec.component.isTag + counter: backgroundCounter ) return Layout( @@ -1056,7 +1023,6 @@ public final class ReactionButtonComponent: Equatable { public let colors: Colors public let reaction: Reaction public let avatarPeers: [EnginePeer] - public let isTag: Bool public let count: Int public let chosenOrder: Int? public let action: (MessageReaction.Reaction) -> Void @@ -1066,7 +1032,6 @@ public final class ReactionButtonComponent: Equatable { colors: Colors, reaction: Reaction, avatarPeers: [EnginePeer], - isTag: Bool, count: Int, chosenOrder: Int?, action: @escaping (MessageReaction.Reaction) -> Void @@ -1075,7 +1040,6 @@ public final class ReactionButtonComponent: Equatable { self.colors = colors self.reaction = reaction self.avatarPeers = avatarPeers - self.isTag = isTag self.count = count self.chosenOrder = chosenOrder self.action = action @@ -1094,9 +1058,6 @@ public final class ReactionButtonComponent: Equatable { if lhs.avatarPeers != rhs.avatarPeers { return false } - if lhs.isTag != rhs.isTag { - return false - } if lhs.count != rhs.count { return false } @@ -1219,7 +1180,6 @@ public final class ReactionButtonsAsyncLayoutContainer { action: @escaping (MessageReaction.Reaction) -> Void, reactions: [ReactionButtonsAsyncLayoutContainer.Reaction], colors: ReactionButtonComponent.Colors, - isTag: Bool, constrainedWidth: CGFloat ) -> Result { var items: [Result.Item] = [] @@ -1268,9 +1228,8 @@ public final class ReactionButtonsAsyncLayoutContainer { context: context, colors: colors, reaction: reaction.reaction, - avatarPeers: isTag ? [] : avatarPeers, - isTag: isTag, - count: isTag ? 0 : reaction.count, + avatarPeers: avatarPeers, + count: reaction.count, chosenOrder: reaction.chosenOrder, action: action )) diff --git a/submodules/ContactListUI/Sources/ContactListNode.swift b/submodules/ContactListUI/Sources/ContactListNode.swift index 44bd193ef4..ed1c0318e3 100644 --- a/submodules/ContactListUI/Sources/ContactListNode.swift +++ b/submodules/ContactListUI/Sources/ContactListNode.swift @@ -213,7 +213,7 @@ private enum ContactListNodeEntry: Comparable, Identifiable { status = .custom(string: text, multiline: false, isActive: false, icon: nil) } - return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: isSearch ? .generalSearch(isSavedMessages: false) : .peer, peer: itemPeer, status: status, enabled: enabled, selection: selection, selectionPosition: .left, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), additionalActions: additionalActions, index: nil, header: header, action: { _ in + return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: isSearch ? .generalSearch : .peer, peer: itemPeer, status: status, enabled: enabled, selection: selection, selectionPosition: .left, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), additionalActions: additionalActions, index: nil, header: header, action: { _ in interaction.openPeer(peer, .generic) }, itemHighlighting: interaction.itemHighlighting, contextAction: itemContextAction, storyStats: storyStats, openStories: { peer, sourceNode in if case let .peer(peerValue, _) = peer, let peerValue { diff --git a/submodules/ContactsPeerItem/Sources/ContactsPeerItem.swift b/submodules/ContactsPeerItem/Sources/ContactsPeerItem.swift index 26b5e00c3d..5b834e9c73 100644 --- a/submodules/ContactsPeerItem/Sources/ContactsPeerItem.swift +++ b/submodules/ContactsPeerItem/Sources/ContactsPeerItem.swift @@ -63,8 +63,8 @@ public struct ContactsPeerItemEditing: Equatable { } } -public enum ContactsPeerItemPeerMode: Equatable { - case generalSearch(isSavedMessages: Bool) +public enum ContactsPeerItemPeerMode { + case generalSearch case peer } @@ -779,13 +779,8 @@ public class ContactsPeerItemNode: ItemListRevealOptionsItemNode { textColor = item.presentationData.theme.list.itemPrimaryTextColor } if case let .user(user) = peer { - if peer.id == item.context.account.peerId, case let .generalSearch(isSavedMessages) = item.peerMode { - if isSavedMessages { - //TODO:localize - titleAttributedString = NSAttributedString(string: "My Notes", font: titleBoldFont, textColor: textColor) - } else { - titleAttributedString = NSAttributedString(string: item.presentationData.strings.DialogList_SavedMessages, font: titleBoldFont, textColor: textColor) - } + if peer.id == item.context.account.peerId, case .generalSearch = item.peerMode { + titleAttributedString = NSAttributedString(string: item.presentationData.strings.DialogList_SavedMessages, font: titleBoldFont, textColor: textColor) } else if peer.id.isReplies { titleAttributedString = NSAttributedString(string: item.presentationData.strings.DialogList_Replies, font: titleBoldFont, textColor: textColor) } else if peer.id.isAnonymousSavedMessages { @@ -1033,12 +1028,8 @@ public class ContactsPeerItemNode: ItemListRevealOptionsItemNode { case let .peer(peer, _): if let peer = peer { var overrideImage: AvatarNodeImageOverride? - if peer.id == item.context.account.peerId, case let .generalSearch(isSavedMessages) = item.peerMode { - if isSavedMessages { - overrideImage = .myNotesIcon - } else { - overrideImage = .savedMessagesIcon - } + if peer.id == item.context.account.peerId, case .generalSearch = item.peerMode { + overrideImage = .savedMessagesIcon } else if peer.id.isReplies, case .generalSearch = item.peerMode { overrideImage = .repliesIcon } else if peer.id.isAnonymousSavedMessages, case .generalSearch = item.peerMode { diff --git a/submodules/ContextUI/Sources/ContextController.swift b/submodules/ContextUI/Sources/ContextController.swift index c93fd1fbb0..024be3fb41 100644 --- a/submodules/ContextUI/Sources/ContextController.swift +++ b/submodules/ContextUI/Sources/ContextController.swift @@ -2249,7 +2249,6 @@ public final class ContextController: ViewController, StandalonePresentableContr public var context: AccountContext? public var reactionItems: [ReactionContextItem] public var selectedReactionItems: Set - public var reactionsTitle: String? public var animationCache: AnimationCache? public var alwaysAllowPremiumReactions: Bool public var getEmojiContent: ((AnimationCache, MultiAnimationRenderer) -> Signal)? @@ -2264,7 +2263,6 @@ public final class ContextController: ViewController, StandalonePresentableContr context: AccountContext? = nil, reactionItems: [ReactionContextItem] = [], selectedReactionItems: Set = Set(), - reactionsTitle: String? = nil, animationCache: AnimationCache? = nil, alwaysAllowPremiumReactions: Bool = false, getEmojiContent: ((AnimationCache, MultiAnimationRenderer) -> Signal)? = nil, @@ -2279,7 +2277,6 @@ public final class ContextController: ViewController, StandalonePresentableContr self.animationCache = animationCache self.reactionItems = reactionItems self.selectedReactionItems = selectedReactionItems - self.reactionsTitle = reactionsTitle self.alwaysAllowPremiumReactions = alwaysAllowPremiumReactions self.getEmojiContent = getEmojiContent self.disablePositionLock = disablePositionLock @@ -2294,7 +2291,6 @@ public final class ContextController: ViewController, StandalonePresentableContr self.context = nil self.reactionItems = [] self.selectedReactionItems = Set() - self.reactionsTitle = nil self.alwaysAllowPremiumReactions = false self.getEmojiContent = nil self.disablePositionLock = false diff --git a/submodules/ContextUI/Sources/ContextControllerActionsStackNode.swift b/submodules/ContextUI/Sources/ContextControllerActionsStackNode.swift index 24fa282f17..bc065566e2 100644 --- a/submodules/ContextUI/Sources/ContextControllerActionsStackNode.swift +++ b/submodules/ContextUI/Sources/ContextControllerActionsStackNode.swift @@ -46,7 +46,7 @@ public protocol ContextControllerActionsStackItem: AnyObject { var id: AnyHashable? { get } var tip: ContextController.Tip? { get } var tipSignal: Signal? { get } - var reactionItems: (context: AccountContext, reactionItems: [ReactionContextItem], selectedReactionItems: Set, reactionsTitle: String?, animationCache: AnimationCache, alwaysAllowPremiumReactions: Bool, getEmojiContent: ((AnimationCache, MultiAnimationRenderer) -> Signal)?)? { get } + var reactionItems: (context: AccountContext, reactionItems: [ReactionContextItem], selectedReactionItems: Set, animationCache: AnimationCache, alwaysAllowPremiumReactions: Bool, getEmojiContent: ((AnimationCache, MultiAnimationRenderer) -> Signal)?)? { get } var dismissed: (() -> Void)? { get } } @@ -911,7 +911,7 @@ final class ContextControllerActionsListStackItem: ContextControllerActionsStack let id: AnyHashable? let items: [ContextMenuItem] - let reactionItems: (context: AccountContext, reactionItems: [ReactionContextItem], selectedReactionItems: Set, reactionsTitle: String?, animationCache: AnimationCache, alwaysAllowPremiumReactions: Bool, getEmojiContent: ((AnimationCache, MultiAnimationRenderer) -> Signal)?)? + let reactionItems: (context: AccountContext, reactionItems: [ReactionContextItem], selectedReactionItems: Set, animationCache: AnimationCache, alwaysAllowPremiumReactions: Bool, getEmojiContent: ((AnimationCache, MultiAnimationRenderer) -> Signal)?)? let tip: ContextController.Tip? let tipSignal: Signal? let dismissed: (() -> Void)? @@ -919,7 +919,7 @@ final class ContextControllerActionsListStackItem: ContextControllerActionsStack init( id: AnyHashable?, items: [ContextMenuItem], - reactionItems: (context: AccountContext, reactionItems: [ReactionContextItem], selectedReactionItems: Set, reactionsTitle: String?, animationCache: AnimationCache, alwaysAllowPremiumReactions: Bool, getEmojiContent: ((AnimationCache, MultiAnimationRenderer) -> Signal)?)?, + reactionItems: (context: AccountContext, reactionItems: [ReactionContextItem], selectedReactionItems: Set, animationCache: AnimationCache, alwaysAllowPremiumReactions: Bool, getEmojiContent: ((AnimationCache, MultiAnimationRenderer) -> Signal)?)?, tip: ContextController.Tip?, tipSignal: Signal?, dismissed: (() -> Void)? @@ -1009,7 +1009,7 @@ final class ContextControllerActionsCustomStackItem: ContextControllerActionsSta let id: AnyHashable? private let content: ContextControllerItemsContent - let reactionItems: (context: AccountContext, reactionItems: [ReactionContextItem], selectedReactionItems: Set, reactionsTitle: String?, animationCache: AnimationCache, alwaysAllowPremiumReactions: Bool, getEmojiContent: ((AnimationCache, MultiAnimationRenderer) -> Signal)?)? + let reactionItems: (context: AccountContext, reactionItems: [ReactionContextItem], selectedReactionItems: Set, animationCache: AnimationCache, alwaysAllowPremiumReactions: Bool, getEmojiContent: ((AnimationCache, MultiAnimationRenderer) -> Signal)?)? let tip: ContextController.Tip? let tipSignal: Signal? let dismissed: (() -> Void)? @@ -1017,7 +1017,7 @@ final class ContextControllerActionsCustomStackItem: ContextControllerActionsSta init( id: AnyHashable?, content: ContextControllerItemsContent, - reactionItems: (context: AccountContext, reactionItems: [ReactionContextItem], selectedReactionItems: Set, reactionsTitle: String?, animationCache: AnimationCache, alwaysAllowPremiumReactions: Bool, getEmojiContent: ((AnimationCache, MultiAnimationRenderer) -> Signal)?)?, + reactionItems: (context: AccountContext, reactionItems: [ReactionContextItem], selectedReactionItems: Set, animationCache: AnimationCache, alwaysAllowPremiumReactions: Bool, getEmojiContent: ((AnimationCache, MultiAnimationRenderer) -> Signal)?)?, tip: ContextController.Tip?, tipSignal: Signal?, dismissed: (() -> Void)? @@ -1046,9 +1046,9 @@ final class ContextControllerActionsCustomStackItem: ContextControllerActionsSta } func makeContextControllerActionsStackItem(items: ContextController.Items) -> [ContextControllerActionsStackItem] { - var reactionItems: (context: AccountContext, reactionItems: [ReactionContextItem], selectedReactionItems: Set, reactionsTitle: String?, animationCache: AnimationCache, alwaysAllowPremiumReactions: Bool, getEmojiContent: ((AnimationCache, MultiAnimationRenderer) -> Signal)?)? + var reactionItems: (context: AccountContext, reactionItems: [ReactionContextItem], selectedReactionItems: Set, animationCache: AnimationCache, alwaysAllowPremiumReactions: Bool, getEmojiContent: ((AnimationCache, MultiAnimationRenderer) -> Signal)?)? if let context = items.context, let animationCache = items.animationCache, !items.reactionItems.isEmpty { - reactionItems = (context, items.reactionItems, items.selectedReactionItems, reactionsTitle: items.reactionsTitle, animationCache, alwaysAllowPremiumReactions: items.alwaysAllowPremiumReactions, items.getEmojiContent) + reactionItems = (context, items.reactionItems, items.selectedReactionItems, animationCache, alwaysAllowPremiumReactions: items.alwaysAllowPremiumReactions, items.getEmojiContent) } switch items.content { case let .list(listItems): @@ -1172,7 +1172,7 @@ final class ContextControllerActionsStackNode: ASDisplayNode { var tip: ContextController.Tip? let tipSignal: Signal? var tipNode: InnerTextSelectionTipContainerNode? - let reactionItems: (context: AccountContext, reactionItems: [ReactionContextItem], selectedReactionItems: Set, reactionsTitle: String?, animationCache: AnimationCache, alwaysAllowPremiumReactions: Bool, getEmojiContent: ((AnimationCache, MultiAnimationRenderer) -> Signal)?)? + let reactionItems: (context: AccountContext, reactionItems: [ReactionContextItem], selectedReactionItems: Set, animationCache: AnimationCache, alwaysAllowPremiumReactions: Bool, getEmojiContent: ((AnimationCache, MultiAnimationRenderer) -> Signal)?)? let itemDismissed: (() -> Void)? var storedScrollingState: CGFloat? let positionLock: CGFloat? @@ -1187,7 +1187,7 @@ final class ContextControllerActionsStackNode: ASDisplayNode { item: ContextControllerActionsStackItem, tip: ContextController.Tip?, tipSignal: Signal?, - reactionItems: (context: AccountContext, reactionItems: [ReactionContextItem], selectedReactionItems: Set, reactionsTitle: String?, animationCache: AnimationCache, alwaysAllowPremiumReactions: Bool, getEmojiContent: ((AnimationCache, MultiAnimationRenderer) -> Signal)?)?, + reactionItems: (context: AccountContext, reactionItems: [ReactionContextItem], selectedReactionItems: Set, animationCache: AnimationCache, alwaysAllowPremiumReactions: Bool, getEmojiContent: ((AnimationCache, MultiAnimationRenderer) -> Signal)?)?, itemDismissed: (() -> Void)?, positionLock: CGFloat? ) { @@ -1338,7 +1338,7 @@ final class ContextControllerActionsStackNode: ASDisplayNode { private var selectionPanGesture: UIPanGestureRecognizer? - var topReactionItems: (context: AccountContext, reactionItems: [ReactionContextItem], selectedReactionItems: Set, reactionsTitle: String?, animationCache: AnimationCache, alwaysAllowPremiumReactions: Bool, getEmojiContent: ((AnimationCache, MultiAnimationRenderer) -> Signal)?)? { + var topReactionItems: (context: AccountContext, reactionItems: [ReactionContextItem], selectedReactionItems: Set, animationCache: AnimationCache, alwaysAllowPremiumReactions: Bool, getEmojiContent: ((AnimationCache, MultiAnimationRenderer) -> Signal)?)? { return self.itemContainers.last?.reactionItems } diff --git a/submodules/ContextUI/Sources/ContextControllerExtractedPresentationNode.swift b/submodules/ContextUI/Sources/ContextControllerExtractedPresentationNode.swift index fbeb50e9f8..9f18b5b3f4 100644 --- a/submodules/ContextUI/Sources/ContextControllerExtractedPresentationNode.swift +++ b/submodules/ContextUI/Sources/ContextControllerExtractedPresentationNode.swift @@ -381,16 +381,7 @@ final class ContextControllerExtractedPresentationNode: ASDisplayNode, ContextCo //TODO: } - if let result = self.scrollNode.hitTest(self.view.convert(point, to: self.scrollNode.view), with: event) { - if let reactionContextNode = self.reactionContextNode, reactionContextNode.isExpanded { - if result === self.actionsContainerNode.view { - return self.dismissTapNode.view - } - } - return result - } - - return nil + return self.scrollNode.hitTest(self.view.convert(point, to: self.scrollNode.view), with: event) } else { return nil } @@ -648,7 +639,6 @@ final class ContextControllerExtractedPresentationNode: ASDisplayNode, ContextCo presentationData: presentationData, items: reactionItems.reactionItems, selectedItems: reactionItems.selectedReactionItems, - title: reactionItems.reactionsTitle, alwaysAllowPremiumReactions: reactionItems.alwaysAllowPremiumReactions, getEmojiContent: reactionItems.getEmojiContent, isExpandedUpdated: { [weak self] transition in diff --git a/submodules/SearchBarNode/Sources/SearchBarNode.swift b/submodules/SearchBarNode/Sources/SearchBarNode.swift index fff5306619..d55566ef4c 100644 --- a/submodules/SearchBarNode/Sources/SearchBarNode.swift +++ b/submodules/SearchBarNode/Sources/SearchBarNode.swift @@ -46,17 +46,15 @@ public struct SearchBarToken { public let icon: UIImage? public let iconOffset: CGFloat? public let peer: (EnginePeer, AccountContext, PresentationTheme)? - public let isTag: Bool public let title: String public let style: Style? public let permanent: Bool - public init(id: AnyHashable, icon: UIImage?, iconOffset: CGFloat? = 0.0, peer: (EnginePeer, AccountContext, PresentationTheme)? = nil, isTag: Bool = false, title: String, style: Style? = nil, permanent: Bool) { + public init(id: AnyHashable, icon: UIImage?, iconOffset: CGFloat? = 0.0, peer: (EnginePeer, AccountContext, PresentationTheme)? = nil, title: String, style: Style? = nil, permanent: Bool) { self.id = id self.icon = icon self.iconOffset = iconOffset self.peer = peer - self.isTag = isTag self.title = title self.style = style self.permanent = permanent @@ -110,20 +108,15 @@ private final class TokenNode: ASDisplayNode { } else { self.containerNode.addSubnode(self.backgroundNode) - let backgroundColor = token.isTag ? theme.inputIcon.withMultipliedAlpha(0.2) : (token.style?.backgroundColor ?? theme.inputIcon) + let backgroundColor = token.style?.backgroundColor ?? theme.inputIcon let strokeColor = token.style?.strokeColor ?? backgroundColor + self.backgroundNode.image = generateStretchableFilledCircleImage(diameter: 8.0, color: backgroundColor, strokeColor: strokeColor, strokeWidth: UIScreenPixel, backgroundColor: nil) - if token.isTag { - self.backgroundNode.image = generateTintedImage(image: UIImage(bundleImageName: "Chat/Title Panels/SearchTagTokenBackground"), color: backgroundColor)?.stretchableImage(withLeftCapWidth: 7, topCapHeight: 0) - } else { - self.backgroundNode.image = generateStretchableFilledCircleImage(diameter: 8.0, color: backgroundColor, strokeColor: strokeColor, strokeWidth: UIScreenPixel, backgroundColor: nil) - } - - let foregroundColor = token.isTag ? theme.primaryText : (token.style?.foregroundColor ?? .white) + let foregroundColor = token.style?.foregroundColor ?? .white self.iconNode.image = generateTintedImage(image: token.icon, color: foregroundColor) self.containerNode.addSubnode(self.iconNode) - self.titleNode.attributedText = NSAttributedString(string: token.title, font: Font.regular(token.isTag ? 14.0 : 17.0), textColor: foregroundColor) + self.titleNode.attributedText = NSAttributedString(string: token.title, font: Font.regular(17.0), textColor: foregroundColor) self.containerNode.addSubnode(self.titleNode) } } @@ -139,24 +132,19 @@ private final class TokenNode: ASDisplayNode { } func animateIn() { - if self.token.isTag { - self.layer.animateScale(from: 0.1, to: 1.0, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring) - self.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.15) - } else { - let targetFrame = self.containerNode.frame - self.containerNode.layer.animateFrame(from: CGRect(origin: targetFrame.origin, size: CGSize(width: 1.0, height: targetFrame.height)), to: targetFrame, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring) - self.backgroundNode.layer.animateFrame(from: CGRect(origin: targetFrame.origin, size: CGSize(width: 1.0, height: targetFrame.height)), to: targetFrame, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring) - - if let avatarNode = self.avatarNode { - avatarNode.layer.animateScale(from: 0.1, to: 1.0, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring) - avatarNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.15) - } - - self.iconNode.layer.animateScale(from: 0.1, to: 1.0, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring) - self.iconNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.15) - self.titleNode.layer.animateScale(from: 0.1, to: 1.0, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring) - self.titleNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.15) + let targetFrame = self.containerNode.frame + self.containerNode.layer.animateFrame(from: CGRect(origin: targetFrame.origin, size: CGSize(width: 1.0, height: targetFrame.height)), to: targetFrame, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring) + self.backgroundNode.layer.animateFrame(from: CGRect(origin: targetFrame.origin, size: CGSize(width: 1.0, height: targetFrame.height)), to: targetFrame, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring) + + if let avatarNode = self.avatarNode { + avatarNode.layer.animateScale(from: 0.1, to: 1.0, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring) + avatarNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.15) } + + self.iconNode.layer.animateScale(from: 0.1, to: 1.0, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring) + self.iconNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.15) + self.titleNode.layer.animateScale(from: 0.1, to: 1.0, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring) + self.titleNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.15) } func animateOut() { @@ -172,21 +160,11 @@ private final class TokenNode: ASDisplayNode { self.isCollapsed = isCollapsed if theme !== self.theme || isSelected != wasSelected { - let backgroundColor: UIColor - if isSelected { - backgroundColor = self.theme.accent - } else { - backgroundColor = token.isTag ? theme.inputIcon.withMultipliedAlpha(0.2) : (token.style?.backgroundColor ?? self.theme.inputIcon) - } - + let backgroundColor = isSelected ? self.theme.accent : (token.style?.backgroundColor ?? self.theme.inputIcon) let strokeColor = isSelected ? backgroundColor : (token.style?.strokeColor ?? backgroundColor) - if token.isTag { - self.backgroundNode.image = generateTintedImage(image: UIImage(bundleImageName: "Chat/Title Panels/SearchTagTokenBackground"), color: backgroundColor)?.stretchableImage(withLeftCapWidth: 7, topCapHeight: 0) - } else { - self.backgroundNode.image = generateStretchableFilledCircleImage(diameter: 8.0, color: backgroundColor, strokeColor: strokeColor, strokeWidth: UIScreenPixel, backgroundColor: nil) - } + self.backgroundNode.image = generateStretchableFilledCircleImage(diameter: 8.0, color: backgroundColor, strokeColor: strokeColor, strokeWidth: UIScreenPixel, backgroundColor: nil) - var foregroundColor = isSelected ? .white : (token.isTag ? self.theme.primaryText : (token.style?.foregroundColor ?? .white)) + var foregroundColor = isSelected ? .white : (token.style?.foregroundColor ?? .white) if foregroundColor.distance(to: backgroundColor) < 1 { foregroundColor = .black } @@ -194,15 +172,12 @@ private final class TokenNode: ASDisplayNode { if let image = token.icon { self.iconNode.image = generateTintedImage(image: image, color: foregroundColor) } - self.titleNode.attributedText = NSAttributedString(string: token.title, font: Font.regular(token.isTag ? 14.0 : 17.0), textColor: foregroundColor) + self.titleNode.attributedText = NSAttributedString(string: token.title, font: Font.regular(17.0), textColor: foregroundColor) } } func updateLayout(constrainedSize: CGSize, transition: ContainedViewLayoutTransition) -> CGSize { - var height: CGFloat = 24.0 - if self.token.isTag { - height += 2.0 - } + let height: CGFloat = 24.0 var leftInset: CGFloat = 3.0 if let icon = self.iconNode.image { @@ -214,9 +189,6 @@ private final class TokenNode: ASDisplayNode { transition.updateFrame(node: self.iconNode, frame: iconFrame) leftInset += icon.size.width + 3.0 } - if self.token.isTag { - leftInset += 2.0 - } let iconSize = self.token.icon?.size ?? CGSize() let titleSize = self.titleNode.measure(CGSize(width: constrainedSize.width - 6.0, height: constrainedSize.height)) @@ -224,9 +196,6 @@ private final class TokenNode: ASDisplayNode { if !iconSize.width.isZero { width += iconSize.width + 7.0 } - if self.token.isTag { - width += 19.0 - } let size: CGSize if let avatarNode = self.avatarNode { @@ -389,10 +358,6 @@ private class SearchBarTextField: UITextField, UIScrollViewDelegate { } longTitlesWidth += resolvedSideInset - if !tokenSizes.isEmpty { - leftOffset -= 8.0 - } - let verticalOffset: CGFloat = 0.0 var horizontalOffset: CGFloat = 0.0 for i in 0 ..< tokenSizes.count { diff --git a/submodules/TelegramUI/BUILD b/submodules/TelegramUI/BUILD index d05ee13e10..e320ebaecf 100644 --- a/submodules/TelegramUI/BUILD +++ b/submodules/TelegramUI/BUILD @@ -420,8 +420,6 @@ swift_library( "//submodules/TelegramUI/Components/Settings/WallpaperGalleryScreen", "//submodules/TelegramUI/Components/Settings/WallpaperGridScreen", "//submodules/TelegramUI/Components/Chat/ChatMessageNotificationItem", - "//submodules/Components/MultilineTextComponent", - "//submodules/TelegramUI/Components/PlainButtonComponent", ] + select({ "@build_bazel_rules_apple//apple:ios_arm64": appcenter_targets, "//build-system:ios_sim_arm64": [], diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageAnimatedStickerItemNode/Sources/ChatMessageAnimatedStickerItemNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageAnimatedStickerItemNode/Sources/ChatMessageAnimatedStickerItemNode.swift index 2a3178bbd8..f70e9ade84 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageAnimatedStickerItemNode/Sources/ChatMessageAnimatedStickerItemNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageAnimatedStickerItemNode/Sources/ChatMessageAnimatedStickerItemNode.swift @@ -1045,7 +1045,6 @@ public class ChatMessageAnimatedStickerItemNode: ChatMessageItemView { reactions: dateReactionsAndPeers.reactions, reactionPeers: dateReactionsAndPeers.peers, displayAllReactionPeers: item.message.id.peerId.namespace == Namespaces.Peer.CloudUser, - isSavedMessages: item.chatLocation.peerId == item.context.account.peerId, replyCount: dateReplies, isPinned: item.message.tags.contains(.pinned) && !item.associatedData.isInPinnedListMode && !isReplyThread, hasAutoremove: item.message.isSelfExpiring, diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageAttachedContentNode/Sources/ChatMessageAttachedContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageAttachedContentNode/Sources/ChatMessageAttachedContentNode.swift index 541b9742a9..98ce2ab888 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageAttachedContentNode/Sources/ChatMessageAttachedContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageAttachedContentNode/Sources/ChatMessageAttachedContentNode.swift @@ -657,7 +657,6 @@ public final class ChatMessageAttachedContentNode: ASDisplayNode { reactions: dateReactionsAndPeers.reactions, reactionPeers: dateReactionsAndPeers.peers, displayAllReactionPeers: message.id.peerId.namespace == Namespaces.Peer.CloudUser, - isSavedMessages: chatLocation == .peer(id: context.account.peerId), replyCount: dateReplies, isPinned: message.tags.contains(.pinned) && !associatedData.isInPinnedListMode && !isReplyThread, hasAutoremove: message.isSelfExpiring, diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift index 51edc4886e..7f2a940148 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift @@ -2113,7 +2113,6 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI reactions: dateReactionsAndPeers.reactions, reactionPeers: dateReactionsAndPeers.peers, displayAllReactionPeers: item.message.id.peerId.namespace == Namespaces.Peer.CloudUser, - isSavedMessages: item.chatLocation.peerId == item.context.account.peerId, replyCount: dateReplies, isPinned: message.tags.contains(.pinned) && !item.associatedData.isInPinnedListMode && !isReplyThread, hasAutoremove: message.isSelfExpiring, diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageContactBubbleContentNode/Sources/ChatMessageContactBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageContactBubbleContentNode/Sources/ChatMessageContactBubbleContentNode.swift index 139a689678..8d87a3e7f7 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageContactBubbleContentNode/Sources/ChatMessageContactBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageContactBubbleContentNode/Sources/ChatMessageContactBubbleContentNode.swift @@ -238,7 +238,6 @@ public class ChatMessageContactBubbleContentNode: ChatMessageBubbleContentNode { reactions: dateReactionsAndPeers.reactions, reactionPeers: dateReactionsAndPeers.peers, displayAllReactionPeers: item.message.id.peerId.namespace == Namespaces.Peer.CloudUser, - isSavedMessages: item.chatLocation.peerId == item.context.account.peerId, replyCount: dateReplies, isPinned: item.message.tags.contains(.pinned) && !item.associatedData.isInPinnedListMode && isReplyThread, hasAutoremove: item.message.isSelfExpiring, diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageDateAndStatusNode/Sources/ChatMessageDateAndStatusNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageDateAndStatusNode/Sources/ChatMessageDateAndStatusNode.swift index 824cc1772d..0b9cee1b0a 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageDateAndStatusNode/Sources/ChatMessageDateAndStatusNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageDateAndStatusNode/Sources/ChatMessageDateAndStatusNode.swift @@ -228,7 +228,6 @@ public class ChatMessageDateAndStatusNode: ASDisplayNode { var reactions: [MessageReaction] var reactionPeers: [(MessageReaction.Reaction, EnginePeer)] var displayAllReactionPeers: Bool - var isSavedMessages: Bool var replyCount: Int var isPinned: Bool var hasAutoremove: Bool @@ -249,7 +248,6 @@ public class ChatMessageDateAndStatusNode: ASDisplayNode { reactions: [MessageReaction], reactionPeers: [(MessageReaction.Reaction, EnginePeer)], displayAllReactionPeers: Bool, - isSavedMessages: Bool, replyCount: Int, isPinned: Bool, hasAutoremove: Bool, @@ -269,7 +267,6 @@ public class ChatMessageDateAndStatusNode: ASDisplayNode { self.reactions = reactions self.reactionPeers = reactionPeers self.displayAllReactionPeers = displayAllReactionPeers - self.isSavedMessages = isSavedMessages self.replyCount = replyCount self.isPinned = isPinned self.hasAutoremove = hasAutoremove @@ -747,7 +744,6 @@ public class ChatMessageDateAndStatusNode: ASDisplayNode { }, reactions: [], colors: reactionColors, - isTag: arguments.isSavedMessages, constrainedWidth: arguments.constrainedSize.width ) case let .trailingContent(contentWidth, reactionSettings): @@ -809,7 +805,6 @@ public class ChatMessageDateAndStatusNode: ASDisplayNode { ) }, colors: reactionColors, - isTag: arguments.isSavedMessages, constrainedWidth: arguments.constrainedSize.width ) } else { @@ -823,7 +818,6 @@ public class ChatMessageDateAndStatusNode: ASDisplayNode { }, reactions: [], colors: reactionColors, - isTag: arguments.isSavedMessages, constrainedWidth: arguments.constrainedSize.width ) } diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageGiveawayBubbleContentNode/Sources/ChatMessageGiveawayBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageGiveawayBubbleContentNode/Sources/ChatMessageGiveawayBubbleContentNode.swift index a206105c42..9c67e031c4 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageGiveawayBubbleContentNode/Sources/ChatMessageGiveawayBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageGiveawayBubbleContentNode/Sources/ChatMessageGiveawayBubbleContentNode.swift @@ -519,7 +519,6 @@ public class ChatMessageGiveawayBubbleContentNode: ChatMessageBubbleContentNode, reactions: dateReactionsAndPeers.reactions, reactionPeers: dateReactionsAndPeers.peers, displayAllReactionPeers: item.message.id.peerId.namespace == Namespaces.Peer.CloudUser, - isSavedMessages: item.chatLocation.peerId == item.context.account.peerId, replyCount: dateReplies, isPinned: item.message.tags.contains(.pinned) && !item.associatedData.isInPinnedListMode && isReplyThread, hasAutoremove: item.message.isSelfExpiring, diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveFileNode/Sources/ChatMessageInteractiveFileNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveFileNode/Sources/ChatMessageInteractiveFileNode.swift index 0aca23b715..a851caebff 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveFileNode/Sources/ChatMessageInteractiveFileNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveFileNode/Sources/ChatMessageInteractiveFileNode.swift @@ -937,7 +937,6 @@ public final class ChatMessageInteractiveFileNode: ASDisplayNode { reactions: dateReactionsAndPeers.reactions, reactionPeers: dateReactionsAndPeers.peers, displayAllReactionPeers: arguments.message.id.peerId.namespace == Namespaces.Peer.CloudUser, - isSavedMessages: arguments.chatLocation == .peer(id: arguments.context.account.peerId), replyCount: dateReplies, isPinned: arguments.isPinned && !arguments.associatedData.isInPinnedListMode, hasAutoremove: arguments.message.isSelfExpiring, diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveInstantVideoNode/Sources/ChatMessageInteractiveInstantVideoNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveInstantVideoNode/Sources/ChatMessageInteractiveInstantVideoNode.swift index 6144637ec1..355eab8cf1 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveInstantVideoNode/Sources/ChatMessageInteractiveInstantVideoNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveInstantVideoNode/Sources/ChatMessageInteractiveInstantVideoNode.swift @@ -570,7 +570,6 @@ public class ChatMessageInteractiveInstantVideoNode: ASDisplayNode { reactions: dateReactionsAndPeers.reactions, reactionPeers: dateReactionsAndPeers.peers, displayAllReactionPeers: item.message.id.peerId.namespace == Namespaces.Peer.CloudUser, - isSavedMessages: item.chatLocation.peerId == item.context.account.peerId, replyCount: dateReplies, isPinned: item.message.tags.contains(.pinned) && !item.associatedData.isInPinnedListMode && !isReplyThread, hasAutoremove: item.message.isSelfExpiring, diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveMediaNode/Sources/ChatMessageInteractiveMediaNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveMediaNode/Sources/ChatMessageInteractiveMediaNode.swift index 5ac8ce5904..52721bf13f 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveMediaNode/Sources/ChatMessageInteractiveMediaNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveMediaNode/Sources/ChatMessageInteractiveMediaNode.swift @@ -872,7 +872,6 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr reactions: dateAndStatus.dateReactions, reactionPeers: dateAndStatus.dateReactionPeers, displayAllReactionPeers: message.id.peerId.namespace == Namespaces.Peer.CloudUser, - isSavedMessages: message.id.peerId == context.account.peerId, replyCount: dateAndStatus.dateReplies, isPinned: dateAndStatus.isPinned, hasAutoremove: message.isSelfExpiring, diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageMapBubbleContentNode/Sources/ChatMessageMapBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageMapBubbleContentNode/Sources/ChatMessageMapBubbleContentNode.swift index f0c7e86898..64e2a050f1 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageMapBubbleContentNode/Sources/ChatMessageMapBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageMapBubbleContentNode/Sources/ChatMessageMapBubbleContentNode.swift @@ -276,7 +276,6 @@ public class ChatMessageMapBubbleContentNode: ChatMessageBubbleContentNode { reactions: dateReactionsAndPeers.reactions, reactionPeers: dateReactionsAndPeers.peers, displayAllReactionPeers: item.message.id.peerId.namespace == Namespaces.Peer.CloudUser, - isSavedMessages: item.chatLocation.peerId == item.context.account.peerId, replyCount: dateReplies, isPinned: item.message.tags.contains(.pinned) && !item.associatedData.isInPinnedListMode && !isReplyThread, hasAutoremove: item.message.isSelfExpiring, diff --git a/submodules/TelegramUI/Components/Chat/ChatMessagePollBubbleContentNode/Sources/ChatMessagePollBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessagePollBubbleContentNode/Sources/ChatMessagePollBubbleContentNode.swift index 6318eb0633..0fb5e22a96 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessagePollBubbleContentNode/Sources/ChatMessagePollBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessagePollBubbleContentNode/Sources/ChatMessagePollBubbleContentNode.swift @@ -1024,7 +1024,6 @@ public class ChatMessagePollBubbleContentNode: ChatMessageBubbleContentNode { reactions: dateReactionsAndPeers.reactions, reactionPeers: dateReactionsAndPeers.peers, displayAllReactionPeers: item.message.id.peerId.namespace == Namespaces.Peer.CloudUser, - isSavedMessages: item.chatLocation.peerId == item.context.account.peerId, replyCount: dateReplies, isPinned: item.message.tags.contains(.pinned) && !item.associatedData.isInPinnedListMode && !isReplyThread, hasAutoremove: item.message.isSelfExpiring, diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageReactionsFooterContentNode/Sources/ChatMessageReactionsFooterContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageReactionsFooterContentNode/Sources/ChatMessageReactionsFooterContentNode.swift index ae9356212d..86b938b6b2 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageReactionsFooterContentNode/Sources/ChatMessageReactionsFooterContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageReactionsFooterContentNode/Sources/ChatMessageReactionsFooterContentNode.swift @@ -178,7 +178,6 @@ public final class MessageReactionButtonsNode: ASDisplayNode { ) }, colors: reactionColors, - isTag: message.id.peerId == context.account.peerId, constrainedWidth: constrainedWidth ) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageRestrictedBubbleContentNode/Sources/ChatMessageRestrictedBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageRestrictedBubbleContentNode/Sources/ChatMessageRestrictedBubbleContentNode.swift index 4ba96ab7cc..c11a20eba4 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageRestrictedBubbleContentNode/Sources/ChatMessageRestrictedBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageRestrictedBubbleContentNode/Sources/ChatMessageRestrictedBubbleContentNode.swift @@ -132,7 +132,6 @@ public class ChatMessageRestrictedBubbleContentNode: ChatMessageBubbleContentNod reactions: dateReactionsAndPeers.reactions, reactionPeers: dateReactionsAndPeers.peers, displayAllReactionPeers: item.message.id.peerId.namespace == Namespaces.Peer.CloudUser, - isSavedMessages: item.chatLocation.peerId == item.context.account.peerId, replyCount: dateReplies, isPinned: item.message.tags.contains(.pinned) && !item.associatedData.isInPinnedListMode && isReplyThread, hasAutoremove: item.message.isSelfExpiring, diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageStickerItemNode/Sources/ChatMessageStickerItemNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageStickerItemNode/Sources/ChatMessageStickerItemNode.swift index 22d2c1b2c0..f9d6593249 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageStickerItemNode/Sources/ChatMessageStickerItemNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageStickerItemNode/Sources/ChatMessageStickerItemNode.swift @@ -628,7 +628,6 @@ public class ChatMessageStickerItemNode: ChatMessageItemView { reactions: dateReactionsAndPeers.reactions, reactionPeers: dateReactionsAndPeers.peers, displayAllReactionPeers: item.message.id.peerId.namespace == Namespaces.Peer.CloudUser, - isSavedMessages: item.chatLocation.peerId == item.context.account.peerId, replyCount: dateReplies, isPinned: item.message.tags.contains(.pinned) && !item.associatedData.isInPinnedListMode && !isReplyThread, hasAutoremove: item.message.isSelfExpiring, diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageTextBubbleContentNode/Sources/ChatMessageTextBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageTextBubbleContentNode/Sources/ChatMessageTextBubbleContentNode.swift index 0d47147dc2..8a98990b74 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageTextBubbleContentNode/Sources/ChatMessageTextBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageTextBubbleContentNode/Sources/ChatMessageTextBubbleContentNode.swift @@ -573,7 +573,6 @@ public class ChatMessageTextBubbleContentNode: ChatMessageBubbleContentNode { reactions: dateReactionsAndPeers.reactions, reactionPeers: dateReactionsAndPeers.peers, displayAllReactionPeers: item.message.id.peerId.namespace == Namespaces.Peer.CloudUser, - isSavedMessages: item.chatLocation.peerId == item.context.account.peerId, replyCount: dateReplies, isPinned: item.message.tags.contains(.pinned) && (!item.associatedData.isInPinnedListMode || isReplyThread), hasAutoremove: item.message.isSelfExpiring, diff --git a/submodules/TelegramUI/Components/ChatTitleView/Sources/ChatTitleView.swift b/submodules/TelegramUI/Components/ChatTitleView/Sources/ChatTitleView.swift index 8b8d14630b..26a2ac8bc4 100644 --- a/submodules/TelegramUI/Components/ChatTitleView/Sources/ChatTitleView.swift +++ b/submodules/TelegramUI/Components/ChatTitleView/Sources/ChatTitleView.swift @@ -31,23 +31,21 @@ public enum ChatTitleContent: Equatable { public var peerId: PeerId public var peer: Peer? public var isContact: Bool - public var isSavedMessages: Bool public var notificationSettings: TelegramPeerNotificationSettings? public var peerPresences: [PeerId: PeerPresence] public var cachedData: CachedPeerData? - public init(peerId: PeerId, peer: Peer?, isContact: Bool, isSavedMessages: Bool, notificationSettings: TelegramPeerNotificationSettings?, peerPresences: [PeerId: PeerPresence], cachedData: CachedPeerData?) { + public init(peerId: PeerId, peer: Peer?, isContact: Bool, notificationSettings: TelegramPeerNotificationSettings?, peerPresences: [PeerId: PeerPresence], cachedData: CachedPeerData?) { self.peerId = peerId self.peer = peer self.isContact = isContact - self.isSavedMessages = isSavedMessages self.notificationSettings = notificationSettings self.peerPresences = peerPresences self.cachedData = cachedData } public init(peerView: PeerView) { - self.init(peerId: peerView.peerId, peer: peerViewMainPeer(peerView), isContact: peerView.peerIsContact, isSavedMessages: false, notificationSettings: peerView.notificationSettings as? TelegramPeerNotificationSettings, peerPresences: peerView.peerPresences, cachedData: peerView.cachedData) + self.init(peerId: peerView.peerId, peer: peerViewMainPeer(peerView), isContact: peerView.peerIsContact, notificationSettings: peerView.notificationSettings as? TelegramPeerNotificationSettings, peerPresences: peerView.peerPresences, cachedData: peerView.cachedData) } public static func ==(lhs: PeerData, rhs: PeerData) -> Bool { @@ -61,9 +59,6 @@ public enum ChatTitleContent: Equatable { if lhs.isContact != rhs.isContact { return false } - if lhs.isSavedMessages != rhs.isSavedMessages { - return false - } if lhs.notificationSettings != rhs.notificationSettings { return false } @@ -251,12 +246,7 @@ public final class ChatTitleView: UIView, NavigationBarTitleView { if let customTitle = customTitle { segments = [.text(0, NSAttributedString(string: customTitle, font: titleFont, textColor: titleTheme.rootController.navigationBar.primaryTextColor))] } else if peerView.peerId == self.context.account.peerId { - if peerView.isSavedMessages { - //TODO:localize - segments = [.text(0, NSAttributedString(string: "My Notes", font: titleFont, textColor: titleTheme.rootController.navigationBar.primaryTextColor))] - } else { - segments = [.text(0, NSAttributedString(string: self.strings.Conversation_SavedMessages, font: titleFont, textColor: titleTheme.rootController.navigationBar.primaryTextColor))] - } + segments = [.text(0, NSAttributedString(string: self.strings.Conversation_SavedMessages, font: titleFont, textColor: titleTheme.rootController.navigationBar.primaryTextColor))] } else if peerView.peerId.isAnonymousSavedMessages { segments = [.text(0, NSAttributedString(string: self.strings.ChatList_AuthorHidden, font: titleFont, textColor: titleTheme.rootController.navigationBar.primaryTextColor))] } else { diff --git a/submodules/TelegramUI/Components/PlainButtonComponent/Sources/PlainButtonComponent.swift b/submodules/TelegramUI/Components/PlainButtonComponent/Sources/PlainButtonComponent.swift index 1152c2cefd..a6e568adb8 100644 --- a/submodules/TelegramUI/Components/PlainButtonComponent/Sources/PlainButtonComponent.swift +++ b/submodules/TelegramUI/Components/PlainButtonComponent/Sources/PlainButtonComponent.swift @@ -13,7 +13,6 @@ public final class PlainButtonComponent: Component { public let content: AnyComponent public let effectAlignment: EffectAlignment public let minSize: CGSize? - public let contentInsets: UIEdgeInsets public let action: () -> Void public let isEnabled: Bool @@ -21,14 +20,12 @@ public final class PlainButtonComponent: Component { content: AnyComponent, effectAlignment: EffectAlignment, minSize: CGSize? = nil, - contentInsets: UIEdgeInsets = UIEdgeInsets(), action: @escaping () -> Void, isEnabled: Bool = true ) { self.content = content self.effectAlignment = effectAlignment self.minSize = minSize - self.contentInsets = contentInsets self.action = action self.isEnabled = isEnabled } @@ -43,9 +40,6 @@ public final class PlainButtonComponent: Component { if lhs.minSize != rhs.minSize { return false } - if lhs.contentInsets != rhs.contentInsets { - return false - } if lhs.isEnabled != rhs.isEnabled { return false } @@ -149,8 +143,6 @@ public final class PlainButtonComponent: Component { size.width = max(size.width, minSize.width) size.height = max(size.height, minSize.height) } - size.width += component.contentInsets.left + component.contentInsets.right - size.height += component.contentInsets.top + component.contentInsets.bottom if let contentView = self.content.view { var contentTransition = transition @@ -159,7 +151,7 @@ public final class PlainButtonComponent: Component { contentView.isUserInteractionEnabled = false self.contentContainer.addSubview(contentView) } - let contentFrame = CGRect(origin: CGPoint(x: component.contentInsets.left + floor((size.width - component.contentInsets.left - component.contentInsets.right - contentSize.width) * 0.5), y: component.contentInsets.top + floor((size.height - component.contentInsets.top - component.contentInsets.bottom - contentSize.height) * 0.5)), size: contentSize) + let contentFrame = CGRect(origin: CGPoint(x: floor((size.width - contentSize.width) * 0.5), y: floor((size.height - contentSize.height) * 0.5)), size: contentSize) contentTransition.setFrame(view: contentView, frame: contentFrame) contentTransition.setAlpha(view: contentView, alpha: contentAlpha) diff --git a/submodules/TelegramUI/Images.xcassets/Avatar/MyNotesIcon.imageset/Contents.json b/submodules/TelegramUI/Images.xcassets/Avatar/MyNotesIcon.imageset/Contents.json deleted file mode 100644 index 040e468b10..0000000000 --- a/submodules/TelegramUI/Images.xcassets/Avatar/MyNotesIcon.imageset/Contents.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "images" : [ - { - "filename" : "mynotes.pdf", - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/submodules/TelegramUI/Images.xcassets/Avatar/MyNotesIcon.imageset/mynotes.pdf b/submodules/TelegramUI/Images.xcassets/Avatar/MyNotesIcon.imageset/mynotes.pdf deleted file mode 100644 index d6d2788e2a..0000000000 Binary files a/submodules/TelegramUI/Images.xcassets/Avatar/MyNotesIcon.imageset/mynotes.pdf and /dev/null differ diff --git a/submodules/TelegramUI/Images.xcassets/Chat/Message/ReactionTagBackground.imageset/Contents.json b/submodules/TelegramUI/Images.xcassets/Chat/Message/ReactionTagBackground.imageset/Contents.json deleted file mode 100644 index 94301dd104..0000000000 --- a/submodules/TelegramUI/Images.xcassets/Chat/Message/ReactionTagBackground.imageset/Contents.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "images" : [ - { - "filename" : "MessageTagBackground.svg", - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/submodules/TelegramUI/Images.xcassets/Chat/Message/ReactionTagBackground.imageset/MessageTagBackground.svg b/submodules/TelegramUI/Images.xcassets/Chat/Message/ReactionTagBackground.imageset/MessageTagBackground.svg deleted file mode 100644 index d4221d3c16..0000000000 --- a/submodules/TelegramUI/Images.xcassets/Chat/Message/ReactionTagBackground.imageset/MessageTagBackground.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/submodules/TelegramUI/Images.xcassets/Chat/Title Panels/SearchTagTokenBackground.imageset/Contents.json b/submodules/TelegramUI/Images.xcassets/Chat/Title Panels/SearchTagTokenBackground.imageset/Contents.json deleted file mode 100644 index 04f56c7a35..0000000000 --- a/submodules/TelegramUI/Images.xcassets/Chat/Title Panels/SearchTagTokenBackground.imageset/Contents.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "images" : [ - { - "filename" : "SearchTagTokenBackground.svg", - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/submodules/TelegramUI/Images.xcassets/Chat/Title Panels/SearchTagTokenBackground.imageset/SearchTagTokenBackground.svg b/submodules/TelegramUI/Images.xcassets/Chat/Title Panels/SearchTagTokenBackground.imageset/SearchTagTokenBackground.svg deleted file mode 100644 index 4f3a05598a..0000000000 --- a/submodules/TelegramUI/Images.xcassets/Chat/Title Panels/SearchTagTokenBackground.imageset/SearchTagTokenBackground.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/submodules/TelegramUI/Sources/Chat/ChatControllerOpenMessageContextMenu.swift b/submodules/TelegramUI/Sources/Chat/ChatControllerOpenMessageContextMenu.swift index 02f609d4db..e9707619da 100644 --- a/submodules/TelegramUI/Sources/Chat/ChatControllerOpenMessageContextMenu.swift +++ b/submodules/TelegramUI/Sources/Chat/ChatControllerOpenMessageContextMenu.swift @@ -110,10 +110,6 @@ extension ChatControllerImpl { if canAddMessageReactions(message: topMessage), let allowedReactions = allowedReactions, !topReactions.isEmpty { actions.reactionItems = topReactions.map(ReactionContextItem.reaction) - if case .peer(self.context.account.peerId) = self.presentationInterfaceState.chatLocation { - //TODO:localize - actions.reactionsTitle = "Tag the message with an emoji for quick access later" - } actions.selectedReactionItems = selectedReactions.reactions if let channel = self.presentationInterfaceState.renderedPeer?.peer as? TelegramChannel, case .broadcast = channel.info { diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 8ac8be5308..c80179798b 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -5920,7 +5920,6 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G peerId: savedMessagesPeerId, peer: savedMessagesPeer?.peer?._asPeer(), isContact: true, - isSavedMessages: true, notificationSettings: nil, peerPresences: [:], cachedData: nil @@ -5931,7 +5930,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G let imageOverride: AvatarNodeImageOverride? if strongSelf.context.account.peerId == savedMessagesPeerId { - imageOverride = .myNotesIcon + imageOverride = .savedMessagesIcon } else if savedMessagesPeerId.isReplies { imageOverride = .repliesIcon } else if savedMessagesPeerId.isAnonymousSavedMessages { @@ -9275,14 +9274,12 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G return state.updatedSearch(ChatSearchData(query: "", domain: .members, domainSuggestionContext: .none, resultsState: nil)) } else if let search = state.search { switch search.domain { - case .everything: - return state - case .tag: - return state.updatedSearch(ChatSearchData(query: "", domain: .everything, domainSuggestionContext: .none, resultsState: nil)) - case .members: - return state.updatedSearch(ChatSearchData(query: "", domain: .everything, domainSuggestionContext: .none, resultsState: nil)) - case .member: - return state.updatedSearch(ChatSearchData(query: "", domain: .members, domainSuggestionContext: .none, resultsState: nil)) + case .everything: + return state + case .members: + return state.updatedSearch(ChatSearchData(query: "", domain: .everything, domainSuggestionContext: .none, resultsState: nil)) + case .member: + return state.updatedSearch(ChatSearchData(query: "", domain: .members, domainSuggestionContext: .none, resultsState: nil)) } } else { return state @@ -15795,14 +15792,12 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G break } switch search.domain { - case .everything: - derivedSearchState = ChatSearchState(query: search.query, location: .peer(peerId: peerId, fromId: nil, tags: nil, threadId: threadId, minDate: nil, maxDate: nil), loadMoreState: loadMoreStateFromResultsState(search.resultsState)) - case .members: - derivedSearchState = nil - case let .member(peer): - derivedSearchState = ChatSearchState(query: search.query, location: .peer(peerId: peerId, fromId: peer.id, tags: nil, threadId: threadId, minDate: nil, maxDate: nil), loadMoreState: loadMoreStateFromResultsState(search.resultsState)) - case let .tag(tag): - derivedSearchState = ChatSearchState(query: "@#\(tag) " + search.query, location: .peer(peerId: peerId, fromId: nil, tags: nil, threadId: threadId, minDate: nil, maxDate: nil), loadMoreState: loadMoreStateFromResultsState(search.resultsState)) + case .everything: + derivedSearchState = ChatSearchState(query: search.query, location: .peer(peerId: peerId, fromId: nil, tags: nil, threadId: threadId, minDate: nil, maxDate: nil), loadMoreState: loadMoreStateFromResultsState(search.resultsState)) + case .members: + derivedSearchState = nil + case let .member(peer): + derivedSearchState = ChatSearchState(query: search.query, location: .peer(peerId: peerId, fromId: peer.id, tags: nil, threadId: threadId, minDate: nil, maxDate: nil), loadMoreState: loadMoreStateFromResultsState(search.resultsState)) } } diff --git a/submodules/TelegramUI/Sources/ChatControllerNode.swift b/submodules/TelegramUI/Sources/ChatControllerNode.swift index f724ecbdc7..d161f7e91b 100644 --- a/submodules/TelegramUI/Sources/ChatControllerNode.swift +++ b/submodules/TelegramUI/Sources/ChatControllerNode.swift @@ -2655,7 +2655,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { var activate = false if self.searchNavigationNode == nil { activate = true - self.searchNavigationNode = ChatSearchNavigationContentNode(context: self.context, theme: self.chatPresentationInterfaceState.theme, strings: self.chatPresentationInterfaceState.strings, chatLocation: self.chatPresentationInterfaceState.chatLocation, interaction: interfaceInteraction) + self.searchNavigationNode = ChatSearchNavigationContentNode(theme: self.chatPresentationInterfaceState.theme, strings: self.chatPresentationInterfaceState.strings, chatLocation: self.chatPresentationInterfaceState.chatLocation, interaction: interfaceInteraction) } self.navigationBar?.setContentNode(self.searchNavigationNode, animated: transitionIsAnimated) self.searchNavigationNode?.update(presentationInterfaceState: self.chatPresentationInterfaceState) diff --git a/submodules/TelegramUI/Sources/ChatInterfaceTitlePanelNodes.swift b/submodules/TelegramUI/Sources/ChatInterfaceTitlePanelNodes.swift index bb226a90da..8abe141e24 100644 --- a/submodules/TelegramUI/Sources/ChatInterfaceTitlePanelNodes.swift +++ b/submodules/TelegramUI/Sources/ChatInterfaceTitlePanelNodes.swift @@ -12,18 +12,8 @@ func titlePanelForChatPresentationInterfaceState(_ chatPresentationInterfaceStat if chatPresentationInterfaceState.renderedPeer?.peer?.restrictionText(platform: "ios", contentSettings: context.currentContentSettings.with { $0 }) != nil { return nil } - if let search = chatPresentationInterfaceState.search { - if chatPresentationInterfaceState.chatLocation.peerId == context.account.peerId, case .everything = search.domain { - if let currentPanel = currentPanel as? ChatSearchTitleAccessoryPanelNode { - return currentPanel - } else { - let panel = ChatSearchTitleAccessoryPanelNode(context: context) - panel.interfaceInteraction = interfaceInteraction - return panel - } - } else { - return nil - } + if chatPresentationInterfaceState.search != nil { + return nil } var inhibitTitlePanelDisplay = false diff --git a/submodules/TelegramUI/Sources/ChatSearchNavigationContentNode.swift b/submodules/TelegramUI/Sources/ChatSearchNavigationContentNode.swift index 38ffcd0589..aded8da70e 100644 --- a/submodules/TelegramUI/Sources/ChatSearchNavigationContentNode.swift +++ b/submodules/TelegramUI/Sources/ChatSearchNavigationContentNode.swift @@ -14,7 +14,6 @@ import ChatPresentationInterfaceState private let searchBarFont = Font.regular(17.0) final class ChatSearchNavigationContentNode: NavigationBarContentNode { - private let context: AccountContext private let theme: PresentationTheme private let strings: PresentationStrings private let chatLocation: ChatLocation @@ -24,8 +23,7 @@ final class ChatSearchNavigationContentNode: NavigationBarContentNode { private var searchingActivityDisposable: Disposable? - init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, chatLocation: ChatLocation, interaction: ChatPanelInterfaceInteraction) { - self.context = context + init(theme: PresentationTheme, strings: PresentationStrings, chatLocation: ChatLocation, interaction: ChatPanelInterfaceInteraction) { self.theme = theme self.strings = strings self.chatLocation = chatLocation @@ -35,12 +33,7 @@ final class ChatSearchNavigationContentNode: NavigationBarContentNode { let placeholderText: String switch chatLocation { case .peer, .replyThread, .feed: - if chatLocation.peerId == context.account.peerId { - //TODO:localize - placeholderText = "Search messages or tags" - } else { - placeholderText = strings.Conversation_SearchPlaceholder - } + placeholderText = strings.Conversation_SearchPlaceholder } self.searchBar.placeholderString = NSAttributedString(string: placeholderText, font: searchBarFont, textColor: theme.rootController.navigationSearchBar.inputPlaceholderTextColor) @@ -106,34 +99,23 @@ final class ChatSearchNavigationContentNode: NavigationBarContentNode { self.searchBar.updateThemeAndStrings(theme: SearchBarNodeTheme(theme: presentationInterfaceState.theme, hasBackground: false, hasSeparator: false), strings: presentationInterfaceState.strings) switch search.domain { - case .everything: - self.searchBar.tokens = [] - self.searchBar.prefixString = nil - let placeholderText: String - switch self.chatLocation { - case .peer, .replyThread, .feed: - if self.chatLocation.peerId == self.context.account.peerId { - //TODO:localize - placeholderText = "Search messages or tags" - } else { + case .everything: + self.searchBar.tokens = [] + self.searchBar.prefixString = nil + let placeholderText: String + switch self.chatLocation { + case .peer, .replyThread, .feed: placeholderText = self.strings.Conversation_SearchPlaceholder } - } - self.searchBar.placeholderString = NSAttributedString(string: placeholderText, font: searchBarFont, textColor: theme.rootController.navigationSearchBar.inputPlaceholderTextColor) - case let .tag(tag): - //TODO:localize - let placeholderText = "Search" - self.searchBar.placeholderString = NSAttributedString(string: placeholderText, font: searchBarFont, textColor: theme.rootController.navigationSearchBar.inputPlaceholderTextColor) - //TODO:localize - self.searchBar.tokens = [SearchBarToken(id: AnyHashable(tag), icon: nil, isTag: true, title: "\(tag) Tag", permanent: false)] - case .members: - self.searchBar.tokens = [] - self.searchBar.prefixString = NSAttributedString(string: strings.Conversation_SearchByName_Prefix, font: searchBarFont, textColor: theme.rootController.navigationSearchBar.inputTextColor) - self.searchBar.placeholderString = nil - case let .member(peer): - self.searchBar.tokens = [SearchBarToken(id: peer.id, icon: UIImage(bundleImageName: "Chat List/Search/User"), title: EnginePeer(peer).compactDisplayTitle, permanent: false)] - self.searchBar.prefixString = nil - self.searchBar.placeholderString = nil + self.searchBar.placeholderString = NSAttributedString(string: placeholderText, font: searchBarFont, textColor: theme.rootController.navigationSearchBar.inputPlaceholderTextColor) + case .members: + self.searchBar.tokens = [] + self.searchBar.prefixString = NSAttributedString(string: strings.Conversation_SearchByName_Prefix, font: searchBarFont, textColor: theme.rootController.navigationSearchBar.inputTextColor) + self.searchBar.placeholderString = nil + case let .member(peer): + self.searchBar.tokens = [SearchBarToken(id: peer.id, icon: UIImage(bundleImageName: "Chat List/Search/User"), title: EnginePeer(peer).compactDisplayTitle, permanent: false)] + self.searchBar.prefixString = nil + self.searchBar.placeholderString = nil } if self.searchBar.text != search.query { diff --git a/submodules/TelegramUI/Sources/ChatSearchResultsContollerNode.swift b/submodules/TelegramUI/Sources/ChatSearchResultsContollerNode.swift index 371f10956c..a99bd19f41 100644 --- a/submodules/TelegramUI/Sources/ChatSearchResultsContollerNode.swift +++ b/submodules/TelegramUI/Sources/ChatSearchResultsContollerNode.swift @@ -76,13 +76,13 @@ private enum ChatListSearchEntry: Comparable, Identifiable { return false } - public func item(context: AccountContext, interaction: ChatListNodeInteraction, location: ChatListControllerLocation) -> ListViewItem { + public func item(context: AccountContext, interaction: ChatListNodeInteraction) -> ListViewItem { switch self { case let .message(message, peer, readState, presentationData): return ChatListItem( presentationData: presentationData, context: context, - chatListLocation: location, + chatListLocation: .chatList(groupId: .root), filterData: nil, index: .chatList(EngineChatList.Item.Index.ChatList(pinningIndex: nil, messageIndex: message.index)), content: .peer(ChatListItemContent.PeerData( @@ -129,12 +129,12 @@ public struct ChatListSearchContainerTransition { } } -private func chatListSearchContainerPreparedTransition(from fromEntries: [ChatListSearchEntry], to toEntries: [ChatListSearchEntry], context: AccountContext, interaction: ChatListNodeInteraction, location: ChatListControllerLocation) -> ChatListSearchContainerTransition { +private func chatListSearchContainerPreparedTransition(from fromEntries: [ChatListSearchEntry], to toEntries: [ChatListSearchEntry], context: AccountContext, interaction: ChatListNodeInteraction) -> ChatListSearchContainerTransition { let (deleteIndices, indicesAndItems, updateIndices) = mergeListsStableWithUpdates(leftList: fromEntries, rightList: toEntries) let deletions = deleteIndices.map { ListViewDeleteItem(index: $0, directionHint: nil) } - let insertions = indicesAndItems.map { ListViewInsertItem(index: $0.0, previousIndex: $0.2, item: $0.1.item(context: context, interaction: interaction, location: location), directionHint: nil) } - let updates = updateIndices.map { ListViewUpdateItem(index: $0.0, previousIndex: $0.2, item: $0.1.item(context: context, interaction: interaction, location: location), directionHint: nil) } + let insertions = indicesAndItems.map { ListViewInsertItem(index: $0.0, previousIndex: $0.2, item: $0.1.item(context: context, interaction: interaction), directionHint: nil) } + let updates = updateIndices.map { ListViewUpdateItem(index: $0.0, previousIndex: $0.2, item: $0.1.item(context: context, interaction: interaction), directionHint: nil) } return ChatListSearchContainerTransition(deletions: deletions, insertions: insertions, updates: updates) } @@ -148,7 +148,6 @@ class ChatSearchResultsControllerNode: ViewControllerTracingNode, UIScrollViewDe private let searchQuery: String private var searchResult: SearchMessagesResult private var searchState: SearchMessagesState - private let mappedLocation: ChatListControllerLocation private var interaction: ChatListNodeInteraction? @@ -174,12 +173,6 @@ class ChatSearchResultsControllerNode: ViewControllerTracingNode, UIScrollViewDe self.searchQuery = searchQuery self.searchResult = searchResult self.searchState = searchState - - if case let .peer(peerId, _, _, _, _, _) = location, peerId == context.account.peerId { - self.mappedLocation = .savedMessagesChats - } else { - self.mappedLocation = .chatList(groupId: .root) - } let presentationData = context.sharedContext.currentPresentationData.with { $0 } self.presentationData = presentationData @@ -290,7 +283,7 @@ class ChatSearchResultsControllerNode: ViewControllerTracingNode, UIScrollViewDe let previousEntries = strongSelf.previousEntries.swap(entries) let firstTime = previousEntries == nil - let transition = chatListSearchContainerPreparedTransition(from: previousEntries ?? [], to: entries, context: context, interaction: interaction, location: strongSelf.mappedLocation) + let transition = chatListSearchContainerPreparedTransition(from: previousEntries ?? [], to: entries, context: context, interaction: interaction) strongSelf.enqueueTransition(transition, firstTime: firstTime) } })) @@ -359,7 +352,7 @@ class ChatSearchResultsControllerNode: ViewControllerTracingNode, UIScrollViewDe let previousEntries = strongSelf.previousEntries.swap(entries) let firstTime = previousEntries == nil - let transition = chatListSearchContainerPreparedTransition(from: previousEntries ?? [], to: entries, context: context, interaction: interaction, location: strongSelf.mappedLocation) + let transition = chatListSearchContainerPreparedTransition(from: previousEntries ?? [], to: entries, context: context, interaction: interaction) strongSelf.enqueueTransition(transition, firstTime: firstTime) } })) diff --git a/submodules/TelegramUI/Sources/ChatSearchTitleAccessoryPanelNode.swift b/submodules/TelegramUI/Sources/ChatSearchTitleAccessoryPanelNode.swift deleted file mode 100644 index 84e24f7e6f..0000000000 --- a/submodules/TelegramUI/Sources/ChatSearchTitleAccessoryPanelNode.swift +++ /dev/null @@ -1,182 +0,0 @@ -import Foundation -import UIKit -import Display -import AsyncDisplayKit -import TelegramPresentationData -import ChatPresentationInterfaceState -import AccountContext -import ComponentFlow -import MultilineTextComponent -import PlainButtonComponent -import UIKitRuntimeUtils - -final class ChatSearchTitleAccessoryPanelNode: ChatTitleAccessoryPanelNode, UIScrollViewDelegate { - private final class Item { - let tag: String - - init(tag: String) { - self.tag = tag - } - } - - private final class ItemView: UIView { - private let context: AccountContext - private let item: Item - private let action: (String) -> Void - - private let view = ComponentView() - - init(context: AccountContext, item: Item, action: @escaping ((String) -> Void)) { - self.context = context - self.item = item - self.action = action - - super.init(frame: CGRect()) - } - - required init?(coder: NSCoder) { - preconditionFailure() - } - - func update(theme: PresentationTheme, height: CGFloat, transition: Transition) -> CGSize { - let viewSize = self.view.update( - transition: transition, - component: AnyComponent(PlainButtonComponent( - content: AnyComponent(MultilineTextComponent( - text: .plain(NSAttributedString(string: self.item.tag, font: Font.regular(15.0), textColor: theme.rootController.navigationBar.primaryTextColor)), - insets: UIEdgeInsets(top: 2.0, left: 2.0, bottom: 2.0, right: 2.0) - )), - effectAlignment: .center, - minSize: CGSize(width: 0.0, height: height), - contentInsets: UIEdgeInsets(top: 0.0, left: 8.0, bottom: 0.0, right: 8.0), - action: { [weak self] in - guard let self else { - return - } - self.action(self.item.tag) - }, - isEnabled: true - )), - environment: {}, - containerSize: CGSize(width: 100.0, height: 100.0) - ) - if let componentView = self.view.view { - if componentView.superview == nil { - self.addSubview(componentView) - } - transition.setFrame(view: componentView, frame: CGRect(origin: CGPoint(), size: viewSize)) - } - return viewSize - } - } - - private final class ScrollView: UIScrollView { - override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { - return super.hitTest(point, with: event) - } - - override func touchesShouldCancel(in view: UIView) -> Bool { - return true - } - } - - private let context: AccountContext - private var theme: PresentationTheme? - private var strings: PresentationStrings? - - private let scrollView: ScrollView - private let itemViews: [ItemView] - - init(context: AccountContext) { - self.context = context - - self.scrollView = ScrollView(frame: CGRect()) - - let tags: [String] = [ - "⭐️", "❤️", "✅", "⏰", "💭", "❗️", "👍", "👎", "🤩", "⚡️", "🤡", "👌", "👏" - ] - let items = tags.map { - Item(tag: $0) - } - var itemAction: ((String) -> Void)? - self.itemViews = items.map { item in - return ItemView(context: context, item: item, action: { tag in - itemAction?(tag) - }) - } - - super.init() - - self.scrollView.delaysContentTouches = false - self.scrollView.canCancelContentTouches = true - self.scrollView.clipsToBounds = false - self.scrollView.contentInsetAdjustmentBehavior = .never - if #available(iOS 13.0, *) { - self.scrollView.automaticallyAdjustsScrollIndicatorInsets = false - } - self.scrollView.showsVerticalScrollIndicator = false - self.scrollView.showsHorizontalScrollIndicator = false - self.scrollView.alwaysBounceHorizontal = false - self.scrollView.alwaysBounceVertical = false - self.scrollView.scrollsToTop = false - self.scrollView.delegate = self - - self.view.addSubview(self.scrollView) - - self.scrollView.disablesInteractiveTransitionGestureRecognizer = true - - for itemView in self.itemViews { - self.scrollView.addSubview(itemView) - } - - itemAction = { [weak self] tag in - guard let self, let interfaceInteraction = self.interfaceInteraction else { - return - } - interfaceInteraction.beginMessageSearch(.tag(tag), "") - } - } - - override func updateLayout(width: CGFloat, leftInset: CGFloat, rightInset: CGFloat, transition: ContainedViewLayoutTransition, interfaceState: ChatPresentationInterfaceState) -> LayoutResult { - if interfaceState.strings !== self.strings { - self.strings = interfaceState.strings - } - - if interfaceState.theme !== self.theme { - self.theme = interfaceState.theme - } - - let panelHeight: CGFloat = 33.0 - - let containerInsets = UIEdgeInsets(top: 0.0, left: leftInset + 2.0, bottom: 0.0, right: rightInset + 2.0) - let itemSpacing: CGFloat = 2.0 - - var contentSize = CGSize(width: 0.0, height: panelHeight) - contentSize.width += containerInsets.left - - var isFirst = true - for itemView in self.itemViews { - if isFirst { - isFirst = false - } else { - contentSize.width += itemSpacing - } - - let itemSize = itemView.update(theme: interfaceState.theme, height: panelHeight, transition: .immediate) - itemView.frame = CGRect(origin: CGPoint(x: contentSize.width, y: 0.0), size: itemSize) - contentSize.width += itemSize.width - } - - contentSize.width += containerInsets.right - - let scrollSize = CGSize(width: width, height: contentSize.height) - if self.scrollView.bounds.size != scrollSize { - self.scrollView.frame = CGRect(origin: CGPoint(x: 0.0, y: -5.0), size: scrollSize) - } - if self.scrollView.contentSize != contentSize { - self.scrollView.contentSize = contentSize - } - - return LayoutResult(backgroundHeight: panelHeight, insetHeight: panelHeight, hitTestSlop: 0.0) - } -}