Brion VIBBER has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/88782


Change subject: Made details image scale from aspect fit to aspect fill upon 
loading.
......................................................................

Made details image scale from aspect fit to aspect fill upon loading.

This gets rid of the black bars which can result from aspect fit and provides 
visual cue to user that the image is draggable and pinchable.

Change-Id: I157f45a40d85fdfd515e75116dc1159e86dcb939
---
M Commons-iOS/ImageScrollViewController.h
M Commons-iOS/ImageScrollViewController.m
M Commons-iOS/MyUploadsViewController.m
3 files changed, 24 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/apps/ios/commons 
refs/changes/82/88782/1

diff --git a/Commons-iOS/ImageScrollViewController.h 
b/Commons-iOS/ImageScrollViewController.h
index 7496f24..3e89a55 100644
--- a/Commons-iOS/ImageScrollViewController.h
+++ b/Commons-iOS/ImageScrollViewController.h
@@ -14,6 +14,6 @@
 @property (nonatomic, strong) UIImage *image;
 @property (nonatomic) float detailsScrollNormal;
 
--(float)getScaleToMakeImageFullscreen;
+-(float)getImageAspectFitScale;
 
 @end
diff --git a/Commons-iOS/ImageScrollViewController.m 
b/Commons-iOS/ImageScrollViewController.m
index 04cc5f2..91c2d17 100644
--- a/Commons-iOS/ImageScrollViewController.m
+++ b/Commons-iOS/ImageScrollViewController.m
@@ -39,7 +39,7 @@
     [self.imageView sizeToFit];
     
     // And zoom so image fits
-    float scale = [self getScaleToMakeImageFullscreen];
+    float scale = [self getImageAspectFitScale];
 
     if (scale < self.imageScrollView.minimumZoomScale) {
         // Must adjust minimumZoomScale down or the image won't be able to be 
shrunken to fit
@@ -51,13 +51,23 @@
 
 #pragma mark - Positioning
 
--(float)getScaleToMakeImageFullscreen
+-(float)getImageAspectFitScale
 {
     // Determine the scale adjustment required to make the imageView fit 
completely within the view
     // (Note: this works because the imageView is sized to its image's size 
when its image is changed)
     CGSize dst = self.view.bounds.size;
     CGSize src = self.imageView.image.size;
     float scale = fminf(dst.width / src.width, dst.height / src.height);
+    return scale;
+}
+
+-(float)getImageAspectFillScale
+{
+    // Determine the scale adjustment required to make the imageView fill 
available screen
+    // (edges in one dimension may overlap)
+    CGSize dst = self.view.bounds.size;
+    CGSize src = self.imageView.image.size;
+    float scale = fmaxf(dst.width / src.width, dst.height / src.height);
     return scale;
 }
 
@@ -145,12 +155,19 @@
     */
 }
 
-/*
 -(void)viewDidAppear:(BOOL)animated
 {
-    [self.view randomlyColorSubviews];
+    [super viewDidAppear:animated];
+
+    // Zoom to aspect fill scale so image isn't surrounded by black bars and to
+    // hint to user that image can be pinch/zoomed. The addition of 0.01f means
+    // there will be a tiny overlap with the edges of the screen for the 
dimension
+    // of the image which would otherwise be exactly flush - this allow drag
+    // gesture to drag the image in this dimension, which otherwise would be
+    // locked to dragging unless the image were expand-pinched a bit. Nice for
+    // discoverability of the drag-ability and pinch-ability of the image.
+    [self.imageScrollView setZoomScale:([self getImageAspectFillScale] + 
0.01f) animated:YES];
 }
-*/
 
 #pragma mark - Image scrolling setup
 
diff --git a/Commons-iOS/MyUploadsViewController.m 
b/Commons-iOS/MyUploadsViewController.m
index 7b317b1..95401ba 100644
--- a/Commons-iOS/MyUploadsViewController.m
+++ b/Commons-iOS/MyUploadsViewController.m
@@ -1298,7 +1298,7 @@
 
 -(void)handleTwoFingerTap:(UITapGestureRecognizer *)recognizer
 {
-    [imageScrollVC_.imageScrollView setZoomScale:[imageScrollVC_ 
getScaleToMakeImageFullscreen] animated:YES];
+    [imageScrollVC_.imageScrollView setZoomScale:[imageScrollVC_ 
getImageAspectFitScale] animated:YES];
 }
 
 @end

-- 
To view, visit https://gerrit.wikimedia.org/r/88782
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I157f45a40d85fdfd515e75116dc1159e86dcb939
Gerrit-PatchSet: 1
Gerrit-Project: apps/ios/commons
Gerrit-Branch: master
Gerrit-Owner: 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

Reply via email to