Mhurd has uploaded a new change for review.

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

Change subject: Search shows new results without blanking results.
......................................................................

Search shows new results without blanking results.

Much less jarring visually. Also small style tweaks adding a bit
more padding above and below the search "Titles/In Articles" buttons.

Change-Id: I1896e0139cd0b029f73329b432a4ee4b53212463
---
M wikipedia/Base.lproj/Main_iPhone.storyboard
M wikipedia/View Controllers/SearchResults/SearchResultsController.m
M wikipedia/View Controllers/SearchResults/SearchTypeMenu.m
3 files changed, 72 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/apps/ios/wikipedia 
refs/changes/90/174490/1

diff --git a/wikipedia/Base.lproj/Main_iPhone.storyboard 
b/wikipedia/Base.lproj/Main_iPhone.storyboard
index 603b90e..8c24700 100644
--- a/wikipedia/Base.lproj/Main_iPhone.storyboard
+++ b/wikipedia/Base.lproj/Main_iPhone.storyboard
@@ -1056,7 +1056,7 @@
                             </label>
                             <view contentMode="scaleToFill" 
translatesAutoresizingMaskIntoConstraints="NO" id="1zy-br-xtt" 
userLabel="Search type chooser" customClass="SearchTypeMenu">
                                 <rect key="frame" x="0.0" y="20" width="320" 
height="34"/>
-                                <color key="backgroundColor" white="1" 
alpha="1" colorSpace="calibratedWhite"/>
+                                <color key="backgroundColor" white="0.0" 
alpha="0.0" colorSpace="calibratedWhite"/>
                                 <constraints>
                                     <constraint firstAttribute="height" 
constant="34" placeholder="YES" id="JQ0-Ku-oZd"/>
                                 </constraints>
diff --git a/wikipedia/View Controllers/SearchResults/SearchResultsController.m 
b/wikipedia/View Controllers/SearchResults/SearchResultsController.m
index a112470..42cdbec 100644
--- a/wikipedia/View Controllers/SearchResults/SearchResultsController.m
+++ b/wikipedia/View Controllers/SearchResults/SearchResultsController.m
@@ -48,6 +48,8 @@
 
 @property (nonatomic, weak) IBOutlet UIView *recentSearchesContainer;
 
+@property (nonatomic) BOOL ignoreScrollEvents;
+
 @end
 
 @implementation SearchResultsController
@@ -94,6 +96,7 @@
 {
     [super viewDidLoad];
 
+    self.ignoreScrollEvents = NO;
     self.searchString = @"";
     
     self.placeholderImage = [UIImage 
imageNamed:@"logo-placeholder-search.png"];
@@ -235,6 +238,8 @@
 
 - (void)scrollViewDidScroll:(UIScrollView *)scrollView
 {
+    if (self.ignoreScrollEvents) return;
+    
     // Hide the keyboard if it was visible when the results are scrolled, but 
only if
     // the results have been scrolled in excess of some small distance 
threshold first.
     // This prevents tiny scroll adjustments, which seem to occur occasionally 
for some
@@ -304,7 +309,7 @@
                 [self fadeAlert];
                 break;
             case FETCH_FINAL_STATUS_FAILED:
-                [self.searchMessageLabel 
showWithText:error.localizedDescription];
+                //[self.searchMessageLabel 
showWithText:error.localizedDescription];
                 //[self showAlert:error.localizedDescription 
type:ALERT_TYPE_MIDDLE duration:-1];
                 break;
         }
@@ -380,14 +385,29 @@
     }
 }
 
+-(void)scrollTableToTop
+{
+    if ([self.searchResultsTable numberOfRowsInSection:0] > 0) {
+        // Ignore scroll event so keyboard doesn't disappear.
+        self.ignoreScrollEvents = YES;
+        [UIView animateWithDuration:0.15f animations:^{
+            [self.searchResultsTable scrollToRowAtIndexPath: [NSIndexPath 
indexPathForRow:0 inSection:0]
+                                           atScrollPosition: 
UITableViewScrollPositionTop
+                                                   animated: NO];
+        } completion:^(BOOL done){
+            self.ignoreScrollEvents = NO;
+        }];
+    }
+}
+
 - (void)searchForTerm:(NSString *)searchTerm
 {
-    [self clearSearchResults];
+    [self scrollTableToTop];
 
     [self.searchMessageLabel hide];
     
     // Show "Searching..." message.
-    [self.searchMessageLabel 
showWithText:MWLocalizedString(@"search-searching", nil)];
+    //[self.searchMessageLabel 
showWithText:MWLocalizedString(@"search-searching", nil)];
     
     //[self showAlert:MWLocalizedString(@"search-searching", nil) 
type:ALERT_TYPE_MIDDLE duration:-1];
     
diff --git a/wikipedia/View Controllers/SearchResults/SearchTypeMenu.m 
b/wikipedia/View Controllers/SearchResults/SearchTypeMenu.m
index aa19158..ff2aa7a 100644
--- a/wikipedia/View Controllers/SearchResults/SearchTypeMenu.m
+++ b/wikipedia/View Controllers/SearchResults/SearchTypeMenu.m
@@ -11,10 +11,10 @@
 #define CORNER_RADIUS (2.0f * MENUS_SCALE_MULTIPLIER)
 #define CORNERS_LEFT (UIRectCornerTopLeft|UIRectCornerBottomLeft)
 #define CORNERS_RIGHT (UIRectCornerTopRight|UIRectCornerBottomRight)
