|
|
@ -31,7 +31,7 @@ final class ConversationTitleView: UIView {
|
|
|
|
|
|
|
|
|
|
|
|
private lazy var pagedScrollView: PagedScrollView = {
|
|
|
|
private lazy var pagedScrollView: PagedScrollView = {
|
|
|
|
let result = PagedScrollView()
|
|
|
|
let result = PagedScrollView()
|
|
|
|
|
|
|
|
result.set(.width, to: 320)
|
|
|
|
return result
|
|
|
|
return result
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
@ -44,6 +44,24 @@ final class ConversationTitleView: UIView {
|
|
|
|
return result
|
|
|
|
return result
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private lazy var userCountLabel: UILabel = {
|
|
|
|
|
|
|
|
let result: UILabel = UILabel()
|
|
|
|
|
|
|
|
result.font = .systemFont(ofSize: 13)
|
|
|
|
|
|
|
|
result.themeTextColor = .textPrimary
|
|
|
|
|
|
|
|
result.lineBreakMode = .byTruncatingTail
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private lazy var notificationSettingsLabel: UILabel = {
|
|
|
|
|
|
|
|
let result: UILabel = UILabel()
|
|
|
|
|
|
|
|
result.font = .systemFont(ofSize: 13)
|
|
|
|
|
|
|
|
result.themeTextColor = .textPrimary
|
|
|
|
|
|
|
|
result.lineBreakMode = .byTruncatingTail
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
private lazy var disappearingMessageSettingLabel: UILabel = {
|
|
|
|
private lazy var disappearingMessageSettingLabel: UILabel = {
|
|
|
|
let result: UILabel = UILabel()
|
|
|
|
let result: UILabel = UILabel()
|
|
|
|
result.font = .systemFont(ofSize: 13)
|
|
|
|
result.font = .systemFont(ofSize: 13)
|
|
|
@ -67,13 +85,15 @@ final class ConversationTitleView: UIView {
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
private lazy var stackView: UIStackView = {
|
|
|
|
private lazy var stackView: UIStackView = {
|
|
|
|
let result = UIStackView(arrangedSubviews: [ titleLabel, subtitleLabel, disappearingMessageSettingsStackView ])
|
|
|
|
let result = UIStackView(arrangedSubviews: [ titleLabel, pagedScrollView ])
|
|
|
|
result.axis = .vertical
|
|
|
|
result.axis = .vertical
|
|
|
|
result.alignment = .center
|
|
|
|
result.alignment = .center
|
|
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
return result
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private var slides: [UIView] = []
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: - Initialization
|
|
|
|
// MARK: - Initialization
|
|
|
|
|
|
|
|
|
|
|
|
init() {
|
|
|
|
init() {
|
|
|
@ -111,6 +131,8 @@ final class ConversationTitleView: UIView {
|
|
|
|
override func layoutSubviews() {
|
|
|
|
override func layoutSubviews() {
|
|
|
|
super.layoutSubviews()
|
|
|
|
super.layoutSubviews()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.pagedScrollView.update(with: slides, slideSize: CGSize(width: bounds.size.width, height: 20), shouldAutoScroll: false)
|
|
|
|
|
|
|
|
|
|
|
|
// There is an annoying issue where pushing seems to update the width of this
|
|
|
|
// There is an annoying issue where pushing seems to update the width of this
|
|
|
|
// view resulting in the content shifting to the right during
|
|
|
|
// view resulting in the content shifting to the right during
|
|
|
|
guard self.oldSize != .zero, self.oldSize != bounds.size else {
|
|
|
|
guard self.oldSize != .zero, self.oldSize != bounds.size else {
|
|
|
@ -159,11 +181,13 @@ final class ConversationTitleView: UIView {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
ThemeManager.onThemeChange(observer: self.subtitleLabel) { [weak subtitleLabel] theme, _ in
|
|
|
|
ThemeManager.onThemeChange(observer: self.subtitleLabel) { [weak self] theme, _ in
|
|
|
|
guard let textPrimary: UIColor = theme.color(for: .textPrimary) else { return }
|
|
|
|
guard let textPrimary: UIColor = theme.color(for: .textPrimary) else { return }
|
|
|
|
|
|
|
|
|
|
|
|
guard Date().timeIntervalSince1970 > (mutedUntilTimestamp ?? 0) else {
|
|
|
|
var slides: [UIView?] = []
|
|
|
|
subtitleLabel?.attributedText = NSAttributedString(
|
|
|
|
|
|
|
|
|
|
|
|
if Date().timeIntervalSince1970 <= (mutedUntilTimestamp ?? 0) {
|
|
|
|
|
|
|
|
self?.notificationSettingsLabel.attributedText = NSAttributedString(
|
|
|
|
string: "\u{e067} ",
|
|
|
|
string: "\u{e067} ",
|
|
|
|
attributes: [
|
|
|
|
attributes: [
|
|
|
|
.font: UIFont.ows_elegantIconsFont(10),
|
|
|
|
.font: UIFont.ows_elegantIconsFont(10),
|
|
|
@ -171,9 +195,9 @@ final class ConversationTitleView: UIView {
|
|
|
|
]
|
|
|
|
]
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.appending(string: "Muted")
|
|
|
|
.appending(string: "Muted")
|
|
|
|
return
|
|
|
|
self?.notificationSettingsLabel.isHidden = false
|
|
|
|
}
|
|
|
|
slides.append(self?.notificationSettingsLabel)
|
|
|
|
guard !onlyNotifyForMentions else {
|
|
|
|
} else if onlyNotifyForMentions{
|
|
|
|
let imageAttachment = NSTextAttachment()
|
|
|
|
let imageAttachment = NSTextAttachment()
|
|
|
|
imageAttachment.image = UIImage(named: "NotifyMentions.png")?.withTint(textPrimary)
|
|
|
|
imageAttachment.image = UIImage(named: "NotifyMentions.png")?.withTint(textPrimary)
|
|
|
|
imageAttachment.bounds = CGRect(
|
|
|
|
imageAttachment.bounds = CGRect(
|
|
|
@ -183,26 +207,32 @@ final class ConversationTitleView: UIView {
|
|
|
|
height: Values.smallFontSize
|
|
|
|
height: Values.smallFontSize
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
subtitleLabel?.attributedText = NSAttributedString(attachment: imageAttachment)
|
|
|
|
self?.notificationSettingsLabel.attributedText = NSAttributedString(attachment: imageAttachment)
|
|
|
|
.appending(string: " ")
|
|
|
|
.appending(string: " ")
|
|
|
|
.appending(string: "view_conversation_title_notify_for_mentions_only".localized())
|
|
|
|
.appending(string: "view_conversation_title_notify_for_mentions_only".localized())
|
|
|
|
return
|
|
|
|
self?.notificationSettingsLabel.isHidden = false
|
|
|
|
|
|
|
|
slides.append(self?.notificationSettingsLabel)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
guard let userCount: Int = userCount else { return }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch threadVariant {
|
|
|
|
if let userCount: Int = userCount {
|
|
|
|
case .contact: break
|
|
|
|
switch threadVariant {
|
|
|
|
|
|
|
|
case .contact: break
|
|
|
|
case .closedGroup:
|
|
|
|
|
|
|
|
subtitleLabel?.attributedText = NSAttributedString(
|
|
|
|
case .closedGroup:
|
|
|
|
string: "\(userCount) member\(userCount == 1 ? "" : "s")"
|
|
|
|
self?.userCountLabel.attributedText = NSAttributedString(
|
|
|
|
)
|
|
|
|
string: "\(userCount) member\(userCount == 1 ? "" : "s")"
|
|
|
|
|
|
|
|
)
|
|
|
|
case .openGroup:
|
|
|
|
|
|
|
|
subtitleLabel?.attributedText = NSAttributedString(
|
|
|
|
case .openGroup:
|
|
|
|
string: "\(userCount) active member\(userCount == 1 ? "" : "s")"
|
|
|
|
self?.userCountLabel.attributedText = NSAttributedString(
|
|
|
|
)
|
|
|
|
string: "\(userCount) active member\(userCount == 1 ? "" : "s")"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
slides.append(self?.userCountLabel)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Disappearing message settings
|
|
|
|
|
|
|
|
self?.slides = slides.compactMap{ $0 }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Contact threads also have the call button to compensate for
|
|
|
|
// Contact threads also have the call button to compensate for
|
|
|
|