Permalink
Browse files

Massive Changes

Shoulda committed earlier...
  • Loading branch information...
1 parent 716c941 commit fdc9c8cc8dd66354e2b9648490f5229cd67bf745 @gresrun committed Jan 10, 2012
View
@@ -5,9 +5,9 @@
// Created by Greg Haines on 11/20/11.
//
+#import <Foundation/Foundation.h>
#import "GHSidebarSearchViewController.h"
-
@interface GHAppDelegate : UIResponder <UIApplicationDelegate, GHSidebarSearchViewControllerDelegate>
@end
View
@@ -40,7 +40,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
self.revealController.view.backgroundColor = bgColor;
RevealBlock revealBlock = ^(){
- [self.revealController toggleSidebar:!self.revealController.sidebarShowing animated:YES];
+ [self.revealController toggleSidebar:!self.revealController.sidebarShowing duration:kGHRevealSidebarDefaultAnimationDuration];
};
NSMutableArray *headers = [[NSMutableArray alloc] initWithCapacity:2];
@@ -72,9 +72,34 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[controllers addObject:favoritesControllers];
self.searchController = [[GHSidebarSearchViewController alloc] initWithSidebarViewController:self.revealController];
- self.searchController.searchDelegate = self;
self.searchController.view.backgroundColor = [UIColor clearColor];
- self.menuController = [[GHMenuViewController alloc] initWithSidebarViewController:self.revealController
+ self.searchController.searchDelegate = self;
+ self.searchController.searchBar.autocapitalizationType = UITextAutocapitalizationTypeNone;
+ self.searchController.searchBar.autocorrectionType = UITextAutocorrectionTypeNo;
+ self.searchController.searchBar.backgroundImage = [UIImage imageNamed:@"searchBarBG.png"];
+ self.searchController.searchBar.placeholder = NSLocalizedString(@"Search", @"");
+ self.searchController.searchBar.tintColor = [UIColor colorWithRed:(58.0f/255.0f) green:(67.0f/255.0f) blue:(104.0f/255.0f) alpha:1.0f];
+ for (UIView *subview in self.searchController.searchBar.subviews) {
+ if ([subview isKindOfClass:[UITextField class]]) {
+ UITextField *searchTextField = (UITextField *) subview;
+ searchTextField.textColor = [UIColor colorWithRed:(154.0f/255.0f) green:(162.0f/255.0f) blue:(176.0f/255.0f) alpha:1.0f];
+ }
+ }
+ UIEdgeInsets insets = UIEdgeInsetsMake(16.0f, 17.0f, 16.0f, 17.0f);
+ UIImage *searchTextBG = [[UIImage imageNamed:@"searchTextBG.png"] resizableImageWithCapInsets:insets];
+ UIImage *searchBarIcon = [UIImage imageNamed:@"searchBarIcon.png"];
+ [self.searchController.searchBar setSearchFieldBackgroundImage:searchTextBG
+ forState:UIControlStateNormal];
+ [self.searchController.searchBar setSearchFieldBackgroundImage:searchTextBG
+ forState:UIControlStateDisabled];
+ [self.searchController.searchBar setImage:searchBarIcon
+ forSearchBarIcon:UISearchBarIconSearch
+ state:UIControlStateNormal];
+ [self.searchController.searchBar setImage:searchBarIcon
+ forSearchBarIcon:UISearchBarIconSearch
+ state:UIControlStateHighlighted];
+
+ self.menuController = [[GHMenuViewController alloc] initWithSidebarViewController:self.revealController
withSearchBar:self.searchController.searchBar
withHeaders:headers
withControllers:controllers
@@ -86,8 +111,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
return YES;
}
-- (NSArray *)searchResultsForText:(NSString *)text withScope:(NSString *)scope {
- return [NSArray arrayWithObjects:@"Foo", @"Bar", @"Baz", nil];
+- (void)searchResultsForText:(NSString *)text withScope:(NSString *)scope callback:(SearchResultsBlock)callback {
+ callback([NSArray arrayWithObjects:@"Foo", @"Bar", @"Baz", nil]);
}
@end
View
@@ -5,10 +5,11 @@
// Created by Greg Haines on 11/20/11.
//
+#import <Foundation/Foundation.h>
+
extern NSString const *kSidebarCellTextKey;
extern NSString const *kSidebarCellImageKey;
-
@interface GHMenuCell : UITableViewCell
@end
@@ -6,9 +6,9 @@
// Copyright (c) 2012 Greg Haines. All rights reserved.
//
+#import <Foundation/Foundation.h>
@class GHRevealViewController;
-
@interface GHMenuViewController : UIViewController <UITableViewDataSource, UITableViewDelegate> {
@private
GHRevealViewController *_sidebarVC;
@@ -24,6 +24,7 @@
withHeaders:(NSArray *)headers
withControllers:(NSArray *)controllers
withCellInfos:(NSArray *)cellInfos;
+
- (void)selectRowAtIndexPath:(NSIndexPath *)indexPath
animated:(BOOL)animated
scrollPosition:(UITableViewScrollPosition)scrollPosition;
@@ -29,32 +29,47 @@ - (id)initWithSidebarViewController:(GHRevealViewController *)sidebarVC
_controllers = controllers;
_cellInfos = cellInfos;
- self.view.frame = CGRectMake(0.0f, 0.0f, kSidebarWidth, CGRectGetHeight(self.view.bounds));
-
- [self.view addSubview:_searchBar];
- [_searchBar sizeToFit];
-
- CGFloat tableHeight = CGRectGetHeight(self.view.bounds) - CGRectGetHeight(_searchBar.frame);
- _menuTableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0f, CGRectGetHeight(_searchBar.frame), kSidebarWidth, tableHeight)
- style:UITableViewStylePlain];
- _menuTableView.delegate = self;
- _menuTableView.dataSource = self;
- _menuTableView.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight;
- _menuTableView.backgroundColor = [UIColor clearColor];
- _menuTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- [self.view addSubview:_menuTableView];
-
_sidebarVC.sidebarViewController = self;
_sidebarVC.contentViewController = [[_controllers objectAtIndex:0] objectAtIndex:0];
}
return self;
}
#pragma mark UIViewController
+- (void)viewDidLoad {
+ [super viewDidLoad];
+ self.view.frame = CGRectMake(0.0f, 0.0f, kGHRevealSidebarWidth, CGRectGetHeight(self.view.bounds));
+ self.view.autoresizingMask = UIViewAutoresizingFlexibleHeight;
+
+ [self.view addSubview:_searchBar];;
+
+ _menuTableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0f, 44.0f, kGHRevealSidebarWidth, CGRectGetHeight(self.view.bounds) - 44.0f)
+ style:UITableViewStylePlain];
+ _menuTableView.delegate = self;
+ _menuTableView.dataSource = self;
+ _menuTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
+ _menuTableView.backgroundColor = [UIColor clearColor];
+ _menuTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
+ [self.view addSubview:_menuTableView];
+}
+
- (void)viewWillAppear:(BOOL)animated {
+ self.view.frame = CGRectMake(0.0f, 0.0f,kGHRevealSidebarWidth, CGRectGetHeight(self.view.bounds));
+ [_searchBar sizeToFit];
[self selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionTop];
}
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation {
+ switch (orientation) {
+ case UIInterfaceOrientationLandscapeLeft:
+ case UIInterfaceOrientationLandscapeRight:
+ case UIInterfaceOrientationPortrait:
+ return YES;
+ case UIInterfaceOrientationPortraitUpsideDown:
+ return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
+ }
+}
+
#pragma mark UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return [_headers count];
@@ -117,7 +132,7 @@ - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
_sidebarVC.contentViewController = [[_controllers objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
- [_sidebarVC toggleSidebar:NO animated:YES];
+ [_sidebarVC toggleSidebar:NO duration:kGHRevealSidebarDefaultAnimationDuration];
}
#pragma mark Public Methods
@@ -5,6 +5,8 @@
// Created by Greg Haines on 11/29/11.
//
+#import <Foundation/Foundation.h>
+
@interface GHPushedViewController : UIViewController
- (id)initWithTitle:(NSString *)title;
@@ -5,8 +5,9 @@
// Created by Greg Haines on 11/20/11.
//
-typedef void (^RevealBlock)();
+#import <Foundation/Foundation.h>
+typedef void (^RevealBlock)();
@interface GHRootViewController : UIViewController {
@private
@@ -10,6 +10,9 @@
6B014F5214B3DAC4001E922B /* GHMenuViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B014F5114B3DAC4001E922B /* GHMenuViewController.m */; };
6B014F5714B41DB6001E922B /* GHSidebarSearchViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B014F5614B41DB6001E922B /* GHSidebarSearchViewController.m */; };
6B4BD80214B10447004BE0CC /* GHMenuCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B4BD80114B10447004BE0CC /* GHMenuCell.m */; };
+ 6B71B28814B8C77B00588FB6 /* searchBarIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = 6B71B28614B8C77B00588FB6 /* searchBarIcon.png */; };
+ 6B71B28914B8C77B00588FB6 /* searchBarIcon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6B71B28714B8C77B00588FB6 /* searchBarIcon@2x.png */; };
+ 6B71B28B14B8C82600588FB6 /* searchTextBG.png in Resources */ = {isa = PBXBuildFile; fileRef = 6B71B28A14B8C82600588FB6 /* searchTextBG.png */; };
6BBA75C014873DFE004E1A5E /* GHAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BBA75BB14873DFD004E1A5E /* GHAppDelegate.m */; };
6BBA75C114873DFE004E1A5E /* GHPushedViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BBA75BD14873DFD004E1A5E /* GHPushedViewController.m */; };
6BBA75C214873DFE004E1A5E /* GHRootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BBA75BF14873DFD004E1A5E /* GHRootViewController.m */; };
@@ -31,6 +34,10 @@
6B014F5614B41DB6001E922B /* GHSidebarSearchViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GHSidebarSearchViewController.m; sourceTree = "<group>"; };
6B4BD80014B10447004BE0CC /* GHMenuCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GHMenuCell.h; path = Demo/GHMenuCell.h; sourceTree = SOURCE_ROOT; };
6B4BD80114B10447004BE0CC /* GHMenuCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GHMenuCell.m; path = Demo/GHMenuCell.m; sourceTree = SOURCE_ROOT; };
+ 6B71B28614B8C77B00588FB6 /* searchBarIcon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = searchBarIcon.png; sourceTree = "<group>"; };
+ 6B71B28714B8C77B00588FB6 /* searchBarIcon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "searchBarIcon@2x.png"; sourceTree = "<group>"; };
+ 6B71B28A14B8C82600588FB6 /* searchTextBG.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = searchTextBG.png; sourceTree = "<group>"; };
+ 6B71B28C14B8C98E00588FB6 /* GHSidebarSearchViewControllerDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GHSidebarSearchViewControllerDelegate.h; sourceTree = "<group>"; };
6BBA75BA14873DFD004E1A5E /* GHAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GHAppDelegate.h; path = Demo/GHAppDelegate.h; sourceTree = SOURCE_ROOT; };
6BBA75BB14873DFD004E1A5E /* GHAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GHAppDelegate.m; path = Demo/GHAppDelegate.m; sourceTree = SOURCE_ROOT; };
6BBA75BC14873DFD004E1A5E /* GHPushedViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GHPushedViewController.h; path = Demo/GHPushedViewController.h; sourceTree = SOURCE_ROOT; };
@@ -130,6 +137,7 @@
children = (
6BE3FCD5147A118100CDEC04 /* GHRevealViewController.h */,
6BE3FCD6147A118200CDEC04 /* GHRevealViewController.m */,
+ 6B71B28C14B8C98E00588FB6 /* GHSidebarSearchViewControllerDelegate.h */,
6B014F5514B41DB6001E922B /* GHSidebarSearchViewController.h */,
6B014F5614B41DB6001E922B /* GHSidebarSearchViewController.m */,
);
@@ -152,6 +160,9 @@
isa = PBXGroup;
children = (
6BBA75CC14873E74004E1A5E /* searchBarBG.png */,
+ 6B71B28614B8C77B00588FB6 /* searchBarIcon.png */,
+ 6B71B28714B8C77B00588FB6 /* searchBarIcon@2x.png */,
+ 6B71B28A14B8C82600588FB6 /* searchTextBG.png */,
6BBA75CD14873E74004E1A5E /* user.png */,
);
name = Resources;
@@ -211,6 +222,9 @@
6BBA75C914873E18004E1A5E /* InfoPlist.strings in Resources */,
6BBA75CE14873E74004E1A5E /* searchBarBG.png in Resources */,
6BBA75CF14873E74004E1A5E /* user.png in Resources */,
+ 6B71B28814B8C77B00588FB6 /* searchBarIcon.png in Resources */,
+ 6B71B28914B8C77B00588FB6 /* searchBarIcon@2x.png in Resources */,
+ 6B71B28B14B8C82600588FB6 /* searchTextBG.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -5,7 +5,10 @@
// Created by Greg Haines on 11/20/11.
//
-extern const CGFloat kSidebarWidth;
+#import <Foundation/Foundation.h>
+
+extern const NSTimeInterval kGHRevealSidebarDefaultAnimationDuration;
+extern const CGFloat kGHRevealSidebarWidth;
@interface GHRevealViewController : UIViewController {
@private
@@ -19,9 +22,9 @@ extern const CGFloat kSidebarWidth;
@property (nonatomic, strong) UIViewController *sidebarViewController;
@property (nonatomic, strong) UIViewController *contentViewController;
-- (void)toggleSidebar:(BOOL)show animated:(BOOL)animated;
-- (void)toggleSidebar:(BOOL)show animated:(BOOL)animated completion:(void (^)(BOOL finsihed))completion;
-- (void)toggleSearch:(BOOL)showSearch withSearchView:(UIView *)searchView animated:(BOOL)animated;
-- (void)toggleSearch:(BOOL)showSearch withSearchView:(UIView *)searchView animated:(BOOL)animated completion:(void (^)(BOOL finsihed))completion;
+- (void)toggleSidebar:(BOOL)show duration:(NSTimeInterval)duration;
+- (void)toggleSidebar:(BOOL)show duration:(NSTimeInterval)duration completion:(void (^)(BOOL finished))completion;
+- (void)toggleSearch:(BOOL)showSearch withSearchView:(UIView *)searchView duration:(NSTimeInterval)duration;
+- (void)toggleSearch:(BOOL)showSearch withSearchView:(UIView *)searchView duration:(NSTimeInterval)duration completion:(void (^)(BOOL finished))completion;
@end
Oops, something went wrong.

0 comments on commit fdc9c8c

Please sign in to comment.