|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:one_key/widgets/MyDivider.dart';
|
|
|
|
import 'package:one_key/widgets/system_app_bar.dart';
|
|
|
|
import 'package:one_key/widgets/v_empty_view.dart';
|
|
|
|
|
|
|
|
import '../../../models/filter_btn_model.dart';
|
|
|
|
import '../../../models/settime.dart';
|
|
|
|
import '../../../res/colors.dart';
|
|
|
|
import '../../../utils/dialog_util.dart';
|
|
|
|
import '../../../utils/screen_util.dart';
|
|
|
|
import '../../../utils/utils.dart';
|
|
|
|
import '../../../widgets/h_empty_view.dart';
|
|
|
|
import '../../../widgets/round_button.dart';
|
|
|
|
import 'package:calendar_date_picker2/calendar_date_picker2.dart';
|
|
|
|
import 'dart:math';
|
|
|
|
import '../../../widgets/set_time_widget.dart';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 多时段编辑页面
|
|
...
|
...
|
@@ -32,24 +31,34 @@ class _BookTimeSettingEditPageState extends State<BookTimeSettingEditPage> { |
|
|
|
List<FilterBtnModel> weekData = [];
|
|
|
|
String weekShow = '点击选择日期(可多选)';
|
|
|
|
|
|
|
|
List<DateTime> _multiDatePickerValueWithDefaultValue = [
|
|
|
|
DateTime(DateTime.now().year, DateTime.now().month, 1),
|
|
|
|
DateTime(DateTime.now().year, DateTime.now().month, 5),
|
|
|
|
DateTime(DateTime.now().year, DateTime.now().month, 14),
|
|
|
|
DateTime(DateTime.now().year, DateTime.now().month, 17),
|
|
|
|
DateTime(DateTime.now().year, DateTime.now().month, 25),
|
|
|
|
];
|
|
|
|
List<DateTime> _selectPickerValues = [];
|
|
|
|
|
|
|
|
List<DateTime> _dialogCalendarPickerValue = [
|
|
|
|
DateTime(DateTime.now().year, DateTime.now().month, 1),
|
|
|
|
DateTime(DateTime.now().year, DateTime.now().month, 5),
|
|
|
|
];
|
|
|
|
List swichState;
|
|
|
|
SetTime morning = SetTime();
|
|
|
|
SetTime noon = SetTime();
|
|
|
|
SetTime night = SetTime();
|
|
|
|
|
|
|
|
ScrollController yearC = ScrollController();
|
|
|
|
TextEditingController _booktime1 = TextEditingController();
|
|
|
|
TextEditingController _booktime2 = TextEditingController();
|
|
|
|
TextEditingController _booktime3 = TextEditingController();
|
|
|
|
TextEditingController _booktime4 = TextEditingController();
|
|
|
|
TextEditingController _booktime5 = TextEditingController();
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
_booktime1.text = '早茶';
|
|
|
|
_booktime2.text = '午餐';
|
|
|
|
_booktime3.text = '晚餐';
|
|
|
|
_booktime4.text = '夜宵';
|
|
|
|
|
|
|
|
morning.start = '07:00';
|
|
|
|
morning.end = '10:00';
|
|
|
|
noon.start = '11:00';
|
|
|
|
noon.end = '14:30';
|
|
|
|
night.start = '16:00';
|
|
|
|
night.end = '21:00';
|
|
|
|
swichState = [false, true, true, false, false];
|
|
|
|
_initWeekData();
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {});
|
|
|
|
}
|
|
...
|
...
|
@@ -87,32 +96,34 @@ class _BookTimeSettingEditPageState extends State<BookTimeSettingEditPage> { |
|
|
|
}
|
|
|
|
|
|
|
|
String _getValueText(
|
|
|
|
CalendarDatePicker2Type datePickerType,
|
|
|
|
// CalendarDatePicker2Type datePickerType,
|
|
|
|
List<DateTime> values,
|
|
|
|
) {
|
|
|
|
values =
|
|
|
|
values.map((e) => e != null ? DateUtils.dateOnly(e) : null).toList();
|
|
|
|
var valueText = (values.isNotEmpty ? values[0] : null)
|
|
|
|
.toString()
|
|
|
|
.replaceAll('00:00:00.000', '');
|
|
|
|
// values =
|
|
|
|
// values.map((e) => e != null ? DateUtils.dateOnly(e) : null).toList();
|
|
|
|
// var valueText = (values.isNotEmpty ? values[0] : null)
|
|
|
|
// .toString()
|
|
|
|
// .replaceAll('00:00:00.000', '');
|
|
|
|
|
|
|
|
if (datePickerType == CalendarDatePicker2Type.multi) {
|
|
|
|
valueText = values.isNotEmpty
|
|
|
|
? values
|
|
|
|
.map((v) => v.toString().replaceAll('00:00:00.000', ''))
|
|
|
|
.join(', ')
|
|
|
|
: 'null';
|
|
|
|
} else if (datePickerType == CalendarDatePicker2Type.range) {
|
|
|
|
if (values.isNotEmpty) {
|
|
|
|
final startDate = values[0].toString().replaceAll('00:00:00.000', '');
|
|
|
|
final endDate = values.length > 1
|
|
|
|
? values[1].toString().replaceAll('00:00:00.000', '')
|
|
|
|
: 'null';
|
|
|
|
valueText = '$startDate to $endDate';
|
|
|
|
} else {
|
|
|
|
return 'null';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// if (datePickerType == CalendarDatePicker2Type.multi) {
|
|
|
|
var valueText = values.isNotEmpty
|
|
|
|
? values
|
|
|
|
.map((v) =>
|
|
|
|
v.toString().replaceAll('00:00:00.000', '').substring(2) +
|
|
|
|
'${Utils.lunarCalendarHolidaysShow(v)}')
|
|
|
|
.join(' ')
|
|
|
|
: '点击选择日期(可多选)';
|
|
|
|
// } else if (datePickerType == CalendarDatePicker2Type.range) {
|
|
|
|
// if (values.isNotEmpty) {
|
|
|
|
// final startDate = values[0].toString().replaceAll('00:00:00.000', '');
|
|
|
|
// final endDate = values.length > 1
|
|
|
|
// ? values[1].toString().replaceAll('00:00:00.000', '')
|
|
|
|
// : 'null';
|
|
|
|
// valueText = '$startDate to $endDate';
|
|
|
|
// } else {
|
|
|
|
// return 'null';
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
return valueText;
|
|
|
|
}
|
|
...
|
...
|
@@ -131,351 +142,23 @@ class _BookTimeSettingEditPageState extends State<BookTimeSettingEditPage> { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//显示日历弹框
|
|
|
|
Future<DateTime> showCalendarDialogMultiple(BuildContext context) {
|
|
|
|
return showModalBottomSheet<DateTime>(
|
|
|
|
context: context,
|
|
|
|
isScrollControlled: true,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
BuildContext dialogContext = context;
|
|
|
|
Widget widget = StatefulBuilder(builder: (context, _setState) {
|
|
|
|
return Container(
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: <Widget>[
|
|
|
|
_buildMultiDatePickerWithValue(),
|
|
|
|
VEmptyView(4),
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
|
children: [
|
|
|
|
RoundButton(
|
|
|
|
onPressed: () async {
|
|
|
|
// _calendarController
|
|
|
|
// .setSelectedDay(DateTime.now());
|
|
|
|
_setState(() {});
|
|
|
|
},
|
|
|
|
text: '取消',
|
|
|
|
fontSize: 28,
|
|
|
|
isBold: false,
|
|
|
|
height: ScreenUtil().setWidth(70),
|
|
|
|
width: ScreenUtil().setWidth(220),
|
|
|
|
gradientStart: MyColours.color_2bb5b7,
|
|
|
|
gradientEnd: MyColours.color_2bb5b7,
|
|
|
|
radius: ScreenUtil().setWidth(10),
|
|
|
|
),
|
|
|
|
RoundButton(
|
|
|
|
onPressed: () async {
|
|
|
|
Navigator.pop(context);
|
|
|
|
},
|
|
|
|
text: '确定',
|
|
|
|
fontSize: 28,
|
|
|
|
isBold: false,
|
|
|
|
textColor: MyColours.color_333333,
|
|
|
|
borderColor: Color.fromRGBO(119, 119, 119, 1),
|
|
|
|
height: ScreenUtil().setWidth(70),
|
|
|
|
width: ScreenUtil().setWidth(220),
|
|
|
|
gradientStart: Colors.transparent,
|
|
|
|
gradientEnd: Colors.transparent,
|
|
|
|
radius: ScreenUtil().setWidth(10),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
VEmptyView(40)
|
|
|
|
],
|
|
|
|
))
|
|
|
|
|
|
|
|
// Positioned(
|
|
|
|
// right: ScreenUtil().setWidth(62),
|
|
|
|
// bottom: ScreenUtil().setHeight(20),
|
|
|
|
// child: Container(
|
|
|
|
// child: GestureDetector(
|
|
|
|
// onTap: () {
|
|
|
|
// _calendarController.setSelectedDay(DateTime.now());
|
|
|
|
// _setState(() {});
|
|
|
|
// },
|
|
|
|
// child: Container(
|
|
|
|
// child: ClipOval(
|
|
|
|
// child: Container(
|
|
|
|
// width: ScreenUtil().setWidth(100),
|
|
|
|
// height: ScreenUtil().setWidth(100),
|
|
|
|
// alignment: Alignment.center,
|
|
|
|
// color: MyColours.color_2bb5b7,
|
|
|
|
// child: Text(
|
|
|
|
// "回到\n今天",
|
|
|
|
// style: TextStyle(
|
|
|
|
// color: MyColours.color_ffffff,
|
|
|
|
// fontSize: ScreenUtil().setSp(26)),
|
|
|
|
// ),
|
|
|
|
// )),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// )
|
|
|
|
// ],
|
|
|
|
;
|
|
|
|
});
|
|
|
|
return SizedBox(
|
|
|
|
width: double.infinity,
|
|
|
|
// height: ScreenUtil().setWidth(975),
|
|
|
|
child: widget,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
String intToWeek(int week) {
|
|
|
|
String str = '';
|
|
|
|
switch (week) {
|
|
|
|
case 0:
|
|
|
|
str = '周日';
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
str = '周一';
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
str = '周二';
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
str = '周三';
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
str = '周四';
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
str = '周五';
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
str = '周六';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildMultiDatePickerWithValue() {
|
|
|
|
final config = CalendarDatePicker2Config(
|
|
|
|
disableMonthPicker: true,
|
|
|
|
calendarType: CalendarDatePicker2Type.multi,
|
|
|
|
currentDate: DateTime.now(),
|
|
|
|
dynamicCalendarRows: true,
|
|
|
|
yearViewController: yearC,
|
|
|
|
centerAlignModePicker: true,
|
|
|
|
controlsTextStyle: TextStyle(color: MyColours.color_F8F9FD),
|
|
|
|
lastMonthIcon: Image.asset(
|
|
|
|
Utils.getImgPath('date_m_l'),
|
|
|
|
width: w(8),
|
|
|
|
),
|
|
|
|
nextMonthIcon: Image.asset(
|
|
|
|
Utils.getImgPath('date_m_r'),
|
|
|
|
width: w(8),
|
|
|
|
),
|
|
|
|
|
|
|
|
// firstDayOfWeek: 0,
|
|
|
|
// controlsHeight: w(100),
|
|
|
|
// yearBuilder: (({decoration, isCurrentYear, isDisabled, isSelected, textStyle, year}) {
|
|
|
|
// return Container(
|
|
|
|
// width: 50,
|
|
|
|
// height: 50,
|
|
|
|
// color: Colors.red,
|
|
|
|
// );
|
|
|
|
// }),
|
|
|
|
|
|
|
|
selectedDayHighlightColor: MyColours.color_438E93,
|
|
|
|
weekdayLabelBuilder: ({isScrollViewTopHeader, weekday}) {
|
|
|
|
return Container(
|
|
|
|
color: MyColours.color_438E93,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
margin: EdgeInsets.only(
|
|
|
|
bottom: ScreenUtil().setWidth(30), right: weekday == 6 ? 0 : 1),
|
|
|
|
// padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(15)),
|
|
|
|
child: Text(
|
|
|
|
intToWeek(weekday),
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_F8F9FD,
|
|
|
|
fontSize: ScreenUtil().setSp(28)),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
dayMaxWidth: w(51),
|
|
|
|
|
|
|
|
dayBorderRadius: BorderRadius.circular(r(5)),
|
|
|
|
dayBuilder: ((
|
|
|
|
{date, decoration, isDisabled, isSelected, isToday, textStyle}) {
|
|
|
|
return Container(
|
|
|
|
margin: EdgeInsets.all(w(4)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(r(5)),
|
|
|
|
color: isSelected
|
|
|
|
? MyColours.color_438E93
|
|
|
|
: isToday
|
|
|
|
? MyColours.color_2bb5b7
|
|
|
|
: MyColours.color_ffffff),
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
// "${_parseDateDay(date)}",
|
|
|
|
'${Utils.addZeroNumber(date.day)}',
|
|
|
|
style: TextStyle().copyWith(
|
|
|
|
fontSize: ScreenUtil().setSp(32),
|
|
|
|
color: isSelected
|
|
|
|
? MyColours.color_F8F9FD
|
|
|
|
: isToday
|
|
|
|
? MyColours.color_F8F9FD
|
|
|
|
: MyColours.color_353535,
|
|
|
|
fontWeight: FontWeight.bold)),
|
|
|
|
Text(
|
|
|
|
"${_parseDateDay(date)}",
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
maxLines: 1,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle().copyWith(
|
|
|
|
fontSize: ScreenUtil().setSp(18),
|
|
|
|
color: isSelected
|
|
|
|
? MyColours.color_F8F9FD
|
|
|
|
: isToday
|
|
|
|
? MyColours.color_F8F9FD
|
|
|
|
: MyColours.color_353535),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
|
|
|
|
// dayBuilder: (context, date, _) {
|
|
|
|
//
|
|
|
|
// },
|
|
|
|
);
|
|
|
|
|
|
|
|
// selectedDayBuilder: (context, date, _) {
|
|
|
|
// return Container(
|
|
|
|
// // alignment: Alignment.center,
|
|
|
|
// // margin: EdgeInsets.fromLTRB(
|
|
|
|
// // ScreenUtil().setWidth(12),
|
|
|
|
// // ScreenUtil().setWidth(12),
|
|
|
|
// // ScreenUtil().setWidth(12),
|
|
|
|
// // ScreenUtil().setWidth(32)),
|
|
|
|
// padding: EdgeInsets.only(
|
|
|
|
// bottom: ScreenUtil().setWidth(10),
|
|
|
|
// left: ScreenUtil().setWidth(5),
|
|
|
|
// right: ScreenUtil().setWidth(5),
|
|
|
|
// top: ScreenUtil().setWidth(10)),
|
|
|
|
// child: Container(
|
|
|
|
// decoration: BoxDecoration(
|
|
|
|
// borderRadius: BorderRadius.circular(
|
|
|
|
// ScreenUtil().setWidth(10)),
|
|
|
|
// color: Color.fromRGBO(42, 110, 109, 1)),
|
|
|
|
// child: Column(
|
|
|
|
// mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
// children: [
|
|
|
|
// Text(
|
|
|
|
// // "${_parseDateDay(date)}",
|
|
|
|
// '${Utils.addZeroNumber(date.day)}',
|
|
|
|
// style: TextStyle().copyWith(
|
|
|
|
// color: MyColours.color_ffffff,
|
|
|
|
// fontSize: ScreenUtil().setSp(32),
|
|
|
|
// fontWeight: FontWeight.bold),
|
|
|
|
// ),
|
|
|
|
// Text(
|
|
|
|
// "${_parseDateDay(date)}",
|
|
|
|
// // '${Utils.lunarCalendarHolidaysShow(date)}',
|
|
|
|
// style: TextStyle().copyWith(
|
|
|
|
// fontSize: ScreenUtil().setSp(22),
|
|
|
|
// color: MyColours.color_ffffff),
|
|
|
|
// )
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// );
|
|
|
|
// },
|
|
|
|
// todayDayBuilder: (context, date, _) {
|
|
|
|
// return Container(
|
|
|
|
// // alignment: Alignment.center,
|
|
|
|
// // margin: EdgeInsets.fromLTRB(
|
|
|
|
// // ScreenUtil().setWidth(12),
|
|
|
|
// // ScreenUtil().setWidth(12),
|
|
|
|
// // ScreenUtil().setWidth(12),
|
|
|
|
// // ScreenUtil().setWidth(32)),
|
|
|
|
// padding: EdgeInsets.only(
|
|
|
|
// bottom: ScreenUtil().setWidth(10),
|
|
|
|
// left: ScreenUtil().setWidth(5),
|
|
|
|
// right: ScreenUtil().setWidth(5),
|
|
|
|
// top: ScreenUtil().setWidth(10)),
|
|
|
|
// child: Container(
|
|
|
|
// decoration: BoxDecoration(
|
|
|
|
// borderRadius: BorderRadius.circular(
|
|
|
|
// ScreenUtil().setWidth(10)),
|
|
|
|
// color: MyColours.color_2bb5b7),
|
|
|
|
// child: Column(
|
|
|
|
// mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
// children: [
|
|
|
|
// Text(
|
|
|
|
// // "${_parseDateDay(date)}",
|
|
|
|
// '${Utils.addZeroNumber(date.day)}',
|
|
|
|
// style: TextStyle().copyWith(
|
|
|
|
// color: MyColours.color_ffffff,
|
|
|
|
// fontSize: ScreenUtil().setSp(32),
|
|
|
|
// fontWeight: FontWeight.bold),
|
|
|
|
// ),
|
|
|
|
// Text(
|
|
|
|
// "${_parseDateDay(date)}",
|
|
|
|
// // '${Utils.lunarCalendarHolidaysShow(date)}',
|
|
|
|
// style: TextStyle().copyWith(
|
|
|
|
// fontSize: ScreenUtil().setSp(22),
|
|
|
|
// color: MyColours.color_ffffff),
|
|
|
|
// )
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// );
|
|
|
|
// );
|
|
|
|
return SizedBox(
|
|
|
|
width: double.infinity,
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
CalendarDatePicker2(
|
|
|
|
config: config,
|
|
|
|
value: _multiDatePickerValueWithDefaultValue,
|
|
|
|
onValueChanged: (dates) =>
|
|
|
|
setState(() => _multiDatePickerValueWithDefaultValue = dates),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 10),
|
|
|
|
Wrap(
|
|
|
|
children: [
|
|
|
|
const Text('Selection(s): '),
|
|
|
|
const SizedBox(width: 10),
|
|
|
|
Text(
|
|
|
|
_getValueText(
|
|
|
|
config.calendarType,
|
|
|
|
_multiDatePickerValueWithDefaultValue,
|
|
|
|
),
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
maxLines: 10,
|
|
|
|
softWrap: false,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
const SizedBox(height: 25),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
///时间选择
|
|
|
|
Widget _select1(String title, GestureTapCallback onTap) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: onTap,
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.only(left: w(16)),
|
|
|
|
padding: EdgeInsets.only(left: w(16), top: w(7), bottom: w(12)),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
Expanded(
|
|
|
|
child: Container(
|
|
|
|
// height: ScreenUtil().setWidth(40),
|
|
|
|
// color: Colors.red,
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
maxLines: 10,
|
|
|
|
style: TextStyle(
|
|
|
|
height: 1.5,
|
|
|
|
color: title == '点击选择日期(可多选)'
|
|
...
|
...
|
@@ -483,9 +166,9 @@ class _BookTimeSettingEditPageState extends State<BookTimeSettingEditPage> { |
|
|
|
: MyColours.color_515151,
|
|
|
|
fontSize: font(16)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
// HEmptyView(20),
|
|
|
|
Spacer(),
|
|
|
|
// Spacer(),
|
|
|
|
// Text(hintText,
|
|
|
|
// style: TextStyle(
|
|
|
|
// color: hintText == '点击设置开始日期' || hintText == '点击设置结束日期'
|
|
...
|
...
|
@@ -505,6 +188,386 @@ class _BookTimeSettingEditPageState extends State<BookTimeSettingEditPage> { |
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _itemMorningNoonAngNight(int tag, TextEditingController booktimes) {
|
|
|
|
return Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
swichState[tag]
|
|
|
|
? Expanded(
|
|
|
|
child: Container(
|
|
|
|
// height: ScreenUtil().setWidth(50),
|
|
|
|
// padding: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(24)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
borderRadius: BorderRadius.circular(r(14))),
|
|
|
|
child: TextField(
|
|
|
|
controller: booktimes,
|
|
|
|
maxLines: 1,
|
|
|
|
// inputFormatters: [
|
|
|
|
// LengthLimitingTextInputFormatter(
|
|
|
|
// 15),
|
|
|
|
// // FilteringTextInputFormatter.digitsOnly
|
|
|
|
// ],
|
|
|
|
|
|
|
|
// //光标颜色
|
|
|
|
// cursorColor:
|
|
|
|
// widget.isSelect ? Colors.white : MyColours.color_199095,
|
|
|
|
//输入文本的样式
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(14), color: MyColours.color_515151),
|
|
|
|
// focusNode: _phoneFocusNode,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
border: OutlineInputBorder(borderSide: BorderSide.none),
|
|
|
|
hintText: '请输入餐段名称',
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
color: MyColours.color_BFC4D4,
|
|
|
|
fontSize: font(14),
|
|
|
|
),
|
|
|
|
contentPadding: EdgeInsets.zero,
|
|
|
|
isCollapsed: true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
|
|
|
|
enabledBorder: new UnderlineInputBorder(
|
|
|
|
borderSide: BorderSide.none,
|
|
|
|
),
|
|
|
|
|
|
|
|
focusedBorder: new UnderlineInputBorder(
|
|
|
|
borderSide: BorderSide.none,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onChanged: (value) {
|
|
|
|
// if (editingController == _nameController) {
|
|
|
|
// _nameController.text = value;
|
|
|
|
// }
|
|
|
|
},
|
|
|
|
onEditingComplete: () {
|
|
|
|
FocusScope.of(context)
|
|
|
|
.requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
},
|
|
|
|
keyboardType: TextInputType.text,
|
|
|
|
),
|
|
|
|
))
|
|
|
|
: Spacer(),
|
|
|
|
// Text(title,
|
|
|
|
// style: TextStyle(
|
|
|
|
// fontSize: ScreenUtil().setSp(28),
|
|
|
|
// color: MyColours.color_999999)),
|
|
|
|
InkWell(
|
|
|
|
onTap: () {
|
|
|
|
setState(() {
|
|
|
|
swichState[tag] = !swichState[tag];
|
|
|
|
});
|
|
|
|
},
|
|
|
|
child: Image.asset(
|
|
|
|
Utils.getImgPath(
|
|
|
|
swichState[tag] ? 'store_swich_on' : 'store_swich_off'),
|
|
|
|
width: w(38))),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
///从时间选择器中获取分钟数字符串 00 or 30
|
|
|
|
String _getMinuteStrFromPickerBookTime(List data, List value) {
|
|
|
|
// if (data.length == 1) {
|
|
|
|
// return '30';
|
|
|
|
// } else {
|
|
|
|
Map map = data[value[0]];
|
|
|
|
|
|
|
|
int minute = map.values.last[value[1]];
|
|
|
|
if (minute == 0) {
|
|
|
|
return '00';
|
|
|
|
}
|
|
|
|
return '${minute}';
|
|
|
|
// if (value[1] == 0) {
|
|
|
|
// return '00';
|
|
|
|
// } else if (value[1] == 1) {
|
|
|
|
// return '15';
|
|
|
|
// } else if (value[1] == 2) {
|
|
|
|
// return '30';
|
|
|
|
// } else {
|
|
|
|
// return '45';
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _itemBookTime(String start, String end, int tag) {
|
|
|
|
return Row(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: InkWell(
|
|
|
|
onTap: () {
|
|
|
|
if (swichState[tag]) {
|
|
|
|
List data = SetTimeWidget.dateData;
|
|
|
|
if (tag == 0) {
|
|
|
|
//早市
|
|
|
|
data = SetTimeWidget.dateData;
|
|
|
|
} else if (tag == 1) {
|
|
|
|
//午市
|
|
|
|
data = Utils.getPickerData(
|
|
|
|
morning.end, SetTimeWidget.dateData);
|
|
|
|
} else if (tag == 2) {
|
|
|
|
//晚市
|
|
|
|
data =
|
|
|
|
Utils.getPickerData(noon.end, SetTimeWidget.dateData);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetTimeWidget().showTimeSelector(context, data, start,
|
|
|
|
(value) {
|
|
|
|
if (value != null) {
|
|
|
|
String tempMinute =
|
|
|
|
_getMinuteStrFromPickerBookTime(data, value);
|
|
|
|
print(data[value[0]].keys.first);
|
|
|
|
String time = Utils.getTimeString(
|
|
|
|
Utils.getHourFromTitle(data[value[0]].keys.first),
|
|
|
|
tempMinute);
|
|
|
|
setState(() {
|
|
|
|
if (tag == 0) {
|
|
|
|
//早市
|
|
|
|
morning.start = time;
|
|
|
|
setState(() {
|
|
|
|
Utils.compareDateTime(morning.end, time,
|
|
|
|
(needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
morning.end = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Utils.compareDateTime(noon.start, time,
|
|
|
|
(needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
noon.start = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Utils.compareDateTime(noon.end, time,
|
|
|
|
(needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
noon.end = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Utils.compareDateTime(night.start, time,
|
|
|
|
(needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
night.start = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Utils.compareDateTime(night.end, time,
|
|
|
|
(needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
night.end = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if (tag == 1) {
|
|
|
|
//午市
|
|
|
|
noon.start = time;
|
|
|
|
setState(() {
|
|
|
|
Utils.compareDateTime(noon.end, time,
|
|
|
|
(needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
noon.end = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Utils.compareDateTime(night.start, time,
|
|
|
|
(needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
night.start = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Utils.compareDateTime(night.end, time,
|
|
|
|
(needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
night.end = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if (tag == 2) {
|
|
|
|
//晚市
|
|
|
|
night.start = time;
|
|
|
|
setState(() {
|
|
|
|
Utils.compareDateTime(night.end, time,
|
|
|
|
(needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
night.end = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
print(value);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
height: w(34),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(r(5)),
|
|
|
|
border: Border.all(
|
|
|
|
width: w(1), color: MyColours.color_438E93)),
|
|
|
|
child: start == '' || start == null || start == 'null'
|
|
|
|
? RichText(
|
|
|
|
text: TextSpan(
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(12),
|
|
|
|
),
|
|
|
|
children: [
|
|
|
|
// const TextSpan(text: '('),
|
|
|
|
TextSpan(
|
|
|
|
text: '选择开始时间',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_438E93)),
|
|
|
|
TextSpan(
|
|
|
|
text: '*',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_E34D59)),
|
|
|
|
]))
|
|
|
|
: Text(
|
|
|
|
start,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_438E93,
|
|
|
|
fontSize: font(12),
|
|
|
|
),
|
|
|
|
)))),
|
|
|
|
HEmptyView(52),
|
|
|
|
Text('至',
|
|
|
|
style:
|
|
|
|
TextStyle(fontSize: font(12), color: MyColours.color_515151)),
|
|
|
|
HEmptyView(52),
|
|
|
|
Expanded(
|
|
|
|
child: InkWell(
|
|
|
|
onTap: () {
|
|
|
|
if (swichState[tag]) {
|
|
|
|
List data = SetTimeWidget.dateData;
|
|
|
|
if (tag == 0) {
|
|
|
|
//早市
|
|
|
|
data = Utils.getPickerData(
|
|
|
|
morning.start, SetTimeWidget.dateData);
|
|
|
|
} else if (tag == 1) {
|
|
|
|
//午市
|
|
|
|
data =
|
|
|
|
Utils.getPickerData(noon.start, SetTimeWidget.dateData);
|
|
|
|
} else if (tag == 2) {
|
|
|
|
//晚市
|
|
|
|
data = Utils.getPickerData(
|
|
|
|
night.start, SetTimeWidget.dateData);
|
|
|
|
}
|
|
|
|
SetTimeWidget().showTimeSelector(context, data, end, (value) {
|
|
|
|
if (value != null) {
|
|
|
|
String tempMinute =
|
|
|
|
_getMinuteStrFromPickerBookTime(data, value);
|
|
|
|
String time = Utils.getTimeString(
|
|
|
|
Utils.getHourFromTitle(data[value[0]].keys.first),
|
|
|
|
tempMinute);
|
|
|
|
setState(() {
|
|
|
|
if (tag == 0) {
|
|
|
|
//早市
|
|
|
|
morning.end = time;
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
Utils.compareDateTime(time, morning.start,
|
|
|
|
(needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
morning.start = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Utils.compareDateTime(noon.start, time,
|
|
|
|
(needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
noon.start = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Utils.compareDateTime(noon.end, time, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
noon.end = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Utils.compareDateTime(night.start, time,
|
|
|
|
(needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
night.start = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Utils.compareDateTime(night.end, time,
|
|
|
|
(needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
night.end = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if (tag == 1) {
|
|
|
|
//午市
|
|
|
|
noon.end = time;
|
|
|
|
setState(() {
|
|
|
|
Utils.compareDateTime(noon.end, noon.start,
|
|
|
|
(needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
noon.start = noon.end;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Utils.compareDateTime(night.start, time,
|
|
|
|
(needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
night.start = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Utils.compareDateTime(night.end, time,
|
|
|
|
(needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
night.end = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if (tag == 2) {
|
|
|
|
//晚市
|
|
|
|
night.end = time;
|
|
|
|
setState(() {
|
|
|
|
Utils.compareDateTime(night.end, night.start,
|
|
|
|
(needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
night.start = night.end;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
print(value);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
height: w(34),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(r(5)),
|
|
|
|
border: Border.all(
|
|
|
|
width: w(1), color: MyColours.color_438E93)),
|
|
|
|
child: end == '' || end == null || end == 'null'
|
|
|
|
? RichText(
|
|
|
|
text: TextSpan(
|
|
|
|
style: TextStyle(fontSize: font(12)),
|
|
|
|
children: [
|
|
|
|
// const TextSpan(text: '('),
|
|
|
|
TextSpan(
|
|
|
|
text: '选择结束时间',
|
|
|
|
style:
|
|
|
|
TextStyle(color: MyColours.color_438E93)),
|
|
|
|
TextSpan(
|
|
|
|
text: '*',
|
|
|
|
style:
|
|
|
|
TextStyle(color: MyColours.color_E34D59)),
|
|
|
|
]))
|
|
|
|
: Text(
|
|
|
|
end,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_438E93,
|
|
|
|
fontSize: font(12)),
|
|
|
|
))),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
...
|
...
|
@@ -559,15 +622,9 @@ class _BookTimeSettingEditPageState extends State<BookTimeSettingEditPage> { |
|
|
|
HEmptyView(30),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
VEmptyView(30),
|
|
|
|
VEmptyView(16),
|
|
|
|
_select1(weekShow, () async {
|
|
|
|
if (isWeek) {
|
|
|
|
FocusScope.of(context)
|
|
|
|
.requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
//弹出时间选择器
|
|
|
|
// showPickerDateTime(context);
|
|
|
|
// showDateSelWidget = false;
|
|
|
|
|
|
|
|
List<FilterBtnModel> data =
|
|
|
|
await DialogUtil.openWeekSelectModalBottomSheet(
|
|
|
|
context, weekData);
|
|
...
|
...
|
@@ -593,29 +650,19 @@ class _BookTimeSettingEditPageState extends State<BookTimeSettingEditPage> { |
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
showCalendarDialogMultiple(context);
|
|
|
|
// _buildMultiDatePickerWithValue();
|
|
|
|
// DateTime dateTime = DateTime.now();
|
|
|
|
// DialogUtil.showCalendarDialogMultiple(context, dateTime)
|
|
|
|
// .then((day) async {
|
|
|
|
// if (day != null) {
|
|
|
|
// // createDateText1(context, day);
|
|
|
|
// // bool success =
|
|
|
|
// // await tableManagerModel.getTableListOrReserve(
|
|
|
|
// // context,
|
|
|
|
// // currTimeIndex,
|
|
|
|
// // dateTime,
|
|
|
|
// // selectNumber,
|
|
|
|
// // showLoading: true,
|
|
|
|
// // );
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
DialogUtil.showCalendarDialogMultiple(
|
|
|
|
context, _selectPickerValues, (value) {
|
|
|
|
_selectPickerValues = value;
|
|
|
|
weekShow = _getValueText(
|
|
|
|
value,
|
|
|
|
);
|
|
|
|
setState(() {});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(left: w(16)),
|
|
|
|
child: MyDivider(
|
|
...
|
...
|
@@ -623,7 +670,53 @@ class _BookTimeSettingEditPageState extends State<BookTimeSettingEditPage> { |
|
|
|
w(1),
|
|
|
|
color: MyColours.color_DBDBDB,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
),
|
|
|
|
VEmptyView(26),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(left: w(12)),
|
|
|
|
child: Text('可预订时段',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(16),
|
|
|
|
color: MyColours.color_515151))),
|
|
|
|
VEmptyView(36),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: w(24),
|
|
|
|
),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
_itemMorningNoonAngNight(0, _booktime1),
|
|
|
|
VEmptyView(34),
|
|
|
|
swichState[0]
|
|
|
|
? _itemBookTime(morning.start, morning.end, 0)
|
|
|
|
: SizedBox(),
|
|
|
|
VEmptyView(32),
|
|
|
|
_itemMorningNoonAngNight(1, _booktime2),
|
|
|
|
VEmptyView(34),
|
|
|
|
swichState[1]
|
|
|
|
? _itemBookTime(noon.start, noon.end, 1)
|
|
|
|
: SizedBox(),
|
|
|
|
VEmptyView(32),
|
|
|
|
_itemMorningNoonAngNight(2, _booktime3),
|
|
|
|
VEmptyView(34),
|
|
|
|
swichState[2]
|
|
|
|
? _itemBookTime(night.start, night.end, 2)
|
|
|
|
: SizedBox(),
|
|
|
|
VEmptyView(32),
|
|
|
|
_itemMorningNoonAngNight(3, _booktime4),
|
|
|
|
VEmptyView(34),
|
|
|
|
swichState[3]
|
|
|
|
? _itemBookTime(night.start, night.end, 3)
|
|
|
|
: SizedBox(),
|
|
|
|
VEmptyView(32),
|
|
|
|
_itemMorningNoonAngNight(4, _booktime5),
|
|
|
|
VEmptyView(34),
|
|
|
|
swichState[4]
|
|
|
|
? _itemBookTime(night.start, night.end, 4)
|
|
|
|
: SizedBox(),
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
VEmptyView(34),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)),
|
...
|
...
|
|