Fix cell layout when thread root is a poll

This commit is contained in:
ismailgulek
2022-01-18 23:41:36 +03:00
parent 31821e205f
commit 11cfae66c7
10 changed files with 135 additions and 34 deletions
@@ -47,6 +47,8 @@ final class BubbleCellContentView: UIView, NibLoadable {
@IBOutlet weak var reactionsContainerView: UIView!
@IBOutlet weak var reactionsContentView: UIView!
@IBOutlet weak var threadSummaryContainerView: UIView!
@IBOutlet weak var bubbleOverlayContainer: UIView!
@@ -69,6 +71,14 @@ final class BubbleCellContentView: UIView, NibLoadable {
self.reactionsContainerView.isHidden = !newValue
}
}
private var showThreadSummary: Bool {
get {
return !self.threadSummaryContainerView.isHidden
} set {
self.threadSummaryContainerView.isHidden = !newValue
}
}
// MARK: Public
@@ -143,3 +153,27 @@ extension BubbleCellContentView: BubbleCellReactionsDisplayable {
self.reactionsContentView.vc_removeAllSubviews()
}
}
// MARK: - BubbleCellThreadSummaryDisplayable
extension BubbleCellContentView: BubbleCellThreadSummaryDisplayable {
func addThreadSummaryView(_ threadSummaryView: ThreadSummaryView) {
self.threadSummaryContainerView.vc_removeAllSubviews()
self.threadSummaryContainerView.addSubview(threadSummaryView)
NSLayoutConstraint.activate([
threadSummaryView.leadingAnchor.constraint(equalTo: innerContentView.leadingAnchor),
threadSummaryView.topAnchor.constraint(equalTo: threadSummaryContainerView.topAnchor),
threadSummaryView.heightAnchor.constraint(equalToConstant: RoomBubbleCellLayout.threadSummaryViewHeight),
threadSummaryView.bottomAnchor.constraint(equalTo: threadSummaryContainerView.bottomAnchor),
threadSummaryView.trailingAnchor.constraint(lessThanOrEqualTo: threadSummaryContainerView.trailingAnchor,
constant: -RoomBubbleCellLayout.reactionsViewRightMargin)
])
self.showThreadSummary = true
}
func removeThreadSummaryView() {
self.showThreadSummary = false
self.threadSummaryContainerView.vc_removeAllSubviews()
}
}