react-native-navigation的迁移库

RNNSideMenuSideOptions.m 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. }
  19. if (self.visible) {
  20. if (self.visible.boolValue) {
  21. [sideMenuController showSideMenu:side animated:YES];
  22. } else {
  23. [sideMenuController hideSideMenu:side animated:YES];
  24. }
  25. }
  26. if (self.shouldStretchDrawer) {
  27. sideMenuController.sideMenu.shouldStretchDrawer = self.shouldStretchDrawer.boolValue;
  28. }
  29. if (self.animationVelocity) {
  30. sideMenuController.sideMenu.animationVelocity = [self.animationVelocity doubleValue];
  31. }
  32. MMDrawerControllerDrawerVisualStateBlock animationTypeStateBlock = nil;
  33. if ([self.animationType isEqualToString:@"door"]) animationTypeStateBlock = [MMDrawerVisualState swingingDoorVisualStateBlock];
  34. else if ([self.animationType isEqualToString:@"parallax"]) animationTypeStateBlock = [MMDrawerVisualState parallaxVisualStateBlockWithParallaxFactor:2.0];
  35. else if ([self.animationType isEqualToString:@"slide"]) animationTypeStateBlock = [MMDrawerVisualState slideVisualStateBlock];
  36. else if ([self.animationType isEqualToString:@"slide-and-scale"]) animationTypeStateBlock = [MMDrawerVisualState slideAndScaleVisualStateBlock];
  37. if (animationTypeStateBlock) {
  38. [sideMenuController.sideMenu setDrawerVisualStateBlock:animationTypeStateBlock];
  39. }
  40. if (self.width) {
  41. switch (side) {
  42. case MMDrawerSideRight:
  43. sideMenuController.sideMenu.maximumRightDrawerWidth = self.width.floatValue;
  44. break;
  45. case MMDrawerSideLeft:
  46. sideMenuController.sideMenu.maximumLeftDrawerWidth = self.width.floatValue;
  47. default:
  48. break;
  49. }
  50. }
  51. }
  52. [self resetOptions];
  53. }
  54. - (void)resetOptions {
  55. self.visible = nil;
  56. self.enabled = nil;
  57. }
  58. @end