react-native-navigation的迁移库

RNNSideMenuSideOptions.m 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #import "RNNSideMenuSideOptions.h"
  2. #import "RNNSideMenuController.h"
  3. #import "MMDrawerVisualState.h"
  4. @implementation RNNSideMenuSideOptions
  5. - (void)applyOnSide:(MMDrawerSide)side viewController:(UIViewController *)viewController {
  6. RNNSideMenuController* sideMenuController = (RNNSideMenuController*)UIApplication.sharedApplication.delegate.window.rootViewController;
  7. if (sideMenuController && [sideMenuController isKindOfClass:[RNNSideMenuController class]]) {
  8. if (self.enabled) {
  9. switch (side) {
  10. case MMDrawerSideRight:
  11. sideMenuController.sideMenu.rightSideEnabled = [self.enabled boolValue];
  12. break;
  13. case MMDrawerSideLeft:
  14. sideMenuController.sideMenu.leftSideEnabled = [self.enabled boolValue];
  15. default:
  16. break;
  17. }
  18. sideMenuController.sideMenu.openDrawerGestureModeMask = [self.enabled boolValue] ? MMOpenDrawerGestureModeAll : MMOpenDrawerGestureModeNone;
  19. }
  20. if (self.visible) {
  21. if (self.visible.boolValue) {
  22. [sideMenuController showSideMenu:side animated:YES];
  23. } else {
  24. [sideMenuController hideSideMenu:side animated:YES];
  25. }
  26. }
  27. if (self.shouldStretchDrawer) {
  28. sideMenuController.sideMenu.shouldStretchDrawer = self.shouldStretchDrawer.boolValue;
  29. }
  30. if (self.animationVelocity) {
  31. sideMenuController.sideMenu.animationVelocity = [self.animationVelocity doubleValue];
  32. }
  33. MMDrawerControllerDrawerVisualStateBlock animationTypeStateBlock = nil;
  34. if ([self.animationType isEqualToString:@"door"]) animationTypeStateBlock = [MMDrawerVisualState swingingDoorVisualStateBlock];
  35. else if ([self.animationType isEqualToString:@"parallax"]) animationTypeStateBlock = [MMDrawerVisualState parallaxVisualStateBlockWithParallaxFactor:2.0];
  36. else if ([self.animationType isEqualToString:@"slide"]) animationTypeStateBlock = [MMDrawerVisualState slideVisualStateBlock];
  37. else if ([self.animationType isEqualToString:@"slide-and-scale"]) animationTypeStateBlock = [MMDrawerVisualState slideAndScaleVisualStateBlock];
  38. if (animationTypeStateBlock) {
  39. [sideMenuController.sideMenu setDrawerVisualStateBlock:animationTypeStateBlock];
  40. }
  41. if (self.width) {
  42. switch (side) {
  43. case MMDrawerSideRight:
  44. sideMenuController.sideMenu.maximumRightDrawerWidth = self.width.floatValue;
  45. break;
  46. case MMDrawerSideLeft:
  47. sideMenuController.sideMenu.maximumLeftDrawerWidth = self.width.floatValue;
  48. default:
  49. break;
  50. }
  51. }
  52. }
  53. [self resetOptions];
  54. }
  55. - (void)resetOptions {
  56. self.visible = nil;
  57. self.enabled = nil;
  58. }
  59. @end