mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Clean up image editor.
This commit is contained in:
parent
fa08b18fd7
commit
7c486d9093
3 changed files with 38 additions and 12 deletions
|
@ -210,13 +210,6 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC
|
|||
|
||||
self.navigationItem.title = nil
|
||||
|
||||
if mode != .sharedNavigation {
|
||||
let cancelButton = UIBarButtonItem(barButtonSystemItem: .cancel,
|
||||
target: self, action: #selector(cancelPressed))
|
||||
cancelButton.tintColor = .white
|
||||
self.navigationItem.leftBarButtonItem = cancelButton
|
||||
}
|
||||
|
||||
guard let firstItem = attachmentItems.first else {
|
||||
owsFailDebug("firstItem was unexpectedly nil")
|
||||
return
|
||||
|
@ -273,13 +266,33 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC
|
|||
|
||||
public func updateNavigationBar() {
|
||||
var navigationBarItems = [UIView]()
|
||||
var isShowingCaptionView = false
|
||||
|
||||
if let viewControllers = viewControllers,
|
||||
viewControllers.count == 1,
|
||||
let firstViewController = viewControllers.first as? AttachmentPrepViewController {
|
||||
navigationBarItems = firstViewController.navigationBarItems()
|
||||
isShowingCaptionView = firstViewController.isShowingCaptionView
|
||||
}
|
||||
|
||||
guard !isShowingCaptionView else {
|
||||
// Hide all navigation bar items while the caption view is open.
|
||||
self.navigationItem.leftBarButtonItem = nil
|
||||
self.navigationItem.rightBarButtonItem = nil
|
||||
return
|
||||
}
|
||||
|
||||
updateNavigationBar(navigationBarItems: navigationBarItems)
|
||||
|
||||
let hasCancel = (mode != .sharedNavigation)
|
||||
if hasCancel {
|
||||
let cancelButton = UIBarButtonItem(barButtonSystemItem: .cancel,
|
||||
target: self, action: #selector(cancelPressed))
|
||||
cancelButton.tintColor = .white
|
||||
self.navigationItem.leftBarButtonItem = cancelButton
|
||||
} else {
|
||||
self.navigationItem.leftBarButtonItem = nil
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - View Helpers
|
||||
|
@ -684,6 +697,12 @@ public class AttachmentPrepViewController: OWSViewController, PlayerProgressBarD
|
|||
private(set) var playVideoButton: UIView?
|
||||
private var imageEditorView: ImageEditorView?
|
||||
|
||||
fileprivate var isShowingCaptionView = false {
|
||||
didSet {
|
||||
prepDelegate?.prepViewControllerUpdateNavigationBar()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Initializers
|
||||
|
||||
init(attachmentItem: SignalAttachmentItem) {
|
||||
|
@ -1033,6 +1052,12 @@ extension AttachmentPrepViewController: AttachmentCaptionDelegate {
|
|||
let attachment = attachmentItem.attachment
|
||||
attachment.captionText = captionText
|
||||
prepDelegate?.prepViewController(self, didUpdateCaptionForAttachmentItem: attachmentItem)
|
||||
|
||||
isShowingCaptionView = false
|
||||
}
|
||||
|
||||
func captionViewDidCancel() {
|
||||
isShowingCaptionView = false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1133,6 +1158,8 @@ extension AttachmentPrepViewController: ImageEditorViewDelegate {
|
|||
public func imageEditorPresentCaptionView() {
|
||||
let view = AttachmentCaptionViewController(delegate: self, attachmentItem: attachmentItem)
|
||||
self.imageEditor(presentFullScreenOverlay: view, withNavigation: true)
|
||||
|
||||
isShowingCaptionView = true
|
||||
}
|
||||
|
||||
public func imageEditorUpdateNavigationBar() {
|
||||
|
|
|
@ -6,6 +6,7 @@ import UIKit
|
|||
|
||||
protocol AttachmentCaptionDelegate: class {
|
||||
func captionView(_ captionView: AttachmentCaptionViewController, didChangeCaptionText captionText: String?, attachmentItem: SignalAttachmentItem)
|
||||
func captionViewDidCancel()
|
||||
}
|
||||
|
||||
class AttachmentCaptionViewController: OWSViewController {
|
||||
|
@ -151,7 +152,7 @@ class AttachmentCaptionViewController: OWSViewController {
|
|||
|
||||
private func completeAndDismiss(didCancel: Bool) {
|
||||
if didCancel {
|
||||
self.delegate?.captionView(self, didChangeCaptionText: originalCaptionText, attachmentItem: attachmentItem)
|
||||
self.delegate?.captionViewDidCancel()
|
||||
} else {
|
||||
self.delegate?.captionView(self, didChangeCaptionText: self.textView.text, attachmentItem: attachmentItem)
|
||||
}
|
||||
|
|
|
@ -183,10 +183,9 @@ public class ImageEditorTextViewController: OWSViewController, VAlignTextViewDel
|
|||
textView.autoHCenterInSuperview()
|
||||
self.autoPinView(toBottomOfViewControllerOrKeyboard: textView, avoidNotch: true)
|
||||
|
||||
// TODO: Honor old color state.
|
||||
paletteView.delegate = self
|
||||
self.view.addSubview(paletteView)
|
||||
paletteView.autoVCenterInSuperview()
|
||||
paletteView.autoAlignAxis(.horizontal, toSameAxisOf: textView)
|
||||
paletteView.autoPinEdge(toSuperviewEdge: .trailing, withInset: 20)
|
||||
// This will determine the text view's size.
|
||||
paletteView.autoPinEdge(.leading, to: .trailing, of: textView, withOffset: 8)
|
||||
|
@ -205,7 +204,7 @@ public class ImageEditorTextViewController: OWSViewController, VAlignTextViewDel
|
|||
// We use a white cursor since we use a dark background.
|
||||
textView.tintColor = .white
|
||||
textView.returnKeyType = .done
|
||||
// TODO: Limit the size of the text.
|
||||
// TODO: Limit the size of the text?
|
||||
// textView.delegate = self
|
||||
textView.isScrollEnabled = true
|
||||
textView.scrollsToTop = false
|
||||
|
@ -231,7 +230,6 @@ public class ImageEditorTextViewController: OWSViewController, VAlignTextViewDel
|
|||
@objc func didTapUndo(sender: UIButton) {
|
||||
Logger.verbose("")
|
||||
|
||||
// TODO: Honor color state.
|
||||
self.delegate?.textEditDidCancel()
|
||||
|
||||
self.dismiss(animated: false) {
|
||||
|
|
Loading…
Reference in a new issue