Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 added an iPad example in SASlideMenuiPad
  • Loading branch information
stefanoa committed Apr 3, 2013
1 parent 8a67c91 commit 6d6d3f8
Show file tree
Hide file tree
Showing 21 changed files with 897 additions and 40 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ Version 1.2.0
* Changes to SASlideMenuDataSource
* SASlideMenuStatic example now cache the content view controllers
* Added CHANGELOG.md

Version 1.2.1
* Fixed issues #47,#52,#53
* added an iPad example in SASlideMenuiPad

252 changes: 252 additions & 0 deletions SASlideMenu.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion SASlideMenu/ExampleDynamicMenuViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import "SASlideMenuViewController.h"
#import "SASlideMenuDataSource.h"
#import "SASlideMenuDelegate.h"
@interface ExampleDynamicMenuViewController : SASlideMenuViewController<SASlideMenuDataSource,SASlideMenuDelegate, UITableViewDataSource>
@interface ExampleDynamicMenuViewController : SASlideMenuViewController

-(void) tap:(id) sender;
@end
16 changes: 2 additions & 14 deletions SASlideMenu/ExampleDynamicMenuViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import "ExampleDynamicMenuViewController.h"
#import "ColoredViewController.h"

@interface ExampleDynamicMenuViewController ()
@interface ExampleDynamicMenuViewController ()<SASlideMenuDataSource,SASlideMenuDelegate, UITableViewDataSource>

@property (nonatomic) CGFloat selectedHue;
@property (nonatomic) CGFloat selectedBrightness;
Expand All @@ -23,28 +23,16 @@ @implementation ExampleDynamicMenuViewController

-(id) initWithCoder:(NSCoder *)aDecoder{
if (self = [super initWithCoder:aDecoder]) {
// Assign self to the slideMenuDataSource because self will implement SASlideMenuDatSource
self.slideMenuDataSource = self;
self.slideMenuDelegate = self;
self.selectedBrightness = 0.3;
self.selectedHue = 0.0;
}
return self;
}

-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
if(self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]){
// Assign self to the slideMenuDataSource because self will implement SASlideMenuDataSource
self.slideMenuDataSource = self;
self.selectedBrightness = 0.3;
self.selectedHue = 0.0;
}
return self;
}

-(void)tap:(id)sender{

}

-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
return YES;
}
Expand Down
3 changes: 1 addition & 2 deletions SASlideMenu/ExampleStaticMenuViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@
#import <UIKit/UIKit.h>
#import "SASlideMenuViewController.h"
#import "SASlideMenuDataSource.h"
@interface ExampleStaticMenuViewController :SASlideMenuViewController<SASlideMenuDataSource,SASlideMenuDelegate>

@interface ExampleStaticMenuViewController :SASlideMenuViewController
@end
19 changes: 1 addition & 18 deletions SASlideMenu/ExampleStaticMenuViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,12 @@
#import "MenuCell.h"
#import "DarkViewController.h"
#import "LightViewController.h"
@interface ExampleStaticMenuViewController ()
@interface ExampleStaticMenuViewController() <SASlideMenuDataSource,SASlideMenuDelegate>

@end

@implementation ExampleStaticMenuViewController

-(id) initWithCoder:(NSCoder *)aDecoder{
if (self = [super initWithCoder:aDecoder]) {
// Assign self to the slideMenuDataSource because self will implement SASlideMenuDatSource
self.slideMenuDataSource = self;
self.slideMenuDelegate = self;
}
return self;
}

-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
if(self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]){
// Assign self to the slideMenuDataSource because self will implement SASlideMenuDataSource
self.slideMenuDataSource = self;
}
return self;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
return YES;
}
Expand Down
8 changes: 4 additions & 4 deletions SASlideMenu/SASlideMenu/SASlideMenuRootViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
@interface SASlideMenuRootViewController : UIViewController<UITableViewDelegate>


