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 a18ac09

Browse files
εΈƒε±€
1 parent baae531 commit a18ac09

File tree

3 files changed

+97
-65
lines changed

3 files changed

+97
-65
lines changed

β€Žlib/components/dialog.dart

Lines changed: 49 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:flutter/material.dart';
22

33
import '../flutter_custom_dialog.dart';
4+
import 'dialog_item.dart';
45

56
YYDialog YYAlertDialog1(BuildContext context) {
67
return YYDialog().build(context)
@@ -86,6 +87,53 @@ YYDialog YYAlertDialog3(BuildContext context) {
8687
..show();
8788
}
8889

90+
var listTileItems = [
91+
ListTileItem(
92+
onTap: () {},
93+
padding: EdgeInsets.fromLTRB(16.0, 6.0, 16.0, 6.0),
94+
leading: ClipOval(
95+
child: Image.network(
96+
"https://imgavater.ui.cn/avatar/3/3/4/9/1269433.jpg?imageMogr2/auto-orient/crop/!1219x1219a12a0/thumbnail/148x148",
97+
height: 50,
98+
width: 50,
99+
fit: BoxFit.cover,
100+
),
101+
),
102+
text: "user01@gmail.com",
103+
color: Colors.grey,
104+
fontSize: 16.0,
105+
),
106+
ListTileItem(
107+
onTap: () {},
108+
padding: EdgeInsets.fromLTRB(16.0, 6.0, 16.0, 6.0),
109+
leading: ClipOval(
110+
child: Image.network(
111+
"https://imgavater.ui.cn/avatar/1/4/7/8/958741.jpg?imageMogr2/auto-orient/crop/!563x563a377a167/thumbnail/60x60",
112+
height: 50,
113+
width: 50,
114+
fit: BoxFit.cover,
115+
),
116+
),
117+
text: "user02@gmail.com",
118+
color: Colors.grey,
119+
fontSize: 16.0,
120+
),
121+
ListTileItem(
122+
onTap: () {},
123+
padding: EdgeInsets.fromLTRB(16.0, 6.0, 16.0, 6.0),
124+
leading: ClipOval(
125+
child: Container(
126+
width: 50,
127+
height: 50,
128+
child: Icon(Icons.add, size: 30, color: Colors.white),
129+
color: Colors.grey[500],
130+
)),
131+
text: "Add account",
132+
color: Colors.grey,
133+
fontSize: 16.0,
134+
),
135+
];
136+
89137
YYDialog YYListTileDialog1(BuildContext context) {
90138
return YYDialog().build(context)
91139
..width = 280
@@ -97,47 +145,7 @@ YYDialog YYListTileDialog1(BuildContext context) {
97145
fontSize: 18.0,
98146
fontWeight: FontWeight.w500,
99147
)
100-
..listTile(
101-
padding: EdgeInsets.fromLTRB(16.0, 6.0, 16.0, 6.0),
102-
leading: ClipOval(
103-
child: Image.network(
104-
"https://imgavater.ui.cn/avatar/3/3/4/9/1269433.jpg?imageMogr2/auto-orient/crop/!1219x1219a12a0/thumbnail/148x148",
105-
height: 50,
106-
width: 50,
107-
fit: BoxFit.cover,
108-
),
109-
),
110-
text: "user01@gmail.com",
111-
color: Colors.grey,
112-
fontSize: 16.0,
113-
)
114-
..listTile(
115-
padding: EdgeInsets.fromLTRB(16.0, 6.0, 16.0, 6.0),
116-
leading: ClipOval(
117-
child: Image.network(
118-
"https://imgavater.ui.cn/avatar/1/4/7/8/958741.jpg?imageMogr2/auto-orient/crop/!563x563a377a167/thumbnail/60x60",
119-
height: 50,
120-
width: 50,
121-
fit: BoxFit.cover,
122-
),
123-
),
124-
text: "user02@gmail.com",
125-
color: Colors.grey,
126-
fontSize: 16.0,
127-
)
128-
..listTile(
129-
padding: EdgeInsets.fromLTRB(16.0, 6.0, 16.0, 6.0),
130-
leading: ClipOval(
131-
child: Container(
132-
width: 50,
133-
height: 50,
134-
child: Icon(Icons.add, size: 30, color: Colors.white),
135-
color: Colors.grey[500],
136-
)),
137-
text: "Add account",
138-
color: Colors.grey,
139-
fontSize: 16.0,
140-
)
148+
..listViewOfListTile(items: listTileItems)
141149
..show();
142150
}
143151

β€Žlib/components/dialog_item.dart

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import 'package:flutter/material.dart';
2+
3+
class ListTileItem {
4+
ListTileItem({
5+
this.padding,
6+
this.leading,
7+
this.text,
8+
this.color,
9+
this.fontSize,
10+
this.fontWeight,
11+
this.onTap,
12+
});
13+
14+
EdgeInsets padding;
15+
Widget leading;
16+
String text;
17+
Color color;
18+
double fontSize;
19+
FontWeight fontWeight;
20+
GestureTapCallback onTap;
21+
}

β€Žlib/flutter_custom_dialog.dart

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import 'package:flutter/material.dart';
22

3+
import 'components/dialog_item.dart';
4+
35
class YYDialog {
46
List<Widget> widgetList = [];
57
BuildContext context;
@@ -87,33 +89,33 @@ class YYDialog {
8789
);
8890
}
8991

90-
YYDialog listTile({
91-
padding,
92-
leading,
93-
text,
94-
color,
95-
fontSize,
96-
fontWeight,
97-
GestureTapCallback onTap,
98-
}) {
92+
YYDialog listViewOfListTile({List<ListTileItem> items}) {
9993
return this.widget(
10094
Material(
101-
borderRadius: BorderRadius.circular(borderRadius),
102-
color: Colors.white,
103-
child: InkWell(
104-
onTap: onTap,
105-
child: ListTile(
106-
contentPadding: padding,
107-
leading: leading,
108-
title: Text(
109-
text ?? "",
110-
style: TextStyle(
111-
color: color ?? null,
112-
fontSize: fontSize ?? null,
113-
fontWeight: fontWeight ?? null,
95+
child: ListView.builder(
96+
padding: EdgeInsets.all(0.0),
97+
shrinkWrap: true,
98+
itemCount: items.length,
99+
itemBuilder: (BuildContext context, int index) {
100+
return Material(
101+
color: Colors.white,
102+
child: InkWell(
103+
onTap: items[index].onTap,
104+
child: ListTile(
105+
contentPadding: items[index].padding,
106+
leading: items[index].leading,
107+
title: Text(
108+
items[index].text ?? "",
109+
style: TextStyle(
110+
color: items[index].color ?? null,
111+
fontSize: items[index].fontSize ?? null,
112+
fontWeight: items[index].fontWeight ?? null,
113+
),
114+
),
115+
),
114116
),
115-
),
116-
),
117+
);
118+
},
117119
),
118120
),
119121
);
@@ -139,6 +141,7 @@ class YYDialog {
139141
Material(
140142
type: MaterialType.transparency,
141143
child: Container(
144+
padding: EdgeInsets.all(borderRadius / 3.14),
142145
width: width ?? null,
143146
height: height ?? null,
144147
decoration: BoxDecoration(

0 commit comments

Comments
(0)

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