-#define BACKGROUND_COLOR SEARCH_BUTTON_BACKGROUND_COLOR
+#define BACKGROUND_COLOR [UIColor whiteColor]
 #define BORDER_WIDTH (1.0f / [UIScreen mainScreen].scale)
 #define BUTTON_PADDING (UIEdgeInsetsMake(6.0f, 6.0f, 6.0f, 6.0f))
-#define BUTTON_MARGIN (UIEdgeInsetsMake(6.0f, 12.0f, 4.0f, 12.0f))
+#define BUTTON_MARGIN (UIEdgeInsetsMake(10.0f, 12.0f, 10.0f, 12.0f))
 
 @interface SearchTypeMenu()
 
@@ -30,17 +30,17 @@
     _searchType = type;
     switch (type) {
         case SEARCH_TYPE_TITLES:
-            self.searchButtonTitles.backgroundColor = BACKGROUND_COLOR;
+            self.searchButtonTitles.backgroundColor = 
SEARCH_BUTTON_BACKGROUND_COLOR;
             self.searchButtonWithinArticles.backgroundColor = [UIColor 
whiteColor];
             self.searchButtonTitles.textColor = [UIColor whiteColor];
-            self.searchButtonWithinArticles.textColor = BACKGROUND_COLOR;
+            self.searchButtonWithinArticles.textColor = 
SEARCH_BUTTON_BACKGROUND_COLOR;
             self.searchButtonTitles.font = [UIFont 
boldSystemFontOfSize:FONT_SIZE];
             self.searchButtonWithinArticles.font = [UIFont 
systemFontOfSize:FONT_SIZE];
             break;
         case SEARCH_TYPE_IN_ARTCILES:
             self.searchButtonTitles.backgroundColor = [UIColor whiteColor];
-            self.searchButtonWithinArticles.backgroundColor = BACKGROUND_COLOR;
-            self.searchButtonTitles.textColor = BACKGROUND_COLOR;
+            self.searchButtonWithinArticles.backgroundColor = 
SEARCH_BUTTON_BACKGROUND_COLOR;
+            self.searchButtonTitles.textColor = SEARCH_BUTTON_BACKGROUND_COLOR;
             self.searchButtonWithinArticles.textColor = [UIColor whiteColor];
             self.searchButtonTitles.font = [UIFont systemFontOfSize:FONT_SIZE];
             self.searchButtonWithinArticles.font = [UIFont 
boldSystemFontOfSize:FONT_SIZE];
@@ -70,6 +70,8 @@
 
 -(void)didMoveToSuperview
 {
+    self.backgroundColor = BACKGROUND_COLOR;
+
     self.searchButtonTitles = [[PaddedLabel alloc] init];
     self.searchButtonWithinArticles = [[PaddedLabel alloc] init];
 
@@ -142,6 +144,10 @@
 {
     [super drawRect:rect];
 
+    // Makes very small gradient at bottom of menu so search results scrolling 
underneath
+    // the menu blend more seamlessly.
+    //[self drawGradientBackground:rect];
+
     // Hack to draw rounded borders exactly how we want them.
     [self drawRoundedBorders];
 }
@@ -150,7 +156,7 @@
 {
     // Hack to draw rounded borders (with inside curve rounding).
 
-    [BACKGROUND_COLOR set];
+    [SEARCH_BUTTON_BACKGROUND_COLOR set];
     
     CGContextRef currentContext = UIGraphicsGetCurrentContext();
     CGContextSetLineWidth(currentContext, BORDER_WIDTH);
@@ -173,4 +179,39 @@
     CGContextDrawPath(currentContext, kCGPathStroke);
 }
 
+- (void)drawGradientBackground:(CGRect)rect
+{
+    CGContextRef ctx = UIGraphicsGetCurrentContext();
+
+    // Make the gradient begin just above the bottom.
+    CGFloat gradientHeight = CGRectGetMaxY(rect) - (2.0 * 
MENUS_SCALE_MULTIPLIER);
+
+    // Draw top part in white.
+    CGRect topHalfRect = CGRectMake(rect.origin.x, rect.origin.y, 
rect.size.width, gradientHeight);
+    CGContextSetRGBFillColor(ctx, 1.0, 1.0, 1.0, 1.0);
+    CGContextSetRGBStrokeColor(ctx, 1.0, 1.0, 1.0, 1.0);
+    CGContextFillRect(ctx, topHalfRect);
+
+    // Draw white to transparent gradient of gradientHeight at bottom of rect.
+    // Gradient drawing based on: http://stackoverflow.com/a/422208
+    CGGradientRef gradient;
+    CGColorSpaceRef rgbSpace;
+    size_t locationCount = 2;
+    CGFloat locations[2] = { 0.0, 1.0 };
+    CGFloat colorComponents[8] = {
+        1.0, 1.0, 1.0, 1.0,    // starting color
+        1.0, 1.0, 1.0, 0.0     // ending color
+    };
+
+    rgbSpace = CGColorSpaceCreateDeviceRGB();
+    gradient = CGGradientCreateWithColorComponents(rgbSpace, colorComponents, 
locations, locationCount);
+
+    CGPoint midCenter = CGPointMake(CGRectGetMidX(rect), gradientHeight);
+    CGPoint bottomCenter = CGPointMake(CGRectGetMidX(rect), 
CGRectGetMaxY(rect));
+    CGContextDrawLinearGradient(ctx, gradient, midCenter, bottomCenter, 0);
+
+    CGGradientRelease(gradient);
+    CGColorSpaceRelease(rgbSpace);
+}
+
 @end

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1896e0139cd0b029f73329b432a4ee4b53212463
Gerrit-PatchSet: 1
Gerrit-Project: apps/ios/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Mhurd <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to