react-native-navigation的迁移库

RNNExternalComponentStore.m 712B

123456789101112131415161718192021222324252627
  1. #import "RNNExternalComponentStore.h"
  2. @interface RNNExternalComponentStore ()
  3. @end
  4. @implementation RNNExternalComponentStore {
  5. NSMutableDictionary* _externalComponentCreators;
  6. }
  7. -(instancetype)init {
  8. self = [super init];
  9. _externalComponentCreators = [NSMutableDictionary new];
  10. return self;
  11. }
  12. - (void)registerExternalComponent:(NSString *)name callback:(RNNExternalViewCreator)callback {
  13. [_externalComponentCreators setObject:[callback copy] forKey:name];
  14. }
  15. - (UIViewController *)getExternalComponent:(RNNLayoutInfo *)layoutInfo bridge:(RCTBridge *)bridge {
  16. RNNExternalViewCreator creator = [_externalComponentCreators objectForKey:layoutInfo.name];
  17. return creator(layoutInfo.props, bridge);
  18. }
  19. @end