Skip to content

Commit 147991d

Browse files
author
xuyingjun
committed
fix dismiss bug v1.0.1
1 parent a66a9d0 commit 147991d

File tree

7 files changed

+109
-14
lines changed

7 files changed

+109
-14
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
## 1.0.0
22

33
* first release
4-
* welcome to submit bug
4+
* welcome to submit bug
5+
6+
## 1.0.1
7+
8+
* fix dismiss Bug

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Global dialog function encapsulation, with a semantic way to fill the content in
1616

1717
```yaml
1818
dependencies:
19-
flutter_custom_dialog: ^1.0.0
19+
flutter_custom_dialog: ^1.0.1
2020
```
2121
2222
**2、import**
@@ -182,6 +182,14 @@ constraints|Dialog constraints|Minimum width and height not less than 10%
182182
animatedFunc|Animation of dialog|Emerge from the middle
183183
barrierDismissible|Whether to click to pop up the external disappear|true
184184

185+
Supported method
186+
187+
method|description
188+
--|--|--|
189+
show|show dialog
190+
dismiss|dismiss dialog
191+
isShowing|Is the dialog showing
192+
185193
## ⚡ Semantic Widget
186194

187195
The contents of the components inside the dialog are encapsulated by semantic functions in advance to quickly build the dialog, as shown in the following table

README_CN.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
```yaml
1616
dependencies:
17-
flutter_custom_dialog: ^1.0.0
17+
flutter_custom_dialog: ^1.0.1
1818
```
1919
2020
**2、import**
@@ -180,6 +180,14 @@ constraints|弹窗约束|最小宽高不低于10%
180180
animatedFunc|弹窗出现的动画|从中间出现
181181
barrierDismissible|是否点击弹出外部消失|true
182182

183+
支持的方法
184+
185+
method|description
186+
--|--|--|
187+
show|显示弹窗
188+
dismiss|隐藏弹窗
189+
isShowing|弹窗是否在展示
190+
183191
## ⚡ Semantic Widget
184192

185193
弹窗内部的组件内容提前通过语义化的函数封装好常用的组件,以便快速构建出弹窗,具体见下表

example/lib/main.dart

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
library flutter_custom_dialog;
22

33
import 'package:flutter/material.dart';
4+
import 'package:flutter_custom_dialog/flutter_custom_dialog.dart';
45
import 'package:flutter_custom_dialog/components/example/alert_dialog.dart';
56
import 'package:flutter_custom_dialog/components/bean/dialog_gravity.dart';
67
import 'package:flutter_custom_dialog/components/example/listview_dialog.dart';
@@ -29,6 +30,7 @@ class AppHome extends StatelessWidget {
2930
showAlertDialog(context),
3031
showListViewDialog(context),
3132
showProgressDialog(context),
33+
showDevelopDialog(context),
3234
],
3335
),
3436
),
@@ -206,6 +208,43 @@ showProgressDialog(BuildContext context) {
206208
);
207209
}
208210

