Skip to content

Commit

Permalink
ADD: First version of conductor with simple navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
yamdraco committed Jul 8, 2014
1 parent ab75f62 commit db21c31
Show file tree
Hide file tree
Showing 22 changed files with 696 additions and 9 deletions.
13 changes: 13 additions & 0 deletions AViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// AViewController.h
// Conductor
//
// Created by Draco Yam on 7/8/14.
//
//

#import <UIKit/UIKit.h>

@interface AViewController : UIViewController

@end
39 changes: 39 additions & 0 deletions AViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// AViewController.m
// Conductor
//
// Created by Draco Yam on 7/8/14.
//
//

#import "AViewController.h"

#import "BViewController.h"

#import "AppDelegate.h"

#import "SegueToLeft.h"

#import "BViewController.h"

@interface AViewController ()

@end

@implementation AViewController

- (void) loadView {
self.view = [[UIView alloc]initWithFrame:[UIScreen mainScreen].bounds];
self.view.backgroundColor = [UIColor redColor];

[self performSelector:@selector(switchToSecond) withObject:nil afterDelay:3.0];
}

- (void) switchToSecond {
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
NSLog(@"Stack Count Before, %d", [appDelegate.conductor.ctrStack count]);
[appDelegate.conductor addCtr:[[BViewController alloc]init] withKey:@"bControl" withSegue:[[SegueToLeft alloc]init]];
NSLog(@"Stack Count After, %d", [appDelegate.conductor.ctrStack count]);
}

@end
13 changes: 13 additions & 0 deletions BViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// BViewController.h
// Conductor
//
// Created by Draco Yam on 7/8/14.
//
//

#import <UIKit/UIKit.h>

@interface BViewController : UIViewController

@end
35 changes: 35 additions & 0 deletions BViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// BViewController.m
// Conductor
//
// Created by Draco Yam on 7/8/14.
//
//

#import "BViewController.h"

#import "AppDelegate.h"

#import "SegueToRight.h"

@interface BViewController ()

@end

@implementation BViewController

- (void) loadView {
self.view = [[UIView alloc]initWithFrame:[UIScreen mainScreen].bounds];
self.view.backgroundColor = [UIColor blueColor];

[self performSelector:@selector(pop) withObject:nil afterDelay:3.0];
}

- (void) pop {
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
NSLog(@"Stack Count Before, %d", [appDelegate.conductor.ctrStack count]);
[appDelegate.conductor popCtrWithSegue:[[SegueToRight alloc]init]];
NSLog(@"Stack Count After, %d", [appDelegate.conductor.ctrStack count]);
}

