diff --git a/doric-iOS/Pod/Classes/DoricContext.h b/doric-iOS/Pod/Classes/DoricContext.h index f919c7cf..01ce3bba 100644 --- a/doric-iOS/Pod/Classes/DoricContext.h +++ b/doric-iOS/Pod/Classes/DoricContext.h @@ -40,7 +40,7 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, strong) NSString *script;; @property(nonatomic, strong) NSMutableDictionary *initialParams; @property(nonatomic, strong) DoricRootNode *rootNode; -@property(nonatomic, strong) NSMutableDictionary *headNodes; +@property(nonatomic, strong) NSMutableDictionary *> *headNodes; @property(nonatomic, copy) NSString *extra; - (instancetype)initWithScript:(NSString *)script source:(NSString *)source extra:(NSString *)extra; diff --git a/doric-iOS/Pod/Classes/DoricContext.m b/doric-iOS/Pod/Classes/DoricContext.m index 7e9815ce..56e15d8a 100644 --- a/doric-iOS/Pod/Classes/DoricContext.m +++ b/doric-iOS/Pod/Classes/DoricContext.m @@ -49,8 +49,13 @@ - (DoricViewNode *)targetViewNode:(NSString *)viewId { if ([self.rootNode.viewId isEqualToString:viewId]) { return self.rootNode; } else { - return self.headNodes[viewId]; + for (NSMutableDictionary *map in self.headNodes.allValues) { + if ([[map allKeys] containsObject:viewId]) { + return map[viewId]; + } + } } + return nil; } - (void)dealloc { diff --git a/doric-iOS/Pod/Classes/Plugin/DoricPopoverPlugin.m b/doric-iOS/Pod/Classes/Plugin/DoricPopoverPlugin.m index 43125f51..f268c5db 100644 --- a/doric-iOS/Pod/Classes/Plugin/DoricPopoverPlugin.m +++ b/doric-iOS/Pod/Classes/Plugin/DoricPopoverPlugin.m @@ -11,6 +11,8 @@ @interface DoricPopoverPlugin () @end @implementation DoricPopoverPlugin +static NSString *TYPE = @"popover"; + - (void)show:(NSDictionary *)params withPromise:(DoricPromise *)promise { dispatch_async(dispatch_get_main_queue(), ^{ UIView *superView = [UIApplication sharedApplication].windows.lastObject; @@ -33,7 +35,15 @@ - (void)show:(NSDictionary *)params withPromise:(DoricPromise *)promise { [it initWithSuperNode:nil]; it.view.layoutConfig = [DoricLayoutConfig new]; [self.fullScreenView addSubview:it.view]; - self.doricContext.headNodes[viewId] = it; + + NSMutableDictionary *map = self.doricContext.headNodes[TYPE]; + if (map != nil) { + self.doricContext.headNodes[TYPE][viewId] = it; + } else { + map = [[NSMutableDictionary alloc] init]; + map[viewId] = it; + self.doricContext.headNodes[TYPE] = map; + } }]; } [viewNode blend:params[@"props"]]; @@ -55,15 +65,15 @@ - (void)dismiss:(NSDictionary *)params withPromise:(DoricPromise *)promise { } - (void)dismissViewNode:(DoricViewNode *)node { - [self.doricContext.headNodes removeObjectForKey:node.viewId]; + [self.doricContext.headNodes[TYPE] removeObjectForKey:node.viewId]; [node.view removeFromSuperview]; - if (self.doricContext.headNodes.count == 0) { + if (self.doricContext.headNodes[TYPE].count == 0) { self.fullScreenView.hidden = YES; } } - (void)dismissPopover { - for (DoricViewNode *node in self.doricContext.headNodes.allValues) { + for (DoricViewNode *node in self.doricContext.headNodes[TYPE].allValues) { [self dismissViewNode:node]; } }