Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c9d1218

Browse files
author
xuyingjun
committed
add gravityAnimationEnable property[v1.0.3]
1 parent 661be0f commit c9d1218

File tree

9 files changed

+191
-107
lines changed

9 files changed

+191
-107
lines changed

‎.idea/workspace.xml‎

Lines changed: 131 additions & 101 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎CHANGELOG.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@
99

1010
## 1.0.2
1111

12-
* add gravity of leftTop,leftBottom,rightTop,rightBottom
12+
* add gravity of leftTop,leftBottom,rightTop,rightBottom
13+
14+
## 1.0.3
15+
16+
* add gravityAnimationEnable property

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ width|Dialog width|0
228228
height|Dialog height|Adaptive component height
229229
duration|Dialog animation time|250 ms
230230
gravity|Where the dialog appears|center
231+
gravityAnimationEnable|The dialog appears with the default animation available|false
231232
margin|The margin of a dialog|EdgeInsets.all(0.0)
232233
barrierColor|Dialog barrierColor|30% of black
233234
backgroundColor|Dialog backgroundColor|white

‎README_CN.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ width|弹窗宽度|0
226226
height|弹窗高度|自适应组件高度
227227
duration|弹窗动画出现的时间|250毫秒
228228
gravity|弹窗出现的位置|居中
229+
gravityAnimationEnable|弹窗出现的位置带有的默认动画是否可用|false
229230
margin|弹窗的外边距|EdgeInsets.all(0.0)
230231
barrierColor|弹窗外的背景色|30%黑色
231232
backgroundColor|弹窗内的背景色|白色