@property (strong, nonatomic) SASlideMenuViewController* leftMenu;
@property (strong, nonatomic) UIViewController* rightMenu;
@property (assign, nonatomic) Boolean isRightMenuEnabled;
@property (strong, nonatomic) SASlideMenuNavigationController* navigationController;
@property (nonatomic,strong) SASlideMenuViewController* leftMenu;
@property (nonatomic,strong) UIViewController* rightMenu;
@property (nonatomic,assign) Boolean isRightMenuEnabled;
@property (nonatomic,strong) SASlideMenuNavigationController* navigationController;

-(void) switchToContentViewController:(UINavigationController*) content;
-(void) addContentViewController:(UIViewController*) content withIndexPath:(NSIndexPath*)indexPath;
Expand Down
27 changes: 26 additions & 1 deletion SASlideMenu/SASlideMenu/SASlideMenuViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,36 @@

#import "SASlideMenuViewController.h"
#import "SASlideMenuRootViewController.h"
@interface SASlideMenuViewController ()
@interface SASlideMenuViewController ()<SASlideMenuDataSource,SASlideMenuDelegate>

@end

@implementation SASlideMenuViewController
#pragma mark -
#pragma mark Init
-(void)setup; {
if(self.slideMenuDataSource == nil)
self.slideMenuDataSource = self;
if(self.slideMenuDelegate == nil)
self.slideMenuDelegate = self;

}

-(id)initWithCoder:(NSCoder *)aDecoder; {
self = [super initWithCoder:aDecoder];
if (self) {
[self setup];
}
return self;
}

-(id)init; {
self = [super self];
if (self) {
[self setup];
}
return self;
}

#pragma mark -
#pragma mark SASlideMenuViewController
Expand Down
Binary file added SASlideMenuiPad/Default-568h@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SASlideMenuiPad/Default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SASlideMenuiPad/Default@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions SASlideMenuiPad/ExampleiPadAppDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// ExampleiPadAppDelegate.h
// SASlideMenuiPad
//
// Created by Stefano Antonelli on 3/13/13.
// Copyright (c) 2013 Stefano Antonelli. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface ExampleiPadAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end
46 changes: 46 additions & 0 deletions SASlideMenuiPad/ExampleiPadAppDelegate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// ExampleiPadAppDelegate.m
// SASlideMenuiPad
//
// Created by Stefano Antonelli on 3/13/13.
// Copyright (c) 2013 Stefano Antonelli. All rights reserved.
//

#import "ExampleiPadAppDelegate.h"

@implementation ExampleiPadAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
return YES;
}

- (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.
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
16 changes: 16 additions & 0 deletions SASlideMenuiPad/ExampleiPadViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// ExampleiPadViewController.h
// SASlideMenuiPad
//
// Created by Stefano Antonelli on 3/13/13.
// Copyright (c) 2013 Stefano Antonelli. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "SASlideMenuViewController.h"
#import "SASlideMenuDataSource.h"
#import "SASlideMenuDelegate.h"

@interface ExampleiPadViewController : SASlideMenuViewController<SASlideMenuDataSource,SASlideMenuDelegate, UITableViewDataSource>

@end
160 changes: 160 additions & 0 deletions SASlideMenuiPad/ExampleiPadViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
//
// ExampleiPadViewController.m
// SASlideMenuiPad
//
// Created by Stefano Antonelli on 3/13/13.
// Copyright (c) 2013 Stefano Antonelli. All rights reserved.
//

#import "ExampleiPadViewController.h"
#import "ColoredViewController.h"
#import "SASlideMenuRootViewController.h"

@interface ExampleiPadViewController ()
@property (nonatomic) CGFloat selectedHue;
@property (nonatomic) CGFloat selectedBrightness;

@end

@implementation ExampleiPadViewController

-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
return YES;
}

#pragma mark -
#pragma mark SASlideMenuDataSource

-(void) prepareForSwitchToContentViewController:(UINavigationController *)content{
UIViewController* controller = [content.viewControllers objectAtIndex:0];
if ([controller isKindOfClass:[ColoredViewController class]]) {
ColoredViewController* coloredViewController = (ColoredViewController*) controller;
[coloredViewController setBackgroundHue:self.selectedHue brightness:self.selectedBrightness];
}
}

