Skip to content

Commit 709c1e8

Browse files
committed
搜索页增加打开动画
1 parent 637abcf commit 709c1e8

File tree

4 files changed

+282
-93
lines changed

4 files changed

+282
-93
lines changed

lib/common/router/anima_route.dart

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import 'package:flutter/material.dart';
2+
3+
///动画大小变化打开的路由
4+
class SizeRoute extends PageRouteBuilder {
5+
final Widget widget;
6+
7+
SizeRoute({this.widget})
8+
: super(
9+
pageBuilder: (
10+
BuildContext context,
11+
Animation<double> animation,
12+
Animation<double> secondaryAnimation,
13+
) =>
14+
widget,
15+
transitionsBuilder: (
16+
BuildContext context,
17+
Animation<double> animation,
18+
Animation<double> secondaryAnimation,
19+
Widget child,
20+
) =>
21+
Align(
22+
child: SizeTransition(
23+
sizeFactor: animation,
24+
child: child,
25+
),
26+
),
27+
);
28+
}
29+
30+
class NoAnimationRoute extends PageRouteBuilder {
31+
final Widget widget;
32+
33+
NoAnimationRoute({this.widget})
34+
: super(
35+
pageBuilder: (
36+
BuildContext context,
37+
Animation<double> animation,
38+
Animation<double> secondaryAnimation,
39+
) =>
40+
widget,
41+
transitionsBuilder: (
42+
BuildContext context,
43+
Animation<double> animation,
44+
Animation<double> secondaryAnimation,
45+
Widget child,
46+
) =>
47+
new SlideTransition(
48+
position: new Tween<Offset>(
49+
begin: const Offset(0.0, 0.0),
50+
end: const Offset(0.0, 0.0),
51+
).animate(animation),
52+
child: child,
53+
),
54+
);
55+
}

lib/common/router/size_route.dart

Lines changed: 0 additions & 28 deletions
This file was deleted.

lib/common/utils/navigator_utils.dart

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import 'dart:async';
22

33
import 'package:flutter/cupertino.dart';
44
import 'package:flutter/material.dart';
5-
import 'package:gsy_github_app_flutter/common/router/size_route.dart';
5+
import 'package:gsy_github_app_flutter/common/router/anima_route.dart';
66
import 'package:gsy_github_app_flutter/page/code_detail_page.dart';
77
import 'package:gsy_github_app_flutter/page/code_detail_page_web.dart';
88
import 'package:gsy_github_app_flutter/page/common_list_page.dart';
@@ -138,7 +138,29 @@ class NavigatorUtils {
138138

139139
///搜索
140140
static Future goSearchPage(BuildContext context) {
141-
return NavigatorRouter(context, new SearchPage());
141+
return showGeneralDialog(
142+
context: context,
143+
pageBuilder: (BuildContext buildContext, Animation<double> animation,
144+
Animation<double> secondaryAnimation) {
145+
return Builder(builder: (BuildContext context) {
146+
return pageContainer(SearchPage());
147+
});
148+
},
149+
barrierDismissible: false,
150+
barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
151+
barrierColor: Color(0x01000000),
152+
transitionDuration: const Duration(milliseconds: 150),
153+
transitionBuilder: (BuildContext context, Animation<double> animation,
154+
Animation<double> secondaryAnimation, Widget child) {
155+
return FadeTransition(
156+
opacity: CurvedAnimation(
157+
parent: animation,
158+
curve: Curves.easeOut,
159+
),
160+
child: child,
161+
);
162+
},
163+
);
142164
}
143165

144166
///提交详情

0 commit comments

Comments
 (0)