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

remove dependency from scaling image view from Photos ViewController #242

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions NYTPhotoViewer/NYTPhotoViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ extern NSString * const NYTPhotoViewControllerPhotoImageUpdatedNotification;
*/
@property (nonatomic, readonly) NYTScalingImageView *scalingImageView;

/**
* Starting/ending view for animation transitions on opening/closing images.
*/
@property (nonatomic, readonly) UIView *transitionView;

/**
* Maximum zoom scale for internal scaling image view.
*/
@property(nonatomic) CGFloat maximumZoomScale;

/**
* The internal activity view shown while the image is loading. Set from the initializer.
*/
Expand Down
12 changes: 12 additions & 0 deletions NYTPhotoViewer/NYTPhotoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,18 @@ - (void)updateImage:(UIImage *)image imageData:(NSData *)imageData {
}
}

- (UIView *)transitionView {
return self.scalingImageView.imageView;
}

- (void)setMaximumZoomScale:(CGFloat)maximumZoomScale {
self.scalingImageView.maximumZoomScale = maximumZoomScale;
}

- (CGFloat)maximumZoomScale {
return self.scalingImageView.maximumZoomScale;
}

#pragma mark - Gesture Recognizers

- (void)setupGestureRecognizers {
Expand Down
7 changes: 3 additions & 4 deletions NYTPhotoViewer/NYTPhotosViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#import "NYTPhotoViewerArrayDataSource.h"
#import "NYTPhotoViewController.h"
#import "NYTPhotoTransitionController.h"
#import "NYTScalingImageView.h"
#import "NYTPhoto.h"
#import "NYTPhotosOverlayView.h"
#import "NYTPhotoCaptionView.h"
Expand Down Expand Up @@ -123,7 +122,7 @@ - (void)viewDidLoad {

UIView *endingView;
if (self.currentlyDisplayedPhoto.image || self.currentlyDisplayedPhoto.placeholderImage) {
endingView = self.currentPhotoViewController.scalingImageView.imageView;
endingView = self.currentPhotoViewController.transitionView;
}

self.transitionController.endingView = endingView;
Expand Down Expand Up @@ -406,7 +405,7 @@ - (void)dismissViewControllerAnimated:(BOOL)animated userInitiated:(BOOL)isUserI

UIView *startingView;
if (self.currentlyDisplayedPhoto.image || self.currentlyDisplayedPhoto.placeholderImage || self.currentlyDisplayedPhoto.imageData) {
startingView = self.currentPhotoViewController.scalingImageView.imageView;
startingView = self.currentPhotoViewController.transitionView;
}

self.transitionController.startingView = startingView;
Expand Down Expand Up @@ -499,7 +498,7 @@ - (NYTPhotoViewController *)newPhotoViewControllerForPhoto:(id <NYTPhoto>)photo

if([self.delegate respondsToSelector:@selector(photosViewController:maximumZoomScaleForPhoto:)]) {
CGFloat maximumZoomScale = [self.delegate photosViewController:self maximumZoomScaleForPhoto:photo];
photoViewController.scalingImageView.maximumZoomScale = maximumZoomScale;
photoViewController.maximumZoomScale = maximumZoomScale;
}

return photoViewController;
Expand Down