Skip to content

Commit 3aab956

Browse files
author
caven775
committed
bug修复
1 parent 0a253d2 commit 3aab956

File tree

9 files changed

+62
-45
lines changed

9 files changed

+62
-45
lines changed

example/ios/Runner/AppDelegate.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010

1111
@DStackInject(AppDelegate);
1212

13-
@interface AppDelegate () <DStackDelegate, UITabBarControllerDelegate, UIAdaptivePresentationControllerDelegate>
13+
@interface AppDelegate () <DStackDelegate, UITabBarControllerDelegate>
1414

1515
@end
1616

17-
static BOOL isFlutterProject = NO;
17+
static BOOL isFlutterProject = YES;
1818

1919
@implementation AppDelegate
2020

@@ -95,9 +95,9 @@ - (void)dStack:(nonnull DStack *)stack pushWithNode:(nonnull DStackNode *)node
9595
UINavigationController *navi = [self dStack:stack navigationControllerForNode:node];
9696
if ([node.route isEqualToString:@"NativePage"]) {
9797
didPushController = [[ThirdViewController alloc] init];
98-
didPushController.hidesBottomBarWhenPushed = YES;
9998
} else if ([node.route isEqualToString:@"SixViewController"]) {
10099
didPushController = [[SixViewController alloc] init];
100+
didPushController.hidesBottomBarWhenPushed = YES;
101101
}
102102
[navi pushViewController:didPushController animated:node.animated];
103103
}

example/ios/Runner/DStackTestCase.m

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,33 @@ - (void)initData
161161
[controller.navigationController pushViewController:five animated:YES];
162162
}
163163
},
164+
@{
165+
@"text": @"弹窗",
166+
@"clicked": ^(UIViewController *controller) {
167+
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"弹窗"
168+
message:@"弹出来了" preferredStyle:UIAlertControllerStyleAlert];
169+
UIAlertAction *action = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleCancel handler:nil];
170+
[alert addAction:action];
171+
[controller presentViewController:alert animated:YES completion:nil];
172+
}
173+
},
174+
@{
175+
@"text": @"调取相册",
176+
@"clicked": ^(UIViewController *controller) {
177+
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
178+
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
179+
180+
[controller presentViewController:picker animated:YES completion:nil];
181+
}
182+
},
183+
@{
184+
@"text": @"present 有navigation的FiveVC",
185+
@"clicked": ^(UIViewController *controller) {
186+
FiveViewController *five = [[FiveViewController alloc] init];
187+
DStackViewController *navi = [[DStackViewController alloc] initWithRootViewController:five];
188+
[controller presentViewController:navi animated:YES completion:nil];
189+
}
190+
},
164191
];
165192

