areas_select_page.dart
8.88 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
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/area.dart';
import 'package:one_key/provider/my_table_manage_home_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/page_exception.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:provider/provider.dart';
import '../../../utils/screen_util.dart';
import '../../../widgets/round_button.dart';
/*
**** 区域选择管理
*/
class AreasSelectPage extends StatefulWidget {
final String? rid;
final String? name;
AreasSelectPage({Key? key, this.rid, this.name}) : super(key: key);
@override
_AreasSelectPageState createState() => _AreasSelectPageState();
}
class _AreasSelectPageState extends State<AreasSelectPage> {
late MyTableManageHomeModel tableManagerModel;
String? rid;
String? name;
@override
void initState() {
// TODO: implement initState
super.initState();
rid = widget.rid;
WidgetsBinding.instance.addPostFrameCallback((_) {
tableManagerModel.initTime(context);
// EventBus().on("refresh_tablemanager", (arg) {
// //订座-完成预订 刷新管理桌位
// tableManagerModel.getReserveList(context,
// needLoading: false, needKeep: true);
// print(tableManagerModel);
// });
// EventBus().on("refresh_tablePhoto", (arg) {
// ///刷新图片显示
// _refreshTablePhoto();
// });
});
}
@override
Widget build(BuildContext context) {
tableManagerModel =
Provider.of<MyTableManageHomeModel>(context, listen: true);
return Scaffold(
resizeToAvoidBottomInset: false, //输入框抵住键盘
appBar: SystemAppBar(
"区域选择",
showLeading: true,
onTap: () {
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
},
),
backgroundColor: MyColours.color_ffffff,
body: SafeArea(child:
Consumer<MyTableManageHomeModel>(builder: (context, model, child) {
return model.pageState != PageState.Success
? ExceptionPage(
pageState: model.pageState,
callback: () {
// if (tableManagerModel.tableOuterList.isEmpty) {
// tableManagerModel.getTableList(context);
// } else {
// tableManagerModel.getReserveList(context);
// }
},
emptyMsg: "暂时没有区域数据哦",
emptyImg: "table_manage_empty",
showMsg: "加载中,请稍候...",
)
: Column(
children: [
Expanded(
child: ListView.builder(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(32),
vertical: ScreenUtil().setWidth(54)),
itemCount: tableManagerModel.areas.length,
shrinkWrap: true,
// scrollDirection: Axis.horizontal,
itemBuilder: (BuildContext contxt, int index) {
Area area = tableManagerModel.areas[index];
return InkWell(
onTap: () async {
if (rid == area.rid) {
return;
}
rid = area.rid;
name = area.name;
setState(() {});
},
child: Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(16),
vertical: ScreenUtil().setWidth(30)),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
width: ScreenUtil().setWidth(2),
color:
MyColours.color_E7E7E7))),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Image.asset(
Utils.getImgPath(rid == area.rid
? 'select'
: 'unselect'),
width: w(20),
),
HEmptyView(30),
Expanded(
child: Text(area.name!,
// textAlign: TextAlign.end,
style: TextStyle(
color:
MyColours.color_000000,
fontSize: ScreenUtil()
.setSp(32)))),
],
),
));
})),
Container(
color: MyColours.color_ffffff,
padding: EdgeInsets.symmetric(horizontal: w(48)),
margin: EdgeInsets.only(bottom: w(35), top: w(25)),
child: RoundButton(
// content: widget.fromPage == 'tablePhoto'
// ? '确定'
// : "已选${selectNum}个 确定",
text: '确定',
// width: w(128),
height: w(40),
radius: r(4),
isBold: false,
gradientStart: MyColours.color_438E93,
gradientEnd: MyColours.color_438E93,
fontSize: 28,
textColor: MyColours.color_ffffff,
onPressed: () {
// // if (widget.fromPage == "tablePhoto") {
// // Map temp = {
// // 'tid': selectTables.length > 0
// // ? selectTables[0].id
// // : '',
// // 'tname': selectTables.length > 0
// // ? selectTables[0].name
// // : ''
// // };
// // Navigator.of(context).pop(temp);
// // } else {
// if (widget.canChoose) {
// // // if (widget.tableList.length > 0) {
// // String tid = "";
// // for (TableList table
// // in widget.tableList) {
// // tid += table.id + ",";
// // }
// // if (widget.tableList.length > 0) {
// // tid = tid.substring(
// // 0, tid.length - 1);
// // }
Map temp = {'rid': rid, 'name': name};
Navigator.of(context).pop(temp);
// // // }
// // } else {
// String tid = "";
// for (t.Table table in selectTables) {
// tid += table.id + ",";
// }
// if (selectTables.length > 0) {
// tid = tid.substring(0, tid.length - 1);
// }
// Map temp = {'object': selectTables, 'tid': tid};
// Navigator.of(context).pop(temp);
// }
// }
},
),
)
],
);
})));
}
}