Skip to content

Commit 03fa994

Browse files
samsam
authored andcommitted
feat: IconButton
1 parent 43bfe2a commit 03fa994

File tree

3 files changed

+78
-5
lines changed

3 files changed

+78
-5
lines changed
Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,32 @@
1-
## **文档完善中**
1+
## **IconButton**
2+
>
3+
图标按钮,通过填充颜色(墨水)对触摸做出反应
4+
5+
### 构造方法
6+
``` dart
7+
IconButton({
8+
Key key,
9+
this.iconSize = 24.0,
10+
this.padding = const EdgeInsets.all(8.0),
11+
this.alignment = Alignment.center,
12+
@required this.icon,
13+
this.color,
14+
this.highlightColor,
15+
this.splashColor,
16+
this.disabledColor,
17+
@required this.onPressed,
18+
this.tooltip
19+
})
20+
```
21+
22+
### 属性介绍
23+
* iconSize = 24.0:图标大小
24+
* padding = const EdgeInsets.all(8.0):按钮图标周围的填充
25+
* alignment = Alignment.center:图标对齐方式
26+
* icon:图标
27+
* color:图标颜色
28+
* highlightColor:按钮处于按下时按钮的辅助颜色
29+
* splashColor:按钮处于按下状态时按钮颜色
30+
* disabledColor:图标被禁用时按钮内图标的颜色
31+
* onPressed:点击回调
32+
* tooltip:长按文本提示

lib/widget/common/iconbutton/demo.dart

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ class Index extends StatefulWidget {
66
}
77

88
class _IndexState extends State<Index> {
9+
List data = [58273,58275,59493,57903,58283,58284,57771,58285];
10+
int index = 0;
911
@override
1012
void initState() {
1113
super.initState();
@@ -17,9 +19,49 @@ class _IndexState extends State<Index> {
1719
appBar: AppBar(
1820
title: Text('IconButton'),
1921
),
20-
body: Center(
21-
child: Text('更新中'),
22-
),
22+
body: Container(
23+
padding: EdgeInsets.fromLTRB(20.0, 0, 20.0, 0),
24+
child: ListView(
25+
children: <Widget>[
26+
IconButton(
27+
iconSize: 30.0,
28+
padding: EdgeInsets.all(8.0),
29+
alignment: Alignment.center,
30+
icon: Icon(IconData(
31+
data[index],
32+
fontFamily: 'MaterialIcons',
33+
matchTextDirection: true
34+
)),
35+
color: Theme.of(context).primaryColor,
36+
highlightColor: Colors.black12,
37+
splashColor: Theme.of(context).primaryColorLight,
38+
onPressed: (){
39+
if (index < 7) {
40+
this.setState(() {
41+
index = index + 1;
42+
});
43+
} else {
44+
this.setState(() {
45+
index = 0;
46+
});
47+
}
48+
},
49+
tooltip: '长按文本提示',
50+
),
51+
IconButton(
52+
iconSize: 30.0,
53+
padding: EdgeInsets.all(8.0),
54+
alignment: Alignment.center,
55+
icon: Icon(Icons.sync_disabled),
56+
color: Theme.of(context).primaryColor,
57+
highlightColor: Colors.black12,
58+
splashColor: Theme.of(context).primaryColorLight,
59+
tooltip: '长按文本提示',
60+
disabledColor: Colors.grey
61+
)
62+
],
63+
),
64+
)
2365
);
2466
}
2567
}

readme/widget_progress.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Flutter UI
5454
│ ├─divider 【✔️ v1.0】
5555
│ ├─flatbutton 【✔️ v1.0】
5656
│ ├─icon 【✔️ v1.0】
57-
│ ├─iconbutton
57+
│ ├─iconbutton 【✔️ v1.0】
5858
│ ├─image 【✔️ v1.0】
5959
│ ├─listtile 【✔️ v1.0】
6060
│ ├─placeholder

0 commit comments

Comments
 (0)