area_item.dart
2.99 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
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';
class AreaItem extends StatefulWidget {
final String? currentArea; //当前选中区域名称
final Area area;
final ValueChanged selectCallback;
final bool need;
AreaItem(this.area, this.currentArea, this.selectCallback,
{this.need = true});
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return new AreaItemState();
}
}
class AreaItemState extends State<AreaItem> {
@override
Widget build(BuildContext context) {
// TODO: implement build
Area area = widget.area;
bool isSelected = area.name == widget.currentArea;
return GestureDetector(
onTap: () {
widget.selectCallback(widget.area);
},
child: Stack(
children: <Widget>[
Container(
width: ScreenUtil().setWidth(189),
height: ScreenUtil().setHeight(207),
alignment: Alignment.center,
decoration: BoxDecoration(
color: isSelected
? MyColours.color_ffffff
: MyColours.color_f1f1f1,
border: Border(
bottom: BorderSide(
color: MyColours.color_ffffff,
width: ScreenUtil().setHeight(1)))),
child: Text(
area.name!,
style: TextStyle(
color: isSelected
? MyColours.color_2bb5b7
: MyColours.color_828282,
fontSize: ScreenUtil().setSp(32),
decoration: TextDecoration.none,
fontWeight: FontWeight.normal),
),
),
widget.need
? 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}",
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(26),
decoration: TextDecoration.none,
fontWeight: FontWeight.normal)),
),
)
: SizedBox(),
],
),
);
}
}