Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1082992

Browse files
committed
部分dialog加入弹出动画
1 parent 84a4bf3 commit 1082992

File tree

12 files changed

+68
-41
lines changed

12 files changed

+68
-41
lines changed

lib/account/add_withdrawal_account_page.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
22
import 'package:flutter_deer/account/account_router.dart';
33
import 'package:flutter_deer/res/resources.dart';
44
import 'package:flutter_deer/routers/fluro_navigator.dart';
5+
import 'package:flutter_deer/util/utils.dart';
56
import 'package:flutter_deer/widgets/app_bar.dart';
67
import 'package:flutter_deer/widgets/my_button.dart';
78
import 'package:flutter_deer/widgets/store_select_text_item.dart';
@@ -131,7 +132,7 @@ class _AddWithdrawalAccountPageState extends State<AddWithdrawalAccountPage> {
131132
}
132133

133134
_showSelectAccountTypeDialog() {
134-
showDialog(
135+
showElasticDialog(
135136
context: context,
136137
builder: (BuildContext context) {
137138
return Material(

lib/account/withdrawal_password_page.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
33
import 'package:flutter_deer/account/sms_verify_dialog.dart';
44
import 'package:flutter_deer/res/resources.dart';
55
import 'package:flutter_deer/routers/fluro_navigator.dart';
6+
import 'package:flutter_deer/util/utils.dart';
67
import 'package:flutter_deer/widgets/app_bar.dart';
78
import 'package:flutter_deer/widgets/base_dialog.dart';
89
import 'package:flutter_deer/widgets/click_item.dart';
@@ -39,7 +40,7 @@ class _WithdrawalPasswordPageState extends State<WithdrawalPasswordPage> {
3940
ClickItem(
4041
title: "忘记密码",
4142
onTap: (){
42-
showDialog(
43+
showElasticDialog(
4344
context: context,
4445
barrierDismissible: false,
4546
builder: (BuildContext context) {

lib/goods/goods_list.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,7 @@ class _GoodsListState extends State<GoodsList> with AutomaticKeepAliveClientMixi
177177
Column(
178178
crossAxisAlignment: CrossAxisAlignment.end,
179179
children: <Widget>[
180-
InkWell(
181-
splashColor: Colors.transparent,
182-
highlightColor: Colors.transparent,
180+
GestureDetector(
183181
child: Container(
184182
width: 24.0,
185183
height: 24.0,

lib/goods/goods_page.dart

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ class _GoodsState extends State<Goods> with SingleTickerProviderStateMixin, Auto
7575
key: _bodyKey,
7676
crossAxisAlignment: CrossAxisAlignment.start,
7777
children: <Widget>[
78-
InkWell(
79-
splashColor: Colors.transparent,
80-
highlightColor: Colors.transparent,
78+
GestureDetector(
8179
key: _buttonKey,
8280
child: Row(
8381
mainAxisSize: MainAxisSize.min,
@@ -219,9 +217,7 @@ class _GoodsState extends State<Goods> with SingleTickerProviderStateMixin, Auto
219217
fullWidth: true,
220218
position: position,
221219
elevation: 0.0,
222-
child: InkWell(
223-
splashColor: Colors.transparent,
224-
highlightColor: Colors.transparent,
220+
child: GestureDetector(
225221
onTap: (){
226222
NavigatorUtils.goBack(context);
227223
},
@@ -285,9 +281,7 @@ class _GoodsState extends State<Goods> with SingleTickerProviderStateMixin, Auto
285281
isShowBg: true,
286282
position: position,
287283
elevation: 0.0,
288-
child: InkWell(
289-
splashColor: Colors.transparent,
290-
highlightColor: Colors.transparent,
284+
child: GestureDetector(
291285
onTap: (){
292286
NavigatorUtils.goBack(context);
293287
},

lib/login/login_page.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,7 @@ class _LoginState extends State<Login> {
141141
Container(
142142
height: 40.0,
143143
alignment: Alignment.centerRight,
144-
child: InkWell(
145-
highlightColor: Colors.transparent,
146-
splashColor: Colors.transparent,
144+
child: GestureDetector(
147145
child: Text(
148146
'忘记密码',
149147
style: TextStyles.textGray12,
@@ -156,9 +154,7 @@ class _LoginState extends State<Login> {
156154
Gaps.vGap16,
157155
Container(
158156
alignment: Alignment.center,
159-
child: InkWell(
160-
highlightColor: Colors.transparent,
161-
splashColor: Colors.transparent,
157+
child: GestureDetector(
162158
child: Text(
163159
'还没账号?快去注册',
164160
style: TextStyle(

lib/login/sms_login_page.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ class _SMSLoginState extends State<SMSLogin> {
8585
Gaps.vGap10,
8686
Container(
8787
alignment: Alignment.centerLeft,
88-
child: InkWell(
89-
highlightColor: Colors.transparent,
90-
splashColor: Colors.transparent,
88+
child: GestureDetector(
9189
child: RichText(
9290
text: TextSpan(
9391
text: '提示:未注册账号的手机号,请先',
@@ -112,9 +110,7 @@ class _SMSLoginState extends State<SMSLogin> {
112110
Container(
113111
height: 40.0,
114112
alignment: Alignment.centerRight,
115-
child: InkWell(
116-
highlightColor: Colors.transparent,
117-
splashColor: Colors.transparent,
113+
child: GestureDetector(
118114
child: Text(
119115
'忘记密码',
120116
style: TextStyles.textGray12,

lib/order/order_page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ class _OrderState extends State<Order> with AutomaticKeepAliveClientMixin<Order>
319319
textColor: Colors.white,
320320
onPressed: (){
321321
if (_index == 2){
322-
showDialog(
322+
showElasticDialog(
323323
context: context,
324324
barrierDismissible: false,
325325
builder: (BuildContext context) {

lib/shop/freight_config_page.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class _FreightConfigPageState extends State<FreightConfigPage> {
8181
// 暂时没有对输入数据进行校验
8282
_buildItem(int index){
8383
return _list[index].isAdd ?
84-
InkWell(
84+
GestureDetector(
8585
onTap: (){
8686
var config = _list[index - 1];
8787
if (config.max.isNotEmpty && config.min.isNotEmpty) {
@@ -93,8 +93,6 @@ class _FreightConfigPageState extends State<FreightConfigPage> {
9393
return;
9494
}
9595
},
96-
highlightColor: Colors.transparent,
97-
splashColor: Colors.transparent,
9896
child: Container(
9997
height: 100.0,
10098
margin: const EdgeInsets.only(bottom: 8.0),

lib/shop/shop_setting_page.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'package:flutter_deer/routers/fluro_navigator.dart';
77
import 'package:flutter_deer/shop/pay_type_dialog.dart';
88
import 'package:flutter_deer/shop/shop_router.dart';
99
import 'package:flutter_deer/util/app_navigator.dart';
10+
import 'package:flutter_deer/util/utils.dart';
1011
import 'package:flutter_deer/widgets/app_bar.dart';
1112
import 'package:flutter_deer/widgets/click_item.dart';
1213
import 'package:flutter_deer/widgets/my_button.dart';
@@ -130,7 +131,7 @@ class _ShopSettingPageState extends State<ShopSettingPage> {
130131
title: "支付方式",
131132
content: _getPayType(),
132133
onTap: (){
133-
showDialog(
134+
showElasticDialog(
134135
context: context,
135136
barrierDismissible: false,
136137
builder: (BuildContext context) {
@@ -155,7 +156,7 @@ class _ShopSettingPageState extends State<ShopSettingPage> {
155156
title: "运费配置",
156157
content: _sendType == 0 ? "运费满免配置" : "运费比例配置",
157158
onTap: (){
158-
showDialog(
159+
showElasticDialog(
159160
context: context,
160161
barrierDismissible: false,
161162
builder: (BuildContext context) {

lib/util/utils.dart

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,51 @@ Widget _buildMaterialDialogTransitions(BuildContext context, Animation<double> a
5757
child: child,
5858
);
5959
}
60+
61+
Future<T> showElasticDialog<T>({
62+
@required BuildContext context,
63+
bool barrierDismissible = true,
64+
WidgetBuilder builder,
65+
}) {
66+
67+
final ThemeData theme = Theme.of(context, shadowThemeOnly: true);
68+
return showGeneralDialog(
69+
context: context,
70+
pageBuilder: (BuildContext buildContext, Animation<double> animation, Animation<double> secondaryAnimation) {
71+
final Widget pageChild = Builder(builder: builder);
72+
return SafeArea(
73+
child: Builder(
74+
builder: (BuildContext context) {
75+
return theme != null
76+
? Theme(data: theme, child: pageChild)
77+
: pageChild;
78+
}
79+
),
80+
);
81+
},
82+
barrierDismissible: barrierDismissible,
83+
barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
84+
barrierColor: Colors.black54,
85+
transitionDuration: const Duration(milliseconds: 550),
86+
transitionBuilder: _buildDialogTransitions,
87+
);
88+
}
89+
90+
Widget _buildDialogTransitions(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
91+
return FadeTransition(
92+
opacity: CurvedAnimation(
93+
parent: animation,
94+
curve: Curves.easeOut,
95+
),
96+
child: SlideTransition(
97+
position: Tween<Offset>(
98+
begin: const Offset(0.0, 0.3),
99+
end: Offset.zero
100+
).animate(CurvedAnimation(
101+
parent: animation,
102+
curve: animation.status != AnimationStatus.forward ? Curves.easeOutBack: ElasticOutCurve(0.85),
103+
)),
104+
child: child,
105+
),
106+
);
107+
}

0 commit comments

Comments
 (0)