Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0d27d41

Browse files
εΈƒε±€
1 parent 22fbac8 commit 0d27d41

File tree

3 files changed

+67
-22
lines changed

3 files changed

+67
-22
lines changed

β€Žexample/lib/main.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ showAlertDialog(BuildContext context) {
3737
Row(
3838
children: <Widget>[
3939
makeTextButton("1", () {
40-
YYAlertDialog(context);
40+
YYAlertDialog1(context);
4141
}),
4242
makeTextButton("2", () {
43-
YYAlertDialog(context);
43+
YYAlertDialog2(context);
4444
}),
4545
],
4646
),

β€Žlib/components/dialog.dart

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,54 @@ import 'package:flutter/material.dart';
22

33
import '../flutter_custom_dialog.dart';
44

5-
YYDialog YYAlertDialog(BuildContext context) {
5+
YYDialog YYAlertDialog1(BuildContext context) {
66
return YYDialog().build(context)
77
..width = 240
8+
..borderRadius = 4.0
89
..text(
9-
padding: EdgeInsets.all(16.0),
10+
padding: EdgeInsets.all(18.0),
1011
text: "Dialog Header",
1112
color: Colors.black,
1213
fontSize: 16.0,
1314
)
1415
..text(
15-
padding: EdgeInsets.only(left: 16.0),
16+
padding: EdgeInsets.only(left: 18.0),
1617
text: "Dialog body text",
1718
color: Colors.grey[500],
1819
)
1920
..doubleButton(
20-
padding: EdgeInsets.only(top: 12.0),
21-
text: "ACTION 1",
22-
color: Colors.deepPurpleAccent,
23-
fontSize: 14.0,
21+
padding: EdgeInsets.only(top: 24.0),
22+
mainAxisAlignment: MainAxisAlignment.end,
23+
text1: "ACTION 1",
24+
color1: Colors.deepPurpleAccent,
25+
fontSize1: 14.0,
26+
text2: "ACTION 2",
27+
color2: Colors.deepPurpleAccent,
28+
fontSize2: 14.0,
29+
)
30+
..show();
31+
}
32+
33+
YYDialog YYAlertDialog2(BuildContext context) {
34+
return YYDialog().build(context)
35+
..width = 240
36+
..borderRadius = 4.0
37+
..text(
38+
padding: EdgeInsets.all(18.0),
39+
text: "Discard draft?",
40+
color: Colors.grey[700],
41+
)
42+
..doubleButton(
43+
padding: EdgeInsets.only(top: 10.0),
44+
mainAxisAlignment: MainAxisAlignment.end,
45+
text1: "CANCEL",
46+
color1: Colors.deepPurpleAccent,
47+
fontSize1: 14.0,
48+
fontWeight1: FontWeight.bold,
49+
text2: "DISCARD",
50+
color2: Colors.deepPurpleAccent,
51+
fontSize2: 14.0,
52+
fontWeight2: FontWeight.bold,
2453
)
2554
..show();
2655
}

β€Žlib/flutter_custom_dialog.dart

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ class YYDialog {
66
MainAxisAlignment mainAxisAlignment = MainAxisAlignment.center;
77
double width;
88
double height;
9-
BoxDecoration decoration;
9+
Color backgroundColor = Colors.white;
10+
double borderRadius = 0.0;
1011
BoxConstraints constraints;
1112

1213
YYDialog build(context) {
@@ -37,30 +38,45 @@ class YYDialog {
3738
);
3839
}
3940

40-
YYDialog doubleButton({padding, text, color, fontSize}) {
41+
YYDialog doubleButton({
42+
padding,
43+
mainAxisAlignment,
44+
text1,
45+
color1,
46+
fontSize1,
47+
fontWeight1,
48+
text2,
49+
color2,
50+
fontSize2,
51+
fontWeight2,
52+
}) {
4153
return this.widget(
4254
Padding(
4355
padding: padding ?? EdgeInsets.all(0.0),
4456
child: Row(
45-
mainAxisAlignment: MainAxisAlignment.end,
57+
mainAxisAlignment: mainAxisAlignment,
4658
children: <Widget>[
4759
FlatButton(
4860
onPressed: () {},
61+
padding: EdgeInsets.all(0.0),
4962
child: Text(
50-
text ?? "",
63+
text1 ?? "",
5164
style: TextStyle(
52-
color: color ?? Colors.black,
53-
fontSize: fontSize ?? 14.0,
65+
color: color1 ?? null,
66+
fontSize: fontSize1 ?? null,
67+
fontWeight: fontWeight1 ?? null,
5468
),
5569
),
5670
),
5771
FlatButton(
5872
onPressed: () {},
73+
padding: EdgeInsets.all(0.0),
5974
child: Text(
60-
text ?? "",
75+
text2 ?? "",
6176
style: TextStyle(
62-
color: color ?? Colors.black,
63-
fontSize: fontSize ?? 14.0,
77+
color: color2 ?? Colors.black,
78+
fontSize: fontSize2 ?? 14.0,
79+
fontWeight: fontWeight2 ?? null,
6480
),
6581
),
6682
)
@@ -83,10 +99,10 @@ class YYDialog {
8399
child: Container(
84100
width: width ?? null,
85101
height: height ?? null,
86-
decoration: decoration ??
87-
BoxDecoration(
88-
color: Colors.white,
89-
),
102+
decoration: BoxDecoration(
103+
borderRadius:BorderRadius.circular(borderRadius),
104+
color: backgroundColor,
105+
),
90106
constraints: constraints ??
91107
BoxConstraints(
92108
minHeight: size.height * .1,

0 commit comments

Comments
(0)

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /