Skip to content

Commit

Permalink
Merge pull request #1949 from artsy/mc-placeholderresults
Browse files Browse the repository at this point in the history
[Onboarding] Add default placeholders for when no search results
  • Loading branch information
orta committed Oct 19, 2016
2 parents 85e59b6 + e035928 commit 90cf0e1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)ce
{
// We only show custom animation in the case of the related suggestions after clicking a row
// This animation has suggestions content coming in from the bottom
if (self.contentDisplayMode == ARTableViewContentDisplayModeRelatedResults && self.shouldAnimate) {
if ((self.contentDisplayMode == ARTableViewContentDisplayModeRelatedResults ||
self.contentDisplayMode == ARTableViewContentDisplayModePlaceholder) &&
self.shouldAnimate) {
// State to animate to
CGRect originalFrame = cell.frame;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ - (void)showViews
self.searchResultsTable.headerPlaceholderText = @"TOP ARTISTS ON ARTSY";
self.headerView.searchField.searchField.delegate = self;
[self.headerView.searchField.searchField setPlaceholder:@"Search artist"];
[self populateTrendingArtists];
[self populateTrendingArtistsAnimated:NO];
break;
case AROnboardingStagePersonalizeCategories:
[self addSearchTable];
Expand All @@ -122,7 +122,7 @@ - (void)showViews
self.searchResultsTable.headerPlaceholderText = @"POPULAR CATEGORIES OF ART ON ARTSY";
[self.headerView.searchField.searchField setPlaceholder:@"Search medium, movement, or style"];
[self.onboardingNavigationItems disableNextStep];
[self populateTrendingCategories];
[self populateTrendingCategoriesAnimated:NO];
break;
case AROnboardingStagePersonalizeBudget:
[self addBudgetTable];
Expand Down Expand Up @@ -219,7 +219,7 @@ - (void)searchEnded:(NSNotification *)notification
#pragma mark -
#pragma mark Network

- (void)populateTrendingArtists
- (void)populateTrendingArtistsAnimated:(BOOL)animated
{
[self.searchRequestOperation cancel];

Expand All @@ -229,13 +229,13 @@ - (void)populateTrendingArtists
self.searchRequestOperation = [ArtsyAPI getPopularArtistsWithSuccess:^(NSArray *artists) {
[self.searchResultsTable updateTableContentsFor:artists
replaceContents:ARSearchResultsReplaceAll
animated:NO];
animated:animated];
} failure:^(NSError *error) {
[self reportError:error];
}];
}

- (void)populateTrendingCategories
- (void)populateTrendingCategoriesAnimated:(BOOL)animated
{
[self.searchRequestOperation cancel];

Expand All @@ -245,7 +245,7 @@ - (void)populateTrendingCategories
self.searchRequestOperation = [ArtsyAPI getPopularGenesWithSuccess:^(NSArray *genes) {
[self.searchResultsTable updateTableContentsFor:genes
replaceContents:ARSearchResultsReplaceAll
animated:NO];
animated:animated];
} failure:^(NSError *error) {
[self reportError:error];
}];
Expand All @@ -259,9 +259,15 @@ - (void)artistFollowed:(Artist *)artist
[self.headerView.searchField.searchField resignFirstResponder];
self.searchResultsTable.contentDisplayMode = ARTableViewContentDisplayModeRelatedResults;
self.searchRequestOperation = [ArtsyAPI getRelatedArtistsForArtist:artist excluding:self.artistsFollowed success:^(NSArray *artists) {
[self.searchResultsTable updateTableContentsFor:artists
replaceContents:ARSearchResultsReplaceAll
animated:YES];
if (artists.count > 0) {
[self.searchResultsTable updateTableContentsFor:artists
replaceContents:ARSearchResultsReplaceAll
animated:YES];
} else {
// show default list
[self populateTrendingArtistsAnimated:YES];
}

} failure:^(NSError *error) {
[self reportError:error];
}];
Expand Down Expand Up @@ -290,9 +296,15 @@ - (void)categoryFollowed:(Gene *)category
[self.headerView.searchField.searchField resignFirstResponder];
self.searchResultsTable.contentDisplayMode = ARTableViewContentDisplayModeRelatedResults;
self.searchRequestOperation = [ArtsyAPI getRelatedGenesForGene:category excluding:self.categoriesFollowed success:^(NSArray *genes) {
[self.searchResultsTable updateTableContentsFor:genes
replaceContents:ARSearchResultsReplaceAll
animated:YES];
if (genes.count > 0) {
[self.searchResultsTable updateTableContentsFor:genes
replaceContents:ARSearchResultsReplaceAll
animated:YES];
} else {
// show default list
[self populateTrendingCategoriesAnimated:YES];
}

} failure:^(NSError *error) {
[self reportError:error];
}];
Expand Down

0 comments on commit 90cf0e1

Please sign in to comment.