Clean up present & dismiss animations for image attachment view.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent 6a3b462541
commit 593c3d53d4

@ -274,14 +274,19 @@
presentViewController:self presentViewController:self
animated:NO animated:NO
completion:^{ completion:^{
[UIView animateWithDuration:0.4f UIWindow *window = [UIApplication sharedApplication].keyWindow;
self.imageView.frame = [self.view convertRect:self.originRect
fromView:window];
[UIView animateWithDuration:0.25f
delay:0 delay:0
options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseOut
animations:^() { animations:^() {
self.view.alpha = 1.0f; self.view.alpha = 1.0f;
self.imageView.frame = [self resizedFrameForImageView:self.image.size]; self.imageView.frame = [self resizedFrameForImageView:self.image.size];
self.imageView.center = self.imageView.center =
CGPointMake(self.view.bounds.size.width / 2.0f, self.view.bounds.size.height / 2.0f); CGPointMake(self.view.bounds.size.width / 2.0f,
self.view.bounds.size.height / 2.0f);
} }
completion:^(BOOL completed) { completion:^(BOOL completed) {
self.scrollView.frame = self.view.bounds; self.scrollView.frame = self.view.bounds;
@ -296,9 +301,9 @@
- (void)dismiss { - (void)dismiss {
self.view.userInteractionEnabled = NO; self.view.userInteractionEnabled = NO;
[UIView animateWithDuration:0.4f [UIView animateWithDuration:0.25f
delay:0 delay:0
options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveLinear
animations:^() { animations:^() {
self.backgroundView.backgroundColor = [UIColor clearColor]; self.backgroundView.backgroundColor = [UIColor clearColor];
self.scrollView.alpha = 0; self.scrollView.alpha = 0;
@ -315,7 +320,6 @@
[self updateLayouts]; [self updateLayouts];
} }
- (void)updateLayouts { - (void)updateLayouts {
if (_isPresenting) { if (_isPresenting) {
return; return;
@ -327,7 +331,6 @@
self.scrollView.contentInset = [self contentInsetForScrollView:self.scrollView.zoomScale]; self.scrollView.contentInset = [self contentInsetForScrollView:self.scrollView.zoomScale];
} }
#pragma mark - Resizing #pragma mark - Resizing
- (CGRect)resizedFrameForImageView:(CGSize)imageSize { - (CGRect)resizedFrameForImageView:(CGSize)imageSize {

@ -1165,9 +1165,12 @@ typedef enum : NSUInteger {
if(tappedImage == nil) { if(tappedImage == nil) {
DDLogWarn(@"tapped TSPhotoAdapter with nil image"); DDLogWarn(@"tapped TSPhotoAdapter with nil image");
} else { } else {
CGRect convertedRect = UIWindow *window = [UIApplication sharedApplication].keyWindow;
[self.collectionView convertRect:[collectionView cellForItemAtIndexPath:indexPath].frame JSQMessagesCollectionViewCell *cell = (JSQMessagesCollectionViewCell *) [collectionView cellForItemAtIndexPath:indexPath];
toView:nil]; OWSAssert([cell isKindOfClass:[JSQMessagesCollectionViewCell class]]);
CGRect convertedRect = [cell.mediaView convertRect:cell.mediaView.bounds
toView:window];
__block TSAttachment *attachment = nil; __block TSAttachment *attachment = nil;
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { [self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
attachment = attachment =
@ -1193,9 +1196,12 @@ typedef enum : NSUInteger {
if(tappedImage == nil) { if(tappedImage == nil) {
DDLogWarn(@"tapped TSAnimatedAdapter with nil image"); DDLogWarn(@"tapped TSAnimatedAdapter with nil image");
} else { } else {
CGRect convertedRect = UIWindow *window = [UIApplication sharedApplication].keyWindow;
[self.collectionView convertRect:[collectionView cellForItemAtIndexPath:indexPath].frame JSQMessagesCollectionViewCell *cell = (JSQMessagesCollectionViewCell *) [collectionView cellForItemAtIndexPath:indexPath];
toView:nil]; OWSAssert([cell isKindOfClass:[JSQMessagesCollectionViewCell class]]);
CGRect convertedRect = [cell.mediaView convertRect:cell.mediaView.bounds
toView:window];
__block TSAttachment *attachment = nil; __block TSAttachment *attachment = nil;
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { [self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
attachment = attachment =

Loading…
Cancel
Save