react-native-navigation的迁移库

RNNSideMenuController.m 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //
  2. // RNNSideMenuController.m
  3. // ReactNativeNavigation
  4. //
  5. // Created by Ran Greenberg on 09/02/2017.
  6. // Copyright © 2017 Wix. All rights reserved.
  7. //
  8. #import "RNNSideMenuController.h"
  9. #import "RNNSideMenuChildVC.h"
  10. #import "MMDrawerController.h"
  11. @interface RNNSideMenuController ()
  12. @property (readwrite) RNNSideMenuChildVC *center;
  13. @property (readwrite) RNNSideMenuChildVC *left;
  14. @property (readwrite) RNNSideMenuChildVC *right;
  15. @property (readwrite) MMDrawerController *sideMenu;
  16. @end
  17. @implementation RNNSideMenuController
  18. -(instancetype)initWithControllers:(NSArray*)controllers;
  19. {
  20. self = [super init];
  21. [self setControllers:controllers];
  22. self.sideMenu = [[MMDrawerController alloc] initWithCenterViewController:self.center leftDrawerViewController:self.left rightDrawerViewController:self.right];
  23. self.sideMenu.openDrawerGestureModeMask = MMOpenDrawerGestureModeAll;
  24. self.sideMenu.closeDrawerGestureModeMask = MMOpenDrawerGestureModeAll;
  25. [self addChildViewController:self.sideMenu];
  26. [self.sideMenu.view setFrame:self.view.bounds];
  27. [self.view addSubview:self.sideMenu.view];
  28. [self.view bringSubviewToFront:self.sideMenu.view];
  29. return self;
  30. }
  31. -(void)setControllers:(NSArray*)controllers {
  32. for (id controller in controllers) {
  33. if ([controller isKindOfClass:[RNNSideMenuChildVC class]]) {
  34. RNNSideMenuChildVC *child = (RNNSideMenuChildVC*)controller;
  35. if (child.type == RNNSideMenuChildTypeCenter) {
  36. self.center = child;
  37. }
  38. else if(child.type == RNNSideMenuChildTypeLeft) {
  39. self.left = child;
  40. }
  41. else if(child.type == RNNSideMenuChildTypeRight) {
  42. self.right = child;
  43. }
  44. }
  45. else {
  46. @throw [NSException exceptionWithName:@"UnknownSideMenuControllerType" reason:[@"Unknown side menu type " stringByAppendingString:[controller description]] userInfo:nil];
  47. }
  48. }
  49. }
  50. @end