Show caption indicators in attachment approval media rail.

This commit is contained in:
Matthew Chen 2019-03-01 12:13:41 -05:00
parent 80d297c10a
commit 371c12bd40

View file

@ -617,6 +617,8 @@ extension AttachmentApprovalViewController: MediaMessageTextToolbarDelegate {
extension AttachmentApprovalViewController: AttachmentPrepViewControllerDelegate {
func prepViewController(_ prepViewController: AttachmentPrepViewController, didUpdateCaptionForAttachmentItem attachmentItem: SignalAttachmentItem) {
self.approvalDelegate?.attachmentApproval?(self, changedCaptionOfAttachment: attachmentItem.attachment)
updateMediaRail()
}
func prepViewControllerUpdateNavigationBar() {
@ -1636,6 +1638,16 @@ public class ApprovalRailCellView: GalleryRailCellView {
return button
}()
lazy var captionIndicator: UIView = {
let image = UIImage(named: "image_editor_caption")?.withRenderingMode(.alwaysTemplate)
let imageView = UIImageView(image: image)
imageView.tintColor = .white
imageView.layer.shadowColor = UIColor.black.cgColor
imageView.layer.shadowRadius = 2
imageView.layer.shadowOpacity = 0.66
return imageView
}()
override func setIsSelected(_ isSelected: Bool) {
super.setIsSelected(isSelected)
@ -1648,4 +1660,26 @@ public class ApprovalRailCellView: GalleryRailCellView {
deleteButton.removeFromSuperview()
}
}
override func configure(item: GalleryRailItem, delegate: GalleryRailCellViewDelegate) {
super.configure(item: item, delegate: delegate)
var hasCaption = false
if let attachmentItem = item as? SignalAttachmentItem {
if let captionText = attachmentItem.captionText {
hasCaption = captionText.count > 0
}
} else {
owsFailDebug("Invalid item.")
}
if hasCaption {
addSubview(captionIndicator)
captionIndicator.autoPinEdge(toSuperviewEdge: .top, withInset: 0)
captionIndicator.autoPinEdge(toSuperviewEdge: .leading, withInset: 4)
} else {
captionIndicator.removeFromSuperview()
}
}
}