|
|
|
@ -31,7 +31,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
@implementation AttachmentMenuView
|
|
|
|
|
|
|
|
|
|
- (BOOL)canBecomeFirstResponder {
|
|
|
|
|
- (BOOL)canBecomeFirstResponder
|
|
|
|
|
{
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -128,7 +129,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
return _fileData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIImage *)image {
|
|
|
|
|
- (UIImage *)image
|
|
|
|
|
{
|
|
|
|
|
if (self.attachmentStream) {
|
|
|
|
|
return self.attachmentStream.image;
|
|
|
|
|
} else if (self.attachment) {
|
|
|
|
@ -191,12 +193,12 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
action:@selector(didTapDismissButton:)];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)viewWillDisappear:(BOOL)animated {
|
|
|
|
|
- (void)viewWillDisappear:(BOOL)animated
|
|
|
|
|
{
|
|
|
|
|
[super viewWillDisappear:animated];
|
|
|
|
|
|
|
|
|
|
if ([UIMenuController sharedMenuController].isMenuVisible) {
|
|
|
|
|
[[UIMenuController sharedMenuController] setMenuVisible:NO
|
|
|
|
|
animated:NO];
|
|
|
|
|
[[UIMenuController sharedMenuController] setMenuVisible:NO animated:NO];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -507,8 +509,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
[self.view addGestureRecognizer:swipe];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self
|
|
|
|
|
action:@selector(longPressGesture:)];
|
|
|
|
|
UILongPressGestureRecognizer *longPress =
|
|
|
|
|
[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressGesture:)];
|
|
|
|
|
longPress.delegate = self;
|
|
|
|
|
[self.view addGestureRecognizer:longPress];
|
|
|
|
|
}
|
|
|
|
@ -564,7 +566,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
[self dismissSelfAnimated:YES completion:nil];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)longPressGesture:(UIGestureRecognizer *)sender {
|
|
|
|
|
- (void)longPressGesture:(UIGestureRecognizer *)sender
|
|
|
|
|
{
|
|
|
|
|
// We "eagerly" respond when the long press begins, not when it ends.
|
|
|
|
|
if (sender.state == UIGestureRecognizerStateBegan) {
|
|
|
|
|
if (!self.viewItem) {
|
|
|
|
@ -574,20 +577,15 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
[self.view becomeFirstResponder];
|
|
|
|
|
|
|
|
|
|
if ([UIMenuController sharedMenuController].isMenuVisible) {
|
|
|
|
|
[[UIMenuController sharedMenuController] setMenuVisible:NO
|
|
|
|
|
animated:NO];
|
|
|
|
|
[[UIMenuController sharedMenuController] setMenuVisible:NO animated:NO];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NSArray *menuItems = self.viewItem.mediaMenuControllerItems;
|
|
|
|
|
[UIMenuController sharedMenuController].menuItems = menuItems;
|
|
|
|
|
CGPoint location = [sender locationInView:self.view];
|
|
|
|
|
CGRect targetRect = CGRectMake(location.x,
|
|
|
|
|
location.y,
|
|
|
|
|
1, 1);
|
|
|
|
|
[[UIMenuController sharedMenuController] setTargetRect:targetRect
|
|
|
|
|
inView:self.view];
|
|
|
|
|
[[UIMenuController sharedMenuController] setMenuVisible:YES
|
|
|
|
|
animated:YES];
|
|
|
|
|
CGRect targetRect = CGRectMake(location.x, location.y, 1, 1);
|
|
|
|
|
[[UIMenuController sharedMenuController] setTargetRect:targetRect inView:self.view];
|
|
|
|
|
[[UIMenuController sharedMenuController] setMenuVisible:YES animated:YES];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -784,9 +782,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
}
|
|
|
|
|
completion:^(BOOL finished) {
|
|
|
|
|
// HACK: Setting the frame to itself *seems* like it should be a no-op, but
|
|
|
|
|
// it ensures the content is drawn at the right frame. In particular I was reproducibly
|
|
|
|
|
// some images squished (they were EXIF rotated, maybe relateed).
|
|
|
|
|
// similar to this report: https://stackoverflow.com/questions/27961884/swift-uiimageview-stretched-aspect
|
|
|
|
|
// it ensures the content is drawn at the right frame. In particular I was
|
|
|
|
|
// reproducibly some images squished (they were EXIF rotated, maybe
|
|
|
|
|
// relateed). similar to this report:
|
|
|
|
|
// https://stackoverflow.com/questions/27961884/swift-uiimageview-stretched-aspect
|
|
|
|
|
self.mediaView.frame = self.mediaView.frame;
|
|
|
|
|
|
|
|
|
|
// At this point our presentation view should be overlayed perfectly
|
|
|
|
@ -973,7 +972,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
#pragma mark - Saving images to Camera Roll
|
|
|
|
|
|
|
|
|
|
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {
|
|
|
|
|
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
|
|
|
|
|
{
|
|
|
|
|
if (error) {
|
|
|
|
|
DDLogWarn(@"There was a problem saving <%@> to camera roll from %s ",
|
|
|
|
|
error.localizedDescription,
|
|
|
|
|