166193
_sixVCSource = @[

example/ios/Runner/FourViewController.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88

99
#import "FourViewController.h"
1010

11-
@interface FourViewController ()<UIAdaptivePresentationControllerDelegate>
11+
@interface FourViewController ()
1212

1313
@end
1414

1515
@implementation FourViewController
1616

1717
- (void)viewDidLoad {
1818
[super viewDidLoad];
19-
// self.presentationController.delegate = self;
2019
}
2120

2221
- (NSArray *)dataSource

example/lib/page_widgets.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class Page7 extends StatelessWidget {
156156
Widget build(BuildContext context) {
157157
return Scaffold(
158158
appBar: AppBar(
159-
title: Text('flutter page6'),
159+
title: Text('flutter page7'),
160160
leading: RaisedButton(
161161
child: Text('返回'),
162162
onPressed: () {

example/lib/test_case.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ class TestCase {
168168
},
169169
{"text": "", "clicked": () {}},
170170
{
171-
"text": "【push】NativePage 有动画",
171+
"text": "【push】SixViewController 有动画",
172172
"clicked": () {
173-
DStack.push("NativePage", PageType.native,
173+
DStack.push("SixViewController", PageType.native,
174174
params: {"name": "flutter 传递的", "id": 1000000});
175175
}
176176
},

ios/Classes/Stack/DFlutterViewController.m

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77

88
#import "DFlutterViewController.h"
9+
#import "DNodeManager.h"
910
#import "DActionManager.h"
1011
#import <objc/runtime.h>
1112
#import "DNavigator.h"
@@ -101,6 +102,15 @@ - (void)checkSelfIsInTabBarController
101102
[DActionManager tabBarWillSelectViewController:selectedViewController
102103
homePageRoute:[DStack sharedInstance].flutterHomePageRoute];
103104
}
105+
} else {
106+
// 检查是不是flutter工程
107+
if ([DActionManager rootControllerIsFlutterController]) {
108+
DNode *node = [[DNode alloc] init];
109+
node.pageType = DNodePageTypeFlutter;
110+
node.action = DNodeActionTypeReplace;
111+
node.target = [DStack sharedInstance].flutterHomePageRoute;
112+
[[DNodeManager sharedInstance] updateRootNode:node];
113+
}
104114
}
105115
}
106116

@@ -137,6 +147,7 @@ - (void)addNotification
137147

138148
- (void)changeBottomBarVisible:(NSNotification *)notification
139149
{
150+
if (!self.tabBarController) {return;}
140151
NSDictionary *userInfo = notification.userInfo;
141152
if (!userInfo) {
142153
if (self.tabBarController.tabBar.hidden == NO) {

ios/Classes/Stack/DNavigator.m

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ BOOL hasFDClass()
3838
return _FDDelegate != NULL;
3939
}
4040

41-
void checkNode(UIViewController *targetVC, DNodeActionType action)
41+
void _checkNodeParams(UIViewController *targetVC, DNodeActionType action, BOOL isFlutter)
4242
{
4343
if (!targetVC) {return;}
4444
NSString *scheme = NSStringFromClass(targetVC.class);
@@ -49,14 +49,19 @@ void checkNode(UIViewController *targetVC, DNodeActionType action)
4949
NSString *identifier = [NSString stringWithFormat:@"%@_%p",
5050
NSStringFromClass(targetVC.class), targetVC];
5151
node.identifier = identifier;
52-
if ([targetVC isKindOfClass:FlutterViewController.class]) {
52+
if (isFlutter) {
5353
node.boundary = YES;
5454
node.fromFlutter = YES;
5555
node.pageType = DNodePageTypeFlutter;
5656
}
5757
[[DNodeManager sharedInstance] checkNode:node];
5858
}
5959

60+
void checkNode(UIViewController *targetVC, DNodeActionType action)
61+
{
62+
_checkNodeParams(targetVC, action, NO);
63+
}
64+
6065
UIViewController *_DStackCurrentController(UIViewController *controller)
6166
{
6267
if (!controller) { return nil;}
@@ -555,7 +560,7 @@ - (BOOL)dStack_interactivePopDisabled
555560
- (void)removeGesturePopNode
556561
{
557562
if (self.isGesturePoped && self.isBeginPoped) {
558-
checkNode(self, DNodeActionTypeGesture);
563+
_checkNodeParams(self, DNodeActionTypeGesture, [self isKindOfClass:DFlutterViewController.class]);
559564
}
560565
}
561566

@@ -708,7 +713,11 @@ - (UIViewController *)d_stackPopViewControllerAnimated:(BOOL)animated
708713
checkNode(viewController, DNodeActionTypePopTo);
709714
}
710715
}
711-
return [self d_stackPopToViewController:viewController animated:animated];
716+
if (viewController) {
717+
return [self d_stackPopToViewController:viewController animated:animated];
718+
}
719+
DStackError(@"PopTo的controller为空");
720+
return @[];
712721
}
713722

714723
- (NSArray<UIViewController *> *)d_stackPopToRootViewControllerAnimated:(BOOL)animated

ios/Classes/Stack/DStack.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,10 @@ - (FlutterEngine *)engine
433433

434434
- (NSString *)flutterHomePageRoute
435435
{
436-
return self.homePageRoute;
436+
if (self.homePageRoute) {
437+
return self.homePageRoute;
438+
}
439+
return @"/";
437440
}
438441

439442
- (FlutterEngine *)engineFromProtocol

lib/navigator/dnavigator_manager.dart

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import 'package:d_stack/navigator/node_entity.dart';
1616
import 'package:d_stack/widget/page_route.dart';
1717
import 'package:flutter/cupertino.dart';
1818
import 'package:flutter/foundation.dart';
19-
import 'package:flutter/gestures.dart';
2019
import 'package:flutter/material.dart';
2120

2221
/// 主要两个部分:
@@ -399,37 +398,6 @@ class DNavigatorManager {
399398
return null;
400399
}
401400

402-
/// 从下往上弹出动画
403-
static PageRouteBuilder slideRoute(
404-
{String routeName,
405-
Map params,
406-
int milliseconds,
407-
bool fullscreenDialog = false}) {
408-
return animationRoute(
409-
routeName: routeName,
410-
params: params,
411-
animatedBuilder: (BuildContext context, Animation<double> animation,
412-
Animation<double> secondaryAnimation, WidgetBuilder widgetBuilder) {
413-
double startOffsetX = fullscreenDialog ? 0 : 1.0;
414-
double startOffsetY = fullscreenDialog ? 1.0 : 0;
415-
Offset startOffset = Offset(startOffsetX, startOffsetY);
416-
Offset endOffset = const Offset(0, 0);
417-
418-
return SlideTransition(
419-
transformHitTests: true,
420-
position: new Tween<Offset>(
421-
begin: startOffset,
422-
end: endOffset,
423-
).animate(CurvedAnimation(
424-
parent: animation,
425-
curve: Curves.easeInOutCubic,
426-
)),
427-
child: widgetBuilder(context),
428-
);
429-
},
430-
transitionDuration: Duration(milliseconds: milliseconds));
431-
}
432-
433401
/// 用户自定义flutter页面转场动画
434402
static PageRouteBuilder animationRoute({
435403
@required AnimatedPageBuilder animatedBuilder,

0 commit comments

Comments
 (0)