Skip to content

Commit 19a8e5f

Browse files
author
caven775
committed
reaplce节点发送生命周期
1 parent 5b8c5d7 commit 19a8e5f

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

ios/Classes/Node/DNode.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ - (NSString *)actionTypeString
4747
case DNodeActionTypePush:{action = @"push";break;}
4848
case DNodeActionTypePresent:{action = @"present";break;}
4949
case DNodeActionTypePop:{action = @"pop";break;}
50-
case DNodeActionTypePopTo:{action = @"popTo";}
51-
case DNodeActionTypePopToRoot:{action = @"popToRoot";}
50+
case DNodeActionTypePopTo:{action = @"popTo";break;}
51+
case DNodeActionTypePopToRoot:{action = @"popToRoot";break;}
5252
case DNodeActionTypePopToNativeRoot:{action = @"popToNativeRoot";break;}
5353
case DNodeActionTypePopSkip:{action = @"popSkip";break;}
5454
case DNodeActionTypeGesture:{action = @"gesture";break;}

ios/Classes/Node/DNodeManager.m

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ - (NSArray *)subArrayWithNode:(DNode *)node
6363
DNode *lastNode = self.nodeList.lastObject;
6464
if (lastNode) {
6565
DStackLog(@"被Replace的节点 === %@", lastNode);
66+
[self sendPageLifeCicleToFlutterWithAppearNode:node
67+
disappearNode:lastNode
68+
actionType:node.actionTypeString];
6669
[lastNode copyWithNode:node];
6770
self.pageCount = self.nodeList.count;
6871
[self dStackDelegateSafeWithSEL:@selector(dStack:inStack:) exe:^(DStack *stack) {
@@ -170,7 +173,10 @@ - (NSArray *)popNodeToListWithNode:(DNode *)node
170173
if (node.fromFlutter) {
171174
subArray = @[lastNode];
172175
} else {
173-
subArray = [self checkRemovedNode:node needRemove:lastNode];
176+
BOOL match = [node.identifier isEqualToString:lastNode.identifier];
177+
if (match) {
178+
subArray = @[lastNode];
179+
}
174180
}
175181
}
176182
}
@@ -266,7 +272,7 @@ - (NSArray *)inStackWithNode:(DNode *)node
266272
}];
267273
[self sendPageLifeCicleToFlutterWithAppearNode:node
268274
disappearNode:self.preNode
269-
isPush:YES];
275+
actionType:node.actionTypeString];
270276
DStackLog(@"来自【%@】的【%@】消息,入栈节点为 == %@, 入栈后的节点列表 == %@", [self _page:node], node.actionTypeString, subArray, self.nodeList);
271277
[self writeLogWithNode:node];
272278
return subArray;
@@ -277,6 +283,14 @@ - (NSArray *)inStackWithNode:(DNode *)node
277283
/// @param subArray 出栈列表
278284
- (void)outStackWithNode:(DNode *)node nodeArray:(NSArray *)subArray
279285
{
286+
// 根节点不能出出栈
287+
NSMutableArray *tempArray = [[NSMutableArray alloc] init];
288+
for (DNode *x in subArray) {
289+
if (!x.isRootPage) {
290+
[tempArray addObject:x];
291+
}
292+
}
293+
subArray = [tempArray copy];
280294
if (!subArray.count) { return;}
281295
[self.nodeList removeObjectsInArray:subArray];
282296
self.removedNodes = [subArray copy];
@@ -291,7 +305,7 @@ - (void)outStackWithNode:(DNode *)node nodeArray:(NSArray *)subArray
291305
}];
292306
[self sendPageLifeCicleToFlutterWithAppearNode:self.currentNode
293307
disappearNode:subArray.lastObject
294-
isPush:NO];
308+
actionType:node.actionTypeString];
295309
[self writeLogWithNode:node];
296310
if ([[DStack sharedInstance] debugMode]) {
297311
// 加入节点检查
@@ -333,7 +347,7 @@ - (void)sendAppliccationLifeCicleToFlutter:(DStackApplicationState)state
333347

334348
- (void)sendPageLifeCicleToFlutterWithAppearNode:(DNode *)appear
335349
disappearNode:(DNode *)disappear
336-
isPush:(BOOL)isPush
350+
actionType:(NSString *)actionType
337351
{
338352
DStack *stack = [DStack sharedInstance];
339353
DStackNode *stackAppearNode = [DActionManager stackNodeFromNode:appear];
@@ -345,7 +359,7 @@ - (void)sendPageLifeCicleToFlutterWithAppearNode:(DNode *)appear
345359
NSString *disappearRoute = stackDisappearNode.route ? stackDisappearNode.route : @"";
346360
NSDictionary *params = @{
347361
@"page": @{
348-
@"actionType": isPush ? @"push" : @"pop",
362+
@"actionType": actionType,
349363
@"appearRoute": appearRoute,
350364
@"disappearRoute": disappearRoute,
351365
@"appearPageType": appear.pageString ? appear.pageString : @"",

0 commit comments

Comments
 (0)