// It configure the menu button. The beahviour of the button should not be modified
-(void) configureMenuButton:(UIButton *)menuButton{
menuButton.frame = CGRectMake(0, 0, 40, 29);
[menuButton setImage:[UIImage imageNamed:@"menuicon.png"] forState:UIControlStateNormal];
[menuButton setBackgroundImage:[UIImage imageNamed:@"menu.png"] forState:UIControlStateNormal];
[menuButton setBackgroundImage:[UIImage imageNamed:@"menuhighlighted.png"] forState:UIControlStateHighlighted];
[menuButton setAdjustsImageWhenHighlighted:NO];
[menuButton setAdjustsImageWhenDisabled:NO];
}

// It configure the right menu button. The beahviour of the button should not be modified
-(void) configureRightMenuButton:(UIButton *)menuButton{
menuButton.frame = CGRectMake(0, 0, 40, 29);
[menuButton setImage:[UIImage imageNamed:@"menuright.png"] forState:UIControlStateNormal];
[menuButton setBackgroundImage:[UIImage imageNamed:@"menu.png"] forState:UIControlStateNormal];
[menuButton setBackgroundImage:[UIImage imageNamed:@"menuhighlighted.png"] forState:UIControlStateHighlighted];
[menuButton setAdjustsImageWhenHighlighted:NO];
[menuButton setAdjustsImageWhenDisabled:NO];
}

// This is the segue you want visibile when the controller is loaded the first time
-(NSIndexPath*) selectedIndexPath{
return [NSIndexPath indexPathForRow:0 inSection:0];
}

// It maps each indexPath to the segueId to be used. The segue is performed only the first time the controller needs to loaded, subsequent switch to the content controller will use the already loaded controller

-(NSString*) segueIdForIndexPath:(NSIndexPath *)indexPath{
return @"colored";
}

#pragma mark -
#pragma mark UITableViewDataSource

-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView{
return 3;
}

-(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
if (section == 0) {
return @"Red";
}else if (section == 1){
return @"Green";
}else {
return @"Blue";
}
}

-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 4;
}
-(void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
CGFloat brightness = 1-((double) indexPath.row)/5;
NSInteger section = indexPath.section;
CGFloat hue=0;
if (section == 0) {
hue = 0.0;
}else if (section==1){
hue = 0.33;
}else if (section==2){
hue = 0.66;
}
cell.backgroundColor = [UIColor colorWithHue:hue saturation:1.0 brightness:brightness alpha:1.0];
}

-(UITableViewCell*) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell* cell = [self.tableView dequeueReusableCellWithIdentifier:@"item"];
return cell;
}

-(CGFloat) leftMenuVisibleWidth{
return 600;
}

-(CGFloat) rightMenuVisibleWidth{
return 300;
}

#pragma mark -
#pragma mark UITableViewDelegate
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
CGFloat brightness = 1-((double) indexPath.row)/5;
NSInteger section = indexPath.section;
CGFloat hue=0;
if (section == 0) {
hue = 0.0;
}else if (section==1){
hue = 0.33;
}else if (section==2){
hue = 0.66;
}
self.selectedHue = hue;
self.selectedBrightness = brightness;
[super tableView:tableView didSelectRowAtIndexPath:indexPath];
}

#pragma mark -
#pragma mark SASlideMenuDelegate

-(void) slideMenuWillSlideIn{
NSLog(@"slideMenuWillSlideIn");
}
-(void) slideMenuDidSlideIn{
NSLog(@"slideMenuDidSlideIn");
}
-(void) slideMenuWillSlideToSide{
NSLog(@"slideMenuWillSlideToSide");
}
-(void) slideMenuDidSlideToSide{
NSLog(@"slideMenuDidSlideToSide");
}
-(void) slideMenuWillSlideOut{
NSLog(@"slideMenuWillSlideOut");
}
-(void) slideMenuDidSlideOut{
NSLog(@"slideMenuDidSlideOut");
}
-(void) slideMenuWillSlideToLeft{
NSLog(@"slideMenuWillSlideToLeft");
}
-(void) slideMenuDidSlideToLeft{
NSLog(@"slideMenuDidSlideToLeft");
}

@end
Loading

0 comments on commit 6d6d3f8

Please sign in to comment.