react-native-navigation的迁移库

RNNBridgeModule.m 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #import "RNNBridgeModule.h"
  2. @implementation RNNBridgeModule {
  3. RNNCommandsHandler* _commandsHandler;
  4. }
  5. @synthesize bridge = _bridge;
  6. RCT_EXPORT_MODULE();
  7. - (dispatch_queue_t)methodQueue {
  8. return dispatch_get_main_queue();
  9. }
  10. -(instancetype)initWithCommandsHandler:(RNNCommandsHandler *)commandsHandler {
  11. self = [super init];
  12. _commandsHandler = commandsHandler;
  13. return self;
  14. }
  15. #pragma mark - JS interface
  16. RCT_EXPORT_METHOD(setRoot:(NSDictionary*)layout) {
  17. [_commandsHandler setRoot:layout];
  18. }
  19. RCT_EXPORT_METHOD(setOptions:(NSString*)containerId options:(NSDictionary*)options) {
  20. [_commandsHandler setOptions:containerId options:options];
  21. }
  22. RCT_EXPORT_METHOD(push:(NSString*)containerId layout:(NSDictionary*)layout resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
  23. [_commandsHandler push:containerId layout:layout completion:^(id result) {
  24. resolve(result);
  25. }];
  26. }
  27. RCT_EXPORT_METHOD(pop:(NSString*)containerId options:(NSDictionary*)options) {
  28. [_commandsHandler pop:containerId options:(NSDictionary*)options];
  29. }
  30. RCT_EXPORT_METHOD(popTo:(NSString*)containerId) {
  31. [_commandsHandler popTo:containerId];
  32. }
  33. RCT_EXPORT_METHOD(popToRoot:(NSString*)containerId) {
  34. [_commandsHandler popToRoot:containerId];
  35. }
  36. RCT_EXPORT_METHOD(showModal:(NSDictionary*)layout resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
  37. [_commandsHandler showModal:layout completion:^(id containerID) {
  38. resolve(containerID);
  39. }];
  40. }
  41. RCT_EXPORT_METHOD(dismissModal:(NSString*)containerId) {
  42. [_commandsHandler dismissModal:containerId];
  43. }
  44. RCT_EXPORT_METHOD(dismissAllModals) {
  45. [_commandsHandler dismissAllModals];
  46. }
  47. @end