Allow to cancel share view controller used for forwarding a message.

Signed-off-by: Ivan Sein <ivan@nextcloud.com>
This commit is contained in:
Ivan Sein 2021-07-30 15:12:04 +02:00
Родитель 0f916e5a23
Коммит e6dba9a006
3 изменённых файлов: 20 добавлений и 1 удалений

Просмотреть файл

@ -88,7 +88,7 @@ typedef enum NCChatMessageAction {
kNCChatMessageActionOpenFileInNextcloud
} NCChatMessageAction;
@interface NCChatViewController () <UIGestureRecognizerDelegate, UINavigationControllerDelegate, UIImagePickerControllerDelegate, UIDocumentPickerDelegate, ShareConfirmationViewControllerDelegate, FileMessageTableViewCellDelegate, NCChatFileControllerDelegate, QLPreviewControllerDelegate, QLPreviewControllerDataSource, ChatMessageTableViewCellDelegate, ShareLocationViewControllerDelegate, LocationMessageTableViewCellDelegate, VoiceMessageTableViewCellDelegate, AVAudioRecorderDelegate, AVAudioPlayerDelegate, CNContactPickerDelegate>
@interface NCChatViewController () <UIGestureRecognizerDelegate, UINavigationControllerDelegate, UIImagePickerControllerDelegate, UIDocumentPickerDelegate, ShareViewControllerDelegate, ShareConfirmationViewControllerDelegate, FileMessageTableViewCellDelegate, NCChatFileControllerDelegate, QLPreviewControllerDelegate, QLPreviewControllerDataSource, ChatMessageTableViewCellDelegate, ShareLocationViewControllerDelegate, LocationMessageTableViewCellDelegate, VoiceMessageTableViewCellDelegate, AVAudioRecorderDelegate, AVAudioPlayerDelegate, CNContactPickerDelegate>
@property (nonatomic, strong) NCChatController *chatController;
@property (nonatomic, strong) NCChatTitleView *titleView;
@ -1182,6 +1182,7 @@ NSString * const NCChatViewControllerForwardNotification = @"NCChatViewControlle
- (void)didPressForward:(NCChatMessage *)message {
ShareViewController *shareViewController = [[ShareViewController alloc] initToForwardMessage:message.parsedMessage.string fromChatViewController:self];
shareViewController.delegate = self;
NCNavigationController *forwardMessageNC = [[NCNavigationController alloc] initWithRootViewController:shareViewController];
[self presentViewController:forwardMessageNC animated:YES completion:nil];
}
@ -1312,6 +1313,13 @@ NSString * const NCChatViewControllerForwardNotification = @"NCChatViewControlle
}
#pragma mark - ShareViewController Delegate
- (void)shareViewControllerDidCancel:(ShareViewController *)viewController
{
[self dismissViewControllerAnimated:YES completion:nil];
}
#pragma mark - ShareConfirmationViewController Delegate
- (void)shareConfirmationViewControllerDidFailed:(ShareConfirmationViewController *)viewController

Просмотреть файл

@ -24,8 +24,17 @@
NS_ASSUME_NONNULL_BEGIN
@class ShareViewController;
@protocol ShareViewControllerDelegate <NSObject>
- (void)shareViewControllerDidCancel:(ShareViewController *)viewController;
@end
@interface ShareViewController : UITableViewController
@property (weak, nonatomic) id<ShareViewControllerDelegate> delegate;
@property (strong, nonatomic) UIViewController *chatViewController;
@property (strong, nonatomic) NSString *forwardMessage;

Просмотреть файл

@ -218,6 +218,8 @@
- (void)cancelButtonPressed
{
[self.delegate shareViewControllerDidCancel:self];
NSError *error = [NSError errorWithDomain:NSCocoaErrorDomain code:0 userInfo:nil];
[self.extensionContext cancelRequestWithError:error];
}