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

* Fixed a glitch in media viewer when dismissing a GIF: the WebView which shows the animation would show in the background while the transition interaction occurred

* adding the changelog entry

Signed-off-by: Milton Moura <miltonmoura@gmail.com>
This commit is contained in:
Milton Moura
2022-08-05 10:01:31 +00:00
committed by GitHub
parent 63da4b7bdf
commit e39982a555
4 changed files with 33 additions and 2 deletions
@@ -701,7 +701,7 @@
width = minSize;
height = minSize;
}
WKWebView *animatedGifViewer = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, width, height)];
animatedGifViewer.center = cell.customView.center;
animatedGifViewer.opaque = NO;
@@ -1379,6 +1379,30 @@
}
}
#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];