Brion VIBBER has submitted this change and it was merged. Change subject: Added double-tap image zoom & two finger tap zoom out. ......................................................................
Added double-tap image zoom & two finger tap zoom out. Also removed an unused overlay. Change-Id: I062484a348144b4295ff93c5a456d91d251057e3 --- M Commons-iOS/DetailScrollViewController.h M Commons-iOS/DetailScrollViewController.m M Commons-iOS/ImageScrollViewController.h M Commons-iOS/ImageScrollViewController.m M Commons-iOS/MyUploadsViewController.m 5 files changed, 27 insertions(+), 32 deletions(-) Approvals: Brion VIBBER: Verified; Looks good to me, approved diff --git a/Commons-iOS/DetailScrollViewController.h b/Commons-iOS/DetailScrollViewController.h index 0402d14..bb62569 100644 --- a/Commons-iOS/DetailScrollViewController.h +++ b/Commons-iOS/DetailScrollViewController.h @@ -18,7 +18,6 @@ @property (nonatomic) float detailsScrollNormal; @property (weak, nonatomic) UINavigationItem *navigationItem; @property (weak, nonatomic) UIView *view; - -(void)clearOverlay; @end @interface DetailScrollViewController : UIViewController <UITextFieldDelegate, UITextViewDelegate, UIGestureRecognizerDelegate> diff --git a/Commons-iOS/DetailScrollViewController.m b/Commons-iOS/DetailScrollViewController.m index 60f3795..f71af9b 100644 --- a/Commons-iOS/DetailScrollViewController.m +++ b/Commons-iOS/DetailScrollViewController.m @@ -297,8 +297,6 @@ // Move details to docking position at bottom of screen [self moveDetailsToDock]; - - [self.delegate clearOverlay]; } if(!self.selectedRecord.complete.boolValue){ diff --git a/Commons-iOS/ImageScrollViewController.h b/Commons-iOS/ImageScrollViewController.h index a6746a3..7496f24 100644 --- a/Commons-iOS/ImageScrollViewController.h +++ b/Commons-iOS/ImageScrollViewController.h @@ -14,6 +14,6 @@ @property (nonatomic, strong) UIImage *image; @property (nonatomic) float detailsScrollNormal; --(void)clearOverlay; +-(float)getScaleToMakeImageFullscreen; @end diff --git a/Commons-iOS/ImageScrollViewController.m b/Commons-iOS/ImageScrollViewController.m index 642cb5e..04cc5f2 100644 --- a/Commons-iOS/ImageScrollViewController.m +++ b/Commons-iOS/ImageScrollViewController.m @@ -103,8 +103,6 @@ // Change back button to be an arrow self.navigationItem.leftBarButtonItem = [[CommonsApp singleton] getBackButtonItemWithTarget:self action:@selector(backButtonPressed:)]; - [self setupOverlayView]; - [self setupImageScrollingViews]; // Don't make the view background clear or the space surrounding the image will @@ -247,27 +245,6 @@ overlayView_.backgroundColor = [UIColor colorWithWhite:0.0f alpha:overlayAlpha]; */ -} - -#pragma mark - Overlay view - --(void)setupOverlayView -{ - overlayView_ = [[UIView alloc] initWithFrame:self.view.bounds]; - overlayView_.translatesAutoresizingMaskIntoConstraints = NO; - overlayView_.userInteractionEnabled = NO; - overlayView_.backgroundColor = [UIColor clearColor]; - - [self.view addSubview:overlayView_]; - - NSDictionary *views = NSDictionaryOfVariableBindings(overlayView_); - [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[overlayView_]|" options:0 metrics:0 views:views]]; - [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[overlayView_]|" options:0 metrics:0 views:views]]; -} - --(void)clearOverlay -{ - overlayView_.backgroundColor = [UIColor clearColor]; } @end diff --git a/Commons-iOS/MyUploadsViewController.m b/Commons-iOS/MyUploadsViewController.m index 6f3ee1e..7b317b1 100644 --- a/Commons-iOS/MyUploadsViewController.m +++ b/Commons-iOS/MyUploadsViewController.m @@ -41,6 +41,7 @@ DetailScrollViewController *detailVC_; UITapGestureRecognizer *imageTapRecognizer_; UITapGestureRecognizer *imageDoubleTapRecognizer_; + UITapGestureRecognizer *imageTwoFingerTapRecognizer_; } @end @@ -810,9 +811,19 @@ if (touch.view == self.choosePhotoButton) return NO; } - if ((gestureRecognizer == imageTapRecognizer_) || (gestureRecognizer == imageDoubleTapRecognizer_)) { + if ( + (gestureRecognizer == imageTapRecognizer_) + || + (gestureRecognizer == imageDoubleTapRecognizer_) + || + (gestureRecognizer == imageTwoFingerTapRecognizer_) + ) { // Ignore touches which fall on the details table or its contents - if (!(imageScrollVC_.imageScrollView == touch.view || imageScrollVC_.imageView == touch.view)) return NO; + if (!( + imageScrollVC_.imageScrollView == touch.view + || + imageScrollVC_.imageView == touch.view + )) return NO; } return YES; @@ -1244,14 +1255,19 @@ imageTapRecognizer_.cancelsTouchesInView = NO; imageTapRecognizer_.delegate = self; + imageTwoFingerTapRecognizer_ = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTwoFingerTap:)]; + imageTwoFingerTapRecognizer_.numberOfTouchesRequired = 2; + imageTwoFingerTapRecognizer_.numberOfTapsRequired = 1; + [imageScrollVC_.view addGestureRecognizer:imageTwoFingerTapRecognizer_]; + imageTwoFingerTapRecognizer_.cancelsTouchesInView = NO; + imageTwoFingerTapRecognizer_.delegate = self; + imageDoubleTapRecognizer_ = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleImageDoubleTap:)]; imageDoubleTapRecognizer_.numberOfTouchesRequired = 1; imageDoubleTapRecognizer_.numberOfTapsRequired = 2; [imageScrollVC_.view addGestureRecognizer:imageDoubleTapRecognizer_]; imageDoubleTapRecognizer_.cancelsTouchesInView = NO; imageDoubleTapRecognizer_.delegate = self; - - imageDoubleTapRecognizer_.enabled = NO; [imageTapRecognizer_ requireGestureRecognizerToFail:imageDoubleTapRecognizer_]; @@ -1277,7 +1293,12 @@ -(void)handleImageDoubleTap:(UITapGestureRecognizer *)recognizer { - //NSLog(@"Add double-tap to zoom here"); + [imageScrollVC_.imageScrollView setZoomScale:(imageScrollVC_.imageScrollView.zoomScale * 2.0f) animated:YES]; +} + +-(void)handleTwoFingerTap:(UITapGestureRecognizer *)recognizer +{ + [imageScrollVC_.imageScrollView setZoomScale:[imageScrollVC_ getScaleToMakeImageFullscreen] animated:YES]; } @end -- To view, visit https://gerrit.wikimedia.org/r/88781 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I062484a348144b4295ff93c5a456d91d251057e3 Gerrit-PatchSet: 1 Gerrit-Project: apps/ios/commons Gerrit-Branch: master Gerrit-Owner: Brion VIBBER <br...@wikimedia.org> Gerrit-Reviewer: Brion VIBBER <br...@wikimedia.org> Gerrit-Reviewer: Mhurd <mh...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits