123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- #import "RNNSideMenuSideOptions.h"
- #import "RNNSideMenuController.h"
- #import "MMDrawerVisualState.h"
-
- @implementation RNNSideMenuSideOptions
-
- - (void)applyOnSide:(MMDrawerSide)side viewController:(UIViewController *)viewController {
- RNNSideMenuController* sideMenuController = [self getParentSideMenuControllerFromChild:viewController];
- if (sideMenuController) {
- if (self.enabled) {
- switch (side) {
- case MMDrawerSideRight:
- sideMenuController.sideMenu.rightSideEnabled = [self.enabled boolValue];
- break;
- case MMDrawerSideLeft:
- sideMenuController.sideMenu.leftSideEnabled = [self.enabled boolValue];
- default:
- break;
- }
- sideMenuController.sideMenu.openDrawerGestureModeMask = [self.enabled boolValue] ? MMOpenDrawerGestureModeAll : MMOpenDrawerGestureModeNone;
- }
-
- if (self.visible) {
- if (self.visible.boolValue) {
- [sideMenuController showSideMenu:side animated:YES];
- } else {
- [sideMenuController hideSideMenu:side animated:YES];
- }
- }
-
- if (self.shouldStretchDrawer) {
- sideMenuController.sideMenu.shouldStretchDrawer = self.shouldStretchDrawer.boolValue;
- }
-
- if (self.animationVelocity) {
- sideMenuController.sideMenu.animationVelocity = [self.animationVelocity doubleValue];
- }
-
- MMDrawerControllerDrawerVisualStateBlock animationTypeStateBlock = nil;
- if ([self.animationType isEqualToString:@"door"]) animationTypeStateBlock = [MMDrawerVisualState swingingDoorVisualStateBlock];
- else if ([self.animationType isEqualToString:@"parallax"]) animationTypeStateBlock = [MMDrawerVisualState parallaxVisualStateBlockWithParallaxFactor:2.0];
- else if ([self.animationType isEqualToString:@"slide"]) animationTypeStateBlock = [MMDrawerVisualState slideVisualStateBlock];
- else if ([self.animationType isEqualToString:@"slide-and-scale"]) animationTypeStateBlock = [MMDrawerVisualState slideAndScaleVisualStateBlock];
-
- if (animationTypeStateBlock) {
- [sideMenuController.sideMenu setDrawerVisualStateBlock:animationTypeStateBlock];
- }
-
- if (self.width) {
- switch (side) {
- case MMDrawerSideRight:
- sideMenuController.sideMenu.maximumRightDrawerWidth = self.width.floatValue;
- break;
- case MMDrawerSideLeft:
- sideMenuController.sideMenu.maximumLeftDrawerWidth = self.width.floatValue;
- default:
- break;
- }
- }
- }
-
- [self resetOptions];
- }
-
- - (RNNSideMenuController *)getParentSideMenuControllerFromChild:(UIViewController *)childViewController {
- UIViewController* vc = childViewController;
- while (vc) {
- if ([vc isKindOfClass:[RNNSideMenuController class]]) {
- return (RNNSideMenuController *)vc;
- }
-
- vc = vc.parentViewController;
- }
-
- return nil;
- }
-
- - (void)resetOptions {
- self.visible = nil;
- self.enabled = nil;
- }
-
- @end
|