Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
[TTCatalog] Add SplitCatalogController.
Browse files Browse the repository at this point in the history
  • Loading branch information
jverkoey committed Nov 17, 2010
1 parent aa52d07 commit 687342f
Show file tree
Hide file tree
Showing 4 changed files with 270 additions and 21 deletions.
157 changes: 136 additions & 21 deletions samples/TTCatalog/Classes/AppDelegate.m
@@ -1,4 +1,5 @@
#import "AppDelegate.h"
#import "SplitCatalogController.h"
#import "CatalogController.h"
#import "PhotoTest1Controller.h"
#import "PhotoTest2Controller.h"
Expand Down Expand Up @@ -33,27 +34,141 @@ - (void)applicationDidFinishLaunching:(UIApplication*)application {

TTURLMap* map = navigator.URLMap;
[map from:@"*" toViewController:[TTWebController class]];
[map from:@"tt://catalog" toViewController:[CatalogController class]];
[map from:@"tt://photoTest1" toViewController:[PhotoTest1Controller class]];
[map from:@"tt://photoTest2" toViewController:[PhotoTest2Controller class]];
[map from:@"tt://imageTest1" toViewController:[ImageTest1Controller class]];
[map from:@"tt://tableTest" toViewController:[TableTestController class]];
[map from:@"tt://tableItemTest" toViewController:[TableItemTestController class]];
[map from:@"tt://tableControlsTest" toViewController:[TableControlsTestController class]];
[map from:@"tt://styledTextTableTest" toViewController:[StyledTextTableTestController class]];
[map from:@"tt://tableWithShadow" toViewController:[TableWithShadowController class]];
[map from:@"tt://tableWithBanner" toViewController:[TableWithBannerController class]];
[map from:@"tt://composerTest" toViewController:[MessageTestController class]];
[map from:@"tt://searchTest" toViewController:[SearchTestController class]];
[map from:@"tt://activityTest" toViewController:[ActivityTestController class]];
[map from:@"tt://styleTest" toViewController:[StyleTestController class]];
[map from:@"tt://styledTextTest" toViewController:[StyledTextTestController class]];
[map from:@"tt://buttonTest" toViewController:[ButtonTestController class]];
[map from:@"tt://tabBarTest" toViewController:[TabBarTestController class]];
[map from:@"tt://youTubeTest" toViewController:[YouTubeTestController class]];
[map from:@"tt://imageTest2" toViewController:[TableImageTestController class]];
[map from:@"tt://scrollViewTest" toViewController:[ScrollViewTestController class]];
[map from:@"tt://launcherTest" toViewController:[LauncherViewTestController class]];


if (TTIsPad()) {
[map from: @"tt://catalog"
toSharedViewController: [SplitCatalogController class]];

SplitCatalogController* controller =
(SplitCatalogController*)[[TTNavigator navigator] viewControllerForURL:@"tt://catalog"];
TTDASSERT([controller isKindOfClass:[SplitCatalogController class]]);
map = controller.rightNavigator.URLMap;

} else {
[map from: @"tt://catalog"
toSharedViewController: [CatalogController class]];
}

[map from: @"tt://photoTest1"
parent: @"tt://catalog"
toViewController: [PhotoTest1Controller class]
selector: nil
transition: 0];
[map from: @"tt://photoTest2"
parent: @"tt://catalog"
toViewController: [PhotoTest2Controller class]
selector: nil
transition: 0];

[map from: @"tt://imageTest1"
parent: @"tt://catalog"
toViewController: [ImageTest1Controller class]
selector: nil
transition: 0];

[map from: @"tt://tableTest"
parent: @"tt://catalog"
toViewController: [TableTestController class]
selector: nil
transition: 0];

[map from: @"tt://tableItemTest"
parent: @"tt://catalog"
toViewController: [TableItemTestController class]
selector: nil
transition: 0];

[map from: @"tt://tableControlsTest"
parent: @"tt://catalog"
toViewController: [TableControlsTestController class]
selector: nil
transition: 0];

[map from: @"tt://styledTextTableTest"
parent: @"tt://catalog"
toViewController: [StyledTextTableTestController class]
selector: nil
transition: 0];

[map from: @"tt://tableWithShadow"
parent: @"tt://catalog"
toViewController: [TableWithShadowController class]
selector: nil
transition: 0];

[map from: @"tt://tableWithBanner"
parent: @"tt://catalog"
toViewController: [TableWithBannerController class]
selector: nil
transition: 0];

[map from: @"tt://composerTest"
parent: @"tt://catalog"
toViewController: [MessageTestController class]
selector: nil
transition: 0];

[map from: @"tt://searchTest"
parent: @"tt://catalog"
toViewController: [SearchTestController class]
selector: nil
transition: 0];

[map from: @"tt://activityTest"
parent: @"tt://catalog"
toViewController: [ActivityTestController class]
selector: nil
transition: 0];

[map from: @"tt://styleTest"
parent: @"tt://catalog"
toViewController: [StyleTestController class]
selector: nil
transition: 0];

[map from: @"tt://styledTextTest"
parent: @"tt://catalog"
toViewController: [StyledTextTestController class]
selector: nil
transition: 0];

[map from: @"tt://buttonTest"
parent: @"tt://catalog"
toViewController: [ButtonTestController class]
selector: nil
transition: 0];

[map from: @"tt://tabBarTest"
parent: @"tt://catalog"
toViewController: [TabBarTestController class]
selector: nil
transition: 0];

[map from: @"tt://youTubeTest"
parent: @"tt://catalog"
toViewController: [YouTubeTestController class]
selector: nil
transition: 0];

[map from: @"tt://imageTest2"
parent: @"tt://catalog"
toViewController: [TableImageTestController class]
selector: nil
transition: 0];

[map from: @"tt://scrollViewTest"
parent: @"tt://catalog"
toViewController: [ScrollViewTestController class]
selector: nil
transition: 0];

[map from: @"tt://launcherTest"
parent: @"tt://catalog"
toViewController: [LauncherViewTestController class]
selector: nil
transition: 0];


if (![navigator restoreViewControllers]) {
[navigator openURLAction:[TTURLAction actionWithURLPath:@"tt://catalog"]];
Expand Down
5 changes: 5 additions & 0 deletions samples/TTCatalog/Classes/SplitCatalogController.h
@@ -0,0 +1,5 @@

@interface SplitCatalogController : TTSplitViewController {
}

@end
89 changes: 89 additions & 0 deletions samples/TTCatalog/Classes/SplitCatalogController.m
@@ -0,0 +1,89 @@
#import "SplitCatalogController.h"

#import "CatalogController.h"


///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
@interface SplitCatalogController()

- (void)setupURLRouting;

@end



///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
@implementation SplitCatalogController


///////////////////////////////////////////////////////////////////////////////////////////////////
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
[self setupURLRouting];
}

return self;
}


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

[self.leftNavigator openURLs:@"tt://catalog", nil];
[self.rightNavigator openURLs:@"http://three20.info/", nil];
}


///////////////////////////////////////////////////////////////////////////////////////////////////
- (id)willOpenUrlPath:(NSURL*)url {
[self.rightNavigator openURLAction:[TTURLAction actionWithURLPath:[url absoluteString]]];

[self.popoverSplitController dismissPopoverAnimated:YES];

// We need to do this because the right navigator clobbered the right navigation controller
// and our button along with it.
[self updateSplitViewButton];

// Don't create a view controller here; we're forwarding the URL routing.
return nil;
}


///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)routeLeftNavigator {
TTURLMap* map = self.leftNavigator.URLMap;

// Forward all unhandled URL actions to the right navigator.
[map from: @"*"
toObject: self
selector: @selector(willOpenUrlPath:)];

[map from: @"tt://catalog"
toViewController: [CatalogController class]];
}


///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)routeRightNavigator {
TTURLMap* map = self.rightNavigator.URLMap;


[map from: @"*"
toViewController: [TTWebController class]];
}


///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)setupURLRouting {
[self routeLeftNavigator];
[self routeRightNavigator];
}


@end

0 comments on commit 687342f

Please sign in to comment.