maintain body text navigating to/from approval view

pull/2/head
Michael Kirk 6 years ago
parent 3c5510438f
commit fa2d5b422b

@ -2858,7 +2858,8 @@ typedef enum : NSUInteger {
UIViewController *pickerModal;
if (SSKFeatureFlags.useCustomPhotoCapture) {
SendMediaNavigationController *navController = [SendMediaNavigationController showingCameraFirst];
SendMediaNavigationController *navController =
[SendMediaNavigationController showingCameraFirstWithMessageText:self.inputToolbar.messageText];
navController.sendMediaNavDelegate = self;
pickerModal = navController;
} else {
@ -2903,7 +2904,8 @@ typedef enum : NSUInteger {
return;
}
SendMediaNavigationController *pickerModal = [SendMediaNavigationController showingMediaLibraryFirst];
SendMediaNavigationController *pickerModal =
[SendMediaNavigationController showingMediaLibraryFirstWithMessageText:self.inputToolbar.messageText];
pickerModal.sendMediaNavDelegate = self;
[self dismissKeyBoard];
@ -3921,6 +3923,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]);

@ -19,6 +19,8 @@ class SendMediaNavigationController: OWSNavigationController {
override var prefersStatusBarHidden: Bool { return true }
var messageText: String?
override func viewDidLoad() {
super.viewDidLoad()
@ -51,19 +53,21 @@ class SendMediaNavigationController: OWSNavigationController {
public weak var sendMediaNavDelegate: SendMediaNavDelegate?
@objc
public class func showingCameraFirst() -> SendMediaNavigationController {
public class func showingCameraFirst(messageText: String) -> SendMediaNavigationController {
let navController = SendMediaNavigationController()
navController.setViewControllers([navController.captureViewController], animated: false)
navController.updateButtons()
navController.messageText = messageText
return navController
}
@objc
public class func showingMediaLibraryFirst() -> SendMediaNavigationController {
public class func showingMediaLibraryFirst(messageText: String) -> SendMediaNavigationController {
let navController = SendMediaNavigationController()
navController.setViewControllers([navController.mediaLibraryViewController], animated: false)
navController.updateButtons()
navController.messageText = messageText
return navController
}
@ -210,6 +214,7 @@ class SendMediaNavigationController: OWSNavigationController {
private func pushApprovalViewController() {
let approvalViewController = AttachmentApprovalViewController(mode: .sharedNavigation, attachments: self.attachments)
approvalViewController.approvalDelegate = self
approvalViewController.messageText = messageText
pushViewController(approvalViewController, animated: true)
updateButtons()
@ -361,6 +366,10 @@ extension SendMediaNavigationController: ImagePickerGridControllerDelegate {
}
extension SendMediaNavigationController: AttachmentApprovalViewControllerDelegate {
func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, didChangeMessageText newMessageText: String?) {
self.messageText = 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