Permalink
Browse files

Adding TKAlertViewController to the mix. Using tintColor for progress…

… indicators. Fixing iPad demo issues.
  • Loading branch information...
1 parent 624a249 commit 0e1cc80276298b24175488d2a17228692819a301 @devinross committed Jan 21, 2014
@@ -49,11 +49,8 @@ - (void) loadView{
self.view.backgroundColor = [UIColor whiteColor];
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"Tap Me" style:UIBarButtonItemStyleBordered target:self action:@selector(beer)];
- if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
- self.navigationItem.rightBarButtonItem = item;
- }else{
- self.toolbarItems = @[item];
- }
+ self.navigationItem.rightBarButtonItem = item;
+
self.tapMeItem = item;
@@ -37,7 +37,9 @@
@class RootViewController;
#pragma mark - AppDelegate
-@interface AppDelegate : TKAppDelegate
+@interface AppDelegate : TKAppDelegate
+
++ (AppDelegate*) instance;
@property (nonatomic,strong) RootViewController *root;
@property (nonatomic,strong) UINavigationController *navigationController;
@@ -54,10 +54,12 @@ - (void) application:(UIApplication *)application commonInitializationLaunching:
self.detail = [[DetailViewController alloc] init];
self.splitViewController.delegate = self.detail;
self.root.detailViewController = self.detail;
+
+ UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:self.detail];
- self.splitViewController.viewControllers = @[self.navigationController,self.detail];
+ self.splitViewController.viewControllers = @[self.navigationController,nav];
self.window.rootViewController = self.splitViewController;
}else{
self.window.rootViewController = self.navigationController;
@@ -74,6 +76,8 @@ - (void) applicationDidStartup:(UIApplication *)application{
}
-
++ (AppDelegate*) instance{
+ return (AppDelegate*)[[UIApplication sharedApplication] delegate];
+}
@end
@@ -40,15 +40,17 @@ - (void) loadView{
CGFloat w = CGRectGetWidth(self.view.frame);
self.glowButton = [TKGlowButton buttonWithFrame:CGRectMake(50, 100, w - 100, 40)];
+ self.glowButton.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[self.glowButton setTitle:@"Glow" forState:UIControlStateNormal];
[self.glowButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[self.glowButton setBackgroundColor:[UIColor colorWithWhite:0 alpha:0.05] forState:UIControlStateNormal];
[self.glowButton setBackgroundColor:[UIColor colorWithWhite:0 alpha:0.2] forState:UIControlStateHighlighted];
[self.view addSubview:self.glowButton];
self.retroButton = [TKRetroButton buttonWithFrame:CGRectMake(50, 200, w - 100, 40)];
+ self.retroButton.autoresizingMask = UIViewAutoresizingFlexibleWidth;
self.retroButton.borderWidth = 2;
- [self.retroButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
+ [self.retroButton setTitleColor:self.view.tintColor forState:UIControlStateNormal];
[self.retroButton setTitle:@"Retro" forState:UIControlStateNormal];
[self.view addSubview:self.retroButton];
@@ -87,7 +87,7 @@ - (void) loadView{
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"Tap Me" style:UIBarButtonItemStyleBordered target:self action:@selector(info)];
- self.toolbarItems = @[item];
+ self.navigationItem.rightBarButtonItem = item;
@@ -35,7 +35,6 @@
@interface DetailViewController : UIViewController <UISplitViewControllerDelegate>
-@property (nonatomic,strong) UIToolbar *toolbar;
@property (nonatomic,strong) UIViewController *mainController;
@property (nonatomic,strong) UIPopoverController *currentPopoverController;
@@ -30,69 +30,45 @@
*/
#import "DetailViewController.h"
+#import "AppDelegate.h"
#pragma mark - DetailViewController
@implementation DetailViewController
- (void) viewDidLoad {
[super viewDidLoad];
-
self.view.backgroundColor = [UIColor whiteColor];
-
- self.toolbar = [[UIToolbar alloc] initWithFrame:CGRectMakeWithPoint(CGPointZero, self.view.bounds.size.width, 44)];
- self.toolbar.autoresizingMask = UIViewAutoresizingFlexibleWidth;
- self.toolbar.items = @[];
- [self.view addSubview:self.toolbar];
}
- (void) setupWithMainController:(UIViewController*)controller{
- [self.mainController.view removeFromSuperview];
- self.mainController = controller;
- CGFloat h = self.toolbar.frame.size.height;
+ UINavigationController *nav = [AppDelegate instance].splitViewController.viewControllers.lastObject;
+
+ nav.viewControllers = @[controller];
+
+ self.mainController = controller;
- CGRect r = CGRectMake(0, h, self.view.frame.size.width, self.view.frame.size.height-h);
- self.mainController.view.frame = r;
- [self.mainController viewWillAppear:NO];
- [self.view addSubview:self.mainController.view];
- [self.mainController viewDidAppear:NO];
- if(self.currentPopoverController!=nil){
-
- UIBarButtonItem *item = [self.toolbar items][0];
-
-
- NSMutableArray *items = [NSMutableArray array];
- [items addObject:item];
+
+ nav.navigationItem.leftBarButtonItem = self.navigationItem.leftBarButtonItem;
- if(self.mainController.toolbarItems!=nil){
- [items addObjectsFromArray:self.mainController.toolbarItems];
- }
- [self.toolbar setItems:items animated:YES];
-
- }else{
- [self.toolbar setItems:self.mainController.toolbarItems];
- }
}
- (void) splitViewController: (UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc {
+ self.navigationItem.leftBarButtonItem = barButtonItem;
- barButtonItem.title = @"Demos";
- NSMutableArray *items = [[self.toolbar items] mutableCopy];
- [items insertObject:barButtonItem atIndex:0];
- [self.toolbar setItems:items animated:YES];
self.currentPopoverController = pc;
}
- (void) splitViewController: (UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {
- NSMutableArray *items = [[self.toolbar items] mutableCopy];
- [items removeObjectAtIndex:0];
- [self.toolbar setItems:items animated:YES];
- self.currentPopoverController = nil;
+
+ self.navigationItem.leftBarButtonItem = nil;
+
+
}
@@ -32,11 +32,10 @@
#import <TapkuLibrary/TapkuLibrary.h>
-@interface HUDViewController : UIViewController
+@interface IndicatorsViewController : UIViewController
@property (nonatomic,strong) TKProgressBarView *progressBar;
@property (nonatomic,strong) TKProgressBarView *progressBarAlternative;
-@property (nonatomic,strong) TKProgressAlertView *alertView;
@property (nonatomic,strong) TKProgressCircleView *progressCircle;
@end
@@ -29,82 +29,71 @@
*/
-#import "HUDViewController.h"
+#import "IndicatorsViewController.h"
-
-@implementation HUDViewController
+@implementation IndicatorsViewController
- (id) init{
if(!(self=[super init])) return nil;
self.title = @"HUD";
return self;
}
+#pragma mark View Lifecycle
+- (void) loadView{
+ [super loadView];
+ self.view.backgroundColor = [UIColor colorWithWhite:0.7 alpha:1];
+
+ [self.view addSubview:self.progressBar];
+ [self.view addSubview:self.progressCircle];
+ [self.view addSubview:self.progressBarAlternative];
+
+ UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"Tap Me" style:UIBarButtonItemStyleBordered target:self action:@selector(tapme)];
+ self.navigationItem.rightBarButtonItem = item;
+
+}
+- (void) viewDidAppear:(BOOL)animated{
+ [super viewDidAppear:animated];
+ [self stepTwo:nil];
+}
+#pragma mark Actions
- (void) tapme{
-
+
[self.progressCircle setTwirlMode:!self.progressCircle.isTwirling];
if(!self.progressCircle.isTwirling){
[self.progressCircle setProgress:0 animated:NO];
[self.progressBar setProgress:0];
[self.progressBarAlternative setProgress:0 animated:NO];
-
- [self performSelector:@selector(stepTwo) withObject:nil afterDelay:2];
- [self performSelector:@selector(stepThree) withObject:nil afterDelay:4];
+ TKProgressAlertView *alert = [[TKProgressAlertView alloc] initWithProgressTitle:@"Loading important stuff!"];
+ alert.progressBar.progress = 0;
+ [alert show];
+
+ [self performSelector:@selector(stepTwo:) withObject:alert afterDelay:2];
+ [self performSelector:@selector(stepThree:) withObject:alert afterDelay:4];
- self.alertView.progressBar.progress = 0;
- [self.alertView show];
}
-
-
+
+
}
-- (void) stepTwo{
+- (void) stepTwo:(TKProgressAlertView*)alert{
[self.progressCircle setProgress:1 animated:YES];
[self.progressBar setProgress:1 animated:YES];
[self.progressBarAlternative setProgress:1 animated:YES];
-
- [self.alertView.progressBar setProgress:1 animated:YES];
-
-}
-- (void) stepThree{
- [self.alertView hide];
+ [alert.progressBar setProgress:1 animated:YES];
}
-
-
-#pragma mark View Lifecycle
-- (void) loadView{
- [super loadView];
- self.view.backgroundColor = [UIColor colorWithWhite:0.7 alpha:1];
+- (void) stepThree:(TKProgressAlertView*)alert{
- [self.view addSubview:self.progressBar];
- [self.view addSubview:self.progressCircle];
- [self.view addSubview:self.progressBarAlternative];
+ [alert hide];
-
-
- UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"Tap Me" style:UIBarButtonItemStyleBordered target:self action:@selector(tapme)];
-
-
- if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
- self.navigationItem.rightBarButtonItem = item;
- }else{
- self.toolbarItems = @[item];
- }
-
-}
-- (void) viewDidAppear:(BOOL)animated{
- [super viewDidAppear:animated];
- [self stepTwo];
}
-
-
#pragma mark Properties
- (TKProgressBarView *) progressBar{
if(_progressBar) return _progressBar;
@@ -120,12 +109,6 @@ - (TKProgressBarView *) progressBarAlternative{
_progressBarAlternative.center = CGPointMake(self.view.bounds.size.width/2, 320);
return _progressBarAlternative;
}
-- (TKProgressAlertView *) alertView{
- if(_alertView) return _alertView;
-
- _alertView = [[TKProgressAlertView alloc] initWithProgressTitle:@"Loading important stuff!"];
- return _alertView;
-}
- (TKProgressCircleView *) progressCircle{
if(_progressCircle) return _progressCircle;
@@ -134,5 +117,4 @@ - (TKProgressCircleView *) progressCircle{
return _progressCircle;
}
-
-@end
+@end
@@ -55,13 +55,8 @@ - (void) loadView{
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"Start" style:UIBarButtonItemStyleBordered target:self action:@selector(start)];
+ self.navigationItem.rightBarButtonItem = item;
-
- if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
- self.navigationItem.rightBarButtonItem = item;
- }else{
- self.toolbarItems = @[item];
- }
}
@@ -34,7 +34,7 @@
#import "DetailViewController.h"
#import "LabelViewController.h"
-#import "HUDViewController.h"
+#import "IndicatorsViewController.h"
#import "EmptyViewController.h"
#import "CalendarMonthViewController.h"
#import "CoverflowViewController.h"
@@ -68,6 +68,7 @@ @implementation RootViewController
- (id) initWithStyle:(UITableViewStyle)s{
if(!(self = [super initWithStyle:s])) return nil;
self.title = @"Tapku Library";
+ self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
return self;
}
- (NSUInteger) supportedInterfaceOrientations{
@@ -136,7 +137,7 @@ - (void) tableView:(UITableView *)tv didSelectRowAtIndexPath:(NSIndexPath *)inde
else if(s==1 && r==0)
vc = [[EmptyViewController alloc] init];
else if(s==1 && r==1)
- vc = [[HUDViewController alloc] init];
+ vc = [[IndicatorsViewController alloc] init];
else if(s==1 && r==2)
vc = [[AlertsViewController alloc] init];
else if(s==1 && r==3)
@@ -44,30 +44,22 @@ - (void) loadView{
self.view.backgroundColor = [UIColor whiteColor];
UIImageView *image = [UIImageView imageViewWithImageNamed:@"wallpaper"];
+ image.frame = self.view.bounds;
+ image.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:image];
if([self respondsToSelector:@selector(edgesForExtendedLayout)])
self.edgesForExtendedLayout = UIRectEdgeNone;
+
+ CGFloat w = CGRectGetWidth(self.view.frame), width = 300;
-
-
-
- self.unlockView = [[TKSlideToUnlockView alloc] init];
+ self.unlockView = [[TKSlideToUnlockView alloc] initWithFrame:CGRectMake((w-width)/2.0f, 330, width, 40)];
+ self.unlockView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
[self.view addSubview:self.unlockView];
-
[self.unlockView addTarget:self action:@selector(didUnlockView:) forControlEvents:UIControlEventValueChanged];
-
- CGRect unlock = self.unlockView.frame;
-
- unlock.origin.y = 330;
-
- self.unlockView.frame = unlock;
-
- self.unlockView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
-
}
- (void) viewDidLoad{
[super viewDidLoad];
Oops, something went wrong.

0 comments on commit 0e1cc80

Please sign in to comment.