Only show caption for multiple images

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

@ -254,6 +254,8 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC
return return
} }
navigationBar.overrideTheme(type: .clear) navigationBar.overrideTheme(type: .clear)
updateCaptionVisibility()
} }
override public func viewDidAppear(_ animated: Bool) { override public func viewDidAppear(_ animated: Bool) {
@ -405,6 +407,12 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC
return pagerScrollView return pagerScrollView
}() }()
func updateCaptionVisibility() {
for pageViewController in pageViewControllers {
pageViewController.updateCaptionVisibility(attachmentCount: attachments.count)
}
}
// MARK: - UIPageViewControllerDelegate // MARK: - UIPageViewControllerDelegate
public func pageViewController(_ pageViewController: UIPageViewController, willTransitionTo pendingViewControllers: [UIViewController]) { public func pageViewController(_ pageViewController: UIPageViewController, willTransitionTo pendingViewControllers: [UIViewController]) {
@ -511,6 +519,7 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC
Logger.debug("cache miss.") Logger.debug("cache miss.")
let viewController = AttachmentPrepViewController(attachmentItem: item) let viewController = AttachmentPrepViewController(attachmentItem: item)
viewController.prepDelegate = self viewController.prepDelegate = self
viewController.updateCaptionVisibility(attachmentCount: attachments.count)
cachedPages[item] = viewController cachedPages[item] = viewController
return viewController return viewController
@ -780,6 +789,22 @@ public class AttachmentPrepViewController: OWSViewController, PlayerProgressBarD
fatalError("init(coder:) has not been implemented") 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 // MARK: - Subviews
lazy var captionView: CaptionView = { lazy var captionView: CaptionView = {

Loading…
Cancel
Save