Search filters improvements

This commit is contained in:
Ilya Laktyushin 2020-09-12 19:49:15 +03:00
parent 02ca03bfb8
commit 1f955a4511
2 changed files with 14 additions and 23 deletions

View File

@ -658,20 +658,20 @@ public enum ChatListSearchContextActionSource {
public struct ChatListSearchOptions {
let peer: (PeerId, String)?
let minDate: Int32?
let maxDate: Int32?
let minDate: (Int32, String)?
let maxDate: (Int32, String)?
let messageTags: MessageTags?
func withUpdatedPeer(_ peerIdAndName: (PeerId, String)?) -> ChatListSearchOptions {
return ChatListSearchOptions(peer: peerIdAndName, minDate: self.minDate, maxDate: self.maxDate, messageTags: self.messageTags)
}
func withUpdatedMinDate(_ minDate: Int32?) -> ChatListSearchOptions {
return ChatListSearchOptions(peer: self.peer, minDate: minDate, maxDate: self.maxDate, messageTags: self.messageTags)
func withUpdatedMinDate(_ minDateAndTitle: (Int32, String)?) -> ChatListSearchOptions {
return ChatListSearchOptions(peer: self.peer, minDate: minDateAndTitle, maxDate: self.maxDate, messageTags: self.messageTags)
}
func withUpdatedMaxDate(_ maxDate: Int32?) -> ChatListSearchOptions {
return ChatListSearchOptions(peer: self.peer, minDate: self.minDate, maxDate: maxDate, messageTags: self.messageTags)
func withUpdatedMaxDate(_ maxDateAndTitle: (Int32, String)?) -> ChatListSearchOptions {
return ChatListSearchOptions(peer: self.peer, minDate: self.minDate, maxDate: maxDateAndTitle, messageTags: self.messageTags)
}
func withUpdatedMessageTags(_ messageTags: MessageTags?) -> ChatListSearchOptions {
@ -911,10 +911,10 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
let location: SearchMessagesLocation
if let options = options {
if let (peerId, _) = options.peer {
location = .peer(peerId: peerId, fromId: nil, tags: options.messageTags, topMsgId: nil, minDate: options.minDate, maxDate: options.maxDate)
location = .peer(peerId: peerId, fromId: nil, tags: options.messageTags, topMsgId: nil, minDate: options.minDate?.0, maxDate: options.maxDate?.0)
} else {
location = .general(tags: options.messageTags, minDate: options.minDate, maxDate: options.maxDate)
location = .general(tags: options.messageTags, minDate: options.minDate?.0, maxDate: options.maxDate?.0)
}
} else {
location = .general(tags: nil, minDate: nil, maxDate: nil)
@ -1621,8 +1621,8 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
guard let strongSelf = self else {
return
}
var messageTags: MessageTags? = strongSelf.currentSearchOptions.messageTags
var maxDate: Int32? = strongSelf.currentSearchOptions.maxDate
var messageTags = strongSelf.currentSearchOptions.messageTags
var maxDate = strongSelf.currentSearchOptions.maxDate
var peer = strongSelf.currentSearchOptions.peer
var clearQuery: Bool = false
switch filter {
@ -1636,8 +1636,8 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
messageTags = .music
case .voice:
messageTags = .voiceOrInstantVideo
case let .date(date, _):
maxDate = date
case let .date(date, title):
maxDate = (date, title)
clearQuery = true
case let .peer(id, name):
peer = (id, name)
@ -1768,12 +1768,8 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
tokens.append(SearchBarToken(id: ChatListTokenId.peer.rawValue, icon: UIImage(bundleImageName: "Chat List/Search/User"), title: peerName))
}
if let maxDate = options?.maxDate {
let formatter = DateFormatter()
formatter.timeStyle = .none
formatter.dateStyle = .medium
let title = formatter.string(from: Date(timeIntervalSince1970: Double(maxDate)))
tokens.append(SearchBarToken(id: ChatListTokenId.date.rawValue, icon: UIImage(bundleImageName: "Chat List/Search/Calendar"), title: title))
if let (_, dateTitle) = options?.maxDate {
tokens.append(SearchBarToken(id: ChatListTokenId.date.rawValue, icon: UIImage(bundleImageName: "Chat List/Search/Calendar"), title: dateTitle))
self.possibleDates = []
}

View File

@ -418,11 +418,6 @@ private class SearchBarTextField: UITextField {
return self.textRect(forBounds: bounds)
}
override func drawText(in rect: CGRect) {
super.drawText(in: rect)
print(rect.debugDescription)
}
override func layoutSubviews() {
super.layoutSubviews()