Only show caption for multiple images

pull/1/head
Michael Kirk 6 years ago
parent 0ac8f13c0b
commit 61758dcf05

@ -254,6 +254,8 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC
return
}
navigationBar.overrideTheme(type: .clear)
updateCaptionVisibility()
}
override public func viewDidAppear(_ animated: Bool) {
@ -405,6 +407,12 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC
return pagerScrollView
}()
func updateCaptionVisibility() {
for pageViewController in pageViewControllers {
pageViewController.updateCaptionVisibility(attachmentCount: attachments.count)
}
}
// MARK: - UIPageViewControllerDelegate
public func pageViewController(_ pageViewController: UIPageViewController, willTransitionTo pendingViewControllers: [UIViewController]) {
@ -511,6 +519,7 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC
Logger.debug("cache miss.")
let viewController = AttachmentPrepViewController(attachmentItem: item)
viewController.prepDelegate = self
viewController.updateCaptionVisibility(attachmentCount: attachments.count)
cachedPages[item] = viewController
return viewController
@ -780,6 +789,22 @@ public class AttachmentPrepViewController: OWSViewController, PlayerProgressBarD
fatalError("init(coder:) has not been implemented")
}
func updateCaptionVisibility(attachmentCount: Int) {
if attachmentCount > 1 {
captionView.isHidden = false
}
// If we previously had multiple attachments, we'd have shown the caption fields.
//
// Subsequently, if the user had added caption text, then removed the other attachments
// we will continue to show this caption field, so as not to hide any already-entered text.
if let captionText = captionView.captionText, captionText.count > 0 {
captionView.isHidden = false
}
captionView.isHidden = true
}
// MARK: - Subviews
lazy var captionView: CaptionView = {

Loading…
Cancel
Save