mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-25 09:41:00 +00:00
Refactoring
This commit is contained in:
parent
670e2f9af6
commit
40b795cd7e
2 changed files with 4 additions and 3 deletions
|
@ -9,7 +9,7 @@ final class StatusAttachmentsView: UIView {
|
||||||
private let rightStackView = UIStackView()
|
private let rightStackView = UIStackView()
|
||||||
private var aspectRatioConstraint: NSLayoutConstraint?
|
private var aspectRatioConstraint: NSLayoutConstraint?
|
||||||
|
|
||||||
var attachmentViewModels = [AttachmentViewModel]() {
|
var viewModel: StatusViewModel? {
|
||||||
didSet {
|
didSet {
|
||||||
for stackView in [leftStackView, rightStackView] {
|
for stackView in [leftStackView, rightStackView] {
|
||||||
for view in stackView.arrangedSubviews {
|
for view in stackView.arrangedSubviews {
|
||||||
|
@ -18,6 +18,7 @@ final class StatusAttachmentsView: UIView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let attachmentViewModels = viewModel?.attachmentViewModels ?? []
|
||||||
let attachmentCount = attachmentViewModels.count
|
let attachmentCount = attachmentViewModels.count
|
||||||
|
|
||||||
rightStackView.isHidden = attachmentCount == 1
|
rightStackView.isHidden = attachmentCount == 1
|
||||||
|
@ -36,7 +37,7 @@ final class StatusAttachmentsView: UIView {
|
||||||
|
|
||||||
let newAspectRatio: CGFloat
|
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)
|
newAspectRatio = max(CGFloat(aspectRatio), 16 / 9)
|
||||||
} else {
|
} else {
|
||||||
newAspectRatio = 16 / 9
|
newAspectRatio = 16 / 9
|
||||||
|
|
|
@ -393,7 +393,7 @@ private extension StatusView {
|
||||||
timeLabel.isHidden = isContextParent
|
timeLabel.isHidden = isContextParent
|
||||||
|
|
||||||
attachmentsView.isHidden = viewModel.attachmentViewModels.count == 0
|
attachmentsView.isHidden = viewModel.attachmentViewModels.count == 0
|
||||||
attachmentsView.attachmentViewModels = viewModel.attachmentViewModels
|
attachmentsView.viewModel = viewModel
|
||||||
|
|
||||||
cardView.viewModel = viewModel.cardViewModel
|
cardView.viewModel = viewModel.cardViewModel
|
||||||
cardView.isHidden = viewModel.cardViewModel == nil
|
cardView.isHidden = viewModel.cardViewModel == nil
|
||||||
|
|
Loading…
Reference in a new issue