mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Search filters improvements
This commit is contained in:
parent
02ca03bfb8
commit
1f955a4511
@ -658,20 +658,20 @@ public enum ChatListSearchContextActionSource {
|
|||||||
|
|
||||||
public struct ChatListSearchOptions {
|
public struct ChatListSearchOptions {
|
||||||
let peer: (PeerId, String)?
|
let peer: (PeerId, String)?
|
||||||
let minDate: Int32?
|
let minDate: (Int32, String)?
|
||||||
let maxDate: Int32?
|
let maxDate: (Int32, String)?
|
||||||
let messageTags: MessageTags?
|
let messageTags: MessageTags?
|
||||||
|
|
||||||
func withUpdatedPeer(_ peerIdAndName: (PeerId, String)?) -> ChatListSearchOptions {
|
func withUpdatedPeer(_ peerIdAndName: (PeerId, String)?) -> ChatListSearchOptions {
|
||||||
return ChatListSearchOptions(peer: peerIdAndName, minDate: self.minDate, maxDate: self.maxDate, messageTags: self.messageTags)
|
return ChatListSearchOptions(peer: peerIdAndName, minDate: self.minDate, maxDate: self.maxDate, messageTags: self.messageTags)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedMinDate(_ minDate: Int32?) -> ChatListSearchOptions {
|
func withUpdatedMinDate(_ minDateAndTitle: (Int32, String)?) -> ChatListSearchOptions {
|
||||||
return ChatListSearchOptions(peer: self.peer, minDate: minDate, maxDate: self.maxDate, messageTags: self.messageTags)
|
return ChatListSearchOptions(peer: self.peer, minDate: minDateAndTitle, maxDate: self.maxDate, messageTags: self.messageTags)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedMaxDate(_ maxDate: Int32?) -> ChatListSearchOptions {
|
func withUpdatedMaxDate(_ maxDateAndTitle: (Int32, String)?) -> ChatListSearchOptions {
|
||||||
return ChatListSearchOptions(peer: self.peer, minDate: self.minDate, maxDate: maxDate, messageTags: self.messageTags)
|
return ChatListSearchOptions(peer: self.peer, minDate: self.minDate, maxDate: maxDateAndTitle, messageTags: self.messageTags)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedMessageTags(_ messageTags: MessageTags?) -> ChatListSearchOptions {
|
func withUpdatedMessageTags(_ messageTags: MessageTags?) -> ChatListSearchOptions {
|
||||||
@ -911,10 +911,10 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
|
|||||||
let location: SearchMessagesLocation
|
let location: SearchMessagesLocation
|
||||||
if let options = options {
|
if let options = options {
|
||||||
if let (peerId, _) = options.peer {
|
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 {
|
} 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 {
|
} else {
|
||||||
location = .general(tags: nil, minDate: nil, maxDate: nil)
|
location = .general(tags: nil, minDate: nil, maxDate: nil)
|
||||||
@ -1621,8 +1621,8 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
|
|||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var messageTags: MessageTags? = strongSelf.currentSearchOptions.messageTags
|
var messageTags = strongSelf.currentSearchOptions.messageTags
|
||||||
var maxDate: Int32? = strongSelf.currentSearchOptions.maxDate
|
var maxDate = strongSelf.currentSearchOptions.maxDate
|
||||||
var peer = strongSelf.currentSearchOptions.peer
|
var peer = strongSelf.currentSearchOptions.peer
|
||||||
var clearQuery: Bool = false
|
var clearQuery: Bool = false
|
||||||
switch filter {
|
switch filter {
|
||||||
@ -1636,8 +1636,8 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
|
|||||||
messageTags = .music
|
messageTags = .music
|
||||||
case .voice:
|
case .voice:
|
||||||
messageTags = .voiceOrInstantVideo
|
messageTags = .voiceOrInstantVideo
|
||||||
case let .date(date, _):
|
case let .date(date, title):
|
||||||
maxDate = date
|
maxDate = (date, title)
|
||||||
clearQuery = true
|
clearQuery = true
|
||||||
case let .peer(id, name):
|
case let .peer(id, name):
|
||||||
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))
|
tokens.append(SearchBarToken(id: ChatListTokenId.peer.rawValue, icon: UIImage(bundleImageName: "Chat List/Search/User"), title: peerName))
|
||||||
}
|
}
|
||||||
|
|
||||||
if let maxDate = options?.maxDate {
|
if let (_, dateTitle) = options?.maxDate {
|
||||||
let formatter = DateFormatter()
|
tokens.append(SearchBarToken(id: ChatListTokenId.date.rawValue, icon: UIImage(bundleImageName: "Chat List/Search/Calendar"), title: dateTitle))
|
||||||
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))
|
|
||||||
|
|
||||||
self.possibleDates = []
|
self.possibleDates = []
|
||||||
}
|
}
|
||||||
|
@ -418,11 +418,6 @@ private class SearchBarTextField: UITextField {
|
|||||||
return self.textRect(forBounds: bounds)
|
return self.textRect(forBounds: bounds)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func drawText(in rect: CGRect) {
|
|
||||||
super.drawText(in: rect)
|
|
||||||
print(rect.debugDescription)
|
|
||||||
}
|
|
||||||
|
|
||||||
override func layoutSubviews() {
|
override func layoutSubviews() {
|
||||||
super.layoutSubviews()
|
super.layoutSubviews()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user