mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
95ee0e7cf3
commit
0bf8b373e3
@ -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
|
||||
|
@ -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] = []
|
||||
|
@ -1834,6 +1834,10 @@ public final class ChatListNode: ListView {
|
||||
return strongSelf.isSelectionGestureEnabled
|
||||
}
|
||||
self.view.addGestureRecognizer(selectionRecognizer)
|
||||
|
||||
if case .forum = location {
|
||||
self.isSelectionGestureEnabled = false
|
||||
}
|
||||
}
|
||||
|
||||
deinit {
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user