211+
showDevelopDialog(BuildContext context) {
212+
YYDialog yyDialog;
213+
214+
return Padding(
215+
padding: EdgeInsets.all(8.0),
216+
child: Column(
217+
crossAxisAlignment: CrossAxisAlignment.start,
218+
children: <Widget>[
219+
Text("YYDevelopDialog", style: titleTextStyle),
220+
Text("1、Debug"),
221+
Row(
222+
children: <Widget>[
223+
makeTextButton("fix dismiss\nbug in v1.0.1", () {
224+
Navigator.push(
225+
context,
226+
MaterialPageRoute(
227+
builder: (context) => Scaffold(
228+
body: Column(
229+
children: <Widget>[
230+
makeTextButton("show", () {
231+
yyDialog = YYAlertDialogBody(context);
232+
}),
233+
makeTextButton("dismiss", () {
234+
yyDialog?.dismiss();
235+
}),
236+
],
237+
),
238+
)),
239+
);
240+
}),
241+
],
242+
),
243+
],
244+
),
245+
);
246+
}
247+
209248
Widget makeTextButton(title, Function() function) {
210249
return SizedBox(
211250
width: 70.0,

example/pubspec.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Generated by pub
2-
# See https://www.dartlang.org/tools/pub/glossary#lockfile
2+
# See https://dart.dev/tools/pub/glossary#lockfile
33
packages:
44
async:
55
dependency: transitive
66
description:
77
name: async
88
url: "https://pub.dartlang.org"
99
source: hosted
10-
version: "2.1.0"
10+
version: "2.2.0"
1111
boolean_selector:
1212
dependency: transitive
1313
description:
@@ -80,14 +80,14 @@ packages:
8080
name: pedantic
8181
url: "https://pub.dartlang.org"
8282
source: hosted
83-
version: "1.5.0"
83+
version: "1.7.0"
8484
quiver:
8585
dependency: transitive
8686
description:
8787
name: quiver
8888
url: "https://pub.dartlang.org"
8989
source: hosted
90-
version: "2.0.2"
90+
version: "2.0.3"
9191
sky_engine:
9292
dependency: transitive
9393
description: flutter
@@ -134,7 +134,7 @@ packages:
134134
name: test_api
135135
url: "https://pub.dartlang.org"
136136
source: hosted
137-
version: "0.2.4"
137+
version: "0.2.5"
138138
typed_data:
139139
dependency: transitive
140140
description:
@@ -150,4 +150,4 @@ packages:
150150
source: hosted
151151
version: "2.0.8"
152152
sdks:
153-
dart: ">=2.2.0 <3.0.0"
153+
dart: ">=2.2.2 <3.0.0"

lib/flutter_custom_dialog.dart

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ class YYDialog {
1919
BoxConstraints constraints; //弹窗约束
2020
Function(Widget child, Animation<double> animation) animatedFunc; //弹窗出现的动画
2121
bool barrierDismissible = true; //是否点击弹出外部消失
22+
23+
get isShowing => _isShowing; //当前弹窗是否可见
24+
bool _isShowing = false;
25+
2226
//============================================================================
2327

2428
YYDialog build(context) {
@@ -168,7 +172,6 @@ class YYDialog {
168172
Color activeColor,
169173
Function(int) onClickItemListener,
170174
}) {
171-
print("YYDialog ==> listViewOfRadioButton()");
172175
Size size = MediaQuery.of(context).size;
173176
return this.widget(
174177
Container(
@@ -239,8 +242,11 @@ class YYDialog {
239242
minHeight: size.height * .1,
240243
minWidth: size.width * .1,
241244
),
242-
child: Column(
243-
children: widgetList,
245+
child: CustomDialogChildren(
246+
widgetList: widgetList,
247+
isShowingChange: (bool isShowingChange) {
248+
_isShowing = isShowingChange;
249+
},
244250
),
245251
),
246252
)
@@ -250,7 +256,9 @@ class YYDialog {
250256
}
251257

252258
void dismiss() {
253-
Navigator.of(context).pop();
259+
if (_isShowing) {
260+
Navigator.of(context, rootNavigator: true).pop();
261+
}
254262
}
255263

256264
getColumnMainAxisAlignment(gravity) {
@@ -317,6 +325,34 @@ class YYDialog {
317325
}
318326
}
319327

328+
///弹窗的内容作为可变组件
329+
class CustomDialogChildren extends StatefulWidget {
330+
List<Widget> widgetList = []; //弹窗内部所有组件
331+
Function(bool) isShowingChange;
332+
333+
CustomDialogChildren({this.widgetList, this.isShowingChange});
334+
335+
@override
336+
CustomDialogChildState createState() => CustomDialogChildState();
337+
}
338+
339+
class CustomDialogChildState extends State<CustomDialogChildren> {
340+
@override
341+
Widget build(BuildContext context) {
342+
widget.isShowingChange(true);
343+
return Column(
344+
children: widget.widgetList,
345+
);
346+
}
347+
348+
@override
349+
void dispose() {
350+
widget.isShowingChange(false);
351+
super.dispose();
352+
}
353+
}
354+
355+
///弹窗API的封装
320356
class CustomDialog {
321357
BuildContext _context;
322358
Widget _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.0
3+
version: 1.0.1
44
author: AndroidHensen <[email protected]>
55
homepage: https://github.com/YYFlutter/flutter-custom-dialog.git
66

0 commit comments

Comments
 (0)