Skip to content

Commit

Permalink
Audited for the expectation that the ARSwitchBoard would push a view …
Browse files Browse the repository at this point in the history
…controller
  • Loading branch information
orta committed Dec 22, 2015
1 parent 83ab59c commit d98aae2
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
4 changes: 1 addition & 3 deletions Artsy/App/ARAppNotificationsDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,9 @@ - (void)applicationDidReceiveRemoteNotification:(NSDictionary *)userInfo inAppli
UIViewController *viewController = nil;

if (url) {
// Theoretically the way JLRoutes works could mean that a view controller would immediately get shown if it mached a
// route, which would be bad, because it should only happen when the user actually tapped the notification. But
// right now we're only expecting notifications for ‘works for you’, which is not routed that way.
viewController = [ARSwitchBoard.sharedInstance loadPath:url];

/// Always set the badge count if we can
NSInteger tabIndex = [[ARTopMenuViewController sharedController] indexOfRootViewController:viewController];
if (tabIndex != NSNotFound) {
NSUInteger count = [userInfo[@"aps"][@"badge"] unsignedLongValue];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ - (void)viewDidLoad

_navigationDataSource = _navigationDataSource ?: [[ARTopMenuNavigationDataSource alloc] init];

// TODO: Turn into custom view?

ARNavigationTabButton *homeButton = [[ARNavigationTabButton alloc] init];
ARNavigationTabButton *showsButton = [[ARNavigationTabButton alloc] init];
ARNavigationTabButton *browseButton = [[ARNavigationTabButton alloc] init];
Expand Down Expand Up @@ -149,7 +151,7 @@ - (void)registerWithSwitchBoard:(ARSwitchBoard *)switchboard

for (NSNumber *tabIndex in menuToPaths.keyEnumerator) {
[switchboard registerPathCallbackAtPath:menuToPaths[tabIndex] callback:^id _Nullable(NSDictionary *_Nullable parameters) {
[self presentRootViewControllerAtIndex:tabIndex.integerValue animated:NO];
[self.tabContentView setCurrentViewIndex:tabIndex.integerValue animated:NO];
return self.rootNavigationController.topViewController;
}];
}
Expand All @@ -160,8 +162,8 @@ - (void)viewWillAppear:(BOOL)animated
[super viewWillAppear:animated];
[ArtsyAPI getXappTokenWithCompletion:^(NSString *xappToken, NSDate *expirationDate) {
[self.navigationDataSource prefetchBrowse];
[self.navigationDataSource prefetchHeroUnits];
}];
[self.navigationDataSource prefetchHeroUnits];
}

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ - (void)tappedOpenArtworkPartner
if (self.fair) {
[ArtsyAPI getShowsForArtworkID:self.artwork.artworkID inFairID:self.fair.fairID success:^(NSArray *shows) {
if (shows.count > 0) {
UIViewController *viewController = [[ARSwitchBoard sharedInstance] loadShow:shows.firstObject fair:self.fair];
UIViewController *viewController = [ARSwitchBoard.sharedInstance loadShow:shows.firstObject fair:self.fair];
[self.navigationController pushViewController:viewController animated:YES];
}
} failure:^(NSError *error){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#import "ARFileUtils.h"
#import <AFNetworking/UIImageView+AFNetworking.h>


@interface ARQuicksilverViewController ()

@property (nonatomic, assign, readwrite) NSInteger selectedIndex;
Expand Down Expand Up @@ -151,7 +152,7 @@ - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldRe
} else {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];

__weak typeof (self) wself = self;
__weak typeof(self) wself = self;
_searchRequest = [ArtsyAPI searchWithQuery:query success:^(NSArray *results) {
__strong typeof (wself) sself = wself;
sself.searchResults = [results copy];
Expand Down Expand Up @@ -232,7 +233,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath

} else if (result.model == [SiteFeature class]) {
NSString *path = NSStringWithFormat(@"/feature/%@", result.modelID);
controller = [[ARSwitchBoard sharedInstance] loadPath:path];
controller = [ARSwitchBoard.sharedInstance loadPath:path];
}

[self.navigationController pushViewController:controller animated:YES];
Expand Down
12 changes: 7 additions & 5 deletions Artsy/View_Controllers/Fair/Guides/ARFairMapViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#import "ARSearchFieldButton.h"
#import <FLKAutoLayout/UIViewController+FLKAutoLayout.h>


@interface ARFairMapViewController () <NAMapViewDelegate, ARFairSearchViewControllerDelegate, ARSearchFieldButtonDelegate>
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong, readwrite) ARFairMapView *mapView;
Expand Down Expand Up @@ -124,7 +125,7 @@ - (void)viewDidLoad
RAC(self.mapShowMapper, expandAnnotations) = RACObserve(self, expandAnnotations);

// Due to a problem in the custom UIViewController transitions API (when the VC's view is a scrollview subclass)
__weak typeof (self) wself = self;
__weak typeof(self) wself = self;
[[self rac_signalForSelector:@selector(viewWillDisappear:)] subscribeNext:^(id x) {
__strong typeof (wself) sself = wself;

Expand Down Expand Up @@ -263,21 +264,22 @@ - (void)hideCallOut

- (void)selectedResult:(SearchResult *)result ofType:(NSString *)type fromQuery:(NSString *)query
{
ARSwitchBoard *switchboard = [ARSwitchBoard sharedInstance];
if (result.model == [Artwork class]) {
UIViewController *controller = [[ARSwitchBoard sharedInstance] loadArtworkWithID:result.modelID inFair:self.fair];
UIViewController *controller = [switchboard loadArtworkWithID:result.modelID inFair:self.fair];
[self.navigationController pushViewController:controller animated:YES];
} else if (result.model == [Artist class]) {
Artist *artist = [[Artist alloc] initWithArtistID:result.modelID];
[self selectedArtist:artist];
} else if (result.model == [Gene class]) {
UIViewController *controller = [[ARSwitchBoard sharedInstance] loadGeneWithID:result.modelID];
UIViewController *controller = [switchboard loadGeneWithID:result.modelID];
[self.navigationController pushViewController:controller animated:YES];
} else if (result.model == [Profile class]) {
UIViewController *controller = [ARSwitchBoard.sharedInstance routeProfileWithID:result.modelID];
UIViewController *controller = [switchboard routeProfileWithID:result.modelID];
[self.navigationController pushViewController:controller animated:YES];
} else if (result.model == [SiteFeature class]) {
NSString *path = NSStringWithFormat(@"/feature/%@", result.modelID);
UIViewController *controller = [[ARSwitchBoard sharedInstance] loadPath:path];
UIViewController *controller = [switchboard loadPath:path];
[self.navigationController pushViewController:controller animated:YES];
} else if (result.model == [PartnerShow class]) {
PartnerShow *partnerShow = [[PartnerShow alloc] initWithShowID:result.modelID];
Expand Down
4 changes: 0 additions & 4 deletions HACKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ Network:
some APIS take ID strings, other takes model objects. Could be unified if there's a base model.
caching? local cache, get cache first then re-run with network layer.

ARSwitchBoard
should return controllers, not doing the pushing itself, this also is easier re: parallax nav
async view controllers are a problem - could be a quantum view controller pattern for doing this.

Overall
things hidden in things
martsy: get an API that accepts a URL, it should respond with the model object or nil if noth
3 changes: 2 additions & 1 deletion docs/eigen_tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ Edit `Artsy/Classes/View Controllers/ARTopMenuViewController+DeveloperExtras.m`
```objc
- (void)runDeveloperExtras
{
[ARSwitchBoard loadFairWithID:@"the-armory-show-2014"];
UIViewController *controller = [ARSwitchBoard loadFairWithID:@"the-armory-show-2014"];
[self.navigationViewController pushViewController:controller animated:YES];
}
```

Expand Down

0 comments on commit d98aae2

Please sign in to comment.