Commit 8a26c243fe4f9e5c4d4d638d53d941b30b8ced7d

Authored by wdn127929
1 parent cdc6147a

已预订----OK

... ... @@ -24,8 +24,9 @@ import 'package:provider/provider.dart';
class NoteBookItemF extends StatefulWidget {
final num index;
final Notebook notebook;
final GestureTapCallback onTap;
NoteBookItemF(this.notebook, this.index);
NoteBookItemF(this.notebook, this.index, this.onTap);
@override
State<StatefulWidget> createState() {
... ... @@ -420,12 +421,7 @@ class NoteBookItemFState extends State<NoteBookItemF>
}
}
Color bgColor = notebook.status == '0' ||
notebook.status == "2" ||
notebook.status == "1" ||
notebook.status == '5'
? MyColours.color_438E93
: MyColours.color_BFC4D4;
Color bgColor = canDo ? MyColours.color_438E93 : MyColours.color_BFC4D4;
String detail = '';
if (notebook.tid.split(",").length >= 2) {
... ... @@ -468,72 +464,90 @@ class NoteBookItemFState extends State<NoteBookItemF>
),
child: Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
width: ScreenUtil().setWidth(82 * 2),
margin:
EdgeInsets.only(bottom: ScreenUtil().setWidth(9 * 2)),
alignment: Alignment.center,
child: Text(
notebook.name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: bgColor,
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(32)),
),
),
Padding(
padding: EdgeInsets.only(
bottom: ScreenUtil().setWidth(9 * 2)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Offstage(
offstage: notebook.tid.split(",").length < 2,
child: Image.asset(
Utils.getImgPath('ordered_lian'),
width: ScreenUtil().setWidth(18 * 2),
),
),
notebook.cusdem == null || notebook.cusdem == ''
? SizedBox()
: HEmptyView(8),
Offstage(
offstage: notebook.cusdem == null ||
notebook.cusdem == '',
child: Image.asset(
Utils.getImgPath('ordered_bei'),
width: ScreenUtil().setWidth(18 * 2),
),
),
false ? SizedBox() : HEmptyView(8),
Offstage(
offstage: notebook.aname == null,
child: Image.asset(
Utils.getImgPath('ordered_hui'),
width: ScreenUtil().setWidth(18 * 2),
),
)
],
)),
widget.notebook.operationText == ''
? SizedBox()
: RoundButton(
text: widget.notebook.operationText,
gradientStart: bgColor,
gradientEnd: bgColor,
textColor: MyColours.color_ffffff,
radius: ScreenUtil().setWidth(6),
fontSize: 24,
width: ScreenUtil().setWidth(42 * 2),
height: ScreenUtil().setWidth(17 * 2),
)
],
),
InkWell(
onTap: widget.onTap,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
width: ScreenUtil().setWidth(82 * 2),
alignment: Alignment.center,
child: Text(
notebook.name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: bgColor,
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(32)),
),
),
canDo &&
(notebook.tid.split(",").length >= 2 ||
(notebook.cusdem != null &&
notebook.cusdem != '') ||
notebook.aname != null)
? VEmptyView(18)
: SizedBox(),
canDo &&
(notebook.tid.split(",").length >= 2 ||
(notebook.cusdem != null &&
notebook.cusdem != '') ||
notebook.aname != null)
? Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: [
Offstage(
offstage:
notebook.tid.split(",").length < 2,
child: Image.asset(
Utils.getImgPath('ordered_lian'),
width: ScreenUtil().setWidth(18 * 2),
),
),
notebook.cusdem == null ||
notebook.cusdem == ''
? SizedBox()
: HEmptyView(8),
Offstage(
offstage: notebook.cusdem == null ||
notebook.cusdem == '',
child: Image.asset(
Utils.getImgPath('ordered_bei'),
width: ScreenUtil().setWidth(18 * 2),
),
),
notebook.aname == null
? SizedBox()
: HEmptyView(8),
Offstage(
offstage: notebook.aname == null,
child: Image.asset(
Utils.getImgPath('ordered_hui'),
width: ScreenUtil().setWidth(18 * 2),
),
)
],
)
: SizedBox(),
widget.notebook.operationText == ''
? SizedBox()
: VEmptyView(18),
widget.notebook.operationText == ''
? SizedBox()
: RoundButton(
text: widget.notebook.operationText,
gradientStart: bgColor,
gradientEnd: bgColor,
textColor: MyColours.color_ffffff,
radius: ScreenUtil().setWidth(6),
fontSize: 24,
width: ScreenUtil().setWidth(42 * 2),
height: ScreenUtil().setWidth(17 * 2),
)
],
)),
HEmptyView(24),
MyDivider(
ScreenUtil().setWidth(2),
... ...
... ... @@ -36,8 +36,9 @@ import 'package:provider/provider.dart';
class NoteBookItemSimple extends StatefulWidget {
final num index;
final Notebook notebook;
final GestureTapCallback onTap;
NoteBookItemSimple(this.notebook, this.index);
NoteBookItemSimple(this.notebook, this.index, this.onTap);
@override
State<StatefulWidget> createState() {
... ... @@ -432,12 +433,7 @@ class NoteBookItemSimpleState extends State<NoteBookItemSimple>
}
}
Color bgColor = notebook.status == '0' ||
notebook.status == "2" ||
notebook.status == "1" ||
notebook.status == '5'
? MyColours.color_438E93
: MyColours.color_BFC4D4;
Color bgColor = canDo ? MyColours.color_438E93 : MyColours.color_BFC4D4;
String detail = '';
if (notebook.tid.split(",").length >= 2) {
... ... @@ -480,38 +476,41 @@ class NoteBookItemSimpleState extends State<NoteBookItemSimple>
),
child: Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
width: ScreenUtil().setWidth(82 * 2),
margin:
EdgeInsets.only(bottom: ScreenUtil().setWidth(9 * 2)),
alignment: Alignment.center,
child: Text(
notebook.name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: bgColor,
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(32)),
),
),
widget.notebook.operationText == ''
? SizedBox()
: RoundButton(
text: widget.notebook.operationText,
gradientStart: bgColor,
gradientEnd: bgColor,
textColor: MyColours.color_ffffff,
radius: ScreenUtil().setWidth(6),
fontSize: 24,
width: ScreenUtil().setWidth(42 * 2),
height: ScreenUtil().setWidth(17 * 2),
)
],
),
InkWell(
onTap: widget.onTap,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
width: ScreenUtil().setWidth(82 * 2),
alignment: Alignment.center,
child: Text(
notebook.name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: bgColor,
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(32)),
),
),
widget.notebook.operationText == ''
? SizedBox()
: VEmptyView(18),
widget.notebook.operationText == ''
? SizedBox()
: RoundButton(
text: widget.notebook.operationText,
gradientStart: bgColor,
gradientEnd: bgColor,
textColor: MyColours.color_ffffff,
radius: ScreenUtil().setWidth(6),
fontSize: 24,
width: ScreenUtil().setWidth(42 * 2),
height: ScreenUtil().setWidth(17 * 2),
)
],
)),
HEmptyView(24),
MyDivider(
ScreenUtil().setWidth(2),
... ... @@ -589,61 +588,68 @@ class NoteBookItemSimpleState extends State<NoteBookItemSimple>
children: [
notebook.nick_name == null
? SizedBox()
: Text(
notebook.nick_name + '订',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: MyColours.color_999999,
fontSize:
ScreenUtil().setSp(24)),
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: [
Offstage(
offstage: notebook.tid
.split(",")
.length <
2,
child: Image.asset(
Utils.getImgPath(
'ordered_lian'),
width: ScreenUtil()
.setWidth(18 * 2),
),
),
notebook.cusdem == null ||
notebook.cusdem == ''
? SizedBox()
: HEmptyView(8),
Offstage(
offstage:
notebook.cusdem == null ||
notebook.cusdem == '',
child: Image.asset(
Utils.getImgPath(
'ordered_bei'),
width: ScreenUtil()
.setWidth(18 * 2),
: Padding(
padding: EdgeInsets.only(
right:
ScreenUtil().setWidth(6)),
child: Text(
notebook.nick_name + '订',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color:
MyColours.color_999999,
fontSize:
ScreenUtil().setSp(24)),
)),
canDo
? Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: [
Offstage(
offstage: notebook.tid
.split(",")
.length <
2,
child: Image.asset(
Utils.getImgPath(
'ordered_lian'),
width: ScreenUtil()
.setWidth(18 * 2),
),
),
),
false
? SizedBox()
: HEmptyView(8),
Offstage(
offstage:
notebook.aname == null,
child: Image.asset(
Utils.getImgPath(
'ordered_hui'),
width: ScreenUtil()
.setWidth(18 * 2),
notebook.cusdem == null ||
notebook.cusdem == ''
? SizedBox()
: HEmptyView(8),
Offstage(
offstage:
notebook.cusdem == null ||
notebook.cusdem == '',
child: Image.asset(
Utils.getImgPath(
'ordered_bei'),
width: ScreenUtil()
.setWidth(18 * 2),
),
),
)
],
),
notebook.aname == null
? SizedBox()
: HEmptyView(8),
Offstage(
offstage:
notebook.aname == null,
child: Image.asset(
Utils.getImgPath(
'ordered_hui'),
width: ScreenUtil()
.setWidth(18 * 2),
),
)
],
)
: SizedBox(),
],
)
],
... ...
... ... @@ -3,6 +3,7 @@ import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/app.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/notebook.dart';
import 'package:one_key/pages/notebook/notebook_item_f.dart';
... ... @@ -68,6 +69,7 @@ class NoteBookPageState extends State<NoteBookPage> {
void initState() {
// TODO: implement initState
super.initState();
isSimple = App.sp.getBool("isSimple") ?? true;
tabIndex = widget.tabIndex;
LogUtil.v("notebook_page initState");
... ... @@ -521,6 +523,26 @@ class NoteBookPageState extends State<NoteBookPage> {
}
}
//获取全选按钮的状态 true or false
getCheckValue() {
bool temp = noteBookModel.notebooks.any((value) {
return value.issimple == false;
});
if (temp == true) {
isSimple = false;
} else {
isSimple = true;
}
setState(() {});
App.sp.setBool("isSimple", isSimple);
}
///单个item切换模式
_itemChangeSimple(Notebook notebook) {
notebook.issimple = !notebook.issimple;
getCheckValue();
}
@override
Widget build(BuildContext context) {
// TODO: implement build
... ... @@ -570,8 +592,8 @@ class NoteBookPageState extends State<NoteBookPage> {
dateText = '更多\n日期';
});
// _currTimeIndex();
// _getSellerTableClass();
_getReserveList();
_reserveCountDay();
}
},
availableGestures: AvailableGestures.none,
... ... @@ -942,6 +964,7 @@ class NoteBookPageState extends State<NoteBookPage> {
isSimple = !isSimple;
});
_simpleState();
App.sp.setBool("isSimple", isSimple);
},
child: Column(
children: [
... ... @@ -991,9 +1014,15 @@ class NoteBookPageState extends State<NoteBookPage> {
bottom: ScreenUtil().setWidth(24)),
child: model.notebooks[index].issimple
? NoteBookItemSimple(
model.notebooks[index], index)
model.notebooks[index], index, () {
_itemChangeSimple(
model.notebooks[index]);
})
: NoteBookItemF(
model.notebooks[index], index),
model.notebooks[index], index, () {
_itemChangeSimple(
model.notebooks[index]);
}),
);
}, childCount: model.notebooks.length),
// itemExtent: ScreenUtil().setWidth(112),
... ... @@ -1009,173 +1038,5 @@ class NoteBookPageState extends State<NoteBookPage> {
],
)),
);
return Container(
width: double.infinity,
height: double.infinity,
color: MyColours.color_f5f5f5,
child: Column(
children: <Widget>[
_buildTabbar(),
Container(
color: MyColours.color_ffffff,
width: double.infinity,
padding: EdgeInsets.only(bottom: ScreenUtil().setWidth(16)),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Expanded(
child: Center(
child: GestureDetector(
onTap: () {
DialogUtil.showCalendarDialog(context, dateTimeNow)
.then((day) {
if (day != null) {
_createDateText(day);
}
});
},
child: Container(
child: Text(
dateText,
style: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setSp(34)),
),
),
),
),
),
MyDivider(
ScreenUtil().setWidth(2),
ScreenUtil().setHeight(68),
color: MyColours.color_E0E0E0,
),
Expanded(
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(30)),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Offstage(
offstage: morning == "00:00-00:00" ? true : false,
child: Padding(
padding: EdgeInsets.only(
right: ScreenUtil().setWidth(18)),
child: CommonButton(
content: "早市",
state: currTimeIndex == 1 ? 1 : 0,
width: 92,
height: 48,
fontSize: 32,
onPress: () {
if (currTimeIndex == 1) return;
setState(() {
currTimeIndex = 1;
});
_getReserveList();
},
))),
Offstage(
offstage: noon == "00:00-00:00" ? true : false,
child: Padding(
padding: EdgeInsets.only(
right: ScreenUtil().setWidth(18)),
child: CommonButton(
content: "午市",
state: currTimeIndex == 2 ? 1 : 0,
width: 92,
height: 48,
fontSize: 32,
onPress: () {
if (currTimeIndex == 2) return;
setState(() {
currTimeIndex = 2;
});
_getReserveList();
},
))),
Offstage(
offstage: night == "00:00-00:00" ? true : false,
child: Container(
// padding: EdgeInsets.symmetric(
// horizontal: ScreenUtil().setWidth(10)),
child: CommonButton(
content: "晚市",
state: currTimeIndex == 3 ? 1 : 0,
width: 92,
height: 48,
fontSize: 32,
onPress: () {
if (currTimeIndex == 3) return;
setState(() {
currTimeIndex = 3;
});
_getReserveList();
},
)),
),
],
),
),
)
],
),
),
// Selector<NoteBookModel, String>(
// selector: (context, model) => model.total,
// builder: (context, total, child) {
// return Container(
// width: double.infinity,
// alignment: Alignment.centerLeft,
// padding: EdgeInsets.only(left: ScreenUtil().setWidth(38)),
// height: ScreenUtil().setHeight(72),
// color: MyColours.color_f5f5f5,
// child: Text(
// total,
// style: TextStyle(
// color: MyColours.color_353535,
// fontSize: ScreenUtil().setSp(26)),
// ),
// );
// },
// ),
_buildListTitle(),
Expanded(child: Consumer<NoteBookModel>(
builder: (context, model, _) {
if (model.pageState != PageState.Success) {
return ExceptionPage(
pageState: model.pageState,
callback: () {
_getReserveList();
_reserveCountDay();
},
emptyMsg: "暂时没有预订哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return EasyRefresh.custom(
controller: _controller,
slivers: [
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return NoteBookItem(model.notebooks[index], index);
}, childCount: model.notebooks.length),
// itemExtent: ScreenUtil().setWidth(112),
)
],
onRefresh: () async {
_getReserveList();
},
);
}
},
))
],
),
);
}
}
... ...