‎example/lib/main.dart‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ showAlertDialog(BuildContext context) {
7474
makeTextButton("pop\nmenu", () {
7575
YYAlertDialogPopMenu(context);
7676
}),
77+
makeTextButton("custom\nx&y", () {
78+
YYAlertDialogCustomXY(context);
79+
}),
7780
],
7881
),
7982
Text("2、dialog property"),
@@ -231,6 +234,9 @@ showDevelopDialog(BuildContext context) {
231234
context,
232235
MaterialPageRoute(
233236
builder: (context) => Scaffold(
237+
appBar: AppBar(
238+
title: Text("fix dismiss bug"),
239+
),
234240
body: Column(
235241
children: <Widget>[
236242
makeTextButton("show", () {

‎example/pubspec.lock‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ packages:
4747
path: ".."
4848
relative: true
4949
source: path
50-
version: "1.0.1"
50+
version: "1.0.2"
5151
flutter_test:
5252
dependency: "direct dev"
5353
description: flutter

‎lib/components/example/alert_dialog.dart‎

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ YYDialog YYAlertDialogWithDuration(BuildContext context) {
102102
return YYDialog().build(context)
103103
..width = 240
104104
..borderRadius = 4.0
105+
..gravityAnimationEnable = true
105106
..gravity = Gravity.left
106107
..duration = Duration(seconds: 1)
107108
..text(
@@ -224,6 +225,7 @@ YYDialog YYAlertDialogWithGravity(
224225
return YYDialog().build(context)
225226
..width = width
226227
..gravity = gravity
228+
..gravityAnimationEnable = true
227229
..borderRadius = 4.0
228230
..text(
229231
padding: EdgeInsets.all(18.0),
@@ -451,16 +453,36 @@ YYDialog YYAlertDialogPopMenu(BuildContext context) {
451453
..barrierColor = Colors.transparent
452454
..margin = EdgeInsets.only(top: 80, right: 20)
453455
..text(
454-
padding: EdgeInsets.fromLTRB(10.0,16.0,10.0,16.0),
456+
padding: EdgeInsets.fromLTRB(10.0,16.0,10.0,16.0),
455457
text: "Edit Libary",
456458
fontSize: 16.0,
457459
color: Colors.grey[700],
458460
)
459461
..text(
460-
padding:EdgeInsets.fromLTRB(10.0,16.0,10.0,16.0),
462+
padding:EdgeInsets.fromLTRB(10.0,16.0,10.0,16.0),
461463
text: "Read History",
462464
fontSize: 16.0,
463465
color: Color(0xFFFF6B2D),
464466
)
465467
..show();
466468
}
469+
470+
YYDialog YYAlertDialogCustomXY(BuildContext context) {
471+
return YYDialog().build(context)
472+
..width = 120
473+
..borderRadius = 8.0
474+
..barrierColor = Colors.transparent
475+
..text(
476+
padding: EdgeInsets.fromLTRB(10.0, 16.0, 10.0, 16.0),
477+
text: "Edit Libary",
478+
fontSize: 16.0,
479+
color: Colors.grey[700],
480+
)
481+
..text(
482+
padding: EdgeInsets.fromLTRB(10.0, 16.0, 10.0, 16.0),
483+
text: "Read History",
484+
fontSize: 16.0,
485+
color: Color(0xFFFF6B2D),
486+
)
487+
..show(80.0, 100.0);
488+
}

‎lib/flutter_custom_dialog.dart‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class YYDialog {
1515
double height; //弹窗高度
1616
Duration duration = Duration(milliseconds: 250); //弹窗动画出现的时间
1717
Gravity gravity = Gravity.center; //弹窗出现的位置
18+
bool gravityAnimationEnable = false; //弹窗出现的位置带有的默认动画是否可用
1819
Color barrierColor = Colors.black.withOpacity(.3); //弹窗外的背景色
1920
Color backgroundColor = Colors.white; //弹窗内的背景色
2021
double borderRadius = 0.0; //弹窗圆角
@@ -214,12 +215,19 @@ class YYDialog {
214215
);
215216
}
216217

217-
void show() {
218+
/// x坐标
219+
/// y坐标
220+
void show([x, y]) {
218221
var mainAxisAlignment = getColumnMainAxisAlignment(gravity);
219222
var crossAxisAlignment = getColumnCrossAxisAlignment(gravity);
220223
Size size = MediaQuery.of(context).size;
224+
if (x != null && y != null) {
225+
gravity = Gravity.leftTop;
226+
margin = EdgeInsets.only(left: x, top: y);
227+
}
221228
CustomDialog(
222229
gravity: gravity,
230+
gravityAnimationEnable: gravityAnimationEnable,
223231
context: context,
224232
barrierColor: barrierColor,
225233
animatedFunc: animatedFunc,
@@ -375,6 +383,7 @@ class CustomDialog {
375383
RouteTransitionsBuilder _transitionsBuilder;
376384
bool _barrierDismissible;
377385
Gravity _gravity;
386+
bool _gravityAnimationEnable;
378387
Function _animatedFunc;
379388

380389
CustomDialog({
@@ -384,11 +393,13 @@ class CustomDialog {
384393
Color barrierColor,
385394
RouteTransitionsBuilder transitionsBuilder,
386395
Gravity gravity,
396+
bool gravityAnimationEnable,
387397
Function animatedFunc,
388398
bool barrierDismissible,
389399
}) : _child = child,
390400
_context = context,
391401
_gravity = gravity,
402+
_gravityAnimationEnable = gravityAnimationEnable,
392403
_duration = duration,
393404
_barrierColor = barrierColor,
394405
_animatedFunc = animatedFunc,
@@ -467,10 +478,19 @@ class CustomDialog {
467478
break;
468479
}
469480

481+
//自定义动画
470482
if (_animatedFunc != null) {
471483
return _animatedFunc(child, animation);
472484
}
473485

486+
//不需要默认动画
487+
if (!_gravityAnimationEnable) {
488+
custom = Tween<Offset>(
489+
begin: Offset(0.0, 0.0),
490+
end: Offset(0.0, 0.0),
491+
).animate(animation);
492+
}
493+
474494
return SlideTransition(
475495
position: custom,
476496
child: child,

‎pubspec.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_custom_dialog
22
description: Semantic dialog
3-
version: 1.0.2
3+
version: 1.0.3
44
author: AndroidHensen <xyj510402535@qq.com>
55
homepage: https://github.com/YYFlutter/flutter-custom-dialog.git
66

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /