mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-21 15:50:59 +00:00
Label uncaptioned attachments
This commit is contained in:
parent
eadbe0ee2a
commit
4934a6e45c
5 changed files with 19 additions and 16 deletions
|
@ -97,6 +97,7 @@
|
|||
"compose.attachment.cancel-upload.accessibility-label" = "Cancel uploading attachment";
|
||||
"compose.attachment.edit" = "Edit attachment";
|
||||
"compose.attachment.remove" = "Remove attachment";
|
||||
"compose.attachment.uncaptioned" = "Uncaptioned";
|
||||
"compose.attachment.uploading" = "Uploading";
|
||||
"compose.attachments-button.accessibility-label" = "Add attachment";
|
||||
"compose.attachments-will-be-discarded" = "Attachments will be discarded when changing accounts";
|
||||
|
|
|
@ -141,6 +141,7 @@
|
|||
D0B32F50250B373600311912 /* RegistrationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0B32F4F250B373600311912 /* RegistrationView.swift */; };
|
||||
D0B5FE9B251583DB00478838 /* ProfileCollection+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0B5FE9A251583DB00478838 /* ProfileCollection+Extensions.swift */; };
|
||||
D0B8510C25259E56004E0744 /* LoadMoreTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0B8510B25259E56004E0744 /* LoadMoreTableViewCell.swift */; };
|
||||
D0BE633125F2C409001139FA /* CapsuleLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0477F4525C72E50005C5368 /* CapsuleLabel.swift */; };
|
||||
D0BE97A325CF44310057E161 /* CGRect+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0BE97A225CF44310057E161 /* CGRect+Extensions.swift */; };
|
||||
D0BE97D725D0863E0057E161 /* ImagePastableTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0BE97D625D0863E0057E161 /* ImagePastableTextView.swift */; };
|
||||
D0BE97E025D086F80057E161 /* ImagePastableTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0BE97D625D0863E0057E161 /* ImagePastableTextView.swift */; };
|
||||
|
@ -1267,6 +1268,7 @@
|
|||
D059373425AAEA7000754FDF /* CompositionPollView.swift in Sources */,
|
||||
D021A67B25C3E32A008A0C0D /* PlayerView.swift in Sources */,
|
||||
D052DBDD25EAF01800FFB628 /* URL+Extensions.swift in Sources */,
|
||||
D0BE633125F2C409001139FA /* CapsuleLabel.swift in Sources */,
|
||||
D005A20125EF574F008B2E63 /* NavigationHandling.swift in Sources */,
|
||||
D021A69025C3E4B8008A0C0D /* EmojiContentConfiguration.swift in Sources */,
|
||||
D08E52D2257C811200FA2C5F /* ShareExtensionError+Extensions.swift in Sources */,
|
||||
|
|
|
@ -11,7 +11,7 @@ final class AttachmentView: UIView {
|
|||
let playerView = PlayerView()
|
||||
let imageView = SDAnimatedImageView()
|
||||
let removeButton = UIButton(type: .close)
|
||||
let editIcon = UIImageView()
|
||||
let uncaptionedLabel = CapsuleLabel()
|
||||
let selectionButton = UIButton()
|
||||
|
||||
var playing: Bool = false {
|
||||
|
@ -159,14 +159,11 @@ private extension AttachmentView {
|
|||
self.parentViewModel.removeAttachment(viewModel: self.viewModel)
|
||||
}])
|
||||
|
||||
addSubview(editIcon)
|
||||
editIcon.translatesAutoresizingMaskIntoConstraints = false
|
||||
editIcon.image = UIImage(
|
||||
systemName: "pencil",
|
||||
withConfiguration: UIImage.SymbolConfiguration(scale: .large))
|
||||
editIcon.layer.shadowOffset = .zero
|
||||
editIcon.layer.shadowRadius = .defaultShadowRadius
|
||||
editIcon.layer.shadowOpacity = .defaultShadowOpacity
|
||||
addSubview(uncaptionedLabel)
|
||||
uncaptionedLabel.translatesAutoresizingMaskIntoConstraints = false
|
||||
uncaptionedLabel.text = NSLocalizedString("compose.attachment.uncaptioned", comment: "")
|
||||
uncaptionedLabel.isHidden = !(parentViewModel.canRemoveAttachments
|
||||
&& (viewModel.attachment.description?.isEmpty ?? true))
|
||||
|
||||
switch viewModel.attachment.type {
|
||||
case .image, .video, .gifv:
|
||||
|
@ -224,8 +221,8 @@ private extension AttachmentView {
|
|||
selectionButton.bottomAnchor.constraint(equalTo: bottomAnchor),
|
||||
removeButton.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor),
|
||||
removeButton.trailingAnchor.constraint(equalTo: layoutMarginsGuide.trailingAnchor),
|
||||
editIcon.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor),
|
||||
editIcon.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor)
|
||||
uncaptionedLabel.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor),
|
||||
uncaptionedLabel.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor)
|
||||
])
|
||||
|
||||
var accessibilityLabel = viewModel.attachment.type.accessibilityName
|
||||
|
|
|
@ -33,7 +33,6 @@ final class AttachmentsView: UIView {
|
|||
let attachmentView = AttachmentView(viewModel: attachmentViewModel, parentViewModel: viewModel)
|
||||
attachmentView.playing = viewModel.shouldShowAttachments && attachmentViewModel.shouldAutoplay
|
||||
attachmentView.removeButton.isHidden = !viewModel.canRemoveAttachments
|
||||
attachmentView.editIcon.isHidden = !viewModel.canRemoveAttachments
|
||||
attachmentView.isAccessibilityElement = !viewModel.canRemoveAttachments
|
||||
|
||||
if viewModel.attachmentViewModels.count == 2 && index == 1
|
||||
|
|
|
@ -17,25 +17,29 @@ final class CapsuleLabel: UILabel {
|
|||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
|
||||
layer.cornerRadius = inset
|
||||
layer.cornerRadius = bounds.height / 2
|
||||
invalidateIntrinsicContentSize()
|
||||
}
|
||||
|
||||
override func drawText(in rect: CGRect) {
|
||||
super.drawText(in: rect.inset(by: .init(top: 0, left: inset, bottom: 0, right: inset)))
|
||||
super.drawText(in: rect.inset(by: .init(
|
||||
top: .compactSpacing,
|
||||
left: .defaultSpacing,
|
||||
bottom: .compactSpacing,
|
||||
right: .defaultSpacing)))
|
||||
}
|
||||
|
||||
override var intrinsicContentSize: CGSize {
|
||||
var size = super.intrinsicContentSize
|
||||
|
||||
size.width += inset * 2
|
||||
size.width += .defaultSpacing * 2
|
||||
size.height += .compactSpacing * 2
|
||||
|
||||
return size
|
||||
}
|
||||
}
|
||||
|
||||
private extension CapsuleLabel {
|
||||
var inset: CGFloat { bounds.height / 2 }
|
||||
|
||||
func initialSetup() {
|
||||
backgroundColor = .secondarySystemBackground
|
||||
|
|
Loading…
Reference in a new issue