Fixup attachment approval vis-a-vis call banner
// FREEBIE
This commit is contained in:
parent
4f80100234
commit
2709a91b5e
|
@ -4038,8 +4038,9 @@ typedef enum : NSUInteger {
|
|||
} else if (skipApprovalDialog) {
|
||||
[self sendMessageAttachment:attachment];
|
||||
} else {
|
||||
AttachmentApprovalViewController *approvalVC = [[AttachmentApprovalViewController alloc] initWithAttachment:attachment delegate:self];
|
||||
[self presentViewController:approvalVC animated:YES completion:nil];
|
||||
OWSNavigationController *modal =
|
||||
[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() {
|
||||
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() {
|
||||
|
@ -66,14 +85,6 @@ public class AttachmentApprovalViewController: OWSViewController, CaptioningTool
|
|||
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) {
|
||||
Logger.debug("\(logTag) in \(#function)")
|
||||
super.viewWillAppear(animated)
|
||||
|
@ -150,19 +161,6 @@ public class AttachmentApprovalViewController: OWSViewController, CaptioningTool
|
|||
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
|
||||
let captioningToolbar = CaptioningToolbar()
|
||||
captioningToolbar.captioningToolbarDelegate = self
|
||||
|
@ -198,7 +196,7 @@ public class AttachmentApprovalViewController: OWSViewController, CaptioningTool
|
|||
// pops the keyboard.
|
||||
contentContainer.addSubview(progressBar)
|
||||
|
||||
progressBar.autoPinEdge(.top, to: .bottom, of: topToolbar)
|
||||
progressBar.autoPin(toTopLayoutGuideOf: self, withInset: 0)
|
||||
progressBar.autoPinWidthToSuperview()
|
||||
progressBar.autoSetDimension(.height, toSize: 44)
|
||||
|
||||
|
@ -320,7 +318,6 @@ public class AttachmentApprovalViewController: OWSViewController, CaptioningTool
|
|||
}
|
||||
|
||||
public func playerProgressBarDidStartScrubbing(_ playerProgressBar: PlayerProgressBar) {
|
||||
// [self.videoPlayer pause];
|
||||
guard let videoPlayer = self.videoPlayer else {
|
||||
owsFail("\(TAG) video player was unexpectedly nil")
|
||||
return
|
||||
|
|
|
@ -23,7 +23,13 @@ public class MessageApprovalViewController: OWSViewController, UITextViewDelegat
|
|||
let contactsManager: OWSContactsManager
|
||||
|
||||
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
|
||||
|
||||
|
@ -48,26 +54,13 @@ public class MessageApprovalViewController: OWSViewController, UITextViewDelegat
|
|||
super.viewDidLoad()
|
||||
self.navigationItem.title = NSLocalizedString("MESSAGE_APPROVAL_DIALOG_TITLE",
|
||||
comment: "Title for the 'message approval' dialog.")
|
||||
|
||||
self.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .stop, target: self, action: #selector(cancelPressed))
|
||||
self.navigationItem.rightBarButtonItem = sendButton
|
||||
}
|
||||
|
||||
private func updateToolbar() {
|
||||
var items = [UIBarButtonItem]()
|
||||
|
||||
let cancelButton = UIBarButtonItem(barButtonSystemItem: .stop, target: self, action: #selector(cancelPressed))
|
||||
items.append(cancelButton)
|
||||
|
||||
if textView.text.count > 0 {
|
||||
let spacer = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
|
||||
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
|
||||
|
@ -77,20 +70,11 @@ public class MessageApprovalViewController: OWSViewController, UITextViewDelegat
|
|||
self.view = UIView.container()
|
||||
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
|
||||
let recipientRow = createRecipientRow()
|
||||
view.addSubview(recipientRow)
|
||||
recipientRow.autoPinWidthToSuperview()
|
||||
recipientRow.autoPinEdge(.top, to: .bottom, of: topToolbar)
|
||||
recipientRow.autoPin(toTopLayoutGuideOf: self, withInset: 0)
|
||||
|
||||
// Text View
|
||||
textView = UITextView()
|
||||
|
@ -105,8 +89,6 @@ public class MessageApprovalViewController: OWSViewController, UITextViewDelegat
|
|||
textView.autoPinWidthToSuperview()
|
||||
textView.autoPinEdge(.top, to: .bottom, of: recipientRow)
|
||||
textView.autoPin(toBottomLayoutGuideOf: self, withInset: 0)
|
||||
|
||||
updateToolbar()
|
||||
}
|
||||
|
||||
private func createRecipientRow() -> UIView {
|
||||
|
@ -223,6 +205,6 @@ public class MessageApprovalViewController: OWSViewController, UITextViewDelegat
|
|||
// MARK: - UITextViewDelegate
|
||||
|
||||
public func textViewDidChange(_ textView: UITextView) {
|
||||
updateToolbar()
|
||||
updateSendButton()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,12 +185,6 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
|
|||
|
||||
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) {
|
||||
MessageApprovalViewController *approvalVC =
|
||||
[[MessageApprovalViewController alloc] initWithMessageText:messageText
|
||||
|
@ -200,10 +194,9 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
|
|||
|
||||
[self.navigationController pushViewController:approvalVC animated:YES];
|
||||
} else {
|
||||
AttachmentApprovalViewController *approvalVC =
|
||||
[[AttachmentApprovalViewController alloc] initWithAttachment:self.attachment delegate:self];
|
||||
|
||||
[self.navigationController pushViewController:approvalVC animated:YES];
|
||||
OWSNavigationController *approvalModal =
|
||||
[AttachmentApprovalViewController wrappedInNavControllerWithAttachment:self.attachment delegate:self];
|
||||
[self presentViewController:approvalModal animated:YES completion:nil];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue