Permalink
Browse files

Adds an Example project

  • Loading branch information...
1 parent f45ca18 commit 8c7a6f72e2dacd0bc13eddeca784034ad40ee622 @erichoracek committed Nov 20, 2012
View
@@ -0,0 +1,48 @@
+# Adapted from http://blog.illuminex.com/2009/10/better-sample-gitignore-file-for-xcode.html
+
+# Mac OS X Finder and whatnot
+.DS_Store
+
+# Sparkle distribution Private Key (Don't check me in!)
+dsa_priv.pem
+
+# XCode (and ancestors) per-user config (very noisy, and not relevant)
+*.mode1
+*.mode1v3
+*.mode2v3
+*.perspective
+*.perspectivev3
+*.pbxuser
+
+# Xcode 4 http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
+xcuserdata
+Breakpoints.xcbkptlist
+UserInterfaceState.xcuserstate
+*.xcuserdatad
+
+# Generated files
+VersionX-revision.h
+
+# Build products
+build/
+*.o
+
+# Other source repository archive directories (protects when importing)
+.hg
+.svn
+CVS
+
+# Automatic backup files
+*~.nib
+*.swp
+*~
+*(Autosaved).rtfd/
+Backup[ ]of[ ]*.pages/
+Backup[ ]of[ ]*.key/
+Backup[ ]of[ ]*.numbers/
+
+# Cocoapods
+Pods/
+Podfile.lock
+lcl_config_components.h.pods
+lcl_config_extensions.h.pods

Large diffs are not rendered by default.

