react-native-navigation的迁移库

RNNSideMenuChildVC.m 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #import "RNNSideMenuChildVC.h"
  2. #import "UIViewController+LayoutProtocol.h"
  3. @interface RNNSideMenuChildVC ()
  4. @property (readwrite) RNNSideMenuChildType type;
  5. @property (nonatomic, retain) UIViewController<RNNLayoutProtocol> *child;
  6. @end
  7. @implementation RNNSideMenuChildVC
  8. - (instancetype)initWithLayoutInfo:(RNNLayoutInfo *)layoutInfo childViewControllers:(NSArray *)childViewControllers options:(RNNNavigationOptions *)options defaultOptions:(RNNNavigationOptions *)defaultOptions presenter:(RNNViewControllerPresenter *)presenter type:(RNNSideMenuChildType)type {
  9. self = [self initWithLayoutInfo:layoutInfo childViewControllers:childViewControllers options:options defaultOptions:defaultOptions presenter:presenter];
  10. self.type = type;
  11. return self;
  12. }
  13. - (instancetype)initWithLayoutInfo:(RNNLayoutInfo *)layoutInfo childViewControllers:(NSArray *)childViewControllers options:(RNNNavigationOptions *)options defaultOptions:(RNNNavigationOptions *)defaultOptions presenter:(RNNViewControllerPresenter *)presenter {
  14. self = [super init];
  15. self.child = childViewControllers[0];
  16. self.presenter = presenter;
  17. [self.presenter bindViewController:self];
  18. self.defaultOptions = defaultOptions;
  19. self.options = options;
  20. self.layoutInfo = layoutInfo;
  21. [self bindChildViewController:self.child];
  22. return self;
  23. }
  24. - (void)renderTreeAndWait:(BOOL)wait perform:(RNNReactViewReadyCompletionBlock)readyBlock {
  25. [self.getCurrentChild renderTreeAndWait:wait perform:readyBlock];
  26. }
  27. - (void)bindChildViewController:(UIViewController<RNNLayoutProtocol>*)child {
  28. self.child = child;
  29. [self addChildViewController:self.child];
  30. [self.child.view setFrame:self.view.bounds];
  31. [self.view addSubview:self.child.view];
  32. [self.view bringSubviewToFront:self.child.view];
  33. }
  34. - (void)setWidth:(CGFloat)width {
  35. CGRect frame = self.child.view.frame;
  36. frame.size.width = width;
  37. self.child.view.frame = frame;
  38. }
  39. - (UIViewController *)getCurrentChild {
  40. return self.child;
  41. }
  42. - (UIStatusBarStyle)preferredStatusBarStyle {
  43. return self.child.preferredStatusBarStyle;
  44. }
  45. - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
  46. return self.child.supportedInterfaceOrientations;
  47. }
  48. @end