Skip to content

Commit 48a213b

Browse files
author
xuyingjun
committed
add gravity for four
1 parent 882b6c0 commit 48a213b

File tree

11 files changed

+184
-32
lines changed

11 files changed

+184
-32
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,36 @@ import 'package:flutter_custom_dialog/flutter_custom_dialog.dart';
109109
110110
</td>
111111
</tr>
112+
<tr>
113+
<td align="center">
114+
<img src="https://github.com/YYFlutter/flutter-custom-dialog/raw/master/image/gif/111.gif" width="150px">
115+
<br />
116+
left bottom
117+
<br />
118+
119+
</td>
120+
<td align="center">
121+
<img src="https://github.com/YYFlutter/flutter-custom-dialog/raw/master/image/gif/222.gif" width="150px">
122+
<br />
123+
left top
124+
<br />
125+
126+
</td>
127+
<td align="center">
128+
<img src="https://github.com/YYFlutter/flutter-custom-dialog/raw/master/image/gif/333.gif" width="150px">
129+
<br />
130+
right bottom
131+
<br />
132+
133+
</td>
134+
<td align="center">
135+
<img src="https://github.com/YYFlutter/flutter-custom-dialog/raw/master/image/gif/444.gif" width="150px">
136+
<br />
137+
right top
138+
<br />
139+
140+
</td>
141+
</tr>
112142
</table>
113143

114144
> dialog_animation
@@ -175,6 +205,7 @@ width|Dialog width|0
175205
height|Dialog height|Adaptive component height
176206
duration|Dialog animation time|250 ms
177207
gravity|Where the dialog appears|center
208+
margin|The margin of a dialog|EdgeInsets.all(0.0)
178209
barrierColor|Dialog barrierColor|30% of black
179210
backgroundColor|Dialog backgroundColor|white
180211
borderRadius|Dialog borderRadius|0.0

README_CN.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,36 @@ import 'package:flutter_custom_dialog/flutter_custom_dialog.dart';
107107
108108
</td>
109109
</tr>
110+
<tr>
111+
<td align="center">
112+
<img src="https://github.com/YYFlutter/flutter-custom-dialog/raw/master/image/gif/111.gif" width="150px">
113+
<br />
114+
left bottom
115+
<br />
116+
117+
</td>
118+
<td align="center">
119+
<img src="https://github.com/YYFlutter/flutter-custom-dialog/raw/master/image/gif/222.gif" width="150px">
120+
<br />
121+
left top
122+
<br />
123+
124+
</td>
125+
<td align="center">
126+
<img src="https://github.com/YYFlutter/flutter-custom-dialog/raw/master/image/gif/333.gif" width="150px">
127+
<br />
128+
right bottom
129+
<br />
130+
131+
</td>
132+
<td align="center">
133+
<img src="https://github.com/YYFlutter/flutter-custom-dialog/raw/master/image/gif/444.gif" width="150px">
134+
<br />
135+
right top
136+
<br />
137+
138+
</td>
139+
</tr>
110140
</table>
111141

112142
> dialog_animation
@@ -173,6 +203,7 @@ width|弹窗宽度|0
173203
height|弹窗高度|自适应组件高度
174204
duration|弹窗动画出现的时间|250毫秒
175205
gravity|弹窗出现的位置|居中
206+
margin|弹窗的外边距|EdgeInsets.all(0.0)
176207
barrierColor|弹窗外的背景色|30%黑色
177208
backgroundColor|弹窗内的背景色|白色
178209
borderRadius|弹窗圆角|0.0

example/lib/main.dart

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ showAlertDialog(BuildContext context) {
6666
YYAlertDialogWithDuration(context);
6767
}),
6868
makeTextButton("barrier\ncolor", () {
69-
YYAlertDialogWithbarrierColor(context);
69+
YYAlertDialogWithbarrierColor(context, Colors.redAccent);
70+
}),
71+
makeTextButton("transparent\ncolor", () {
72+
YYAlertDialogWithbarrierColor(context, Colors.transparent);
7073
}),
7174
makeTextButton("background\ncolor", () {
7275
YYAlertDialogWithBackgroundColor(context);
@@ -114,6 +117,38 @@ showAlertDialog(BuildContext context) {
114117
}),
115118
],
116119
),
120+
Row(
121+
children: <Widget>[
122+
makeTextButton("left\nbottom", () {
123+
YYAlertDialogWithGravity(
124+
context: context,
125+
width: 250.0,
126+
gravity: Gravity.leftBottom,
127+
);
128+
}),
129+
makeTextButton("left\ntop", () {
130+
YYAlertDialogWithGravity(
131+
context: context,
132+
width: 250.0,
133+
gravity: Gravity.leftTop,
134+
);
135+
}),
136+
makeTextButton("right\nbottom", () {
137+
YYAlertDialogWithGravity(
138+
context: context,
139+
width: 250.0,
140+
gravity: Gravity.rightBottom,
141+
);
142+
}),
143+
makeTextButton("right\ntop", () {
144+
YYAlertDialogWithGravity(
145+
context: context,
146+
width: 250.0,
147+
gravity: Gravity.rightTop,
148+
);
149+
}),
150+
],
151+
),
117152
Text("4、double button gravity"),
118153
Row(
119154
children: <Widget>[
@@ -157,6 +192,14 @@ showAlertDialog(BuildContext context) {
157192
}),
158193
],
159194
),
195+
Text("6、projects using"),
196+
Row(
197+
children: <Widget>[
198+
makeTextButton("pop\nmenu", () {
199+
YYAlertDialogPopMenu(context);
200+
}),
201+
],
202+
),
160203
],
161204
),
162205
);

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

image/gif/111.gif

242 KB
Loading

image/gif/222.gif

390 KB
Loading

image/gif/333.gif

304 KB
Loading

image/gif/444.gif

437 KB
Loading

lib/components/bean/dialog_gravity.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ enum Gravity {
66
bottom,
77
right,
88
center,
9+
rightTop,
10+
leftTop,
11+
rightBottom,
12+
leftBottom,
913
}

lib/components/example/alert_dialog.dart

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ YYDialog YYAlertDialogWithDuration(BuildContext context) {
129129
..show();
130130
}
131131

132-
YYDialog YYAlertDialogWithbarrierColor(BuildContext context) {
132+
YYDialog YYAlertDialogWithbarrierColor(BuildContext context, Color color) {
133133
return YYDialog().build(context)
134134
..width = 240
135135
..borderRadius = 4.0
136-
..barrierColor = Colors.redAccent
136+
..barrierColor = color
137137
..text(
138138
padding: EdgeInsets.all(18.0),
139139
text: "Dialog header",
@@ -442,3 +442,25 @@ YYDialog YYDialogDemo(BuildContext context) {
442442
)
443443
..show();
444444
}
445+
446+
YYDialog YYAlertDialogPopMenu(BuildContext context) {
447+
return YYDialog().build(context)
448+
..width = 120
449+
..borderRadius = 8.0
450+
..gravity = Gravity.rightTop
451+
..barrierColor = Colors.transparent
452+
..margin = EdgeInsets.only(top: 80, right: 20)
453+
..text(
454+
padding: EdgeInsets.fromLTRB(10.0,16.0,10.0,16.0),
455+
text: "Edit Libary",
456+
fontSize: 16.0,
457+
color: Colors.grey[700],
458+
)
459+
..text(
460+
padding:EdgeInsets.fromLTRB(10.0,16.0,10.0,16.0),
461+
text: "Read History",
462+
fontSize: 16.0,
463+
color: Color(0xFFFF6B2D),
464+
)
465+
..show();
466+
}

0 commit comments

Comments
 (0)