Fixup attachment approval vis-a-vis call banner

// FREEBIE
pull/1/head
Michael Kirk 7 years ago committed by Matthew Chen
parent 4f80100234
commit 2709a91b5e

@ -4038,8 +4038,9 @@ typedef enum : NSUInteger {
} else if (skipApprovalDialog) { } else if (skipApprovalDialog) {
[self sendMessageAttachment:attachment]; [self sendMessageAttachment:attachment];
} else { } else {
AttachmentApprovalViewController *approvalVC = [[AttachmentApprovalViewController alloc] initWithAttachment:attachment delegate:self]; OWSNavigationController *modal =
[self presentViewController:approvalVC animated:YES completion:nil]; [AttachmentApprovalViewController wrappedInNavControllerWithAttachment:attachment delegate:self];
[self presentViewController:modal animated:YES completion:nil];
} }
}); });
} }

@ -55,7 +55,26 @@ public class AttachmentApprovalViewController: OWSViewController, CaptioningTool
override public func viewDidLoad() { override public func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
self.navigationItem.title = dialogTitle() self.navigationItem.title = nil
let cancelButton = UIBarButtonItem(barButtonSystemItem: .stop, target: self, action: #selector(cancelPressed))
cancelButton.tintColor = .white
self.navigationItem.leftBarButtonItem = cancelButton
}
@objc
public class func wrappedInNavController(attachment: SignalAttachment, delegate: AttachmentApprovalViewControllerDelegate) -> OWSNavigationController {
let vc = AttachmentApprovalViewController(attachment: attachment, delegate: delegate)
let navController = OWSNavigationController(rootViewController: vc)
// Make navigationBar clear
navController.navigationBar.backgroundColor = .clear
navController.navigationBar.setBackgroundImage(UIImage(), for: .default)
navController.navigationBar.isTranslucent = true
navController.navigationBar.shadowImage = UIImage()
navController.navigationBar.clipsToBounds = true
return navController
} }
override public func viewWillLayoutSubviews() { override public func viewWillLayoutSubviews() {
@ -66,14 +85,6 @@ public class AttachmentApprovalViewController: OWSViewController, CaptioningTool
updateMinZoomScaleForSize(view.bounds.size) updateMinZoomScaleForSize(view.bounds.size)
} }
private func dialogTitle() -> String {
guard let filename = mediaMessageView.formattedFileName() else {
return NSLocalizedString("ATTACHMENT_APPROVAL_DIALOG_TITLE",
comment: "Title for the 'attachment approval' dialog.")
}
return filename
}
override public func viewWillAppear(_ animated: Bool) { override public func viewWillAppear(_ animated: Bool) {
Logger.debug("\(logTag) in \(#function)") Logger.debug("\(logTag) in \(#function)")
super.viewWillAppear(animated) super.viewWillAppear(animated)
@ -150,19 +161,6 @@ public class AttachmentApprovalViewController: OWSViewController, CaptioningTool
topGradient.autoSetDimension(.height, toSize: ScaleFromIPhone5(60)) topGradient.autoSetDimension(.height, toSize: ScaleFromIPhone5(60))
} }
// Top Toolbar
let topToolbar = makeClearToolbar()
self.view.addSubview(topToolbar)
topToolbar.autoPinWidthToSuperview()
topToolbar.autoPin(toTopLayoutGuideOf: self, withInset: 0)
topToolbar.setContentHuggingVerticalHigh()
topToolbar.setCompressionResistanceVerticalHigh()
let cancelButton = UIBarButtonItem(barButtonSystemItem: .stop, target: self, action: #selector(cancelPressed))
cancelButton.tintColor = UIColor.white
topToolbar.items = [cancelButton]
// Bottom Toolbar // Bottom Toolbar
let captioningToolbar = CaptioningToolbar() let captioningToolbar = CaptioningToolbar()
captioningToolbar.captioningToolbarDelegate = self captioningToolbar.captioningToolbarDelegate = self
@ -198,7 +196,7 @@ public class AttachmentApprovalViewController: OWSViewController, CaptioningTool
// pops the keyboard. // pops the keyboard.
contentContainer.addSubview(progressBar) contentContainer.addSubview(progressBar)
progressBar.autoPinEdge(.top, to: .bottom, of: topToolbar) progressBar.autoPin(toTopLayoutGuideOf: self, withInset: 0)
progressBar.autoPinWidthToSuperview() progressBar.autoPinWidthToSuperview()
progressBar.autoSetDimension(.height, toSize: 44) progressBar.autoSetDimension(.height, toSize: 44)
@ -320,7 +318,6 @@ public class AttachmentApprovalViewController: OWSViewController, CaptioningTool
} }
public func playerProgressBarDidStartScrubbing(_ playerProgressBar: PlayerProgressBar) { public func playerProgressBarDidStartScrubbing(_ playerProgressBar: PlayerProgressBar) {
// [self.videoPlayer pause];
guard let videoPlayer = self.videoPlayer else { guard let videoPlayer = self.videoPlayer else {
owsFail("\(TAG) video player was unexpectedly nil") owsFail("\(TAG) video player was unexpectedly nil")
return return

@ -23,7 +23,13 @@ public class MessageApprovalViewController: OWSViewController, UITextViewDelegat
let contactsManager: OWSContactsManager let contactsManager: OWSContactsManager
private(set) var textView: UITextView! private(set) var textView: UITextView!
private(set) var topToolbar: UIToolbar! private var sendButton: UIBarButtonItem = {
return UIBarButtonItem(title: NSLocalizedString("SEND_BUTTON_TITLE",
comment: "Label for the send button in the conversation view."),
style: .plain,
target: self,
action: #selector(sendPressed))
}()
// MARK: Initializers // MARK: Initializers
@ -48,26 +54,13 @@ public class MessageApprovalViewController: OWSViewController, UITextViewDelegat
super.viewDidLoad() super.viewDidLoad()
self.navigationItem.title = NSLocalizedString("MESSAGE_APPROVAL_DIALOG_TITLE", self.navigationItem.title = NSLocalizedString("MESSAGE_APPROVAL_DIALOG_TITLE",
comment: "Title for the 'message approval' dialog.") comment: "Title for the 'message approval' dialog.")
}
private func updateToolbar() {
var items = [UIBarButtonItem]()
let cancelButton = UIBarButtonItem(barButtonSystemItem: .stop, target: self, action: #selector(cancelPressed))
items.append(cancelButton)
if textView.text.count > 0 { self.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .stop, target: self, action: #selector(cancelPressed))
let spacer = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil) self.navigationItem.rightBarButtonItem = sendButton
items.append(spacer)
let sendButton = UIBarButtonItem(title: NSLocalizedString("SEND_BUTTON_TITLE",
comment: "Label for the send button in the conversation view."),
style: .plain,
target: self,
action: #selector(sendPressed))
items.append(sendButton)
} }
topToolbar.items = items private func updateSendButton() {
sendButton.isEnabled = textView.text.count > 0
} }
// MARK: - Create Views // MARK: - Create Views
@ -77,20 +70,11 @@ public class MessageApprovalViewController: OWSViewController, UITextViewDelegat
self.view = UIView.container() self.view = UIView.container()
self.view.backgroundColor = UIColor.white self.view.backgroundColor = UIColor.white
// Top Toolbar
topToolbar = UIToolbar()
topToolbar.backgroundColor = UIColor.ows_toolbarBackground
self.view.addSubview(topToolbar)
topToolbar.autoPinWidthToSuperview()
topToolbar.autoPin(toTopLayoutGuideOf: self, withInset: 0)
topToolbar.setContentHuggingVerticalHigh()
topToolbar.setCompressionResistanceVerticalHigh()
// Recipient Row // Recipient Row
let recipientRow = createRecipientRow() let recipientRow = createRecipientRow()
view.addSubview(recipientRow) view.addSubview(recipientRow)
recipientRow.autoPinWidthToSuperview() recipientRow.autoPinWidthToSuperview()
recipientRow.autoPinEdge(.top, to: .bottom, of: topToolbar) recipientRow.autoPin(toTopLayoutGuideOf: self, withInset: 0)
// Text View // Text View
textView = UITextView() textView = UITextView()
@ -105,8 +89,6 @@ public class MessageApprovalViewController: OWSViewController, UITextViewDelegat
textView.autoPinWidthToSuperview() textView.autoPinWidthToSuperview()
textView.autoPinEdge(.top, to: .bottom, of: recipientRow) textView.autoPinEdge(.top, to: .bottom, of: recipientRow)
textView.autoPin(toBottomLayoutGuideOf: self, withInset: 0) textView.autoPin(toBottomLayoutGuideOf: self, withInset: 0)
updateToolbar()
} }
private func createRecipientRow() -> UIView { private func createRecipientRow() -> UIView {
@ -223,6 +205,6 @@ public class MessageApprovalViewController: OWSViewController, UITextViewDelegat
// MARK: - UITextViewDelegate // MARK: - UITextViewDelegate
public func textViewDidChange(_ textView: UITextView) { public func textViewDidChange(_ textView: UITextView) {
updateToolbar() updateSendButton()
} }
} }

@ -185,12 +185,6 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
NSString *_Nullable messageText = [self convertAttachmentToMessageTextIfPossible]; NSString *_Nullable messageText = [self convertAttachmentToMessageTextIfPossible];
// Hide the navigation bar before presenting the approval view.
//
// Note that cancelling in the approval views will dismiss the entire
// share extension, so there is no "back" button.
self.navigationController.navigationBarHidden = YES;
if (messageText) { if (messageText) {
MessageApprovalViewController *approvalVC = MessageApprovalViewController *approvalVC =
[[MessageApprovalViewController alloc] initWithMessageText:messageText [[MessageApprovalViewController alloc] initWithMessageText:messageText
@ -200,10 +194,9 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
[self.navigationController pushViewController:approvalVC animated:YES]; [self.navigationController pushViewController:approvalVC animated:YES];
} else { } else {
AttachmentApprovalViewController *approvalVC = OWSNavigationController *approvalModal =
[[AttachmentApprovalViewController alloc] initWithAttachment:self.attachment delegate:self]; [AttachmentApprovalViewController wrappedInNavControllerWithAttachment:self.attachment delegate:self];
[self presentViewController:approvalModal animated:YES completion:nil];
[self.navigationController pushViewController:approvalVC animated:YES];
} }
} }

Loading…
Cancel
Save