@@ -219,6 +219,7 @@ - (BOOL)presentationControllerShouldDismiss:(UIPresentationController *)presenta
219
219
{
220
220
NSString *name = presentationController.oldDismissDelegateName ;
221
221
UIViewController *presented = presentationController.presentedViewController ;
222
+ presented.isGesturePoped = YES ;
222
223
if ([presented isKindOfClass: UINavigationController.class]) {
223
224
presented = [(UINavigationController *)presented topViewController ];
224
225
}
@@ -238,22 +239,7 @@ - (void)presentationControllerWillDismiss:(UIPresentationController *)presentati
238
239
if ([presented isKindOfClass: UINavigationController.class]) {
239
240
presented = [(UINavigationController *)presented topViewController ];
240
241
}
241
- UIViewController *willAppear = presented.presentingViewController ;
242
- if ([willAppear isKindOfClass: UITabBarController.class]) {
243
- willAppear = [(UITabBarController *)willAppear selectedViewController ];
244
- if ([willAppear isKindOfClass: UINavigationController.class]) {
245
- willAppear = [(UINavigationController *)willAppear topViewController ];
246
- }
247
- } else if ([willAppear isKindOfClass: UINavigationController.class]) {
248
- willAppear = [(UINavigationController *)willAppear topViewController ];
249
- }
250
- if ([willAppear isKindOfClass: DFlutterViewController.class]) {
251
- DStack *stack = [DStack sharedInstance ];
252
- if (!stack.engine .viewController ) {
253
- DFlutterViewController *flutterVC = (DFlutterViewController *)willAppear;
254
- [flutterVC willUpdateView ];
255
- }
256
- }
242
+ [self willAppearViewController: presented.presentingViewController];
257
243
[self checkSelectorToDelegate: @selector (presentationControllerWillDismiss: )
258
244
controller: presentationController
259
245
forward: ^(id <UIAdaptivePresentationControllerDelegate> delegate) {
@@ -269,16 +255,7 @@ - (void)presentationControllerDidDismiss:(UIPresentationController *)presentatio
269
255
target = [[(UINavigationController *)presented viewControllers ] firstObject ];
270
256
checkNode (target, DNodeActionTypePopTo);
271
257
}
272
-
273
- DNodeManager *manager = [DNodeManager sharedInstance ];
274
- DNode *didAppearNode = [manager preNode ];
275
- if (didAppearNode.pageType == DNodePageTypeFlutter) {
276
- DStack *stack = [DStack sharedInstance ];
277
- if (stack.engine .viewController ) {
278
- DFlutterViewController *flutterVC = (DFlutterViewController *)stack.engine .viewController ;
279
- [flutterVC didUpdateView ];
280
- }
281
- }
258
+ [self didAppearViewControllerWithGestureDismiss: YES ];
282
259
checkNode (target, DNodeActionTypeGesture);
283
260
[self checkSelectorToDelegate: @selector (presentationControllerDidDismiss: )
284
261
controller: presentationController
@@ -337,6 +314,38 @@ - (BOOL)gestureRecognizerShouldBeginWithNavigationController:(UINavigationContro
337
314
return shouldBegin;
338
315
}
339
316
317
+ - (void )willAppearViewController : (UIViewController *)willAppear
318
+ {
319
+ if ([willAppear isKindOfClass: UITabBarController.class]) {
320
+ willAppear = [(UITabBarController *)willAppear selectedViewController ];
321
+ if ([willAppear isKindOfClass: UINavigationController.class]) {
322
+ willAppear = [(UINavigationController *)willAppear topViewController ];
323
+ }
324
+ } else if ([willAppear isKindOfClass: UINavigationController.class]) {
325
+ willAppear = [(UINavigationController *)willAppear topViewController ];
326
+ }
327
+ if ([willAppear isKindOfClass: DFlutterViewController.class]) {
328
+ DStack *stack = [DStack sharedInstance ];
329
+ if (!stack.engine .viewController ) {
330
+ DFlutterViewController *flutterVC = (DFlutterViewController *)willAppear;
331
+ [flutterVC willUpdateView ];
332
+ }
333
+ }
334
+ }
335
+
336
+ - (void )didAppearViewControllerWithGestureDismiss : (BOOL )gesture
337
+ {
338
+ DNodeManager *manager = [DNodeManager sharedInstance ];
339
+ DNode *didAppearNode = gesture ? [manager preNode ] : [manager currentNode ];
340
+ if (didAppearNode.pageType == DNodePageTypeFlutter) {
341
+ DStack *stack = [DStack sharedInstance ];
342
+ if (stack.engine .viewController ) {
343
+ DFlutterViewController *flutterVC = (DFlutterViewController *)stack.engine .viewController ;
344
+ [flutterVC didUpdateView ];
345
+ }
346
+ }
347
+ }
348
+
340
349
- (NSMutableDictionary <NSString *,id> *)dismissDelegateClass
341
350
{
342
351
if (!_dismissDelegateClass) {
@@ -447,6 +456,7 @@ - (void)d_stackDismissViewControllerAnimated:(BOOL)flag completion:(void (^)(voi
447
456
UIViewController *dismiss = _DStackCurrentController (self);
448
457
if (!dismiss.isGesturePoped ) {
449
458
// 不是手势触发的dismiss
459
+ [[DStackNavigator instance ] willAppearViewController: dismiss.presentingViewController];
450
460
checkNode (dismiss, DNodeActionTypeDismiss);
451
461
}
452
462
}
@@ -473,6 +483,9 @@ - (void)d_stackViewDidDisappear:(BOOL)animated
473
483
if (![self isFlutterViewController ]) {
474
484
[self removeGesturePopNode ];
475
485
}
486
+ if (self.beingDismissed && !self.isGesturePoped ) {
487
+ [[DStackNavigator instance ] didAppearViewControllerWithGestureDismiss: NO ];
488
+ }
476
489
}
477
490
478
491
- (void )setIsGesturePoped : (BOOL )isGesturePoped
0 commit comments