|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_screenutil/screenutil.dart';
|
|
|
|
import 'package:one_key/res/colors.dart';
|
|
|
|
import 'package:one_key/utils/utils.dart';
|
|
|
|
import 'package:one_key/widgets/app_bar.dart';
|
|
|
|
import 'package:one_key/widgets/h_empty_view.dart';
|
|
|
|
import 'package:one_key/widgets/round_button.dart';
|
|
|
|
|
|
|
|
class NoteBookChangePage extends StatefulWidget {
|
|
|
|
@override
|
|
|
|
_NoteBookChangePageState createState() => _NoteBookChangePageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _NoteBookChangePageState extends State<NoteBookChangePage> {
|
|
|
|
String dateText = ""; //当前显示日期时间
|
|
|
|
int currTimeIndex = 1; //当前选中时间段
|
|
|
|
String morning; //早市时间段
|
|
|
|
String noon; //午市时间段
|
|
|
|
String night; //晚市时间段
|
|
|
|
|
|
|
|
DateTime dateTime; //当前日期
|
|
|
|
|
|
|
|
//生成日期文本
|
|
|
|
_createDateText(DateTime day) {
|
|
|
|
if (Utils.isOneDay(day, dateTime)) return; //日期没变
|
|
|
|
setState(() {
|
|
|
|
DateTime dateNow = DateTime.now();
|
|
|
|
if (Utils.isOneDay(day, dateNow)) {
|
|
|
|
dateText = Utils.addZeroNumber(dateNow.month) +
|
|
|
|
"-" +
|
|
|
|
Utils.addZeroNumber(dateNow.day) +
|
|
|
|
" 今天";
|
|
|
|
} else {
|
|
|
|
dateText =
|
|
|
|
Utils.addZeroNumber(day.month) + "-" + Utils.addZeroNumber(day.day);
|
|
|
|
}
|
|
|
|
dateTime = day;
|
|
|
|
});
|
|
|
|
// _getReserveList();
|
|
|
|
// _reserveCountDay();
|
|
|
|
}
|
|
|
|
|
|
|
|
//初始化时间
|
|
|
|
_initTime() {
|
|
|
|
dateTime = DateTime.now();
|
|
|
|
dateText = Utils.addZeroNumber(dateTime.month) +
|
|
|
|
"-" +
|
|
|
|
Utils.addZeroNumber(dateTime.day);
|
|
|
|
// morning =
|
|
|
|
// userModel.user.morning.isEmpty ? "00:00-00:00" : userModel.user.morning;
|
|
|
|
// noon = userModel.user.noon.isEmpty ? "00:00-00:00" : userModel.user.noon;
|
|
|
|
// night = userModel.user.night.isEmpty ? "00:00-00:00" : userModel.user.night;
|
|
|
|
// if (dateTime.isBefore(DateTime.parse(dateTime.year.toString() +
|
|
|
|
// "-" +
|
|
|
|
// Utils.addZeroNumber(dateTime.month) +
|
|
|
|
// "-" +
|
|
|
|
// Utils.addZeroNumber(dateTime.day) +
|
|
|
|
// " " +
|
|
|
|
// morning.split("-")[1] +
|
|
|
|
// ":00"))) {
|
|
|
|
// //未过早市
|
|
|
|
// currTimeIndex = 1;
|
|
|
|
// } else if (dateTime.isAfter(DateTime.parse(dateTime.year.toString() +
|
|
|
|
// "-" +
|
|
|
|
// Utils.addZeroNumber(dateTime.month) +
|
|
|
|
// "-" +
|
|
|
|
// Utils.addZeroNumber(dateTime.day) +
|
|
|
|
// " " +
|
|
|
|
// morning.split("-")[1] +
|
|
|
|
// ":00")) &&
|
|
|
|
// dateTime.isBefore(DateTime.parse(dateTime.year.toString() +
|
|
|
|
// "-" +
|
|
|
|
// Utils.addZeroNumber(dateTime.month) +
|
|
|
|
// "-" +
|
|
|
|
// Utils.addZeroNumber(dateTime.day) +
|
|
|
|
// " " +
|
|
|
|
// noon.split("-")[1] +
|
|
|
|
// ":00"))) {
|
|
|
|
// //过了早市,未过午市
|
|
|
|
// currTimeIndex = 2;
|
|
|
|
// } else if (dateTime.isAfter(DateTime.parse(dateTime.year.toString() +
|
|
|
|
// "-" +
|
|
|
|
// Utils.addZeroNumber(dateTime.month) +
|
|
|
|
// "-" +
|
|
|
|
// Utils.addZeroNumber(dateTime.day) +
|
|
|
|
// " " +
|
|
|
|
// noon.split("-")[1] +
|
|
|
|
// ":00")) &&
|
|
|
|
// dateTime.isBefore(DateTime.parse(dateTime.year.toString() +
|
|
|
|
// "-" +
|
|
|
|
// Utils.addZeroNumber(dateTime.month) +
|
|
|
|
// "-" +
|
|
|
|
// Utils.addZeroNumber(dateTime.day) +
|
|
|
|
// " " +
|
|
|
|
// night.split("-")[1] +
|
|
|
|
// ":00"))) {
|
|
|
|
// //过了午市,未过晚市
|
|
|
|
// currTimeIndex = 3;
|
|
|
|
// } else {
|
|
|
|
// //过了晚市
|
|
|
|
// currTimeIndex = 3;
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
_initTime();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
body: SingleChildScrollView(
|
|
|
|
child: Column(children: <Widget>[
|
|
|
|
SizedBox(height: ScreenUtil.statusBarHeight),
|
|
|
|
MyAppBar(
|
|
|
|
"在线预订详情",
|
|
|
|
showBack: true,
|
|
|
|
),
|
|
|
|
//第一行
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.all(ScreenUtil().setWidth(40)),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
CustomButton(
|
|
|
|
dateText: dateText,
|
|
|
|
dayText: ' 今天',
|
|
|
|
isSelect: true,
|
|
|
|
),
|
|
|
|
CustomButton(
|
|
|
|
dateText: dateText,
|
|
|
|
dayText: ' 明天',
|
|
|
|
isSelect: false,
|
|
|
|
),
|
|
|
|
CustomButton(
|
|
|
|
dateText: '其他',
|
|
|
|
fontSize: 30,
|
|
|
|
dayText: '',
|
|
|
|
isImage: true,
|
|
|
|
isSelect: false,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
//第二行
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.all(ScreenUtil().setWidth(40)),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
CustomButton(
|
|
|
|
dateText: '早市',
|
|
|
|
dayText: '',
|
|
|
|
isSelect: true,
|
|
|
|
),
|
|
|
|
CustomButton(
|
|
|
|
dateText: '午市',
|
|
|
|
dayText: '',
|
|
|
|
isSelect: false,
|
|
|
|
),
|
|
|
|
CustomButton(
|
|
|
|
dateText: '晚市',
|
|
|
|
dayText: '',
|
|
|
|
isSelect: false,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
]),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class CustomButton extends StatefulWidget {
|
|
|
|
final String dateText;
|
|
|
|
final String dayText;
|
|
|
|
final bool isSelect;
|
|
|
|
final double fontSize;
|
|
|
|
final bool isImage;
|
|
|
|
|
|
|
|
const CustomButton(
|
|
|
|
{Key key,
|
|
|
|
this.dateText,
|
|
|
|
this.dayText,
|
|
|
|
this.isSelect,
|
|
|
|
this.fontSize = 34,
|
|
|
|
this.isImage = false})
|
|
|
|
: super(key: key);
|
|
|
|
@override
|
|
|
|
_ButtonState createState() => _ButtonState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _ButtonState extends State<CustomButton> {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Container(
|
|
|
|
width: ScreenUtil().setWidth(105 * 2),
|
|
|
|
height: ScreenUtil().setWidth(25 * 2),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: widget.isSelect ? MyColours.color_199095 : Colors.white,
|
|
|
|
borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10)),
|
|
|
|
border: Border.all(
|
|
|
|
color: MyColours.color_199095, width: ScreenUtil().setWidth(2))),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Text(widget.dateText,
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: widget.isSelect
|
|
|
|
? MyColours.color_fefefe
|
|
|
|
: MyColours.color_199095,
|
|
|
|
fontSize: ScreenUtil().setSp(widget.fontSize))),
|
|
|
|
widget.isImage ? HEmptyView(20) : Container(),
|
|
|
|
widget.isImage
|
|
|
|
? Image.asset(
|
|
|
|
widget.isSelect
|
|
|
|
? 'assets/message_selected.png'
|
|
|
|
: 'assets/message_default.png',
|
|
|
|
width: ScreenUtil().setWidth(36))
|
|
|
|
: Text(widget.dayText,
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: widget.isSelect
|
|
|
|
? MyColours.color_fefefe
|
|
|
|
: MyColours.color_199095,
|
|
|
|
fontSize: ScreenUtil().setSp(30)))
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|