react-native-navigation的迁移库

RNNViewController.m 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //
  2. // RNNViewController.m
  3. // ReactNativeNavigation
  4. //
  5. // Created by Ran Greenberg on 21/12/2016.
  6. // Copyright © 2016 artal. All rights reserved.
  7. //
  8. #import "RNNViewController.h"
  9. #import "RCTRootView.h"
  10. #define SCREEN @"screen"
  11. #define SIDE_MENU @"sideMenu"
  12. #define TABS @"tabs"
  13. #define SCREEN_KEY @"key"
  14. @interface RNNViewController ()
  15. @end
  16. @implementation RNNViewController
  17. #pragma mark - Static function
  18. + (UIViewController*)controllerWithLayout:(NSDictionary *)layout bridge:(RCTBridge *)bridge {
  19. UIViewController *controller = nil;
  20. NSDictionary *screen = layout[SCREEN];
  21. if (screen) {
  22. NSString *screenKey = screen[SCREEN_KEY];
  23. if (screenKey)
  24. controller = [RNNViewController navigationControllerWithScreenKey:screenKey bridge:bridge];
  25. }
  26. return controller;
  27. }
  28. +(UINavigationController*)navigationControllerWithScreenKey:(NSString*)screenKey bridge:(RCTBridge*)bridge {
  29. UINavigationController *controller = nil;
  30. UIViewController *viewController = [UIViewController new];
  31. RCTRootView *reactView = [[RCTRootView alloc] initWithBridge:bridge moduleName:SCREEN_KEY initialProperties:nil];
  32. controller = [[UINavigationController alloc] initWithRootViewController:viewController];
  33. return controller;
  34. }
  35. @end