Skip to content

Commit

Permalink
add rudimentary support for modal view controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronbrethorst committed Sep 5, 2011
1 parent ea1526e commit 7d8701c
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 18 deletions.
1 change: 1 addition & 0 deletions ABRouter/ABRouter.h
Expand Up @@ -31,4 +31,5 @@
+ (ABRouter*)sharedRouter;
- (void)registerURLPattern:(NSString*)pattern forViewControllerClass:(Class)aClass;
- (void)navigateTo:(NSString*)route withNavigationController:(UINavigationController*)navController;
- (void)modallyPresent:(NSString*)route from:(UIViewController*)viewController;
@end
8 changes: 8 additions & 0 deletions ABRouter/ABRouter.m
Expand Up @@ -73,6 +73,14 @@ - (void)registerURLPattern:(NSString*)pattern forViewControllerClass:(Class)aCla
[routePatterns addObject:[NSDictionary dictionaryWithObjectsAndKeys:[SOCPattern patternWithString:pattern], kPatternKey, aClass, kViewControllerKey, nil]];
}

- (void)modallyPresent:(NSString*)route from:(UIViewController*)viewController
{
UIViewController<Routable> * pushMe = [self match:route];
pushMe.apiPath = route;
UINavigationController *nav = [[[UINavigationController alloc] initWithRootViewController:pushMe] autorelease];
[viewController presentModalViewController:nav animated:YES];
}

- (void)navigateTo:(NSString*)route withNavigationController:(UINavigationController*)navController
{
UIViewController<Routable> * pushMe = [self match:route];
Expand Down
1 change: 1 addition & 0 deletions Example/View Controllers/RootViewController.h
Expand Up @@ -11,4 +11,5 @@
@interface RootViewController : UIViewController
- (IBAction)viewAlbums:(id)sender;
- (IBAction)viewPhotos:(id)sender;
- (IBAction)modal:(id)sender;
@end
5 changes: 5 additions & 0 deletions Example/View Controllers/RootViewController.m
Expand Up @@ -32,4 +32,9 @@ - (IBAction)viewPhotos:(id)sender
[[ABRouter sharedRouter] navigateTo:@"/photos" withNavigationController:self.navigationController];
}

- (IBAction)modal:(id)sender
{
[[ABRouter sharedRouter] modallyPresent:@"/photos" from:self];
}

@end
82 changes: 64 additions & 18 deletions Example/View Controllers/RootViewController.xib
Expand Up @@ -42,65 +42,87 @@
<int key="NSvFlags">274</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBUIButton" id="1000320211">
<object class="IBUIButton" id="377241421">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{80, 48}, {160, 37}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="102877774"/>
<reference key="NSNextKeyView" ref="1004451029"/>
<string key="NSReuseIdentifierKey">_NS:222</string>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
<int key="IBUIContentVerticalAlignment">0</int>
<object class="NSFont" key="IBUIFont" id="614582912">
<object class="NSFont" key="IBUIFont" id="1012634139">
<string key="NSName">Helvetica-Bold</string>
<double key="NSSize">15</double>
<int key="NSfFlags">16</int>
</object>
<int key="IBUIButtonType">1</int>
<string key="IBUINormalTitle">View some albums</string>
<object class="NSColor" key="IBUIHighlightedTitleColor" id="205011688">
<object class="NSColor" key="IBUIHighlightedTitleColor" id="551215250">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
</object>
<object class="NSColor" key="IBUINormalTitleColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
</object>
<object class="NSColor" key="IBUINormalTitleShadowColor" id="507797649">
<object class="NSColor" key="IBUINormalTitleShadowColor" id="101457347">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC41AA</bytes>
</object>
</object>
<object class="IBUIButton" id="102877774">
<object class="IBUIButton" id="1004451029">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{80, 101}, {160, 37}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<reference key="NSNextKeyView" ref="859803701"/>
<string key="NSReuseIdentifierKey">_NS:222</string>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
<int key="IBUIContentVerticalAlignment">0</int>
<reference key="IBUIFont" ref="614582912"/>
<reference key="IBUIFont" ref="1012634139"/>
<int key="IBUIButtonType">1</int>
<string key="IBUINormalTitle">View some photos</string>
<reference key="IBUIHighlightedTitleColor" ref="205011688"/>
<reference key="IBUIHighlightedTitleColor" ref="551215250"/>
<object class="NSColor" key="IBUINormalTitleColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
</object>
<reference key="IBUINormalTitleShadowColor" ref="507797649"/>
<reference key="IBUINormalTitleShadowColor" ref="101457347"/>
</object>
<object class="IBUIButton" id="859803701">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{74, 178}, {173, 37}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:222</string>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
<int key="IBUIContentVerticalAlignment">0</int>
<reference key="IBUIFont" ref="1012634139"/>
<int key="IBUIButtonType">1</int>
<string key="IBUINormalTitle">How about a modal?</string>
<reference key="IBUIHighlightedTitleColor" ref="551215250"/>
<object class="NSColor" key="IBUINormalTitleColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
</object>
<reference key="IBUINormalTitleShadowColor" ref="101457347"/>
</object>
</object>
<string key="NSFrame">{{0, 20}, {320, 460}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1000320211"/>
<reference key="NSNextKeyView" ref="377241421"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
Expand All @@ -126,7 +148,7 @@
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">viewAlbums:</string>
<reference key="source" ref="1000320211"/>
<reference key="source" ref="377241421"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
</object>
Expand All @@ -135,12 +157,21 @@
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">viewPhotos:</string>
<reference key="source" ref="102877774"/>
<reference key="source" ref="1004451029"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
</object>
<int key="connectionID">7</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">modal:</string>
<reference key="source" ref="859803701"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
</object>
<int key="connectionID">9</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
Expand All @@ -156,8 +187,9 @@
<reference key="object" ref="191373211"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="1000320211"/>
<reference ref="102877774"/>
<reference ref="377241421"/>
<reference ref="1004451029"/>
<reference ref="859803701"/>
</object>
<reference key="parent" ref="0"/>
</object>
Expand All @@ -174,12 +206,17 @@
</object>
<object class="IBObjectRecord">
<int key="objectID">4</int>
<reference key="object" ref="1000320211"/>
<reference key="object" ref="377241421"/>
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">5</int>
<reference key="object" ref="102877774"/>
<reference key="object" ref="1004451029"/>
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">8</int>
<reference key="object" ref="859803701"/>
<reference key="parent" ref="191373211"/>
</object>
</object>
Expand All @@ -195,6 +232,7 @@
<string>1.IBPluginDependency</string>
<string>4.IBPluginDependency</string>
<string>5.IBPluginDependency</string>
<string>8.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand All @@ -205,6 +243,7 @@
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
Expand All @@ -219,7 +258,7 @@
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
<int key="maxID">7</int>
<int key="maxID">9</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand All @@ -231,24 +270,31 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>modal:</string>
<string>viewAlbums:</string>
<string>viewPhotos:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>modal:</string>
<string>viewAlbums:</string>
<string>viewPhotos:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBActionInfo">
<string key="name">modal:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">viewAlbums:</string>
<string key="candidateClassName">id</string>
Expand Down

0 comments on commit 7d8701c

Please sign in to comment.