Skip to content

Commit 3b455b5

Browse files
author
xuyingjun
committed
v1.0.15 addCallBack
1 parent 902165f commit 3b455b5

10 files changed

+292
-66
lines changed

.idea/workspace.xml

+158-49
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,8 @@
5757

5858
## 1.0.14
5959

60-
* remove log
60+
* remove log
61+
62+
## 1.0.15
63+
64+
* add callback

README.md

+33-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Global dialog function encapsulation, with a semantic way to fill the content in
1717

1818
```yaml
1919
dependencies:
20-
flutter_custom_dialog: ^1.0.14
20+
flutter_custom_dialog: ^1.0.15
2121
```
2222
2323
**2、import**
@@ -219,18 +219,42 @@ import 'package:flutter_custom_dialog/flutter_custom_dialog.dart';
219219
dialog property Settings can be called through the method of member variables, as detailed in the following table
220220

221221
```dart
222-
YYDialog YYDialogDemo(BuildContext context) {
223-
return YYDialog().build(context)
224-
..width = 220
225-
..height = 500
226-
..barrierColor = Colors.black.withOpacity(.3)
222+
YYDialog YYNoticeDialog() {
223+
return YYDialog().build()
224+
..width = 120
225+
..height = 110
226+
..backgroundColor = Colors.black.withOpacity(0.8)
227+
..borderRadius = 10.0
228+
..showCallBack = () {
229+
print("showCallBack invoke");
230+
}
231+
..dismissCallBack = () {
232+
print("dismissCallBack invoke");
233+
}
234+
..widget(Padding(
235+
padding: EdgeInsets.only(top: 21),
236+
child: Image.asset(
237+
'images/success.png',
238+
width: 38,
239+
height: 38,
240+
),
241+
))
242+
..widget(Padding(
243+
padding: EdgeInsets.only(top: 10),
244+
child: Text(
245+
"Success",
246+
style: TextStyle(
247+
fontSize: 15,
248+
color: Colors.white,
249+
),
250+
),
251+
))
227252
..animatedFunc = (child, animation) {
228253
return ScaleTransition(
229254
child: child,
230255
scale: Tween(begin: 0.0, end: 1.0).animate(animation),
231256
);
232257
}
233-
..borderRadius = 4.0
234258
..show();
235259
}
236260
```
@@ -250,6 +274,8 @@ backgroundColor|Dialog backgroundColor|white
250274
borderRadius|Dialog borderRadius|0.0
251275
constraints|Dialog constraints|no constraints
252276
animatedFunc|Animation of dialog|Emerge from the middle
277+
showCallBack|dialog show callbacks|not
278+
dismissCallBack|dialog dismiss callbacks|not
253279
barrierDismissible|Whether to click to pop up the external disappear|true
254280

255281
Supported method

README_CN.md

+33-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
```yaml
1717
dependencies:
18-
flutter_custom_dialog: ^1.0.14
18+
flutter_custom_dialog: ^1.0.15
1919
```
2020
2121
**2、import**
@@ -217,18 +217,42 @@ import 'package:flutter_custom_dialog/flutter_custom_dialog.dart';
217217
弹窗的属性设置可以通过成员变量的方法去调用,具体详见下表
218218

219219
```dart
220-
YYDialog YYDialogDemo(BuildContext context) {
221-
return YYDialog().build(context)
222-
..width = 220
223-
..height = 500
224-
..barrierColor = Colors.black.withOpacity(.3)
220+
YYDialog YYNoticeDialog() {
221+
return YYDialog().build()
222+
..width = 120
223+
..height = 110
224+
..backgroundColor = Colors.black.withOpacity(0.8)
225+
..borderRadius = 10.0
226+
..showCallBack = () {
227+
print("showCallBack invoke");
228+
}
229+
..dismissCallBack = () {
230+
print("dismissCallBack invoke");
231+
}
232+
..widget(Padding(
233+
padding: EdgeInsets.only(top: 21),
234+
child: Image.asset(
235+
'images/success.png',
236+
width: 38,
237+
height: 38,
238+
),
239+
))
240+
..widget(Padding(
241+
padding: EdgeInsets.only(top: 10),
242+
child: Text(
243+
"Success",
244+
style: TextStyle(
245+
fontSize: 15,
246+
color: Colors.white,
247+
),
248+
),
249+
))
225250
..animatedFunc = (child, animation) {
226251
return ScaleTransition(
227252
child: child,
228253
scale: Tween(begin: 0.0, end: 1.0).animate(animation),
229254
);
230255
}
231-
..borderRadius = 4.0
232256
..show();
233257
}
234258
```
@@ -248,6 +272,8 @@ backgroundColor|弹窗内的背景色|白色
248272
borderRadius|弹窗圆角|0.0
249273
constraints|弹窗约束|无
250274
animatedFunc|弹窗出现的动画|从中间出现
275+
showCallBack|弹窗展示的回调|无
276+
dismissCallBack|弹窗消失的回调|无
251277
barrierDismissible|是否点击弹出外部消失|true
252278

