diff --git a/Session/Conversations/Views & Modals/ConversationTitleView.swift b/Session/Conversations/Views & Modals/ConversationTitleView.swift index 8b50d9dee..327772bd2 100644 --- a/Session/Conversations/Views & Modals/ConversationTitleView.swift +++ b/Session/Conversations/Views & Modals/ConversationTitleView.swift @@ -16,6 +16,10 @@ final class ConversationTitleView: UIView { } private lazy var labelCarouselViewWidth = labelCarouselView.set(.width, to: 200) + + public var currentLabelType: SessionLabelCarouselView.LabelType { + return self.labelCarouselView.currentLabelType + } // MARK: - UI Components @@ -137,6 +141,7 @@ final class ConversationTitleView: UIView { guard let textPrimary: UIColor = theme.color(for: .textPrimary) else { return } var labelStrings: [NSAttributedString] = [] + var labelTypes: [SessionLabelCarouselView.LabelType] = [] if Date().timeIntervalSince1970 <= (mutedUntilTimestamp ?? 0) { let notificationSettingsLabelString = NSAttributedString( @@ -149,6 +154,7 @@ final class ConversationTitleView: UIView { .appending(string: "Muted") labelStrings.append(notificationSettingsLabelString) + labelTypes.append(.notificationSettings) } else if onlyNotifyForMentions{ let imageAttachment = NSTextAttachment() imageAttachment.image = UIImage(named: "NotifyMentions.png")?.withTint(textPrimary) @@ -164,6 +170,7 @@ final class ConversationTitleView: UIView { .appending(string: "view_conversation_title_notify_for_mentions_only".localized()) labelStrings.append(notificationSettingsLabelString) + labelTypes.append(.notificationSettings) } if let userCount: Int = userCount { @@ -184,6 +191,7 @@ final class ConversationTitleView: UIView { }() labelStrings.append(userCountLabelString) + labelTypes.append(.userCount) } if let config = disappearingMessagesConfig, config.isEnabled == true { @@ -203,10 +211,12 @@ final class ConversationTitleView: UIView { .appending(string: floor(config.durationSeconds).formatted(format: .short)) labelStrings.append(disappearingMessageSettingLabelString) + labelTypes.append(.disappearingMessageSetting) } self?.labelCarouselView.update( with: labelStrings, + labelTypes: labelTypes, labelSize: CGSize( width: self?.labelCarouselViewWidth.constant ?? 0, height: 20 diff --git a/Session/Conversations/Views & Modals/SessionLabelCarouselView.swift b/Session/Conversations/Views & Modals/SessionLabelCarouselView.swift index 118c24de5..0a72407cf 100644 --- a/Session/Conversations/Views & Modals/SessionLabelCarouselView.swift +++ b/Session/Conversations/Views & Modals/SessionLabelCarouselView.swift @@ -6,6 +6,7 @@ import SessionUIKit final class SessionLabelCarouselView: UIView, UIScrollViewDelegate { private static let autoScrollingTimeInterval: TimeInterval = 10 private var labelStrings: [NSAttributedString] = [] + private var labelTypes: [LabelType] = [] private var labelSize: CGSize = .zero private var shouldAutoScroll: Bool = false private var timer: Timer? @@ -21,6 +22,18 @@ final class SessionLabelCarouselView: UIView, UIScrollViewDelegate { } } + // MARK: - Types + + public enum LabelType { + case notificationSettings + case userCount + case disappearingMessageSetting + } + + public var currentLabelType: LabelType { + return self.labelTypes[pageControl.currentPage] + } + // MARK: - UI Components private lazy var scrollView: UIScrollView = { @@ -68,10 +81,10 @@ final class SessionLabelCarouselView: UIView, UIScrollViewDelegate { // MARK: - Initialization - init(labelStrings: [NSAttributedString] = [], labelSize: CGSize = .zero, shouldAutoScroll: Bool = false) { + init(labelStrings: [NSAttributedString] = [], labelTypes: [LabelType] = [], labelSize: CGSize = .zero, shouldAutoScroll: Bool = false) { super.init(frame: .zero) setUpViewHierarchy() - self.update(with: labelStrings, labelSize: labelSize, shouldAutoScroll: shouldAutoScroll) + self.update(with: labelStrings, labelTypes: labelTypes, labelSize: labelSize, shouldAutoScroll: shouldAutoScroll) } required init?(coder: NSCoder) { @@ -80,8 +93,9 @@ final class SessionLabelCarouselView: UIView, UIScrollViewDelegate { // MARK: - Content - public func update(with labelStrings: [NSAttributedString] = [], labelSize: CGSize = .zero, shouldAutoScroll: Bool = false) { + public func update(with labelStrings: [NSAttributedString] = [], labelTypes: [LabelType] = [], labelSize: CGSize = .zero, shouldAutoScroll: Bool = false) { self.labelStrings = labelStrings + self.labelTypes = labelTypes self.labelSize = labelSize self.shouldAutoScroll = shouldAutoScroll self.shouldScroll = labelStrings.count > 1