Skip to content

Improvements #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion SASlideMenu/SASlideMenu/SASlideMenuContentSegue.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,17 @@ -(void) perform{
[panGesture setMaximumNumberOfTouches:2];
[panGesture setDelegate:source];
[destination.view addGestureRecognizer:panGesture];
}
}

Boolean disableSwipeGesture= NO;
if ([rootController.leftMenu.slideMenuDataSource respondsToSelector:@selector(disableSwipeGestureForIndexPath:)]) {
disableSwipeGesture = [rootController.leftMenu.slideMenuDataSource disableSwipeGestureForIndexPath:selectedIndexPath];
}
if(disablePanGesture && !disableSwipeGesture) {
UISwipeGestureRecognizer* swipeGesture= [[UISwipeGestureRecognizer alloc] initWithTarget:rootController action:@selector(swipeItem:)];
[swipeGesture setDelegate:source];
[destination.view addGestureRecognizer:swipeGesture];
}
}];

}
Expand Down
3 changes: 3 additions & 0 deletions SASlideMenu/SASlideMenu/SASlideMenuDataSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
// It is used to selectively disable the pan gesture that slide the view controller. If not implemented the pan gesture is active for all the view controller.
-(Boolean) disablePanGestureForIndexPath:(NSIndexPath*) indexPath;

// It is used to selectively disable the swipe gesture that slide the view controller. If not implemented the swipe gesture is active for all the view controller if pan gesture is disabled.
-(Boolean) disableSwipeGestureForIndexPath:(NSIndexPath*) indexPath;

// It is used to enable the pan gesture that slide the view controller only on certain view zones. If not implemented the pan gesture is active for the entier view.
-(Boolean) shouldRespondToGesture:(UIGestureRecognizer*) gesture forIndexPath:(NSIndexPath*)indexPath;
@end
3 changes: 3 additions & 0 deletions SASlideMenu/SASlideMenu/SASlideMenuRootViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@

-(void) doSlideToSide;
-(void) doSlideToLeftSide;
-(void) doSlideIn:(void (^)(BOOL completed))completion;
-(void) rightMenuAction;
-(void) addRightMenu;

-(void) panItem:(UIPanGestureRecognizer*)gesture;
- (void) swipeItem:(UISwipeGestureRecognizer*)gesture;
- (void) clearControllers;
@end
26 changes: 22 additions & 4 deletions SASlideMenu/SASlideMenu/SASlideMenuRootViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ @interface SASlideMenuRootViewController ()<UIDynamicAnimatorDelegate>{
NSDate* panningPreviousEventDate;
CGFloat panningXSpeed; // panning speed expressed in px/ms
NSMutableDictionary* controllers;
NSMutableDictionary* controllersDict;

UIPanGestureRecognizer* menuPanGesture;
UITapGestureRecognizer* tapGesture;
Expand Down Expand Up @@ -331,7 +332,7 @@ -(void) panItem:(UIPanGestureRecognizer*)gesture{
[collisionBehaviour addItem:self.selectedContent.view];

CGFloat leftMenuWidth = [self leftMenuSize];
[collisionBehaviour setTranslatesReferenceBoundsIntoBoundaryWithInsets:UIEdgeInsetsMake(0, 0, 0, -leftMenuWidth)];
[collisionBehaviour setTranslatesReferenceBoundsIntoBoundaryWithInsets:UIEdgeInsetsMake(0, 1, 0, -leftMenuWidth)];

pushBehavior = [[UIPushBehavior alloc] init];
pushBehavior.pushDirection = CGVectorMake(velocity.x, 0);
Expand Down Expand Up @@ -406,8 +407,17 @@ -(void) panItem:(UIPanGestureRecognizer*)gesture{
}
}

- (void) swipeItem:(UISwipeGestureRecognizer*)gesture {
if(gesture.direction == UISwipeGestureRecognizerDirectionRight) {
[self doSlideToSide];
} else if(gesture.direction == UISwipeGestureRecognizerDirectionLeft) {
[self doSlideIn:nil];
}

}

-(UINavigationController*) controllerForIndexPath:(NSIndexPath*) indexPath{
return [controllers objectForKey:indexPath];
return [controllersDict objectForKey:[controllers objectForKey:indexPath]];
}

-(void) switchToContentViewController:(UINavigationController*) content completion:(void (^)(void))completion{
Expand Down Expand Up @@ -495,7 +505,9 @@ -(void) addContentViewController:(UIViewController*) content withIndexPath:(NSIn
disableContentViewControllerCaching = [self.leftMenu.slideMenuDataSource disableContentViewControllerCachingForIndexPath:indexPath];
}
if (!disableContentViewControllerCaching) {
[controllers setObject:content forKey:indexPath];

[controllersDict setObject:content forKey:@(content.hash)];
[controllers setObject:@(content.hash) forKey:indexPath];
}
}
}
Expand Down Expand Up @@ -560,8 +572,9 @@ -(void) viewWillAppear:(BOOL)animated{
}
-(void) viewDidLoad{
[super viewDidLoad];

controllers = [[NSMutableDictionary alloc] init];
controllersDict = [[NSMutableDictionary alloc] init];
animator = [[UIDynamicAnimator alloc] initWithReferenceView:self.view];
animator.delegate = self;

Expand All @@ -583,6 +596,11 @@ -(void) viewDidLoad{
-(void) didReceiveMemoryWarning{
[super didReceiveMemoryWarning];
[controllers removeAllObjects];
[controllersDict removeAllObjects];
}

- (void) clearControllers {
[controllers removeAllObjects];
}


Expand Down
6 changes: 3 additions & 3 deletions SASlideMenu/SASlideMenu/SASlideMenuViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

@interface SASlideMenuViewController : UITableViewController<UIGestureRecognizerDelegate>

@property(nonatomic,strong) SASlideMenuRootViewController* rootController;
@property (strong, nonatomic) NSObject<SASlideMenuDataSource>* slideMenuDataSource;
@property (strong, nonatomic) NSObject<SASlideMenuDelegate>* slideMenuDelegate;
@property(nonatomic,weak) SASlideMenuRootViewController* rootController;
@property (weak, nonatomic) NSObject<SASlideMenuDataSource>* slideMenuDataSource;
@property (weak, nonatomic) NSObject<SASlideMenuDelegate>* slideMenuDelegate;

-(void)selectContentAtIndexPath:(NSIndexPath *)indexPath scrollPosition:(UITableViewScrollPosition)scrollPosition;
-(void) revealLeftMenu;
Expand Down
27 changes: 27 additions & 0 deletions SASlideMenuDynamic/en.lproj/MainStoryboard.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

/* Class = "IBUILabel"; text = "Brigthness"; ObjectID = "4GY-rn-OIy"; */
"4GY-rn-OIy.text" = "Brigthness";

/* Class = "IBUILabel"; text = "Hue"; ObjectID = "PoZ-Le-dnE"; */
"PoZ-Le-dnE.text" = "Hue";

/* Class = "IBUINavigationItem"; title = "Second"; ObjectID = "RYj-gg-Xxr"; */
"RYj-gg-Xxr.title" = "Second";

/* Class = "IBUINavigationItem"; title = "First"; ObjectID = "Y9V-OI-yLR"; */
"Y9V-OI-yLR.title" = "First";

/* Class = "IBUILabel"; text = "100"; ObjectID = "gfC-SH-g6m"; */
"gfC-SH-g6m.text" = "100";

/* Class = "IBUILabel"; text = "70%"; ObjectID = "kcZ-od-SS0"; */
"kcZ-od-SS0.text" = "70%";

/* Class = "IBUILabel"; text = "360"; ObjectID = "mAa-dA-voK"; */
"mAa-dA-voK.text" = "360";

/* Class = "IBUILabel"; text = "Color"; ObjectID = "pU9-Fl-EKa"; */
"pU9-Fl-EKa.text" = "Color";

/* Class = "IBUILabel"; text = "Saturation"; ObjectID = "qNX-Or-eOh"; */
"qNX-Or-eOh.text" = "Saturation";
18 changes: 18 additions & 0 deletions SASlideMenuStatic/en.lproj/MainStoryboard.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

/* Class = "IBUILabel"; text = "Dark"; ObjectID = "Fnc-Dq-dWr"; */
"Fnc-Dq-dWr.text" = "Dark";

/* Class = "IBUILabel"; text = "Shades"; ObjectID = "IRv-6F-pnO"; */
"IRv-6F-pnO.text" = "Shades";

/* Class = "IBUILabel"; text = "Light"; ObjectID = "KbX-ze-Lzv"; */
"KbX-ze-Lzv.text" = "Light";

/* Class = "IBUILabel"; text = "Darkness"; ObjectID = "RlY-60-SEB"; */
"RlY-60-SEB.text" = "Darkness";

/* Class = "IBUIButton"; normalTitle = "Left Menu"; ObjectID = "TnT-C8-lYJ"; */
"TnT-C8-lYJ.normalTitle" = "Left Menu";

/* Class = "IBUIButton"; normalTitle = "Back to Dark"; ObjectID = "xWG-5D-zlw"; */
"xWG-5D-zlw.normalTitle" = "Back to Dark";
21 changes: 21 additions & 0 deletions SASlideMenuiPad/en.lproj/MainStoryboard_iPad.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

/* Class = "IBUILabel"; text = "360"; ObjectID = "4fz-tO-4Oc"; */
"4fz-tO-4Oc.text" = "360";

/* Class = "IBUILabel"; text = "70%"; ObjectID = "BUE-1P-7Xd"; */
"BUE-1P-7Xd.text" = "70%";

/* Class = "IBUILabel"; text = "Hue"; ObjectID = "INn-CT-Jne"; */
"INn-CT-Jne.text" = "Hue";

/* Class = "IBUILabel"; text = "Saturation"; ObjectID = "TTQ-A6-vD3"; */
"TTQ-A6-vD3.text" = "Saturation";

/* Class = "IBUILabel"; text = "100"; ObjectID = "V82-kJ-gGM"; */
"V82-kJ-gGM.text" = "100";

/* Class = "IBUILabel"; text = "Brigthness"; ObjectID = "mVh-kk-Zaf"; */
"mVh-kk-Zaf.text" = "Brigthness";

/* Class = "IBUILabel"; text = "Color"; ObjectID = "ts0-gd-xhY"; */
"ts0-gd-xhY.text" = "Color";
Empty file.