Skip to content

Commit 0ba9ed0

Browse files
author
caven775
committed
添加测试用例
1 parent b3b3acb commit 0ba9ed0

File tree

6 files changed

+294
-105
lines changed

6 files changed

+294
-105
lines changed

example/ios/Runner/AppDelegate.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ - (void)dStack:(nonnull DStack *)stack presentWithNode:(nonnull DStackNode *)nod
4040
UINavigationController *navi = [self dStack:stack navigationControllerForNode:node];
4141
if ([node.route isEqualToString:@"NativePage2"]) {
4242
didPushController = [[FourViewController alloc] init];
43-
[navi.topViewController presentViewController:didPushController animated:YES completion:nil];
43+
[navi.topViewController presentViewController:didPushController animated:node.animated completion:nil];
4444
}
4545
}
4646

@@ -50,7 +50,7 @@ - (void)dStack:(nonnull DStack *)stack pushWithNode:(nonnull DStackNode *)node
5050
UINavigationController *navi = [self dStack:stack navigationControllerForNode:node];
5151
if ([node.route isEqualToString:@"NativePage"]) {
5252
didPresentController = [[ThirdViewController alloc] init];
53-
[navi pushViewController:didPresentController animated:YES];
53+
[navi pushViewController:didPresentController animated:node.animated];
5454
}
5555
}
5656

example/lib/page_widgets.dart

Lines changed: 28 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
* tartget: page_widgets
88
*/
99

10-
//import 'package:battery/battery.dart';
11-
import 'dart:io';
12-
1310
import 'package:d_stack/d_stack.dart';
11+
import 'package:d_stack_example/test_case.dart';
1412
import 'package:flutter/material.dart';
1513

1614
class Student {
@@ -26,6 +24,29 @@ class Page1 extends StatefulWidget {
2624
}
2725
}
2826

27+
Widget _caseWidget(List<Map> items) {
28+
return Center(
29+
child: ListView.builder(
30+
itemExtent: 60,
31+
itemCount: items.length,
32+
itemBuilder: (BuildContext context, index) {
33+
Map caseMap = items[index];
34+
return GestureDetector(
35+
behavior: HitTestBehavior.opaque,
36+
child: Container(
37+
alignment: Alignment.center,
38+
decoration: BoxDecoration(
39+
border:
40+
Border(bottom: BorderSide(color: Colors.grey, width: 0.5))),
41+
child: Text(caseMap["text"]),
42+
),
43+
onTap: caseMap["clicked"],
44+
);
45+
},
46+
),
47+
);
48+
}
49+
2950
class _Page1 extends State<Page1> {
3051
@override
3152
Widget build(BuildContext context) {
@@ -39,57 +60,7 @@ class _Page1 extends State<Page1> {
3960
},
4061
)),
4162
backgroundColor: Colors.white,
42-
body: Center(
43-
child: Column(
44-
children: [
45-
TextField(),
46-
RaisedButton(
47-
child: Text('push flutter page 2'),
48-
onPressed: () {
49-
Student student = Student();
50-
student.name = '😁🍎111';
51-
student.age = 12;
52-
53-
// 自定义动画
54-
// DStack.animationPage('page2', PageType.flutter,
55-
// (BuildContext context,
56-
// Animation<double> animation,
57-
// Animation<double> secondaryAnimation,
58-
// WidgetBuilder widgetBuilder) {
59-
// Offset startOffset = const Offset(1.0, 0.0);
60-
// Offset endOffset = const Offset(0.0, 0.0);
61-
// return SlideTransition(
62-
// position: new Tween<Offset>(
63-
// begin: startOffset,
64-
// end: endOffset,
65-
// ).animate(animation),
66-
// child: widgetBuilder(context),
67-
// );
68-
// },
69-
// params: {'key1': 12},
70-
// transitionDuration: Duration(milliseconds: 250));
71-
72-
// DStack.pushWithAnimation('page2', PageType.flutter,
73-
// (context, animation, secondaryAnimation, child) {
74-
// Offset startOffset = const Offset(1.0, 0.0);
75-
// Offset endOffset = const Offset(0.0, 0.0);
76-
// return SlideTransition(
77-
// position: new Tween<Offset>(
78-
// begin: startOffset,
79-
// end: endOffset,
80-
// ).animate(animation),
81-
// child: child,
82-
// );
83-
// }, popGesture: true);
84-
85-
DStack.push('page2', PageType.flutter).then((data) {
86-
return print('pop to Page1 result $data');
87-
});
88-
},
89-
),
90-
],
91-
),
92-
),
63+
body: _caseWidget(TestCase.openFlutterPageCase),
9364
);
9465
}
9566

@@ -111,41 +82,17 @@ class Page2 extends StatelessWidget {
11182
leading: RaisedButton(
11283
child: Text('返回'),
11384
onPressed: () {
114-
Student student = Student();
115-
student.name = '😁🍎33333';
116-
student.age = 12;
117-
DStack.pop(result: {'params': 'value222'}, animated: false);
85+
DStack.pop();
11886
},
11987
)),
120-
body: Center(
121-
child: RaisedButton(
122-
child: Text('present flutter page 3'),
123-
onPressed: () {
124-
// DStack.present('page3', PageType.flutter);
125-
DStack.push('page3', PageType.flutter);
126-
},
127-
),
128-
),
88+
body: _caseWidget(TestCase.closeFlutterPage),
12989
);
13090
}
13191
}
13292

13393
class Page3 extends StatelessWidget {
13494
@override
13595
Widget build(BuildContext context) {
136-
Widget present() {
137-
if (Platform.isIOS) {
138-
return RaisedButton(
139-
child: Text('Present打开NativePage2'),
140-
onPressed: () {
141-
DStack.push("NativePage2", PageType.native,
142-
params: {"name": "flutter 传递的", "id": 1000000});
143-
},
144-
);
145-
}
146-
return Container();
147-
}
148-
14996
return Scaffold(
15097
appBar: AppBar(
15198
title: Text('flutter page3'),
@@ -155,20 +102,7 @@ class Page3 extends StatelessWidget {
155102
DStack.pop();
156103
},
157104
)),
158-
body: Center(
159-
child: Column(
160-
children: <Widget>[
161-
RaisedButton(
162-
child: Text('打开NativePage'),
163-
onPressed: () {
164-
// DStack.push("NativePage", PageType.native,
165-
// params: {"name": "flutter 传递的", "id": 1000000});
166-
DStack.popTo("page1", PageType.flutter, animated: true);
167-
},
168-
),
169-
present(),
170-
],
171-
)),
105+
body: _caseWidget(TestCase.popToPage),
172106
);
173107
}
174108
}

0 commit comments

Comments
 (0)