diff --git a/Session/Conversations/Views & Modals/ConversationTitleView.swift b/Session/Conversations/Views & Modals/ConversationTitleView.swift index 499def50d..7b27558db 100644 --- a/Session/Conversations/Views & Modals/ConversationTitleView.swift +++ b/Session/Conversations/Views & Modals/ConversationTitleView.swift @@ -15,7 +15,7 @@ final class ConversationTitleView: UIView { return UIView.layoutFittingExpandedSize } - private lazy var pagedScrollViewWidth = pagedScrollView.set(.width, to: 0) + private lazy var pagedScrollViewWidth = pagedScrollView.set(.width, to: 200) // MARK: - UI Components @@ -122,9 +122,6 @@ final class ConversationTitleView: UIView { // view resulting in the content shifting to the right during guard self.oldSize != .zero, self.oldSize != bounds.size else { self.oldSize = bounds.size - if pagedScrollViewWidth.constant == 0 { - pagedScrollViewWidth.constant = bounds.size.width - stackViewLeadingConstraint.constant - } return } diff --git a/Session/Conversations/Views & Modals/PagedScrollView.swift b/Session/Conversations/Views & Modals/PagedScrollView.swift index 12ffdc7e7..1a04e2408 100644 --- a/Session/Conversations/Views & Modals/PagedScrollView.swift +++ b/Session/Conversations/Views & Modals/PagedScrollView.swift @@ -13,6 +13,13 @@ final class PagedScrollView: UIView, UIScrollViewDelegate { private lazy var contentWidth = stackView.set(.width, to: 0) private lazy var contentHeight = stackView.set(.height, to: 0) + private var shouldArrowsShow: Bool = false { + didSet { + arrowLeft.isHidden = !shouldArrowsShow + arrowRight.isHidden = !shouldArrowsShow + } + } + // MARK: - UI Components private lazy var scrollView: UIScrollView = { @@ -42,6 +49,22 @@ final class PagedScrollView: UIView, UIScrollViewDelegate { return result }() + private lazy var arrowLeft: UIImageView = { + let result = UIImageView(image: UIImage(systemName: "chevron.left")?.withRenderingMode(.alwaysTemplate)) + result.themeTintColor = .textPrimary + result.set(.height, to: 10) + result.set(.width, to: 5) + return result + }() + + private lazy var arrowRight: UIImageView = { + let result = UIImageView(image: UIImage(systemName: "chevron.right")?.withRenderingMode(.alwaysTemplate)) + result.themeTintColor = .textPrimary + result.set(.height, to: 10) + result.set(.width, to: 5) + return result + }() + // MARK: - Initialization init(slides: [UIView] = [], slideSize: CGSize = .zero, shouldAutoScroll: Bool = false) { @@ -60,6 +83,7 @@ final class PagedScrollView: UIView, UIScrollViewDelegate { self.slides = slides self.slideSize = slideSize self.shouldAutoScroll = shouldAutoScroll + self.shouldArrowsShow = slides.count > 1 pageControl.numberOfPages = slides.count pageControl.currentPage = 0 @@ -90,6 +114,14 @@ final class PagedScrollView: UIView, UIScrollViewDelegate { addSubview(scrollView) scrollView.pin(to: self) + addSubview(arrowLeft) + arrowLeft.pin(.left, to: .left, of: self) + arrowLeft.center(.vertical, in: self, withInset: -2) + + addSubview(arrowRight) + arrowRight.pin(.right, to: .right, of: self) + arrowRight.center(.vertical, in: self, withInset: -2) + addSubview(pageControl) pageControl.center(.horizontal, in: self) pageControl.pin(.bottom, to: .bottom, of: self, withInset: -1)