/
cardview.dart
187 lines (183 loc) · 7.64 KB
/
cardview.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
import 'package:extended_image/extended_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_learn/utils/toast.dart';
class CardViewPage extends StatefulWidget {
CardViewPage(this.title, {Key key}) : super(key: key);
final String title;
@override
_CardViewPageState createState() => _CardViewPageState();
}
class _CardViewPageState extends State<CardViewPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Container(
padding: const EdgeInsets.all(0),
child: ListView(
scrollDirection: Axis.vertical, // 水平listView
children: <Widget>[getCardView1(), getCardView2()],
)));
}
Widget getCardView1() {
return Card(
clipBehavior: Clip.antiAlias, // 根据设置裁剪内容
color: Theme.of(context).primaryColor, // 卡片背景颜色
elevation: 20.0, // 卡片的z坐标,控制卡片下面的阴影大小
margin: EdgeInsets.all(20.0),
// margin: EdgeInsetsDirectional.only(bottom: 30.0, top: 30.0, start: 30.0),// 边距
semanticContainer:
true, // 表示单个语义容器,还是false表示单个语义节点的集合,接受单个child,但该child可以是Row,Column或其他包含子级列表的widget
// shape: Border.all(
// color: Colors.indigo, width: 1.0, style: BorderStyle.solid), // 卡片材质的形状,以及边框
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0)), // 圆角
//borderRadius: BorderRadius.all(Radius.circular(8.0)),
child: Column(
//card里面的子控件
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const ListTile(
leading: Icon(Icons.access_time, color: Colors.white),
title: Text('主题',
style: TextStyle(color: Colors.white, fontSize: 40.0)),
subtitle: Text('这里是副标题的内容,这里是副标题的内容,这里是副标题的内容',
style: TextStyle(color: Colors.white, fontSize: 16.0)),
contentPadding: EdgeInsets.only(
left: 20, top: 10, bottom: 10, right: 20), // item 内容内边距
),
ButtonBar(
children: <Widget>[
FlatButton(
child: const Text('按钮1',
style: TextStyle(color: Colors.white, fontSize: 14.0)),
onPressed: () {
XToast.toast('按钮1');
},
),
FlatButton(
child: const Text('按钮2',
style: TextStyle(color: Colors.white, fontSize: 14.0)),
onPressed: () {
XToast.toast('按钮2');
},
),
],
),
],
),
);
}
Widget getCardView2() {
return Card(
clipBehavior: Clip.antiAlias, // 根据设置裁剪内容
color: Colors.white, // 卡片背景颜色
elevation: 20.0, // 卡片的z坐标,控制卡片下面的阴影大小
margin: EdgeInsets.all(20.0),
semanticContainer: true,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0)), // 圆角
//borderRadius: BorderRadius.all(Radius.circular(8.0)),
child: Padding(
padding: EdgeInsets.only(left: 20, top: 20, bottom: 10, right: 20),
child: Column(
//card里面的子控件
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
children: <Widget>[
ClipOval(
child: ExtendedImage.network(
"https://gitee.com/xuexiangjys/Resource/raw/master/img/avatar/avatar_github.jpg",
fit: BoxFit.fitWidth,
width: 40,
height: 40,
)),
SizedBox(width: 10),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text("xuexiangjys",
style: TextStyle(color: Colors.black, fontSize: 16.0)),
Text("Android架构师 @南京某智能科技有限公司",
style: TextStyle(color: Colors.grey, fontSize: 12.0)),
],
),
],
),
SizedBox(height: 10),
Row(
children: <Widget>[
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text("XUI 一个简洁而优雅的Android原生UI框架,解放你的双手",
maxLines: 2,
softWrap: true,
overflow: TextOverflow.ellipsis,
style: TextStyle(color: Colors.black, fontSize: 16.0)),
SizedBox(height: 10),
Text(
"涵盖绝大部分的UI组件:TextView、Button、EditText、ImageView、Spinner、Picker、Dialog、PopupWindow、ProgressBar、LoadingView、StateLayout、FlowLayout、Switch、Actionbar、TabBar、Banner、GuideView、BadgeView、MarqueeView、WebView、SearchView等一系列的组件和丰富多彩的样式主题。",
maxLines: 4,
softWrap: true,
overflow: TextOverflow.ellipsis,
style: TextStyle(color: Colors.grey, fontSize: 12.0))
],
)),
SizedBox(width: 10),
ClipOval(
child: FadeInImage.assetNetwork(
placeholder: "assets/images/normal_user_icon.png", //预览图
fit: BoxFit.fitWidth,
image:
"https://img-blog.csdnimg.cn/2019011614245559.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3h1ZXhpYW5nanlz,size_16,color_FFFFFF,t_70",
width: 80,
height: 80,
),
),
],
),
SizedBox(height: 10),
Divider(height: 3),
Row(
children: <Widget>[
Expanded(
child: FlatButton.icon(
icon: Icon(Icons.thumb_up, size: 20, color: Colors.grey),
label: const Text('99',
style: TextStyle(color: Colors.grey, fontSize: 12)),
onPressed: () {
XToast.toast("点赞");
}),
),
Expanded(
child: FlatButton.icon(
icon: Icon(Icons.comment, size: 20, color: Colors.grey),
label: const Text('25',
style: TextStyle(color: Colors.grey, fontSize: 12)),
onPressed: () {
XToast.toast("评论");
}),
),
Expanded(
child: FlatButton.icon(
icon: Icon(Icons.share, size: 20, color: Colors.grey),
label: const Text('分享',
style: TextStyle(color: Colors.grey, fontSize: 12)),
onPressed: () {
XToast.toast("分享");
}),
)
],
)
],
),
),
);
}
}