mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
snippet for group members
This commit is contained in:
parent
037d70b185
commit
8be5768ad2
4 changed files with 26 additions and 8 deletions
|
@ -305,7 +305,7 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, NewConv
|
|||
}
|
||||
|
||||
@objc private func handleSeedViewedNotification(_ notification: Notification) {
|
||||
self.tableView.reloadSections(IndexSet(integer: 0), with: .none) // TODO: Just reload header
|
||||
self.tableView.reloadSections(IndexSet(integer: 0), with: .none) // TODO: Just reload header if possible
|
||||
}
|
||||
|
||||
@objc private func handleBlockedContactsUpdatedNotification(_ notification: Notification) {
|
||||
|
|
|
@ -82,7 +82,7 @@ class BaseVC : UIViewController {
|
|||
headingImageView.image = UIImage(named: "SessionHeading")?.withRenderingMode(.alwaysTemplate)
|
||||
headingImageView.contentMode = .scaleAspectFit
|
||||
headingImageView.set(.width, to: 150)
|
||||
headingImageView.set(.height, to: 18)
|
||||
headingImageView.set(.height, to: Values.mediumFontSize)
|
||||
navigationItem.titleView = headingImageView
|
||||
}
|
||||
|
||||
|
|
|
@ -210,17 +210,35 @@ final class ConversationCell : UITableViewCell {
|
|||
}
|
||||
|
||||
public func configure(messageDate: Date?, snippet: String?, searchText: String) {
|
||||
let normalizedSearchText = searchText.lowercased()
|
||||
if let messageDate = messageDate, let snippet = snippet {
|
||||
// Message
|
||||
displayNameLabel.attributedText = NSMutableAttributedString(string: getDisplayName(), attributes: [.foregroundColor:Colors.text])
|
||||
timestampLabel.isHidden = false
|
||||
timestampLabel.text = DateUtil.formatDate(forDisplay: messageDate)
|
||||
bottomLabelStackView.isHidden = false
|
||||
snippetLabel.attributedText = getHighlightedSnippet(snippet: snippet, searchText: searchText, fontSize: Values.smallFontSize)
|
||||
snippetLabel.attributedText = getHighlightedSnippet(snippet: snippet, searchText: normalizedSearchText, fontSize: Values.smallFontSize)
|
||||
} else {
|
||||
// Contact
|
||||
displayNameLabel.attributedText = getHighlightedSnippet(snippet: getDisplayName(), searchText: searchText, fontSize: Values.mediumFontSize)
|
||||
bottomLabelStackView.isHidden = true
|
||||
displayNameLabel.attributedText = getHighlightedSnippet(snippet: getDisplayName(), searchText: normalizedSearchText, fontSize: Values.mediumFontSize)
|
||||
if threadViewModel.isGroupThread, let thread = threadViewModel.threadRecord as? TSGroupThread {
|
||||
bottomLabelStackView.isHidden = false
|
||||
let context: Contact.Context = thread.isOpenGroup ? .openGroup : .regular
|
||||
var rawSnippet: String = ""
|
||||
thread.groupModel.groupMemberIds.forEach{ id in
|
||||
if let displayName = Storage.shared.getContact(with: id)?.displayName(for: context) {
|
||||
if !rawSnippet.isEmpty {
|
||||
rawSnippet += ", \(displayName)"
|
||||
}
|
||||
if displayName.lowercased().contains(normalizedSearchText) {
|
||||
rawSnippet = displayName
|
||||
}
|
||||
}
|
||||
}
|
||||
snippetLabel.attributedText = getHighlightedSnippet(snippet: rawSnippet, searchText: normalizedSearchText, fontSize: Values.smallFontSize)
|
||||
} else {
|
||||
bottomLabelStackView.isHidden = true
|
||||
}
|
||||
timestampLabel.isHidden = true
|
||||
}
|
||||
}
|
||||
|
@ -232,11 +250,10 @@ final class ConversationCell : UITableViewCell {
|
|||
|
||||
let result = NSMutableAttributedString(string: snippet, attributes: [.foregroundColor:Colors.text.withAlphaComponent(Values.lowOpacity)])
|
||||
let normalizedSnippet = snippet.lowercased() as NSString
|
||||
let normalizedSearchText = searchText.lowercased()
|
||||
|
||||
guard normalizedSnippet.contains(normalizedSearchText) else { return result }
|
||||
guard normalizedSnippet.contains(searchText) else { return result }
|
||||
|
||||
let range = normalizedSnippet.range(of: normalizedSearchText)
|
||||
let range = normalizedSnippet.range(of: searchText)
|
||||
result.addAttribute(.foregroundColor, value: Colors.text, range: range)
|
||||
result.addAttribute(.font, value: UIFont.boldSystemFont(ofSize: fontSize), range: range)
|
||||
return result
|
||||
|
|
|
@ -97,6 +97,7 @@ public class FullTextSearchFinder: NSObject {
|
|||
let snippetOptions = YapDatabaseFullTextSearchSnippetOptions()
|
||||
snippetOptions.startMatchText = ""
|
||||
snippetOptions.endMatchText = ""
|
||||
snippetOptions.numberOfTokens = 5
|
||||
ext.enumerateKeysAndObjects(matching: query, with: snippetOptions) { (snippet: String, _: String, _: String, object: Any, stop: UnsafeMutablePointer<ObjCBool>) in
|
||||
guard searchResultCount < maxSearchResults else {
|
||||
stop.pointee = true
|
||||
|
|
Loading…
Reference in a new issue