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? {
let result = NSMutableAttributedString()
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: "Muted"))
return result
} else if let thread = self.thread as? TSGroupThread {
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")
if thread.isOnlyNotifyMentions {
let imageAttachment = NSTextAttachment()
imageAttachment.image = UIImage(named: "NotifyMentions.png")?.asTintedImage(color: Colors.text)
imageAttachment.bounds = CGRect(x: 0, y: -2, width: Values.smallFontSize, height: Values.smallFontSize)
let imageString = NSAttributedString(attachment: imageAttachment)
result.append(imageString)
result.append(NSAttributedString(string: " Only Notify Mentions"))
return result
} else {
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