Refactoring

This commit is contained in:
Justin Mazzocchi 2020-10-13 13:18:49 -07:00
parent 670e2f9af6
commit 40b795cd7e
No known key found for this signature in database
GPG Key ID: E223E6937AAFB01C
2 changed files with 4 additions and 3 deletions

View File

@ -9,7 +9,7 @@ final class StatusAttachmentsView: UIView {
private let rightStackView = UIStackView()
private var aspectRatioConstraint: NSLayoutConstraint?
var attachmentViewModels = [AttachmentViewModel]() {
var viewModel: StatusViewModel? {
didSet {
for stackView in [leftStackView, rightStackView] {
for view in stackView.arrangedSubviews {
@ -18,6 +18,7 @@ final class StatusAttachmentsView: UIView {
}
}
let attachmentViewModels = viewModel?.attachmentViewModels ?? []
let attachmentCount = attachmentViewModels.count
rightStackView.isHidden = attachmentCount == 1
@ -36,7 +37,7 @@ final class StatusAttachmentsView: UIView {
let newAspectRatio: CGFloat
if attachmentViewModels.count == 1, let aspectRatio = attachmentViewModels.first?.aspectRatio {
if attachmentCount == 1, let aspectRatio = attachmentViewModels.first?.aspectRatio {
newAspectRatio = max(CGFloat(aspectRatio), 16 / 9)
} else {
newAspectRatio = 16 / 9

View File

@ -393,7 +393,7 @@ private extension StatusView {
timeLabel.isHidden = isContextParent
attachmentsView.isHidden = viewModel.attachmentViewModels.count == 0
attachmentsView.attachmentViewModels = viewModel.attachmentViewModels
attachmentsView.viewModel = viewModel
cardView.viewModel = viewModel.cardViewModel
cardView.isHidden = viewModel.cardViewModel == nil