Skip to content

Commit 8ea1e72

Browse files
committed
feat: SimpleDialog
1 parent d65ec9d commit 8ea1e72

File tree

5 files changed

+128
-1
lines changed

5 files changed

+128
-1
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## **SimpleDialog**
2+
3+
>
4+
SimpleDialog用于向用户传递确定信息并提供多个选项之间的选择的弹出层
5+
* 对于通知用户情况的弹出框,请考虑使用AlertDialog
6+
7+
### 构造方法
8+
``` dart
9+
SimpleDialog({
10+
Key key,
11+
this.title,
12+
this.titlePadding = const EdgeInsets.fromLTRB(24.0, 24.0, 24.0, 0.0),
13+
this.children,
14+
this.contentPadding = const EdgeInsets.fromLTRB(0.0, 12.0, 0.0, 16.0),
15+
this.semanticLabel,
16+
this.shape,
17+
})
18+
```
19+
20+
### 属性介绍
21+
* title: 对话框的标题(可选)
22+
* titlePadding: 标题的周围填充
23+
* children: 对话框的内容Widget
24+
* contentPadding: 内容的周围填充
25+
* semanticLabel: 可访问性框架用于在打开和关闭对话框时通知屏幕转换的对话框的语义标签
26+
* shape: 对话框边框的形状

lib/widget/bulletbox/index.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
import 'package:efox_flutter/store/objects/widget_info.dart';
2+
import 'simpledialog/index.dart' as SimpleDialog;
23

34
const nameSpaces = '/bulletbox_';
45

5-
List widgets = [];
6+
List widgets = [
7+
ItemInfo(
8+
widget: SimpleDialog.Index(),
9+
code: 57451, // branding_watermark
10+
title: SimpleDialog.Index.title
11+
)
12+
];
613

714
List widgetMap = [
815
ItemListInfo(
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import 'package:flutter/material.dart';
2+
3+
class Index extends StatefulWidget {
4+
@override
5+
_IndexState createState() => _IndexState();
6+
}
7+
8+
class _IndexState extends State<Index> {
9+
10+
List Option = ['A', 'B', 'C'];
11+
String _choose = 'Nothing';
12+
13+
Future _openSimpleDialog () async {
14+
final option = await showDialog(
15+
context: context,
16+
builder: (BuildContext context) {
17+
return SimpleDialog(
18+
title: Text('SimpleDialog'),
19+
titlePadding: EdgeInsets.fromLTRB(24.0, 24.0, 24.0, 0.0),
20+
contentPadding: EdgeInsets.fromLTRB(0.0, 12.0, 0.0, 16.0),
21+
children: List.generate(3, (index) {
22+
return SimpleDialogOption(
23+
child: Text('Option ${Option[index]}'),
24+
onPressed: (){
25+
Navigator.pop(context, Option[index]);
26+
},
27+
);
28+
}),
29+
);
30+
}
31+
);
32+
switch (option) {
33+
case "A":
34+
setState(() {
35+
_choose = 'A';
36+
});
37+
break;
38+
case "B":
39+
setState(() {
40+
_choose = 'B';
41+
});
42+
break;
43+
case "C":
44+
setState(() {
45+
_choose = 'C';
46+
});
47+
break;
48+
default:
49+
}
50+
}
51+
52+
53+
@override
54+
Widget build(BuildContext context) {
55+
return Scaffold(
56+
appBar: AppBar(title: Text('SimpleDialog'),),
57+
body: Center(
58+
child: Text('你的选择是:$_choose')
59+
),
60+
floatingActionButton: FloatingActionButton(
61+
onPressed: _openSimpleDialog,
62+
child: Icon(Icons.branding_watermark, color: Colors.white, size: 30.0,),
63+
backgroundColor: Theme.of(context).primaryColor,
64+
),
65+
);
66+
}
67+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:efox_flutter/components/widgetComp.dart' as WidgetComp;
3+
import 'demo.dart' as Demo;
4+
5+
class Index extends StatefulWidget {
6+
static String title = 'SimpleDialog';
7+
static String originCodeUrl = 'https://docs.flutter.io/flutter/material/SimpleDialog-class.html';
8+
static String mdUrl = 'docs/widget/bulletbox/simpledialog/index.md';
9+
@override
10+
@override
11+
_IndexState createState() => _IndexState();
12+
}
13+
14+
class _IndexState extends State<Index> {
15+
@override
16+
Widget build(BuildContext context) {
17+
return WidgetComp.Index(
18+
title: Index.title,
19+
originCodeUrl: Index.originCodeUrl,
20+
mdUrl: Index.mdUrl,
21+
demoChild: <Widget>[
22+
Demo.Index()
23+
],
24+
);
25+
}
26+
}

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ flutter:
7878
- docs/widget/regular/listview/
7979
- docs/widget/regular/listbody/
8080
- docs/widget/regular/layoutbuilder/
81+
- docs/widget/bulletbox/simpledialog/
8182
- docs/widget/navigator/appbar/
8283
- docs/widget/navigator/scaffold/
8384
# An image asset can refer to one or more resolution-specific "variants", see

0 commit comments

Comments
 (0)