add only notify mentions subtitle in conversation creen

This commit is contained in:
ryanzhao 2021-07-26 16:15:47 +10:00
parent b5d1ccdbc3
commit 0181b57f1a
1 changed files with 21 additions and 11 deletions

View File

@ -86,22 +86,32 @@ final class ConversationTitleView : UIView {
} }
private func getSubtitle() -> NSAttributedString? { private func getSubtitle() -> NSAttributedString? {
let result = NSMutableAttributedString()
if thread.isMuted { if thread.isMuted {
let result = NSMutableAttributedString()
result.append(NSAttributedString(string: "\u{e067} ", attributes: [ .font : UIFont.ows_elegantIconsFont(10), .foregroundColor : Colors.text ])) result.append(NSAttributedString(string: "\u{e067} ", attributes: [ .font : UIFont.ows_elegantIconsFont(10), .foregroundColor : Colors.text ]))
result.append(NSAttributedString(string: "Muted")) result.append(NSAttributedString(string: "Muted"))
return result return result
} else if let thread = self.thread as? TSGroupThread { } else if let thread = self.thread as? TSGroupThread {
var userCount: UInt64? if thread.isOnlyNotifyMentions {
switch thread.groupModel.groupType { let imageAttachment = NSTextAttachment()
case .closedGroup: userCount = UInt64(thread.groupModel.groupMemberIds.count) imageAttachment.image = UIImage(named: "NotifyMentions.png")?.asTintedImage(color: Colors.text)
case .openGroup: imageAttachment.bounds = CGRect(x: 0, y: -2, width: Values.smallFontSize, height: Values.smallFontSize)
guard let openGroupV2 = Storage.shared.getV2OpenGroup(for: self.thread.uniqueId!) else { return nil } let imageString = NSAttributedString(attachment: imageAttachment)
userCount = Storage.shared.getUserCount(forV2OpenGroupWithID: openGroupV2.id) result.append(imageString)
default: break result.append(NSAttributedString(string: " Only Notify Mentions"))
} return result
if let userCount = userCount { } else {
return NSAttributedString(string: "\(userCount) members") var userCount: UInt64?
switch thread.groupModel.groupType {
case .closedGroup: userCount = UInt64(thread.groupModel.groupMemberIds.count)
case .openGroup:
guard let openGroupV2 = Storage.shared.getV2OpenGroup(for: self.thread.uniqueId!) else { return nil }
userCount = Storage.shared.getUserCount(forV2OpenGroupWithID: openGroupV2.id)
default: break
}
if let userCount = userCount {
return NSAttributedString(string: "\(userCount) members")
}
} }
} }
return nil return nil