feast_wine_manage_page.dart
9.04 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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/wine_model.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
import '../../../constant/state.dart';
import '../../../provider/feast_model.dart';
import '../../../provider/user_model.dart';
import '../../../res/colors.dart';
import '../../../utils/dialog_util.dart';
import '../../../utils/event_bus.dart';
import '../../../utils/screen_util.dart';
import '../../../utils/utils.dart';
import '../../../widgets/h_empty_view.dart';
import '../../../widgets/page_exception.dart';
import '../../../widgets/round_button.dart';
import '../../../widgets/system_app_bar.dart';
/**
* 酒水管理
*/
class FeastWineManagePage extends StatefulWidget {
FeastWineManagePage({Key? key}) : super(key: key);
@override
_FeastWineManagePageState createState() => _FeastWineManagePageState();
}
class _FeastWineManagePageState extends State<FeastWineManagePage> {
late FeastModel feastModel;
@override
void initState() {
super.initState();
Utils.changeStatusColor(color: MyColours.color_438E93);
WidgetsBinding.instance.addPostFrameCallback((_) {
_getWine();
// scrollController.jumpTo(scrollController.position.minScrollExtent);
});
bus.on("feast_wine_list", (arg) {
_getWine();
});
}
@override
void dispose() {
bus.off('feast_wine_list');
super.dispose();
}
///获取酒水
_getWine({bool isShowLoading = true}) async {
await feastModel.getWine(context, isShowLoading: isShowLoading);
}
Widget buildFeastTypeHeader() {
return RoundButton(
onPressed: () async {
NavigatorUtil.goFeastWineManageEditPage(
context,
);
},
text: '添加一项',
fontSize: 32,
isBold: false,
height: h(32),
width: w(80),
margin: EdgeInsets.only(top: w(18), bottom: w(4)),
textColor: MyColours.color_438E93,
gradientStart: MyColours.color_ffffff,
gradientEnd: MyColours.color_ffffff,
borderColor: MyColours.color_438E93,
radius: r(6),
);
}
Widget buildFeastTypeItem(WineSunModel data, int index) {
return Container(
height: h(48),
margin: EdgeInsets.only(top: w(12)),
decoration: BoxDecoration(
border: Border(
bottom:
BorderSide(width: w(0.5), color: MyColours.color_E7E7E7))),
child: Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
data.wineName!,
style: TextStyle(
fontSize: font(16), color: MyColours.color_E6000000),
),
VEmptyView(12),
Text(
// '剑南春52度500ml', '1150元/份 不可议价'
'${data.price}元/${data.spec} ${data.bargaining == '1' ? '可议价' : '不可议价'}',
style: TextStyle(
fontSize: font(12), color: MyColours.color_999999),
)
],
),
Spacer(),
InkWell(
onTap: () {
NavigatorUtil.goFeastWineManageEditPage(context,
isNew: false, wineSunModel: data);
},
child: Text(
'修改',
style: TextStyle(
decoration: TextDecoration.underline,
fontSize: font(16),
color: MyColours.color_438E93),
)),
HEmptyView(32),
InkWell(
onTap: () {
//已经传到服务器,弹提醒窗口,是否删除
//修改之前有内容,则弹框
DialogUtil.cupertinoAlertDialogFeast(context,
rTitle: '删除',
title: "是否确认删除",
content: data.wineName, lCallback: () {
print("取消");
}, rCallback: () async {
print("确定");
Map<String, String?> pramas = {'id': data.id};
bool success = await feastModel.delWine(context, pramas) ;
if (success) {
Utils.showToast('删除成功');
_getWine(isShowLoading: true);
}
});
},
child: Image.asset(
Utils.getImgPath('f_delete_red'),
width: w(32),
height: w(32),
)),
HEmptyView(32),
],
),
);
}
Widget _callButton(
{GestureTapCallback? onPress,
required content,
hasLeftBorder = true,
isSelect = false}) {
return InkWell(
onTap: onPress,
child: Container(
height: h(48),
decoration: BoxDecoration(
color: isSelect ? MyColours.color_438E93 : MyColours.color_ffffff,
border: Border(
bottom: BorderSide(
color: MyColours.color_438E93,
width: ScreenUtil().setWidth(2)),
top: BorderSide(
color: MyColours.color_438E93,
width: ScreenUtil().setWidth(2)),
left: hasLeftBorder
? BorderSide(
color: MyColours.color_438E93,
width: ScreenUtil().setWidth(2))
: BorderSide.none,
right: BorderSide(
color: MyColours.color_438E93,
width: ScreenUtil().setWidth(2)))),
child: Align(
alignment: Alignment.center,
child: Text(
content,
style: TextStyle(
color:
isSelect ? MyColours.color_F6F6F6 : MyColours.color_438E93,
fontSize: ScreenUtil().setSp(36)),
),
),
),
);
}
@override
Widget build(BuildContext context) {
feastModel = Provider.of<FeastModel>(context, listen: true);
return Scaffold(
backgroundColor: MyColours.color_ffffff,
resizeToAvoidBottomInset: false,
/// 这里必须禁止重绘
appBar: SystemAppBar(
'酒水管理',
needWhite: true,
bgColor: MyColours.color_438E93,
titleColor: MyColours.color_F6F6F6,
onTap: () {
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
},
),
body: Column(
children: [
Expanded(
child: NestedScrollView(
// controller: _scrollViewController,
headerSliverBuilder:
(BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverAppBar(
pinned: true,
floating: false,
leading: null,
backgroundColor: MyColours.color_ffffff,
expandedHeight: ScreenUtil().setWidth(56 * 2),
automaticallyImplyLeading: false,
title: buildFeastTypeHeader(),
// flexibleSpace: FlexibleSpaceBar(
// collapseMode: CollapseMode.pin,
// title: buildFeastTypeHeader())
)
];
}, body: Consumer<FeastModel>(builder: (context, model, _) {
if (model.pageStateWine != PageState.Success) {
return ExceptionPage(
pageState: model.pageStateWine,
callback: () {
_getWine();
},
emptyMsg: "暂时没有酒水哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍候...",
);
} else {
return ListView.builder(
itemCount: feastModel.wineData!.length,
padding: EdgeInsets.only(left: w(16)),
itemBuilder: (BuildContext context, int index) {
WineSunModel data = feastModel.wineData![index];
return buildFeastTypeItem(data, index);
// '剑南春52度500ml', '1150元/份 不可议价'
});
}
}))),
// Row(
// children: [
// Expanded(
// child: _callButton(
// onPress: () {
// Navigator.pop(context);
// },
// content: '返回',
// hasLeftBorder: true,
// isSelect: false)),
// Expanded(
// child: _callButton(
// onPress: () {},
// content: '保存',
// hasLeftBorder: true,
// isSelect: true))
// ],
// )
],
));
}
}