area_item_table.dart
3.2 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
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/area.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/widgets/h_empty_view.dart';
class AreaItemTable extends StatefulWidget {
final String currentArea; //当前选中区域名称
final Area area;
final ValueChanged selectCallback;
AreaItemTable(this.area, this.currentArea, this.selectCallback);
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return new AreaItemTableState();
}
}
class AreaItemTableState extends State<AreaItemTable> {
@override
Widget build(BuildContext context) {
// TODO: implement build
Area area = widget.area;
bool isSelected = area.name == widget.currentArea;
return GestureDetector(
onTap: () {
if (widget.selectCallback != null) {
widget.selectCallback(widget.area);
}
},
child: Stack(
children: <Widget>[
Container(
// width: ScreenUtil().setWidth(189),
height: ScreenUtil().setWidth(50),
margin: EdgeInsets.only(right: ScreenUtil().setWidth(40)),
padding:
EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(40)),
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(ScreenUtil().setWidth(30)),
color: isSelected
? MyColours.color_199095
: MyColours.color_ffffff,
border: Border.all(
color: MyColours.color_199095,
width: ScreenUtil().setWidth(2))),
child: Text(
area.name,
style: TextStyle(
color: isSelected
? MyColours.color_ffffff
: MyColours.color_199095,
fontSize: ScreenUtil().setSp(32),
decoration: TextDecoration.none,
fontWeight: FontWeight.normal),
),
),
Positioned(
left: 0,
top: 0,
child: Container(
width: ScreenUtil().setWidth(73),
height: ScreenUtil().setHeight(37),
alignment: Alignment.center,
decoration: BoxDecoration(
color: area.count <= 0
? MyColours.color_999999
: MyColours.color_63a6d1,
borderRadius: BorderRadius.only(
topRight: Radius.circular(ScreenUtil().setWidth(8)),
bottomRight: Radius.circular(ScreenUtil().setWidth(8)))),
child: Text(
area.count == 0
? "满座"
: area.count == -1
? '无'
: "余${area.count}",
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(26),
decoration: TextDecoration.none,
fontWeight: FontWeight.normal)),
),
),
],
),
);
}
}