@end
85 changes: 85 additions & 0 deletions Conductor.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@
C0B85958196BB414005EB028 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C0B85940196BB414005EB028 /* UIKit.framework */; };
C0B85960196BB414005EB028 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = C0B8595E196BB414005EB028 /* InfoPlist.strings */; };
C0B85962196BB414005EB028 /* ConductorTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C0B85961196BB414005EB028 /* ConductorTests.m */; };
C0B85976196BCBDA005EB028 /* Conductor.m in Sources */ = {isa = PBXBuildFile; fileRef = C0B8596D196BCBDA005EB028 /* Conductor.m */; };
C0B85977196BCBDA005EB028 /* Conductor.m in Sources */ = {isa = PBXBuildFile; fileRef = C0B8596D196BCBDA005EB028 /* Conductor.m */; };
C0B85978196BCBDA005EB028 /* ConductorSegue.m in Sources */ = {isa = PBXBuildFile; fileRef = C0B8596F196BCBDA005EB028 /* ConductorSegue.m */; };
C0B85979196BCBDA005EB028 /* ConductorSegue.m in Sources */ = {isa = PBXBuildFile; fileRef = C0B8596F196BCBDA005EB028 /* ConductorSegue.m */; };
C0B85989196BCF24005EB028 /* RootController.m in Sources */ = {isa = PBXBuildFile; fileRef = C0B85988196BCF24005EB028 /* RootController.m */; };
C0B8598A196BCF24005EB028 /* RootController.m in Sources */ = {isa = PBXBuildFile; fileRef = C0B85988196BCF24005EB028 /* RootController.m */; };
C0B8598D196BCF95005EB028 /* AViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C0B8598C196BCF95005EB028 /* AViewController.m */; };
C0B8598E196BCF95005EB028 /* AViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C0B8598C196BCF95005EB028 /* AViewController.m */; };
C0B85991196BCF9E005EB028 /* BViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C0B85990196BCF9E005EB028 /* BViewController.m */; };
C0B85992196BCF9E005EB028 /* BViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C0B85990196BCF9E005EB028 /* BViewController.m */; };
C0B85998196BEAC1005EB028 /* SegueToLeft.m in Sources */ = {isa = PBXBuildFile; fileRef = C0B85995196BEAC1005EB028 /* SegueToLeft.m */; };
C0B85999196BEAC1005EB028 /* SegueToLeft.m in Sources */ = {isa = PBXBuildFile; fileRef = C0B85995196BEAC1005EB028 /* SegueToLeft.m */; };
C0B8599A196BEAC1005EB028 /* SegueToRight.m in Sources */ = {isa = PBXBuildFile; fileRef = C0B85997196BEAC1005EB028 /* SegueToRight.m */; };
C0B8599B196BEAC1005EB028 /* SegueToRight.m in Sources */ = {isa = PBXBuildFile; fileRef = C0B85997196BEAC1005EB028 /* SegueToRight.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -48,6 +62,21 @@
C0B8595D196BB414005EB028 /* ConductorTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "ConductorTests-Info.plist"; sourceTree = "<group>"; };
C0B8595F196BB414005EB028 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
C0B85961196BB414005EB028 /* ConductorTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ConductorTests.m; sourceTree = "<group>"; };
C0B8596C196BCBDA005EB028 /* Conductor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Conductor.h; sourceTree = "<group>"; };
C0B8596D196BCBDA005EB028 /* Conductor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Conductor.m; sourceTree = "<group>"; };
C0B8596E196BCBDA005EB028 /* ConductorSegue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConductorSegue.h; sourceTree = "<group>"; };
C0B8596F196BCBDA005EB028 /* ConductorSegue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ConductorSegue.m; sourceTree = "<group>"; };
C0B85975196BCBDA005EB028 /* UIViewController+Conductor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+Conductor.h"; sourceTree = "<group>"; };
C0B85987196BCF24005EB028 /* RootController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootController.h; sourceTree = "<group>"; };
C0B85988196BCF24005EB028 /* RootController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RootController.m; sourceTree = "<group>"; };
C0B8598B196BCF95005EB028 /* AViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AViewController.h; sourceTree = "<group>"; };
C0B8598C196BCF95005EB028 /* AViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AViewController.m; sourceTree = "<group>"; };
C0B8598F196BCF9E005EB028 /* BViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BViewController.h; sourceTree = "<group>"; };
C0B85990196BCF9E005EB028 /* BViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BViewController.m; sourceTree = "<group>"; };
C0B85994196BEAC1005EB028 /* SegueToLeft.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SegueToLeft.h; sourceTree = "<group>"; };
C0B85995196BEAC1005EB028 /* SegueToLeft.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SegueToLeft.m; sourceTree = "<group>"; };
C0B85996196BEAC1005EB028 /* SegueToRight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SegueToRight.h; sourceTree = "<group>"; };
C0B85997196BEAC1005EB028 /* SegueToRight.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SegueToRight.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -77,6 +106,8 @@
C0B85930196BB414005EB028 = {
isa = PBXGroup;
children = (
C0B8597E196BCDF5005EB028 /* Controllers */,
C0B8596B196BCBDA005EB028 /* lib */,
C0B85942196BB414005EB028 /* Conductor */,
C0B8595B196BB414005EB028 /* ConductorTests */,
C0B8593B196BB414005EB028 /* Frameworks */,
Expand Down Expand Up @@ -144,6 +175,44 @@
name = "Supporting Files";
sourceTree = "<group>";
};
C0B8596B196BCBDA005EB028 /* lib */ = {
isa = PBXGroup;
children = (
C0B85993196BEAC1005EB028 /* segue */,
C0B8596C196BCBDA005EB028 /* Conductor.h */,
C0B8596D196BCBDA005EB028 /* Conductor.m */,
C0B8596E196BCBDA005EB028 /* ConductorSegue.h */,
C0B8596F196BCBDA005EB028 /* ConductorSegue.m */,
C0B85975196BCBDA005EB028 /* UIViewController+Conductor.h */,
);
name = lib;
path = Conductor/lib;
sourceTree = "<group>";
};
C0B8597E196BCDF5005EB028 /* Controllers */ = {
isa = PBXGroup;
children = (
C0B85987196BCF24005EB028 /* RootController.h */,
C0B85988196BCF24005EB028 /* RootController.m */,
C0B8598B196BCF95005EB028 /* AViewController.h */,
C0B8598C196BCF95005EB028 /* AViewController.m */,
C0B8598F196BCF9E005EB028 /* BViewController.h */,
C0B85990196BCF9E005EB028 /* BViewController.m */,
);
name = Controllers;
sourceTree = "<group>";
};
C0B85993196BEAC1005EB028 /* segue */ = {
isa = PBXGroup;
children = (
C0B85994196BEAC1005EB028 /* SegueToLeft.h */,
C0B85995196BEAC1005EB028 /* SegueToLeft.m */,
C0B85996196BEAC1005EB028 /* SegueToRight.h */,
C0B85997196BEAC1005EB028 /* SegueToRight.m */,
);
path = segue;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -239,15 +308,29 @@
buildActionMask = 2147483647;
files = (
C0B8594D196BB414005EB028 /* AppDelegate.m in Sources */,
C0B8599A196BEAC1005EB028 /* SegueToRight.m in Sources */,
C0B85989196BCF24005EB028 /* RootController.m in Sources */,
C0B85978196BCBDA005EB028 /* ConductorSegue.m in Sources */,
C0B85991196BCF9E005EB028 /* BViewController.m in Sources */,
C0B8598D196BCF95005EB028 /* AViewController.m in Sources */,
C0B85976196BCBDA005EB028 /* Conductor.m in Sources */,
C0B85949196BB414005EB028 /* main.m in Sources */,
C0B85998196BEAC1005EB028 /* SegueToLeft.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
C0B85950196BB414005EB028 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C0B85979196BCBDA005EB028 /* ConductorSegue.m in Sources */,
C0B8598E196BCF95005EB028 /* AViewController.m in Sources */,
C0B85999196BEAC1005EB028 /* SegueToLeft.m in Sources */,
C0B8599B196BEAC1005EB028 /* SegueToRight.m in Sources */,
C0B85962196BB414005EB028 /* ConductorTests.m in Sources */,
C0B8598A196BCF24005EB028 /* RootController.m in Sources */,
C0B85992196BCF9E005EB028 /* BViewController.m in Sources */,
C0B85977196BCBDA005EB028 /* Conductor.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -436,6 +519,7 @@
C0B85967196BB414005EB028 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
C0B85968196BB414005EB028 /* Build configuration list for PBXNativeTarget "ConductorTests" */ = {
isa = XCConfigurationList;
Expand All @@ -444,6 +528,7 @@
C0B8596A196BB414005EB028 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
1 change: 1 addition & 0 deletions Conductor.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Conductor/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@

#import <UIKit/UIKit.h>

#import "Conductor.h"

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@property (nonatomic, strong) Conductor *conductor;

@end
35 changes: 26 additions & 9 deletions Conductor/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,36 @@

#import "AppDelegate.h"

// Controller
#import "RootController.h"
#import "AViewController.h"
#import "BViewController.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
@synthesize conductor;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
RootController *root = [[RootController alloc]init];
self.window.rootViewController = root;


conductor = [[Conductor alloc]init];
conductor.rootCtr = root;

AViewController *firstController = [[AViewController alloc]init];
[root.view addSubview:firstController.view];
[conductor push:firstController withKey:@"start"];


return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
Expand Down
74 changes: 74 additions & 0 deletions Conductor/lib/Conductor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//
// Conductor.h
// cube
//
// Created by Draco on 5/7/14.
// Copyright (c) 2014 Draco. All rights reserved.
//

#import <Foundation/Foundation.h>

// Segue
#import "ConductorSegue.h"

@interface Conductor : NSObject

@property (nonatomic, strong) UIViewController *rootCtr;
@property (nonatomic, strong) NSMutableArray *ctrStack;

#pragma mark -
#pragma mark Stack controls
/**
* Push viewController to the stack
* @param vctr, viewController to push to stack
*/
- (void) push:(UIViewController*)vctr;


/**
* Push viewController to the stack and append a key with it so that you can remove together
* @param vctr, viewController to push to stack
* @param key, key to recognize each controller or a collection of controller
*/
- (void) push:(UIViewController*)vctr withKey:(NSString*)key;


/**
* Pop the last controller from the stack and remove from stack
* @return last viewController from stack
*/
- (UIViewController*) pop;


/**
* Get the last controller from the stack without remove from stack
* @return last viewController from stack
*/
- (UIViewController*) last;

#pragma mark -
#pragma mark Transitions
/**
* Add Ctr to stack and perform animation with segue (key is tagged as @"")
* @param ctr, viewController to add to manager
* @param segue, defining transition
*/
- (void) addCtr:(UIViewController*)ctr withSegue:(ConductorSegue*)segue;


/**
* Add Ctr to stack and perform animation with segue (key of controller is also tag)
* @param ctr, viewController to add to manager
* @param key, the key to tag the controller
* @param segue, defining transition
*/
- (void) addCtr:(UIViewController*)ctr withKey:(NSString*)key withSegue:(ConductorSegue*)segue;


/**
* Return to last controller
* @param segue, defining transition
*/
- (void) popCtrWithSegue:(ConductorSegue*)segue;

@end
Loading

0 comments on commit db21c31

Please sign in to comment.