Merge branch 'mkirk/maintain-body-context'

pull/2/head
Michael Kirk 5 years ago
commit 0a43d6c6e6

@ -2939,9 +2939,26 @@ typedef enum : NSUInteger {
messageText:(nullable NSString *)messageText
{
[self tryToSendAttachments:attachments messageText:messageText];
[self.inputToolbar clearTextMessageAnimated:NO];
// we want to already be at the bottom when the user returns, rather than have to watch
// the new message scroll into view.
[self scrollToBottomAnimated:NO];
[self dismissViewControllerAnimated:YES completion:nil];
}
- (nullable NSString *)sendMediaNavInitialMessageText:(SendMediaNavigationController *)sendMediaNavigationController
{
return self.inputToolbar.messageText;
}
- (void)sendMediaNav:(SendMediaNavigationController *)sendMediaNavigationController
didChangeMessageText:(nullable NSString *)messageText
{
[self.inputToolbar setMessageText:messageText animated:NO];
}
#pragma mark - UIImagePickerControllerDelegate
/*
@ -3908,7 +3925,9 @@ typedef enum : NSUInteger {
messageText:(NSString *_Nullable)messageText
{
[self tryToSendAttachments:attachments messageText:messageText];
[self.inputToolbar clearTextMessageAnimated:NO];
[self dismissViewControllerAnimated:YES completion:nil];
// We always want to scroll to the bottom of the conversation after the local user
// sends a message. Normally, this is taken care of in yapDatabaseModified:, but
// we don't listen to db modifications when this view isn't visible, i.e. when the
@ -3921,6 +3940,14 @@ typedef enum : NSUInteger {
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)attachmentApproval:(AttachmentApprovalViewController *)attachmentApproval
didChangeMessageText:(nullable NSString *)newMessageText
{
[self.inputToolbar setMessageText:newMessageText animated:NO];
}
#pragma mark -
- (void)showErrorAlertForAttachment:(SignalAttachment *_Nullable)attachment
{
OWSAssertDebug(attachment == nil || [attachment hasError]);

@ -10,6 +10,9 @@ import PromiseKit
protocol SendMediaNavDelegate: AnyObject {
func sendMediaNavDidCancel(_ sendMediaNavigationController: SendMediaNavigationController)
func sendMediaNav(_ sendMediaNavigationController: SendMediaNavigationController, didApproveAttachments attachments: [SignalAttachment], messageText: String?)
func sendMediaNavInitialMessageText(_ sendMediaNavigationController: SendMediaNavigationController) -> String?
func sendMediaNav(_ sendMediaNavigationController: SendMediaNavigationController, didChangeMessageText newMessageText: String?)
}
@objc
@ -208,8 +211,14 @@ class SendMediaNavigationController: OWSNavigationController {
}()
private func pushApprovalViewController() {
guard let sendMediaNavDelegate = self.sendMediaNavDelegate else {
owsFailDebug("sendMediaNavDelegate was unexpectedly nil")
return
}
let approvalViewController = AttachmentApprovalViewController(mode: .sharedNavigation, attachments: self.attachments)
approvalViewController.approvalDelegate = self
approvalViewController.messageText = sendMediaNavDelegate.sendMediaNavInitialMessageText(self)
pushViewController(approvalViewController, animated: true)
updateButtons()
@ -361,6 +370,10 @@ extension SendMediaNavigationController: ImagePickerGridControllerDelegate {
}
extension SendMediaNavigationController: AttachmentApprovalViewControllerDelegate {
func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, didChangeMessageText newMessageText: String?) {
sendMediaNavDelegate?.sendMediaNav(self, didChangeMessageText: newMessageText)
}
func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, didRemoveAttachment attachment: SignalAttachment) {
guard let removedDraft = attachmentDraftCollection.attachmentDrafts.first(where: { $0.attachment == attachment}) else {
owsFailDebug("removedDraft was unexpectedly nil")

@ -9,17 +9,19 @@ import PromiseKit
@objc
public protocol AttachmentApprovalViewControllerDelegate: class {
func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, didApproveAttachments attachments: [SignalAttachment], messageText: String?)
func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController,
didApproveAttachments attachments: [SignalAttachment], messageText: String?)
func attachmentApprovalDidCancel(_ attachmentApproval: AttachmentApprovalViewController)
func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController,
didChangeMessageText newMessageText: String?)
@objc
optional func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, didRemoveAttachment attachment: SignalAttachment)
@objc
optional func attachmentApprovalDidTapAddMore(_ attachmentApproval: AttachmentApprovalViewController)
@objc
optional func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, changedCaptionOfAttachment attachment: SignalAttachment)
}
// MARK: -
@ -216,6 +218,15 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC
bottomToolView.update(isEditingCaptions: isEditingCaptions, currentAttachmentItem: currentAttachmentItem)
}
public var messageText: String? {
get {
return attachmentTextToolbar.messageText
}
set {
attachmentTextToolbar.messageText = newValue
}
}
// MARK: - Navigation Bar
public func updateNavigationBar() {
@ -678,6 +689,10 @@ extension AttachmentApprovalViewController: AttachmentTextToolbarDelegate {
func attachmentTextToolbarDidAddMore(_ attachmentTextToolbar: AttachmentTextToolbar) {
self.approvalDelegate?.attachmentApprovalDidTapAddMore?(self)
}
func attachmentTextToolbarDidChange(_ attachmentTextToolbar: AttachmentTextToolbar) {
approvalDelegate?.attachmentApproval(self, didChangeMessageText: attachmentTextToolbar.messageText)
}
}
// MARK: -

@ -13,6 +13,7 @@ protocol AttachmentTextToolbarDelegate: class {
func attachmentTextToolbarDidBeginEditing(_ attachmentTextToolbar: AttachmentTextToolbar)
func attachmentTextToolbarDidEndEditing(_ attachmentTextToolbar: AttachmentTextToolbar)
func attachmentTextToolbarDidAddMore(_ attachmentTextToolbar: AttachmentTextToolbar)
func attachmentTextToolbarDidChange(_ attachmentTextToolbar: AttachmentTextToolbar)
}
// MARK: -
@ -228,6 +229,7 @@ class AttachmentTextToolbar: UIView, UITextViewDelegate {
public func textViewDidChange(_ textView: UITextView) {
updateHeight(textView: textView)
attachmentTextToolbarDelegate?.attachmentTextToolbarDidChange(self)
}
public func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {

@ -310,6 +310,12 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
[self cancelShareExperience];
}
- (void)attachmentApproval:(AttachmentApprovalViewController *)attachmentApproval
didChangeMessageText:(nullable NSString *)newMessageText
{
// no-op
}
#pragma mark - MessageApprovalViewControllerDelegate
- (void)messageApproval:(MessageApprovalViewController *)approvalViewController

Loading…
Cancel
Save