Clean up present & dismiss animations for image attachment view.

// FREEBIE
This commit is contained in:
Matthew Chen 2017-02-10 23:21:40 -05:00
parent 6a3b462541
commit 593c3d53d4
2 changed files with 22 additions and 13 deletions

View file

@ -274,14 +274,19 @@
presentViewController:self
animated:NO
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
options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut
options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseOut
animations:^() {
self.view.alpha = 1.0f;
self.imageView.frame = [self resizedFrameForImageView:self.image.size];
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) {
self.scrollView.frame = self.view.bounds;
@ -296,9 +301,9 @@
- (void)dismiss {
self.view.userInteractionEnabled = NO;
[UIView animateWithDuration:0.4f
[UIView animateWithDuration:0.25f
delay:0
options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut
options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveLinear
animations:^() {
self.backgroundView.backgroundColor = [UIColor clearColor];
self.scrollView.alpha = 0;
@ -315,7 +320,6 @@
[self updateLayouts];
}
- (void)updateLayouts {
if (_isPresenting) {
return;
@ -327,7 +331,6 @@
self.scrollView.contentInset = [self contentInsetForScrollView:self.scrollView.zoomScale];
}
#pragma mark - Resizing
- (CGRect)resizedFrameForImageView:(CGSize)imageSize {

View file

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