category_item.dart
3.46 KB
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
import 'package:common_utils/common_utils.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:one_poem/category/models/category_item_entity.dart';
import 'package:one_poem/res/gaps.dart';
import 'package:one_poem/res/resources.dart';
import 'package:one_poem/util/device_utils.dart';
import 'package:one_poem/util/other_utils.dart';
import 'package:one_poem/widgets/load_image.dart';
class CategoryItem extends StatelessWidget {
const CategoryItem({
Key? key,
required this.item,
required this.index,
required this.selectIndex,
required this.onTapMenu,
required this.onTapEdit,
required this.onTapOperation,
required this.onTapDelete,
required this.onTapMenuClose,
required this.animation,
required this.heroTag,
}) : super(key: key);
final CategoryItemEntity item;
final int index;
final int selectIndex;
final VoidCallback onTapMenu;
final VoidCallback onTapEdit;
final VoidCallback onTapOperation;
final VoidCallback onTapDelete;
final VoidCallback onTapMenuClose;
final Animation<double> animation;
final String heroTag;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(left: 10.0, top: 10.0, right: 10.0),
child: DecoratedBox(
decoration: BoxDecoration(
image: const DecorationImage(
image: AssetImage("assets/images/category/category_item_bg.png"),
fit: BoxFit.fill,
),
border: Border.all(color: Colors.grey, width: 0.5), // 边色与边宽度
borderRadius: BorderRadius.circular(2.0),
),
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.max,
//交叉轴的布局方式,对于column来说就是水平方向的布局方式
crossAxisAlignment: CrossAxisAlignment.center,
children: const <Widget>[
Text("此地"),
Text("北京 海淀 万泉庄", maxLines: 3,),
Text("京", style: TextStyle(fontSize: 30)),
],
),
Gaps.vGap16,
const Text(
"前不见古人,后不见来者。\n念天地之悠悠,独怆然而涕下。\n",
style: TextStyle(fontSize: 22.0, fontFamily: "ZCOOLXiaoWei"),
),
const Text("[唐] 陈子昂《登幽州台歌》", maxLines: 1,),
],
),
),
),
);
}
}
class _GoodsItemTag extends StatelessWidget {
const _GoodsItemTag({
Key? key,
required this.color,
required this.text,
}) : super(key: key);
final Color? color;
final String text;
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 4.0),
margin: const EdgeInsets.only(right: 4.0),
decoration: BoxDecoration(
color: color,
borderRadius: BorderRadius.circular(2.0),
),
height: 16.0,
alignment: Alignment.center,
child: Text(
text,
style: TextStyle(
color: Colors.white,
fontSize: Dimens.font_sp10,
height: Device.isAndroid ? 1.1 : null,
),
),
);
}
}