Skip to content

Commit 4059dbd

Browse files
author
xuyingjun
committed
ReadMe
1 parent 35279d0 commit 4059dbd

File tree

3 files changed

+111
-5
lines changed

3 files changed

+111
-5
lines changed

README.md

Lines changed: 104 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,21 @@ import 'package:flutter_custom_dialog/flutter_custom_dialog.dart';
3131
<td align="center">
3232
<img src="https://github.com/YYFlutter/flutter-custom-dialog/raw/master/image/png/1.png" width="150px">
3333
<br />
34-
body
34+
divider
3535
<br />
3636
3737
</td>
3838
<td align="center">
3939
<img src="https://github.com/YYFlutter/flutter-custom-dialog/raw/master/image/png/2.png" width="150px">
4040
<br />
41-
head
41+
body
4242
<br />
4343
4444
</td>
4545
<td align="center">
4646
<img src="https://github.com/YYFlutter/flutter-custom-dialog/raw/master/image/png/3.png" width="150px">
4747
<br />
48-
divider
48+
head&body
4949
<br />
5050
5151
</td>
@@ -145,12 +145,112 @@ import 'package:flutter_custom_dialog/flutter_custom_dialog.dart';
145145

146146
**3、use**
147147

148-
> 弹窗支持功能
148+
> 功能属性的设置
149+
150+
属性的设置通过成员变量的方法去调用,具体详见下表
149151

152+
```dart
153+
YYDialog YYAlertDialogWithDivider(BuildContext context) {
154+
return YYDialog().build(context)
155+
..width = 220
156+
..borderRadius = 4.0
157+
..show();
158+
}
159+
```
160+
161+
支持的功能属性
150162

163+
property|description|default
164+
--|--|--|
165+
width|弹窗宽度|0
166+
height|弹窗高度|自适应组件高度
167+
duration|弹窗动画出现的时间|250毫秒
168+
gravity|弹窗出现的位置|居中
169+
barrierColor|弹窗外的背景色|30%黑色
170+
backgroundColor|弹窗内的背景色|白色
171+
borderRadius|弹窗圆角|0.0
172+
constraints|弹窗约束|最小宽高不低于10%
173+
animatedFunc|弹窗出现的动画|从中间出现
174+
barrierDismissible|是否点击弹出外部消失|true
151175

152176
> 语义化组件
153177
178+
弹窗内部的组件内容提前通过语义化的函数封装好常用的组件,以便快速构建出弹窗,具体见下表
179+
180+
```dart
181+
YYDialog YYAlertDialogWithDivider(BuildContext context) {
182+
return YYDialog().build(context)
183+
..width = 220
184+
..borderRadius = 4.0
185+
..text(
186+
padding: EdgeInsets.all(25.0),
187+
alignment: Alignment.center,
188+
text: "确定要退出登录吗?",
189+
color: Colors.black,
190+
fontSize: 14.0,
191+
fontWeight: FontWeight.w500,
192+
)
193+
..divider()
194+
..doubleButton(
195+
padding: EdgeInsets.only(top: 10.0),
196+
gravity: Gravity.center,
197+
withDivider: true,
198+
text1: "取消",
199+
color1: Colors.redAccent,
200+
fontSize1: 14.0,
201+
fontWeight1: FontWeight.bold,
202+
onTap1: () {
203+
print("取消");
204+
},
205+
text2: "确定",
206+
color2: Colors.redAccent,
207+
fontSize2: 14.0,
208+
fontWeight2: FontWeight.bold,
209+
onTap2: () {
210+
print("确定");
211+
},
212+
)
213+
..show();
214+
}
215+
```
216+
217+
支持的语义化组件
218+
219+
method|description
220+
--|--|
221+
text|文本控件
222+
doubleButton|双按钮控件
223+
listViewOfListTile|列表Tile组件
224+
listViewOfRadioButton|列表按钮组件
225+
divider|分割线组件
226+
height|弹窗高度
227+
widget|自定义语义化组件
228+
229+
由于组件提供只是辅助快速搭建UI,在实际项目开发中远远不能满足需求,所以提供了自定义语义化组件的插入
230+
231+
> 例如:text语义化组件
232+
233+
```dart
234+
YYDialog text({padding, text, color, fontSize, alignment, fontWeight}) {
235+
return this.widget(
236+
Padding(
237+
padding: padding ?? EdgeInsets.all(0.0),
238+
child: Align(
239+
alignment: alignment ?? Alignment.centerLeft,
240+
child: Text(
241+
text ?? "",
242+
style: TextStyle(
243+
color: color ?? Colors.black,
244+
fontSize: fontSize ?? 14.0,
245+
fontWeight: fontWeight,
246+
),
247+
),
248+
),
249+
),
250+
);
251+
}
252+
```
253+
154254
## Bugs/Requests
155255

156256
* If your application has problems, please submit your code and effect to Issue.

example/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ showAlertDialog(BuildContext context) {
4949
makeTextButton("body", () {
5050
YYAlertDialogBody(context);
5151
}),
52-
makeTextButton("head", () {
52+
makeTextButton("head&body", () {
5353
YYAlertDialogHeadAndBody(context);
5454
}),
5555
makeTextButton("divider", () {

lib/components/example/alert_dialog.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,16 @@ YYDialog YYAlertDialogWithDivider(BuildContext context) {
8484
color1: Colors.redAccent,
8585
fontSize1: 14.0,
8686
fontWeight1: FontWeight.bold,
87+
onTap1: () {
88+
print("取消");
89+
},
8790
text2: "确定",
8891
color2: Colors.redAccent,
8992
fontSize2: 14.0,
9093
fontWeight2: FontWeight.bold,
94+
onTap2: () {
95+
print("确定");
96+
},
9197
)
9298
..show();
9399
}

0 commit comments

Comments
 (0)