253279
支持的方法

example/lib/dialog/alert_dialog.dart

+39
Original file line numberDiff line numberDiff line change
@@ -484,3 +484,42 @@ YYDialog YYAlertDialogCustomXY() {
484484
)
485485
..show(80.0, 100.0);
486486
}
487+
488+
YYDialog YYNoticeDialogCallback() {
489+
return YYDialog().build()
490+
..width = 120
491+
..height = 110
492+
..backgroundColor = Colors.black.withOpacity(0.8)
493+
..borderRadius = 10.0
494+
..showCallBack = () {
495+
print("showCallBack invoke");
496+
}
497+
..dismissCallBack = () {
498+
print("dismissCallBack invoke");
499+
}
500+
..widget(Padding(
501+
padding: EdgeInsets.only(top: 21),
502+
child: Image.asset(
503+
'images/success.png',
504+
width: 38,
505+
height: 38,
506+
),
507+
))
508+
..widget(Padding(
509+
padding: EdgeInsets.only(top: 10),
510+
child: Text(
511+
"Success",
512+
style: TextStyle(
513+
fontSize: 15,
514+
color: Colors.white,
515+
),
516+
),
517+
))
518+
..animatedFunc = (child, animation) {
519+
return ScaleTransition(
520+
child: child,
521+
scale: Tween(begin: 0.0, end: 1.0).animate(animation),
522+
);
523+
}
524+
..show();
525+
}

example/lib/dialog/notice_dialog.dart

+6
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,11 @@ YYDialog YYNoticeDialog() {
2525
),
2626
),
2727
))
28+
..animatedFunc = (child, animation) {
29+
return ScaleTransition(
30+
child: child,
31+
scale: Tween(begin: 0.0, end: 1.0).animate(animation),
32+
);
33+
}
2834
..show();
2935
}

example/lib/main.dart

+3
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ showAlertDialog(BuildContext context) {
9494
makeTextButton("notice", () {
9595
YYNoticeDialog();
9696
}),
97+
makeTextButton("callback", () {
98+
YYNoticeDialogCallback();
99+
}),
97100
],
98101
),
99102
Text("2、dialog property"),

example/pubspec.lock

+1-1
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.13"
50+
version: "1.0.14"
5151
flutter_test:
5252
dependency: "direct dev"
5353
description: flutter

lib/flutter_custom_dialog.dart

+13
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class YYDialog {
2323
bool barrierDismissible = true; //是否点击弹出外部消失
2424
EdgeInsets margin = EdgeInsets.all(0.0); //弹窗布局的外边距
2525

26+
Function() showCallBack; //展示的回调
27+
Function() dismissCallBack; //消失的回调
28+
2629
get isShowing => _isShowing; //当前弹窗是否可见
2730
bool _isShowing = false;
2831

@@ -280,6 +283,16 @@ class YYDialog {
280283
child: CustomDialogChildren(
281284
widgetList: widgetList,
282285
isShowingChange: (bool isShowingChange) {
286+
// showing or dismiss Callback
287+
if (isShowingChange) {
288+
if (showCallBack != null) {
289+
showCallBack();
290+
}
291+
} else {
292+
if (dismissCallBack != null) {
293+
dismissCallBack();
294+
}
295+
}
283296
_isShowing = isShowingChange;
284297
},
285298
),

pubspec.yaml

+1-1
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.14
3+
version: 1.0.15
44
author: AndroidHensen <xyj510402535@qq.com>
55
homepage: https://github.com/YYFlutter/flutter-custom-dialog.git
66

0 commit comments

Comments
 (0)