react-native-navigation的迁移库

RNNNavigationEvent.m 1.0KB

123456789101112131415161718192021222324252627
  1. #import "RNNNavigationEvent.h"
  2. @interface RNNNavigationEvent ()
  3. @property (nonatomic, strong) NavigationCommand command;
  4. @property (nonatomic, strong) NSString* toComponentId;
  5. @property (nonatomic, strong) NSString* fromComponentId;
  6. @end
  7. @implementation RNNNavigationEvent
  8. + (instancetype)create:(NavigationCommand)commandType fromComponent:(NSString *)fromComponentId toComponent:(NSString *)toComponentId {
  9. RNNNavigationEvent* navigationCommand = [[RNNNavigationEvent alloc] init];
  10. navigationCommand.command = commandType;
  11. navigationCommand.fromComponentId = fromComponentId;
  12. navigationCommand.toComponentId = toComponentId;
  13. return navigationCommand;
  14. }
  15. - (NSDictionary *)body {
  16. NSMutableDictionary* mutableParams = [NSMutableDictionary new];
  17. self.fromComponentId ? [mutableParams setObject:self.fromComponentId forKey:@"fromComponentId"] : nil;
  18. self.toComponentId ? [mutableParams setObject:self.toComponentId forKey:@"toComponentId"] : nil;
  19. return @{@"commandName": self.command, @"params": mutableParams};
  20. }
  21. @end