Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes a glitch when dismissing a GIF in the media attachment viewer (#6475) #6476

Merged
2 changes: 2 additions & 0 deletions Riot/Modules/MatrixKit/Animators/MXKAttachmentAnimator.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ typedef NS_ENUM(NSInteger, PhotoBrowserAnimationType) {

@protocol MXKDestinationAttachmentAnimatorDelegate <NSObject>

- (BOOL)prepareSubviewsForTransition:(BOOL)isStartInteraction;

- (UIImageView *)finalImageView;

@end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ - (void)handleGesture:(UIPanGestureRecognizer *)recognizer
- (void)startInteractiveTransition:(id <UIViewControllerContextTransitioning>)transitionContext
{
self.transitionContext = transitionContext;


[self.destinationViewController prepareSubviewsForTransition:YES];

UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIImageView *destinationImageView = [self.destinationViewController finalImageView];
destinationImageView.hidden = YES;
Expand Down Expand Up @@ -158,6 +160,8 @@ - (void)cancelInteractiveTransition {

[self.transitionContext cancelInteractiveTransition];
[self.transitionContext completeTransition:NO];

[self.destinationViewController prepareSubviewsForTransition:NO];
}
}];
}
Expand Down
26 changes: 25 additions & 1 deletion Riot/Modules/Room/Attachements/MXKAttachmentsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell
width = minSize;
height = minSize;
}

WKWebView *animatedGifViewer = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, width, height)];
animatedGifViewer.center = cell.customView.center;
animatedGifViewer.opaque = NO;
Expand Down Expand Up @@ -1379,6 +1379,30 @@ - (void)documentInteractionControllerDidDismissOpenInMenu:(UIDocumentInteraction
}
}

#pragma mark - MXKDestinationAttachmentAnimatorDelegate

- (BOOL)prepareSubviewsForTransition:(BOOL)isStartInteraction
{
MXKMediaCollectionViewCell *cell = (MXKMediaCollectionViewCell *)[self.attachmentsCollection.visibleCells firstObject];
MXKAttachment *attachment = attachments[currentVisibleItemIndex];
NSString *mimeType = attachment.contentInfo[@"mimetype"];

// Check attachment type for GIFs - this is required because of the extra WKWebView
if (attachment.type == MXKAttachmentTypeImage && attachment.contentURL && [mimeType isEqualToString:@"image/gif"])
{
UIView *customView = cell.customView;
for (UIView *v in customView.subviews)
{
if ([v isKindOfClass:[WKWebView class]])
{
v.hidden = isStartInteraction;
return YES;
}
}
}
return NO;
}

- (UIImageView *)finalImageView
{
MXKMediaCollectionViewCell *cell = (MXKMediaCollectionViewCell *)[self.attachmentsCollection.visibleCells firstObject];
Expand Down
1 change: 1 addition & 0 deletions changelog.d/6475.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Media Attachments Viewer: Fixed an issue where dismissing GIFs would show the WebView playing the animation below the interaction transition animation.