-
-
Save kallekoo/5676489 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// BLAppDelegate.m | |
// Braid | |
// | |
// Created by Idan Gazit on 5/14/13. | |
// Copyright (c) 2013 BraidLabs. All rights reserved. | |
// | |
#import "BLAppDelegate.h" | |
#import "BLFirstRunViewController.h" | |
@implementation BLAppDelegate | |
@synthesize firstrunNavigationController; | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
{ | |
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; | |
BOOL (^nameFieldValidator)() = ^BOOL (NSString *str) { | |
return [str hasPrefix:@"hello"]; | |
}; | |
NSDictionary *stepOneValidators = @{@"nameField": nameFieldValidator}; | |
NSDictionary *cfg = @{@"stepTitle": @"Let’s Get Started.", | |
@"stepSubTitle": @"Braid works with your existing GMail account.", | |
@"stepImageName": @"Mail.png", | |
@"validators": stepOneValidators}; | |
BLFirstRunViewController *gmailViewController = [[BLFirstRunViewController alloc] initWithConfig:cfg nibName:@"BLFirstRunViewController"]; | |
self.firstrunNavigationController = [[UINavigationController alloc] | |
initWithRootViewController:gmailViewController]; | |
[self.firstrunNavigationController setNavigationBarHidden:YES]; | |
self.window.rootViewController = self.firstrunNavigationController; | |
[self.window makeKeyAndVisible]; | |
return YES; | |
} | |
// ... more stuff | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// BLFirstRunViewController.h | |
// Braid | |
// | |
// Created by Idan Gazit on 5/29/13. | |
// Copyright (c) 2013 BraidLabs. All rights reserved. | |
// | |
#import <UIKit/UIKit.h> | |
@interface BLFirstRunViewController : UIViewController | |
@property (weak, nonatomic) IBOutlet UILabel *stepTitle; | |
@property (weak, nonatomic) IBOutlet UIImageView *stepImage; | |
@property (weak, nonatomic) IBOutlet UILabel *stepSubtitle; | |
@property (weak, nonatomic) IBOutlet UIButton *stepButton; | |
@property (strong, nonatomic) NSDictionary *config; | |
-(id)initWithConfig:(NSDictionary *)config nibName:(NSString *)nibName; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// BLFirstRunViewController.m | |
// Braid | |
// | |
// Created by Idan Gazit on 5/29/13. | |
// Copyright (c) 2013 BraidLabs. All rights reserved. | |
// | |
#import "BLFirstRunViewController.h" | |
@interface BLFirstRunViewController () | |
@end | |
@implementation BLFirstRunViewController | |
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil | |
{ | |
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; | |
if (self) { | |
} | |
return self; | |
} | |
-(id)initWithConfig:(NSDictionary *)config nibName:(NSString *)nibName | |
{ | |
if ((self = [super initWithNibName:nibName bundle:nil])) { | |
self.config = config; | |
} | |
return self; | |
} | |
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
// Do any additional setup after loading the view from its nib. | |
_stepTitle.font = [UIFont fontWithName:@"OpenSans-Light" size:28.0]; | |
_stepSubtitle.font = [UIFont fontWithName:@"OpenSans-Light" size:20]; | |
_stepButton.titleLabel.font = [UIFont fontWithName:@"OpenSans-Bold" size:15]; | |
} | |
- (void)viewWillAppear:(BOOL)animated | |
{ | |
_stepTitle.text = [self.config objectForKey:@"stepTitle"]; | |
_stepSubtitle.text = [self.config objectForKey:@"stepSubTitle"]; | |
// additionally, do all view frame adjustments here in viewWillAppear | |
} | |
-(void)validateFields:(UIButton *)sender | |
{ | |
BOOL (^ validator)() = self.config[@"validators"][@"nameField"]; | |
NSLog(@"%@", validator(@"hello, world") ? @"passes": @"failed"); | |
NSLog(@"%@", validator(@"ello, world") ? @"passes": @"failed"); | |
} | |
- (void)didReceiveMemoryWarning | |
{ | |
[super didReceiveMemoryWarning]; | |
// Dispose of any resources that can be recreated. | |
} | |
- (IBAction)stepButtonTouchUp:(id)sender { | |
} | |
@end |
ah so that gtmoViewController is the modal view controller you want to display?
@idan You could make that modal displaying of the view controller a method on the generic BLFirstRunViewController and determine from the config if you need to display it
Ah, good idea.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@kallekoo the problem with this approach for me is that I need the button in one of the steps to display a modal. In other circumstances I did something like
[self presentViewController:gtmoViewController animated:YES completion:nil];
except that I'm not sure how to makeself
inside a block refer to the controller instance in which it is invoked.Thanks again for the mentoring. This stuff is super-confusing for me, coming from the web.