Skip to content

Commit

Permalink
Merge pull request #1936 from artsy/ashfurrow-fair-search
Browse files Browse the repository at this point in the history
Re-applies fair search design
  • Loading branch information
sarahscott committed Oct 18, 2016
2 parents e59b5a0 + d818676 commit 7977be4
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 12 deletions.
6 changes: 6 additions & 0 deletions Artsy.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@
5E6BA6EA1C56B5D700B942C1 /* CircularCancelButton.png in Resources */ = {isa = PBXBuildFile; fileRef = 5E6BA6E81C56B5D700B942C1 /* CircularCancelButton.png */; };
5E6CBB011DB54A5500988CDF /* AROnboardingPersonalizationGeneImageStateReconciler.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E6CBB001DB54A5500988CDF /* AROnboardingPersonalizationGeneImageStateReconciler.m */; };
5E6CBB031DB54BC000988CDF /* AROnboardingPersonalizationGeneImageStateReconcilerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E6CBB021DB54BC000988CDF /* AROnboardingPersonalizationGeneImageStateReconcilerTests.m */; };
5E6CBB061DB668D100988CDF /* ARSearchViewControllerStyling.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E6CBB051DB668D100988CDF /* ARSearchViewControllerStyling.m */; };
5E71AFC7195C64C1000F6325 /* ARFairGuideContainerViewControllerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E71AFC6195C64C1000F6325 /* ARFairGuideContainerViewControllerTests.m */; };
5E73C93A1C6933FA00496C7C /* AuctionTitleViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E73C9391C6933FA00496C7C /* AuctionTitleViewTests.swift */; };
5E7598061D9D92F60084AAEC /* LiveAuctionLotBidHistoryGestureControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7598041D9D92F20084AAEC /* LiveAuctionLotBidHistoryGestureControllerTests.swift */; };
Expand Down Expand Up @@ -1314,6 +1315,8 @@
5E6CBAFF1DB54A5500988CDF /* AROnboardingPersonalizationGeneImageStateReconciler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AROnboardingPersonalizationGeneImageStateReconciler.h; sourceTree = "<group>"; };
5E6CBB001DB54A5500988CDF /* AROnboardingPersonalizationGeneImageStateReconciler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AROnboardingPersonalizationGeneImageStateReconciler.m; sourceTree = "<group>"; };
5E6CBB021DB54BC000988CDF /* AROnboardingPersonalizationGeneImageStateReconcilerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AROnboardingPersonalizationGeneImageStateReconcilerTests.m; sourceTree = "<group>"; };
5E6CBB041DB668D100988CDF /* ARSearchViewControllerStyling.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARSearchViewControllerStyling.h; sourceTree = "<group>"; };
5E6CBB051DB668D100988CDF /* ARSearchViewControllerStyling.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARSearchViewControllerStyling.m; sourceTree = "<group>"; };
5E71AF231912826B008B1426 /* ARPersonalizeViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ARPersonalizeViewController.h; sourceTree = "<group>"; };
5E71AFC6195C64C1000F6325 /* ARFairGuideContainerViewControllerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARFairGuideContainerViewControllerTests.m; sourceTree = "<group>"; };
5E73C9391C6933FA00496C7C /* AuctionTitleViewTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AuctionTitleViewTests.swift; path = Auctions/AuctionTitleViewTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2551,6 +2554,8 @@
3C9F215D18B25D0D00D8898B /* ARSearchViewController.h */,
5EFF52BB1976D57C00E2A563 /* ARSearchViewController+Private.h */,
3C9F215E18B25D0D00D8898B /* ARSearchViewController.m */,
5E6CBB041DB668D100988CDF /* ARSearchViewControllerStyling.h */,
5E6CBB051DB668D100988CDF /* ARSearchViewControllerStyling.m */,
3C205ACB1908041700B3C2B4 /* ARSearchResultsDataSource.h */,
3C205ACC1908041700B3C2B4 /* ARSearchResultsDataSource.m */,
);
Expand Down Expand Up @@ -5807,6 +5812,7 @@
342F9CB876CC63CF8E8C656F /* ARTextView.m in Sources */,
342F917E6CFBD49D6F43873D /* ARCollapsableTextView.m in Sources */,
342F97971D28FDC703392765 /* MTLModel+JSON.m in Sources */,
5E6CBB061DB668D100988CDF /* ARSearchViewControllerStyling.m in Sources */,
342F949383329F78F589BE53 /* MTLModel+Dictionary.m in Sources */,
60AF60C91CB2D8BD0041B430 /* LiveAuctionPlaceMaxBidViewController.swift in Sources */,
5E088DAE1C58072B00C448D7 /* RefinementOptionsViewController+Private.swift in Sources */,
Expand Down
12 changes: 12 additions & 0 deletions Artsy/View_Controllers/Fair/ARFairSearchViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#import "ArtsyAPI+Search.h"
#import "ARFonts.h"
#import "ARTopMenuViewController.h"
#import "ARSearchViewController+Private.h"
#import "Fair.h"
#import "Partner.h"
Expand Down Expand Up @@ -60,6 +61,12 @@ - (void)viewDidLoad
[searchBox alignCenterYWithView:self.searchBoxView predicate:@"0"];
}

- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];

[[[ARTopMenuViewController sharedController] rootNavigationController] showBackButton:NO animated:YES];
}

- (void)fetchSearchResults:(NSString *)text replace:(BOOL)replaceResults
{
ar_dispatch_async(^{
Expand Down Expand Up @@ -128,11 +135,16 @@ - (void)selectedResult:(SearchResult *)result ofType:(NSString *)type fromQuery:
- (void)closeSearch:(id)sender
{
[super closeSearch:sender];
[[[ARTopMenuViewController sharedController] rootNavigationController] showBackButton:YES animated:YES];
if ([self.delegate respondsToSelector:@selector(cancelledSearch:)]) {
[self.delegate cancelledSearch:self];
} else {
[self clearSearchAnimated:YES];
}
}

- (ARSearchViewControllerStylingMode)searchPresentationMode {
return ARSearchViewControllerStylingModeFair;
}

@end
3 changes: 3 additions & 0 deletions Artsy/View_Controllers/Search/ARSearchViewController.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#import "ARSearchResultsDataSource.h"
#import "ARSearchViewControllerStyling.h"

typedef NS_ENUM(NSInteger, ARMenuState) {
ARMenuStateCollapsed,
Expand Down Expand Up @@ -43,4 +44,6 @@ typedef NS_ENUM(NSInteger, ARMenuState) {
- (void)addResults:(NSArray *)results replace:(BOOL)replaceResults;
- (void)selectedResult:(SearchResult *)result ofType:(NSString *)type fromQuery:(NSString *)query;

- (ARSearchViewControllerStylingMode)searchPresentationMode;

@end
25 changes: 14 additions & 11 deletions Artsy/View_Controllers/Search/ARSearchViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ @interface ARSearchViewController () <UITextFieldDelegate, UITableViewDelegate>
@property (readonly, nonatomic) UITableView *resultsView;
@property (readonly, nonatomic) UIView *contentView;
@property (readonly, nonatomic) AFHTTPRequestOperation *searchRequest;
@property (readonly, nonatomic) ARSearchViewControllerStyling *styling;
@end


Expand All @@ -34,6 +35,7 @@ - (instancetype)init
_searchDataSource = [[ARSearchResultsDataSource alloc] init];
_fontSize = 16;
_noResultsInfoLabelText = @"No results found.";
_styling = [ARSearchViewControllerStyling new];

return self;
}
Expand All @@ -44,7 +46,8 @@ - (void)viewDidLoad

UIView *searchBoxView = [[UIView alloc] initWithFrame:CGRectZero];
[self.view addSubview:searchBoxView];
[searchBoxView constrainTopSpaceToView:self.flk_topLayoutGuide predicate:@"70"];
[searchBoxView constrainTopSpaceToView:self.flk_topLayoutGuide
predicate:[self.styling topLayoutConstraintForStyleMode:self.searchPresentationMode]];
[searchBoxView alignLeading:@"10" trailing:@"-10" toView:self.view];
[searchBoxView constrainHeight:@(self.fontSize).stringValue];
_searchBoxView = searchBoxView;
Expand All @@ -53,11 +56,12 @@ - (void)viewDidLoad
UIImageView *searchIcon = [[UIImageView alloc] init];
searchIcon.image = [[UIImage imageNamed:self.searchIconImageName ?: @"SearchButton"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
searchIcon.contentMode = UIViewContentModeScaleAspectFit;
searchIcon.tintColor = [UIColor whiteColor];
searchIcon.tintColor = [self.styling searchIconTintColorForStyleMode:self.searchPresentationMode];
[searchBoxView addSubview:searchIcon];
_searchIcon = searchIcon;

[searchIcon alignLeadingEdgeWithView:searchBoxView predicate:@"30"];
[searchIcon alignLeadingEdgeWithView:searchBoxView
predicate:[self.styling searchIconLeadingConstraintForStyleMode:self.searchPresentationMode]];
[searchIcon alignAttribute:NSLayoutAttributeWidth toAttribute:NSLayoutAttributeHeight ofView:searchIcon predicate:@"0"];

// input text field
Expand All @@ -83,13 +87,8 @@ - (void)viewDidLoad
[closeButton constrainLeadingSpaceToView:textField predicate:@"14"];
[closeButton alignTrailingEdgeWithView:searchBoxView predicate:@"0"];

NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:@"CLOSE" attributes:@{
NSKernAttributeName : @1,
NSFontAttributeName : [UIFont sansSerifFontWithSize:[UIDevice isPad] ? 13 : 10],
NSForegroundColorAttributeName : [UIColor whiteColor],
}];

[closeButton setAttributedTitle:attributedString forState:UIControlStateNormal];
[closeButton setAttributedTitle:[self.styling closeButtonAttribtedTextForStyleMode:self.searchPresentationMode]
forState:UIControlStateNormal];

[closeButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
closeButton.contentEdgeInsets = [UIDevice isPad] ? UIEdgeInsetsMake(0, 10, 0, 10) : UIEdgeInsetsMake(0, 0, 0, 0);
Expand Down Expand Up @@ -326,6 +325,10 @@ - (void)presentNoResults
[self stopSearching];
}

- (ARSearchViewControllerStylingMode)searchPresentationMode {
return ARSearchViewControllerStylingModeMainScreen;
}

#pragma mark - Info Label

- (void)showInfoLabel:(BOOL)show animated:(BOOL)animated
Expand Down Expand Up @@ -377,7 +380,7 @@ - (void)presentResultsViewAnimated:(BOOL)animated
[self stopSearching];

[self.view addSubview:tableView];
[tableView alignTop:@"10" leading:@"10" bottom:@"0" trailing:@"10" toView:self.contentView];
[self.styling constrainTableView:tableView toContentView:self.contentView forStyleMode:self.searchPresentationMode];
_resultsView = tableView;
[self.view layoutIfNeeded];
}
Expand Down
16 changes: 16 additions & 0 deletions Artsy/View_Controllers/Search/ARSearchViewControllerStyling.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#import <UIKit/UIKit.h>

typedef NS_ENUM(NSInteger, ARSearchViewControllerStylingMode) {
ARSearchViewControllerStylingModeMainScreen,
ARSearchViewControllerStylingModeFair
};

@interface ARSearchViewControllerStyling : NSObject

- (NSString *)topLayoutConstraintForStyleMode:(ARSearchViewControllerStylingMode)styleMode;
- (NSString *)searchIconLeadingConstraintForStyleMode:(ARSearchViewControllerStylingMode)styleMode;
- (UIColor *)searchIconTintColorForStyleMode:(ARSearchViewControllerStylingMode)styleMode;
- (NSAttributedString *)closeButtonAttribtedTextForStyleMode:(ARSearchViewControllerStylingMode)styleMode;
- (void)constrainTableView:(UITableView *)tableView toContentView:(UIView *)contentView forStyleMode:(ARSearchViewControllerStylingMode)styleMode;

@end
67 changes: 67 additions & 0 deletions Artsy/View_Controllers/Search/ARSearchViewControllerStyling.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#import "ARSearchViewControllerStyling.h"
#import "UIDevice-Hardware.h"

@import FLKAutoLayout;
@import Artsy_UIFonts;
@import Artsy_UIColors;

@implementation ARSearchViewControllerStyling

- (NSString *)topLayoutConstraintForStyleMode:(ARSearchViewControllerStylingMode)styleMode {
switch (styleMode) {
case ARSearchViewControllerStylingModeMainScreen:
return @"70";
case ARSearchViewControllerStylingModeFair:
return @"24";
}
}

- (NSString *)searchIconLeadingConstraintForStyleMode:(ARSearchViewControllerStylingMode)styleMode {
switch (styleMode) {
case ARSearchViewControllerStylingModeMainScreen:
return @"30";
case ARSearchViewControllerStylingModeFair:
return @"10";
}
}

- (UIColor *)searchIconTintColorForStyleMode:(ARSearchViewControllerStylingMode)styleMode {
switch (styleMode) {
case ARSearchViewControllerStylingModeMainScreen:
return [UIColor whiteColor];
case ARSearchViewControllerStylingModeFair:
return [UIColor artsyGraySemibold];
}
}

- (NSAttributedString *)closeButtonAttribtedTextForStyleMode:(ARSearchViewControllerStylingMode)styleMode {
UIColor *textColor;

switch (styleMode) {
case ARSearchViewControllerStylingModeMainScreen:
textColor = [UIColor whiteColor];
break;
case ARSearchViewControllerStylingModeFair:
textColor = [UIColor artsyGraySemibold];
break;
}

return [[NSAttributedString alloc] initWithString:@"CLOSE" attributes:@{
NSKernAttributeName : @1,
NSFontAttributeName : [UIFont sansSerifFontWithSize:[UIDevice isPad] ? 13 : 10],
NSForegroundColorAttributeName : textColor,
}];
}

- (void)constrainTableView:(UITableView *)tableView toContentView:(UIView *)contentView forStyleMode:(ARSearchViewControllerStylingMode)styleMode {
switch (styleMode) {
case ARSearchViewControllerStylingModeMainScreen:
[tableView alignTop:@"10" leading:@"10" bottom:@"0" trailing:@"10" toView:contentView];
break;
case ARSearchViewControllerStylingModeFair:
[tableView alignToView:contentView];
break;
}
}

@end
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ - (BOOL)hasSufficientDataForParallaxHeader;
}]).willNot.beNil();
});

xit(@"search view looks correct", ^{
it(@"search view looks correct", ^{
[fairVC searchFieldButtonWasPressed:nil];
[fairVC.searchVC beginAppearanceTransition:YES animated:NO];
[fairVC.searchVC endAppearanceTransition];
Expand Down

0 comments on commit 7977be4

Please sign in to comment.