diff --git a/submodules/ChatListUI/Sources/ChatListSearchContainerNode.swift b/submodules/ChatListUI/Sources/ChatListSearchContainerNode.swift index fa5c562064..6872c774f4 100644 --- a/submodules/ChatListUI/Sources/ChatListSearchContainerNode.swift +++ b/submodules/ChatListUI/Sources/ChatListSearchContainerNode.swift @@ -92,6 +92,7 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo private let openMessage: (EnginePeer, Int64?, EngineMessage.Id, Bool) -> Void private let navigationController: NavigationController? + private let dimNode: ASDisplayNode let filterContainerNode: ChatListSearchFiltersContainerNode private let paneContainerNode: ChatListSearchPaneContainerNode private var selectionPanelNode: ChatListSearchMessageSelectionPanelNode? @@ -149,6 +150,9 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo self.present = present self.presentInGlobalOverlay = presentInGlobalOverlay + self.dimNode = ASDisplayNode() + self.dimNode.backgroundColor = UIColor.black.withAlphaComponent(0.5) + self.filterContainerNode = ChatListSearchFiltersContainerNode() self.paneContainerNode = ChatListSearchPaneContainerNode(context: context, animationCache: animationCache, animationRenderer: animationRenderer, updatedPresentationData: updatedPresentationData, peersFilter: self.peersFilter, location: location, searchQuery: self.searchQuery.get(), searchOptions: self.searchOptions.get(), navigationController: navigationController) self.paneContainerNode.clipsToBounds = true @@ -157,6 +161,7 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo self.backgroundColor = filter.contains(.excludeRecent) ? nil : self.presentationData.theme.chatList.backgroundColor + self.addSubnode(self.dimNode) self.addSubnode(self.paneContainerNode) let interaction = ChatListSearchInteraction(openPeer: { peer, chatPeer, threadId, value in @@ -483,10 +488,21 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo self.copyProtectionTooltipController?.dismiss() } + public override func didLoad() { + super.didLoad() + + + self.dimNode.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.dimTapGesture(_:)))) + } + public override var hasDim: Bool { return self.peersFilter.contains(.excludeRecent) } + public override var animateBackgroundAppearance: Bool { + return !self.hasDim + } + private func updateState(_ f: (ChatListSearchContainerNodeSearchState) -> ChatListSearchContainerNodeSearchState) { let state = f(self.stateValue) if state != self.stateValue { @@ -606,6 +622,12 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo } self.setQuery?(nil, tokens, query ?? "") } + + @objc private func dimTapGesture(_ recognizer: UITapGestureRecognizer) { + if case .ended = recognizer.state { + self.cancel?() + } + } override public func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationBarHeight: CGFloat, transition: ContainedViewLayoutTransition) { super.containerLayoutUpdated(layout, navigationBarHeight: navigationBarHeight, transition: transition) @@ -614,6 +636,8 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo self.validLayout = (layout, navigationBarHeight) let topInset = navigationBarHeight + + transition.updateFrame(node: self.dimNode, frame: CGRect(origin: CGPoint(x: 0.0, y: topInset), size: CGSize(width: layout.size.width, height: layout.size.height - topInset))) transition.updateFrame(node: self.filterContainerNode, frame: CGRect(origin: CGPoint(x: 0.0, y: navigationBarHeight + 6.0), size: CGSize(width: layout.size.width, height: 38.0))) var isForum = false diff --git a/submodules/ChatListUI/Sources/ChatListSearchPaneContainerNode.swift b/submodules/ChatListUI/Sources/ChatListSearchPaneContainerNode.swift index 115adc9ccd..795ee660c9 100644 --- a/submodules/ChatListUI/Sources/ChatListSearchPaneContainerNode.swift +++ b/submodules/ChatListUI/Sources/ChatListSearchPaneContainerNode.swift @@ -191,7 +191,7 @@ final class ChatListSearchPaneContainerNode: ASDisplayNode, UIGestureRecognizerD self.searchQuery = searchQuery self.searchOptions = searchOptions self.navigationController = navigationController - + super.init() } @@ -339,7 +339,7 @@ final class ChatListSearchPaneContainerNode: ASDisplayNode, UIGestureRecognizerD pane.pane.node.updateSelectedMessages(animated: animated) } } - + func update(size: CGSize, sideInset: CGFloat, bottomInset: CGFloat, visibleHeight: CGFloat, presentationData: PresentationData, availablePanes: [ChatListSearchPaneKey], transition: ContainedViewLayoutTransition) { let previousAvailablePanes = self.currentAvailablePanes ?? [] self.currentAvailablePanes = availablePanes @@ -376,8 +376,11 @@ final class ChatListSearchPaneContainerNode: ASDisplayNode, UIGestureRecognizerD self.currentParams = (size, sideInset, bottomInset, visibleHeight, presentationData, availablePanes) - self.backgroundColor = presentationData.theme.list.itemBlocksBackgroundColor - + if case .forum = self.location { + self.backgroundColor = .clear + } else { + self.backgroundColor = presentationData.theme.list.itemBlocksBackgroundColor + } let paneFrame = CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: size.height)) var visiblePaneIndices: [Int] = [] diff --git a/submodules/ChatListUI/Sources/Node/ChatListNode.swift b/submodules/ChatListUI/Sources/Node/ChatListNode.swift index de8ee202df..589910dec7 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListNode.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListNode.swift @@ -1834,6 +1834,10 @@ public final class ChatListNode: ListView { return strongSelf.isSelectionGestureEnabled } self.view.addGestureRecognizer(selectionRecognizer) + + if case .forum = location { + self.isSelectionGestureEnabled = false + } } deinit { diff --git a/submodules/SearchUI/Sources/SearchDisplayController.swift b/submodules/SearchUI/Sources/SearchDisplayController.swift index 3dc9dafaa6..8a0cddbde0 100644 --- a/submodules/SearchUI/Sources/SearchDisplayController.swift +++ b/submodules/SearchUI/Sources/SearchDisplayController.swift @@ -213,7 +213,9 @@ public final class SearchDisplayController { if let placeholder = placeholder { let initialTextBackgroundFrame = placeholder.convert(placeholder.backgroundNode.frame, to: nil) let contentNodePosition = self.backgroundNode.layer.position - self.backgroundNode.layer.animatePosition(from: CGPoint(x: contentNodePosition.x, y: contentNodePosition.y + (initialTextBackgroundFrame.maxY + 8.0 - contentNavigationBarHeight)), to: contentNodePosition, duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring) + if contentNode.animateBackgroundAppearance { + self.backgroundNode.layer.animatePosition(from: CGPoint(x: contentNodePosition.x, y: contentNodePosition.y + (initialTextBackgroundFrame.maxY + 8.0 - contentNavigationBarHeight)), to: contentNodePosition, duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring) + } self.searchBar.placeholderString = placeholder.placeholderString } } diff --git a/submodules/SearchUI/Sources/SearchDisplayControllerContentNode.swift b/submodules/SearchUI/Sources/SearchDisplayControllerContentNode.swift index 346c3fa137..885c4ef2c7 100644 --- a/submodules/SearchUI/Sources/SearchDisplayControllerContentNode.swift +++ b/submodules/SearchUI/Sources/SearchDisplayControllerContentNode.swift @@ -12,6 +12,10 @@ open class SearchDisplayControllerContentNode: ASDisplayNode { public final var setQuery: ((NSAttributedString?, [SearchBarToken], String) -> Void)? public final var setPlaceholder: ((String) -> Void)? + open var animateBackgroundAppearance: Bool { + return true + } + open var hasDim: Bool { return false } diff --git a/submodules/TelegramUI/Sources/ChatControllerNode.swift b/submodules/TelegramUI/Sources/ChatControllerNode.swift index 98d5af0c50..edae928325 100644 --- a/submodules/TelegramUI/Sources/ChatControllerNode.swift +++ b/submodules/TelegramUI/Sources/ChatControllerNode.swift @@ -1394,8 +1394,6 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { isSelectionEnabled = false } else if case .pinnedMessages = self.chatPresentationInterfaceState.subject { isSelectionEnabled = false - } else if case .forum = self.chatLocation { - isSelectionEnabled = false } self.historyNode.isSelectionGestureEnabled = isSelectionEnabled diff --git a/submodules/TelegramUI/Sources/ChatLoadingNode.swift b/submodules/TelegramUI/Sources/ChatLoadingNode.swift index a080cab335..1766a1fc64 100644 --- a/submodules/TelegramUI/Sources/ChatLoadingNode.swift +++ b/submodules/TelegramUI/Sources/ChatLoadingNode.swift @@ -348,7 +348,7 @@ final class ChatLoadingPlaceholderNode: ASDisplayNode { let messageContainer = self.messageContainers[k] let messageSize = messageContainer.frame.size - messageContainer.update(size: size, hasAvatar: self.isGroup, rect: CGRect(origin: CGPoint(x: 0.0, y: offset - messageSize.height), size: messageSize), transition: transition) + messageContainer.update(size: size, hasAvatar: self.chatType != .channel, rect: CGRect(origin: CGPoint(x: 0.0, y: offset - messageSize.height), size: messageSize), transition: transition) offset -= messageSize.height } } @@ -374,19 +374,28 @@ final class ChatLoadingPlaceholderNode: ASDisplayNode { } } - private var isGroup = false + enum ChatType: Equatable { + case generic + case group + case channel + } + private var chatType: ChatType = .channel func updatePresentationInterfaceState(_ chatPresentationInterfaceState: ChatPresentationInterfaceState) { - var isGroup = false + var chatType: ChatType = .channel if let peer = chatPresentationInterfaceState.renderedPeer?.peer { if peer is TelegramGroup { - isGroup = true - } else if let channel = peer as? TelegramChannel, case .group = channel.info { - isGroup = true + chatType = .group + } else if let channel = peer as? TelegramChannel { + if case .group = channel.info { + chatType = .group + } else { + chatType = .channel + } } } - if self.isGroup != isGroup { - self.isGroup = isGroup + if self.chatType != chatType { + self.chatType = chatType if let (size, insets) = self.validLayout { self.updateLayout(size: size, insets: insets, transition: .immediate) } @@ -414,30 +423,33 @@ final class ChatLoadingPlaceholderNode: ASDisplayNode { let shortHeight: CGFloat = 71.0 let tallHeight: CGFloat = 93.0 - + let dimensions: [CGSize] = [ CGSize(width: floorToScreenPixels(0.47 * size.width), height: tallHeight), - CGSize(width: floorToScreenPixels(0.57 * size.width), height: tallHeight), - CGSize(width: floorToScreenPixels(0.73 * size.width), height: tallHeight), + CGSize(width: floorToScreenPixels(0.58 * size.width), height: tallHeight), + CGSize(width: floorToScreenPixels(0.69 * size.width), height: tallHeight), CGSize(width: floorToScreenPixels(0.47 * size.width), height: tallHeight), - CGSize(width: floorToScreenPixels(0.57 * size.width), height: tallHeight), - CGSize(width: floorToScreenPixels(0.36 * size.width), height: shortHeight), - CGSize(width: floorToScreenPixels(0.47 * size.width), height: tallHeight), - CGSize(width: floorToScreenPixels(0.57 * size.width), height: tallHeight), - CGSize(width: floorToScreenPixels(0.73 * size.width), height: tallHeight), + CGSize(width: floorToScreenPixels(0.58 * size.width), height: shortHeight), CGSize(width: floorToScreenPixels(0.36 * size.width), height: tallHeight), - CGSize(width: floorToScreenPixels(0.57 * size.width), height: shortHeight), - ] - + CGSize(width: floorToScreenPixels(0.47 * size.width), height: tallHeight), + CGSize(width: floorToScreenPixels(0.36 * size.width), height: shortHeight), + CGSize(width: floorToScreenPixels(0.58 * size.width), height: tallHeight), + CGSize(width: floorToScreenPixels(0.69 * size.width), height: tallHeight), + CGSize(width: floorToScreenPixels(0.58 * size.width), height: tallHeight), + ].map { + if self.chatType == .channel { + return CGSize(width: floor($0.width * 1.3), height: floor($0.height * 1.8)) + } else { + return $0 + } + } + var offset: CGFloat = 5.0 var index = 0 -// if let (insetCount, _) = self.bottomInset { -// index += insetCount -// } for messageContainer in self.messageContainers { let messageSize = dimensions[index % 11] - messageContainer.update(size: bounds.size, hasAvatar: self.isGroup, rect: CGRect(origin: CGPoint(x: 0.0, y: bounds.size.height - insets.bottom - offset - messageSize.height), size: messageSize), transition: transition) + messageContainer.update(size: bounds.size, hasAvatar: self.chatType != .channel, rect: CGRect(origin: CGPoint(x: 0.0, y: bounds.size.height - insets.bottom - offset - messageSize.height), size: messageSize), transition: transition) offset += messageSize.height index += 1 }