mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
fix carousel view for media preview views
This commit is contained in:
parent
3f33caf91a
commit
31d081ff49
|
@ -12,6 +12,22 @@ final class MediaInfoVC: BaseVC {
|
|||
|
||||
// MARK: - UI
|
||||
private lazy var mediaInfoView: MediaInfoView = MediaInfoView(attachment: nil)
|
||||
private lazy var mediaCarouselView: SessionCarouselView = {
|
||||
let result: SessionCarouselView = SessionCarouselView(
|
||||
slices: self.attachments.map {
|
||||
MediaPreviewView(
|
||||
attachment: $0,
|
||||
isOutgoing: self.isOutgoing
|
||||
)
|
||||
},
|
||||
sliceSize: CGSize(
|
||||
width: Self.mediaSize,
|
||||
height: Self.mediaSize
|
||||
)
|
||||
)
|
||||
|
||||
return result
|
||||
}()
|
||||
|
||||
// MARK: - Initialization
|
||||
|
||||
|
@ -43,30 +59,9 @@ final class MediaInfoVC: BaseVC {
|
|||
let mediaStackView: UIStackView = UIStackView()
|
||||
mediaStackView.axis = .horizontal
|
||||
|
||||
attachments.forEach {
|
||||
let mediaPreviewView: MediaPreviewView = MediaPreviewView(
|
||||
attachment: $0,
|
||||
isOutgoing: isOutgoing)
|
||||
mediaStackView.addArrangedSubview(mediaPreviewView)
|
||||
}
|
||||
|
||||
let contentWidth: CGFloat = Self.mediaSize * CGFloat(attachments.count)
|
||||
let contentHeight: CGFloat = Self.mediaSize
|
||||
mediaStackView.set(.width, to: contentWidth)
|
||||
mediaStackView.set(.height, to: contentHeight)
|
||||
|
||||
let scrollView: UIScrollView = UIScrollView()
|
||||
scrollView.isPagingEnabled = true
|
||||
scrollView.showsVerticalScrollIndicator = false
|
||||
scrollView.showsHorizontalScrollIndicator = false
|
||||
scrollView.set(.width, to: Self.mediaSize)
|
||||
scrollView.set(.height, to: Self.mediaSize)
|
||||
scrollView.contentSize = CGSize(width: contentWidth, height: contentHeight)
|
||||
scrollView.addSubview(mediaStackView)
|
||||
|
||||
mediaInfoView.update(attachment: attachments[0])
|
||||
|
||||
let stackView: UIStackView = UIStackView(arrangedSubviews: [ scrollView, mediaInfoView ])
|
||||
let stackView: UIStackView = UIStackView(arrangedSubviews: [ mediaCarouselView, mediaInfoView ])
|
||||
stackView.axis = .vertical
|
||||
stackView.spacing = Values.largeSpacing
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import Foundation
|
||||
|
||||
final class SessionCarouselView: UIView {
|
||||
final class SessionCarouselView: UIView, UIScrollViewDelegate {
|
||||
private let slices: [UIView]
|
||||
private let sliceSize: CGSize
|
||||
|
||||
|
@ -16,6 +16,7 @@ final class SessionCarouselView: UIView {
|
|||
// MARK: - UI
|
||||
private lazy var scrollView: UIScrollView = {
|
||||
let result: UIScrollView = UIScrollView()
|
||||
result.delegate = self
|
||||
result.isPagingEnabled = true
|
||||
result.showsHorizontalScrollIndicator = false
|
||||
result.showsVerticalScrollIndicator = false
|
||||
|
@ -59,10 +60,17 @@ final class SessionCarouselView: UIView {
|
|||
|
||||
addSubview(self.scrollView)
|
||||
scrollView.pin(to: self)
|
||||
scrollView.set(.width, to: self.sliceSize.width)
|
||||
scrollView.set(.height, to: self.sliceSize.height)
|
||||
scrollView.addSubview(stackView)
|
||||
|
||||
addSubview(self.pageControl)
|
||||
self.pageControl.center(.horizontal, in: self)
|
||||
self.pageControl.pin(.bottom, to: .bottom, of: self)
|
||||
}
|
||||
|
||||
// MARK: - UIScrollViewDelegate
|
||||
func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue