react-native-navigation的迁移库

ReactNativeNavigation.m 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #import "ReactNativeNavigation.h"
  2. #import <React/RCTUIManager.h>
  3. #import "RNNBridgeManager.h"
  4. #import "RNNSplashScreen.h"
  5. @interface ReactNativeNavigation()
  6. @property (nonatomic, strong) RNNBridgeManager *bridgeManager;
  7. @end
  8. @implementation ReactNativeNavigation
  9. # pragma mark - public API
  10. +(void)bootstrap:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOptions {
  11. [[ReactNativeNavigation sharedInstance] bootstrap:jsCodeLocation launchOptions:launchOptions];
  12. }
  13. +(void)bootstrap:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOptions bridgeManagerDelegate:(id<RNNBridgeManagerDelegate>)delegate {
  14. [[ReactNativeNavigation sharedInstance] bootstrap:jsCodeLocation launchOptions:launchOptions bridgeManagerDelegate:delegate];
  15. }
  16. + (void)registerExternalComponent:(NSString *)name callback:(RNNExternalViewCreator)callback {
  17. [[ReactNativeNavigation sharedInstance].bridgeManager registerExternalComponent:name callback:callback];
  18. }
  19. + (RCTBridge *)getBridge {
  20. return [[ReactNativeNavigation sharedInstance].bridgeManager bridge];
  21. }
  22. # pragma mark - instance
  23. + (instancetype) sharedInstance {
  24. static ReactNativeNavigation *instance = nil;
  25. static dispatch_once_t onceToken = 0;
  26. dispatch_once(&onceToken,^{
  27. if (instance == nil) {
  28. instance = [[ReactNativeNavigation alloc] init];
  29. }
  30. });
  31. return instance;
  32. }
  33. -(void)bootstrap:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOptions {
  34. [self bootstrap:jsCodeLocation launchOptions:launchOptions bridgeManagerDelegate:nil];
  35. }
  36. -(void)bootstrap:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOptions bridgeManagerDelegate:(id<RNNBridgeManagerDelegate>)delegate {
  37. self.bridgeManager = [[RNNBridgeManager alloc] initWithJsCodeLocation:jsCodeLocation launchOptions:launchOptions bridgeManagerDelegate:delegate];
  38. [RNNSplashScreen show];
  39. }
  40. @end