Oops, something went wrong.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,38 @@
+//
+// MSAppDelegate.h
+// MSNavigationPaneViewController
+//
+// Created by Eric Horacek on 11/20/12.
+// Copyright (c) 2012 Monospace Ltd. All rights reserved.
+//
+// This code is distributed under the terms and conditions of the MIT license.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#import <UIKit/UIKit.h>
+
+@class MSNavigationPaneViewController;
+
+@interface MSAppDelegate : UIResponder <UIApplicationDelegate>
+
+@property (strong, nonatomic) UIWindow *window;
+@property (strong, nonatomic) MSNavigationPaneViewController *navigationPaneViewController;
+
+@end
@@ -0,0 +1,53 @@
+//
+// MSAppDelegate.m
+// MSNavigationPaneViewController
+//
+// Created by Eric Horacek on 11/20/12.
+// Copyright (c) 2012 Monospace Ltd. All rights reserved.
+//
+// This code is distributed under the terms and conditions of the MIT license.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#import "MSAppDelegate.h"
+#import "MSNavigationPaneViewController.h"
+#import "MSMasterViewController.h"
+
+@implementation MSAppDelegate
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
+ self.navigationPaneViewController = [[MSNavigationPaneViewController alloc] init];
+
+ MSMasterViewController *masterViewController = [[MSMasterViewController alloc] init];
+ masterViewController.navigationPaneViewController = self.navigationPaneViewController;
+
+ self.navigationPaneViewController.masterViewController = masterViewController;
+
+ [masterViewController transitionToViewController:MSPaneViewControllerTypeRed];
+
+ self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
+ self.window.rootViewController = self.navigationPaneViewController;
+ [self.window makeKeyAndVisible];
+
+ return YES;
+}
+
+@end
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,47 @@
+//
+// MSMasterViewController.h
+// MSNavigationPaneViewController
+//
+// Created by Eric Horacek on 11/20/12.
+// Copyright (c) 2012 Monospace Ltd. All rights reserved.
+//
+// This code is distributed under the terms and conditions of the MIT license.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#import <UIKit/UIKit.h>
+#import "MSNavigationPaneViewController.h"
+
+typedef NS_ENUM(NSUInteger, MSPaneViewControllerType) {
+ MSPaneViewControllerTypeRed,
+ MSPaneViewControllerTypeGreen,
+ MSPaneViewControllerTypeBlue,
+ MSPaneViewControllerTypeMonospace,
+ MSPaneViewControllerTypeCount,
+};
+
+@interface MSMasterViewController : UITableViewController
+
+@property (nonatomic, assign) MSPaneViewControllerType paneViewControllerType;
+@property (nonatomic, weak) MSNavigationPaneViewController *navigationPaneViewController;
+
+- (void)transitionToViewController:(MSPaneViewControllerType)paneViewControllerType;
+
+@end
@@ -0,0 +1,176 @@
+//
+// MSMasterViewController.m
+// MSNavigationPaneViewController
+//
+// Created by Eric Horacek on 11/20/12.
+// Copyright (c) 2012 Monospace Ltd. All rights reserved.
+//
+// This code is distributed under the terms and conditions of the MIT license.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#import "MSMasterViewController.h"
+#import "MSMonospaceViewController.h"
+
+NSString * const MSMasterViewControllerCellReuseIdentifier = @"MSMasterViewControllerCellReuseIdentifier";
+
+typedef NS_ENUM(NSUInteger, MSMasterViewControllerTableViewSectionType) {
+ MSMasterViewControllerTableViewSectionTypeColors,
+ MSMasterViewControllerTableViewSectionTypeAbout,
+ MSMasterViewControllerTableViewSectionTypeCount,
+};
+
+@interface MSMasterViewController ()
+
+@property (nonatomic, strong) NSDictionary *paneViewControllerTitles;
+@property (nonatomic, strong) NSDictionary *paneViewControllerTintColor;
+@property (nonatomic, strong) NSDictionary *paneViewControllerClasses;
+@property (nonatomic, strong) NSArray *tableViewSectionBreaks;
+
+@end
+
+@implementation MSMasterViewController
+
+#pragma mark - UIViewController
+
+- (id)initWithStyle:(UITableViewStyle)style
+{
+ self = [super initWithStyle:style];
+ if (self) {
+ self.paneViewControllerType = NSUIntegerMax;
+ self.paneViewControllerTitles = @{
+ @(MSPaneViewControllerTypeRed) : @"Red",
+ @(MSPaneViewControllerTypeGreen) : @"Green",
+ @(MSPaneViewControllerTypeBlue) : @"Blue",
+ @(MSPaneViewControllerTypeMonospace) : @"Monospace Ltd.",
+ };
+ self.paneViewControllerClasses = @{
+ @(MSPaneViewControllerTypeRed) : UITableViewController.class,
+ @(MSPaneViewControllerTypeGreen) : UITableViewController.class,
+ @(MSPaneViewControllerTypeBlue) : UITableViewController.class,
+ @(MSPaneViewControllerTypeMonospace) : MSMonospaceViewController.class,
+ };
+ self.paneViewControllerTintColor = @{
+ @(MSPaneViewControllerTypeRed) : [UIColor colorWithRed:0.502 green:0.000 blue:0.000 alpha:1.000],
+ @(MSPaneViewControllerTypeGreen) : [UIColor colorWithRed:0.251 green:0.502 blue:0.000 alpha:1.000],
+ @(MSPaneViewControllerTypeBlue) : [UIColor colorWithRed:0.000 green:0.251 blue:0.502 alpha:1.000],
+ @(MSPaneViewControllerTypeMonospace) : [UIColor blackColor],
+ };
+ self.tableViewSectionBreaks = @[
+ @(MSPaneViewControllerTypeMonospace),
+ @(MSPaneViewControllerTypeCount)
+ ];
+ }
+ return self;
+}
+
+- (void)viewDidLoad
+{
+ [super viewDidLoad];
+ [self.tableView registerClass:UITableViewCell.class forCellReuseIdentifier:MSMasterViewControllerCellReuseIdentifier];
+}
+
+#pragma mark - MSMasterViewController
+
+- (MSPaneViewControllerType)paneViewControllerTypeForIndexPath:(NSIndexPath *)indexPath
+{
+ MSPaneViewControllerType paneViewControllerType;
+ if (indexPath.section == 0) {
+ paneViewControllerType = indexPath.row;
+ } else {
+ paneViewControllerType = [self.tableViewSectionBreaks[indexPath.section - 1] integerValue] + indexPath.row;
+ }
+ NSAssert(paneViewControllerType < MSPaneViewControllerTypeCount, @"Invalid Index Path");
+ return paneViewControllerType;
+}
+
+- (void)transitionToViewController:(MSPaneViewControllerType)paneViewControllerType
+{
+ if (paneViewControllerType == self.paneViewControllerType) {
+ [self.navigationPaneViewController setPaneState:MSNavigationPaneStateClosed animated:YES];
+ return;
+ }
+
+ BOOL animateTransition = self.navigationPaneViewController.paneViewController != nil;
+
+ Class paneViewControllerClass = self.paneViewControllerClasses[@(paneViewControllerType)];
+ NSParameterAssert([paneViewControllerClass isSubclassOfClass:UIViewController.class]);
+ UIViewController *paneViewController = (UIViewController *)[[paneViewControllerClass alloc] init];
+ paneViewController.navigationItem.title = self.paneViewControllerTitles[@(paneViewControllerType)];
+ paneViewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"MSBarButtonIconNavigationPane.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(navigationPaneBarButtonItemTapped:)];
+
+ UINavigationController *paneNavigationViewController = [[UINavigationController alloc] initWithRootViewController:paneViewController];
+ paneNavigationViewController.navigationBar.tintColor = self.paneViewControllerTintColor[@(paneViewControllerType)];
+
+ [self.navigationPaneViewController setPaneViewController:paneNavigationViewController animated:animateTransition completion:nil];
+
+ self.paneViewControllerType = paneViewControllerType;
+}
+
+- (void)navigationPaneBarButtonItemTapped:(id)sender;
+{
+ [self.navigationPaneViewController setPaneState:MSNavigationPaneStateOpen animated:YES];
+}
+
+#pragma mark - UITableViewDataSource
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
+{
+ return MSMasterViewControllerTableViewSectionTypeCount;
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
+{
+ if (section == 0) {
+ return [self.tableViewSectionBreaks[section] integerValue];
+ } else {
+ return ([self.tableViewSectionBreaks[section] integerValue] - [self.tableViewSectionBreaks[(section - 1)] integerValue]);
+ }
+}
+
+- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
+{
+ switch (section) {
+ case MSMasterViewControllerTableViewSectionTypeColors:
+ return @"Colors";
+ case MSMasterViewControllerTableViewSectionTypeAbout:
+ return @"About";
+ default:
+ return nil;
+ }
+}
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MSMasterViewControllerCellReuseIdentifier forIndexPath:indexPath];
+ cell.selectionStyle = UITableViewCellSelectionStyleGray;
+ cell.textLabel.text = self.paneViewControllerTitles[@([self paneViewControllerTypeForIndexPath:indexPath])];
+ return cell;
+}
+
+#pragma mark - UITableViewDelegate
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ [self transitionToViewController:[self paneViewControllerTypeForIndexPath:indexPath]];
+ [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
+}
+
+@end
Oops, something went wrong.

0 comments on commit 8c7a6f7

Please sign in to comment.