Commit cc76ea7bee63ebf9a0c69d4c62ffbab96867c042

Authored by wdn127929
1 parent 4a1ac5f9

多时段UI

1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
2 -import 'package:flutter_screenutil/flutter_screenutil.dart';  
3 import 'package:one_key/widgets/MyDivider.dart'; 2 import 'package:one_key/widgets/MyDivider.dart';
4 import 'package:one_key/widgets/system_app_bar.dart'; 3 import 'package:one_key/widgets/system_app_bar.dart';
5 import 'package:one_key/widgets/v_empty_view.dart'; 4 import 'package:one_key/widgets/v_empty_view.dart';
6 5
7 import '../../../models/filter_btn_model.dart'; 6 import '../../../models/filter_btn_model.dart';
  7 +import '../../../models/settime.dart';
8 import '../../../res/colors.dart'; 8 import '../../../res/colors.dart';
9 import '../../../utils/dialog_util.dart'; 9 import '../../../utils/dialog_util.dart';
10 import '../../../utils/screen_util.dart'; 10 import '../../../utils/screen_util.dart';
11 import '../../../utils/utils.dart'; 11 import '../../../utils/utils.dart';
12 import '../../../widgets/h_empty_view.dart'; 12 import '../../../widgets/h_empty_view.dart';
13 import '../../../widgets/round_button.dart'; 13 import '../../../widgets/round_button.dart';
14 -import 'package:calendar_date_picker2/calendar_date_picker2.dart';  
15 -import 'dart:math'; 14 +import '../../../widgets/set_time_widget.dart';
16 15
17 /** 16 /**
18 * 多时段编辑页面 17 * 多时段编辑页面
@@ -32,24 +31,34 @@ class _BookTimeSettingEditPageState extends State<BookTimeSettingEditPage> { @@ -32,24 +31,34 @@ class _BookTimeSettingEditPageState extends State<BookTimeSettingEditPage> {
32 List<FilterBtnModel> weekData = []; 31 List<FilterBtnModel> weekData = [];
33 String weekShow = '点击选择日期(可多选)'; 32 String weekShow = '点击选择日期(可多选)';
34 33
35 - List<DateTime> _multiDatePickerValueWithDefaultValue = [  
36 - DateTime(DateTime.now().year, DateTime.now().month, 1),  
37 - DateTime(DateTime.now().year, DateTime.now().month, 5),  
38 - DateTime(DateTime.now().year, DateTime.now().month, 14),  
39 - DateTime(DateTime.now().year, DateTime.now().month, 17),  
40 - DateTime(DateTime.now().year, DateTime.now().month, 25),  
41 - ]; 34 + List<DateTime> _selectPickerValues = [];
42 35
43 - List<DateTime> _dialogCalendarPickerValue = [  
44 - DateTime(DateTime.now().year, DateTime.now().month, 1),  
45 - DateTime(DateTime.now().year, DateTime.now().month, 5),  
46 - ]; 36 + List swichState;
  37 + SetTime morning = SetTime();
  38 + SetTime noon = SetTime();
  39 + SetTime night = SetTime();
47 40
48 - ScrollController yearC = ScrollController(); 41 + TextEditingController _booktime1 = TextEditingController();
  42 + TextEditingController _booktime2 = TextEditingController();
  43 + TextEditingController _booktime3 = TextEditingController();
  44 + TextEditingController _booktime4 = TextEditingController();
  45 + TextEditingController _booktime5 = TextEditingController();
49 46
50 @override 47 @override
51 void initState() { 48 void initState() {
52 super.initState(); 49 super.initState();
  50 + _booktime1.text = '早茶';
  51 + _booktime2.text = '午餐';
  52 + _booktime3.text = '晚餐';
  53 + _booktime4.text = '夜宵';
  54 +
  55 + morning.start = '07:00';
  56 + morning.end = '10:00';
  57 + noon.start = '11:00';
  58 + noon.end = '14:30';
  59 + night.start = '16:00';
  60 + night.end = '21:00';
  61 + swichState = [false, true, true, false, false];
53 _initWeekData(); 62 _initWeekData();
54 WidgetsBinding.instance.addPostFrameCallback((_) {}); 63 WidgetsBinding.instance.addPostFrameCallback((_) {});
55 } 64 }
@@ -87,32 +96,34 @@ class _BookTimeSettingEditPageState extends State<BookTimeSettingEditPage> { @@ -87,32 +96,34 @@ class _BookTimeSettingEditPageState extends State<BookTimeSettingEditPage> {
87 } 96 }
88 97
89 String _getValueText( 98 String _getValueText(
90 - CalendarDatePicker2Type datePickerType, 99 + // CalendarDatePicker2Type datePickerType,
91 List<DateTime> values, 100 List<DateTime> values,
92 ) { 101 ) {
93 - values =  
94 - values.map((e) => e != null ? DateUtils.dateOnly(e) : null).toList();  
95 - var valueText = (values.isNotEmpty ? values[0] : null)  
96 - .toString()  
97 - .replaceAll('00:00:00.000', ''); 102 + // values =
  103 + // values.map((e) => e != null ? DateUtils.dateOnly(e) : null).toList();
  104 + // var valueText = (values.isNotEmpty ? values[0] : null)
  105 + // .toString()
  106 + // .replaceAll('00:00:00.000', '');
98 107
99 - if (datePickerType == CalendarDatePicker2Type.multi) {  
100 - valueText = values.isNotEmpty  
101 - ? values  
102 - .map((v) => v.toString().replaceAll('00:00:00.000', ''))  
103 - .join(', ')  
104 - : 'null';  
105 - } else if (datePickerType == CalendarDatePicker2Type.range) {  
106 - if (values.isNotEmpty) {  
107 - final startDate = values[0].toString().replaceAll('00:00:00.000', '');  
108 - final endDate = values.length > 1  
109 - ? values[1].toString().replaceAll('00:00:00.000', '')  
110 - : 'null';  
111 - valueText = '$startDate to $endDate';  
112 - } else {  
113 - return 'null';  
114 - }  
115 - } 108 + // if (datePickerType == CalendarDatePicker2Type.multi) {
  109 + var valueText = values.isNotEmpty
  110 + ? values
  111 + .map((v) =>
  112 + v.toString().replaceAll('00:00:00.000', '').substring(2) +
  113 + '${Utils.lunarCalendarHolidaysShow(v)}')
  114 + .join(' ')
  115 + : '点击选择日期(可多选)';
  116 + // } else if (datePickerType == CalendarDatePicker2Type.range) {
  117 + // if (values.isNotEmpty) {
  118 + // final startDate = values[0].toString().replaceAll('00:00:00.000', '');
  119 + // final endDate = values.length > 1
  120 + // ? values[1].toString().replaceAll('00:00:00.000', '')
  121 + // : 'null';
  122 + // valueText = '$startDate to $endDate';
  123 + // } else {
  124 + // return 'null';
  125 + // }
  126 + // }
116 127
117 return valueText; 128 return valueText;
118 } 129 }
@@ -131,351 +142,23 @@ class _BookTimeSettingEditPageState extends State<BookTimeSettingEditPage> { @@ -131,351 +142,23 @@ class _BookTimeSettingEditPageState extends State<BookTimeSettingEditPage> {
131 } 142 }
132 } 143 }
133 144
134 - //显示日历弹框  
135 - Future<DateTime> showCalendarDialogMultiple(BuildContext context) {  
136 - return showModalBottomSheet<DateTime>(  
137 - context: context,  
138 - isScrollControlled: true,  
139 - builder: (BuildContext context) {  
140 - BuildContext dialogContext = context;  
141 - Widget widget = StatefulBuilder(builder: (context, _setState) {  
142 - return Container(  
143 - color: MyColours.color_ffffff,  
144 - child: Column(  
145 - mainAxisSize: MainAxisSize.min,  
146 - children: <Widget>[  
147 - _buildMultiDatePickerWithValue(),  
148 - VEmptyView(4),  
149 - Row(  
150 - mainAxisAlignment: MainAxisAlignment.spaceEvenly,  
151 - children: [  
152 - RoundButton(  
153 - onPressed: () async {  
154 - // _calendarController  
155 - // .setSelectedDay(DateTime.now());  
156 - _setState(() {});  
157 - },  
158 - text: '取消',  
159 - fontSize: 28,  
160 - isBold: false,  
161 - height: ScreenUtil().setWidth(70),  
162 - width: ScreenUtil().setWidth(220),  
163 - gradientStart: MyColours.color_2bb5b7,  
164 - gradientEnd: MyColours.color_2bb5b7,  
165 - radius: ScreenUtil().setWidth(10),  
166 - ),  
167 - RoundButton(  
168 - onPressed: () async {  
169 - Navigator.pop(context);  
170 - },  
171 - text: '确定',  
172 - fontSize: 28,  
173 - isBold: false,  
174 - textColor: MyColours.color_333333,  
175 - borderColor: Color.fromRGBO(119, 119, 119, 1),  
176 - height: ScreenUtil().setWidth(70),  
177 - width: ScreenUtil().setWidth(220),  
178 - gradientStart: Colors.transparent,  
179 - gradientEnd: Colors.transparent,  
180 - radius: ScreenUtil().setWidth(10),  
181 - )  
182 - ],  
183 - ),  
184 - VEmptyView(40)  
185 - ],  
186 - ))  
187 -  
188 - // Positioned(  
189 - // right: ScreenUtil().setWidth(62),  
190 - // bottom: ScreenUtil().setHeight(20),  
191 - // child: Container(  
192 - // child: GestureDetector(  
193 - // onTap: () {  
194 - // _calendarController.setSelectedDay(DateTime.now());  
195 - // _setState(() {});  
196 - // },  
197 - // child: Container(  
198 - // child: ClipOval(  
199 - // child: Container(  
200 - // width: ScreenUtil().setWidth(100),  
201 - // height: ScreenUtil().setWidth(100),  
202 - // alignment: Alignment.center,  
203 - // color: MyColours.color_2bb5b7,  
204 - // child: Text(  
205 - // "回到\n今天",  
206 - // style: TextStyle(  
207 - // color: MyColours.color_ffffff,  
208 - // fontSize: ScreenUtil().setSp(26)),  
209 - // ),  
210 - // )),  
211 - // ),  
212 - // ),  
213 - // ),  
214 - // )  
215 - // ],  
216 - ;  
217 - });  
218 - return SizedBox(  
219 - width: double.infinity,  
220 - // height: ScreenUtil().setWidth(975),  
221 - child: widget,  
222 - );  
223 - });  
224 - }  
225 -  
226 - String intToWeek(int week) {  
227 - String str = '';  
228 - switch (week) {  
229 - case 0:  
230 - str = '周日';  
231 - break;  
232 - case 1:  
233 - str = '周一';  
234 - break;  
235 - case 2:  
236 - str = '周二';  
237 - break;  
238 - case 3:  
239 - str = '周三';  
240 - break;  
241 - case 4:  
242 - str = '周四';  
243 - break;  
244 - case 5:  
245 - str = '周五';  
246 - break;  
247 - case 6:  
248 - str = '周六';  
249 - break;  
250 - }  
251 - return str;  
252 - }  
253 -  
254 - Widget _buildMultiDatePickerWithValue() {  
255 - final config = CalendarDatePicker2Config(  
256 - disableMonthPicker: true,  
257 - calendarType: CalendarDatePicker2Type.multi,  
258 - currentDate: DateTime.now(),  
259 - dynamicCalendarRows: true,  
260 - yearViewController: yearC,  
261 - centerAlignModePicker: true,  
262 - controlsTextStyle: TextStyle(color: MyColours.color_F8F9FD),  
263 - lastMonthIcon: Image.asset(  
264 - Utils.getImgPath('date_m_l'),  
265 - width: w(8),  
266 - ),  
267 - nextMonthIcon: Image.asset(  
268 - Utils.getImgPath('date_m_r'),  
269 - width: w(8),  
270 - ),  
271 -  
272 - // firstDayOfWeek: 0,  
273 - // controlsHeight: w(100),  
274 - // yearBuilder: (({decoration, isCurrentYear, isDisabled, isSelected, textStyle, year}) {  
275 - // return Container(  
276 - // width: 50,  
277 - // height: 50,  
278 - // color: Colors.red,  
279 - // );  
280 - // }),  
281 -  
282 - selectedDayHighlightColor: MyColours.color_438E93,  
283 - weekdayLabelBuilder: ({isScrollViewTopHeader, weekday}) {  
284 - return Container(  
285 - color: MyColours.color_438E93,  
286 - alignment: Alignment.center,  
287 - margin: EdgeInsets.only(  
288 - bottom: ScreenUtil().setWidth(30), right: weekday == 6 ? 0 : 1),  
289 - // padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(15)),  
290 - child: Text(  
291 - intToWeek(weekday),  
292 - style: TextStyle(  
293 - color: MyColours.color_F8F9FD,  
294 - fontSize: ScreenUtil().setSp(28)),  
295 - ),  
296 - );  
297 - },  
298 - dayMaxWidth: w(51),  
299 -  
300 - dayBorderRadius: BorderRadius.circular(r(5)),  
301 - dayBuilder: ((  
302 - {date, decoration, isDisabled, isSelected, isToday, textStyle}) {  
303 - return Container(  
304 - margin: EdgeInsets.all(w(4)),  
305 - decoration: BoxDecoration(  
306 - borderRadius: BorderRadius.circular(r(5)),  
307 - color: isSelected  
308 - ? MyColours.color_438E93  
309 - : isToday  
310 - ? MyColours.color_2bb5b7  
311 - : MyColours.color_ffffff),  
312 - child: Column(  
313 - mainAxisAlignment: MainAxisAlignment.center,  
314 - children: [  
315 - Text(  
316 - // "${_parseDateDay(date)}",  
317 - '${Utils.addZeroNumber(date.day)}',  
318 - style: TextStyle().copyWith(  
319 - fontSize: ScreenUtil().setSp(32),  
320 - color: isSelected  
321 - ? MyColours.color_F8F9FD  
322 - : isToday  
323 - ? MyColours.color_F8F9FD  
324 - : MyColours.color_353535,  
325 - fontWeight: FontWeight.bold)),  
326 - Text(  
327 - "${_parseDateDay(date)}",  
328 - textAlign: TextAlign.center,  
329 - maxLines: 1,  
330 - overflow: TextOverflow.ellipsis,  
331 - style: TextStyle().copyWith(  
332 - fontSize: ScreenUtil().setSp(18),  
333 - color: isSelected  
334 - ? MyColours.color_F8F9FD  
335 - : isToday  
336 - ? MyColours.color_F8F9FD  
337 - : MyColours.color_353535),  
338 - ),  
339 - ],  
340 - ),  
341 - );  
342 - }),  
343 -  
344 - // dayBuilder: (context, date, _) {  
345 - //  
346 - // },  
347 - );  
348 -  
349 - // selectedDayBuilder: (context, date, _) {  
350 - // return Container(  
351 - // // alignment: Alignment.center,  
352 - // // margin: EdgeInsets.fromLTRB(  
353 - // // ScreenUtil().setWidth(12),  
354 - // // ScreenUtil().setWidth(12),  
355 - // // ScreenUtil().setWidth(12),  
356 - // // ScreenUtil().setWidth(32)),  
357 - // padding: EdgeInsets.only(  
358 - // bottom: ScreenUtil().setWidth(10),  
359 - // left: ScreenUtil().setWidth(5),  
360 - // right: ScreenUtil().setWidth(5),  
361 - // top: ScreenUtil().setWidth(10)),  
362 - // child: Container(  
363 - // decoration: BoxDecoration(  
364 - // borderRadius: BorderRadius.circular(  
365 - // ScreenUtil().setWidth(10)),  
366 - // color: Color.fromRGBO(42, 110, 109, 1)),  
367 - // child: Column(  
368 - // mainAxisAlignment: MainAxisAlignment.center,  
369 - // children: [  
370 - // Text(  
371 - // // "${_parseDateDay(date)}",  
372 - // '${Utils.addZeroNumber(date.day)}',  
373 - // style: TextStyle().copyWith(  
374 - // color: MyColours.color_ffffff,  
375 - // fontSize: ScreenUtil().setSp(32),  
376 - // fontWeight: FontWeight.bold),  
377 - // ),  
378 - // Text(  
379 - // "${_parseDateDay(date)}",  
380 - // // '${Utils.lunarCalendarHolidaysShow(date)}',  
381 - // style: TextStyle().copyWith(  
382 - // fontSize: ScreenUtil().setSp(22),  
383 - // color: MyColours.color_ffffff),  
384 - // )  
385 - // ],  
386 - // ),  
387 - // ),  
388 - // );  
389 - // },  
390 - // todayDayBuilder: (context, date, _) {  
391 - // return Container(  
392 - // // alignment: Alignment.center,  
393 - // // margin: EdgeInsets.fromLTRB(  
394 - // // ScreenUtil().setWidth(12),  
395 - // // ScreenUtil().setWidth(12),  
396 - // // ScreenUtil().setWidth(12),  
397 - // // ScreenUtil().setWidth(32)),  
398 - // padding: EdgeInsets.only(  
399 - // bottom: ScreenUtil().setWidth(10),  
400 - // left: ScreenUtil().setWidth(5),  
401 - // right: ScreenUtil().setWidth(5),  
402 - // top: ScreenUtil().setWidth(10)),  
403 - // child: Container(  
404 - // decoration: BoxDecoration(  
405 - // borderRadius: BorderRadius.circular(  
406 - // ScreenUtil().setWidth(10)),  
407 - // color: MyColours.color_2bb5b7),  
408 - // child: Column(  
409 - // mainAxisAlignment: MainAxisAlignment.center,  
410 - // children: [  
411 - // Text(  
412 - // // "${_parseDateDay(date)}",  
413 - // '${Utils.addZeroNumber(date.day)}',  
414 - // style: TextStyle().copyWith(  
415 - // color: MyColours.color_ffffff,  
416 - // fontSize: ScreenUtil().setSp(32),  
417 - // fontWeight: FontWeight.bold),  
418 - // ),  
419 - // Text(  
420 - // "${_parseDateDay(date)}",  
421 - // // '${Utils.lunarCalendarHolidaysShow(date)}',  
422 - // style: TextStyle().copyWith(  
423 - // fontSize: ScreenUtil().setSp(22),  
424 - // color: MyColours.color_ffffff),  
425 - // )  
426 - // ],  
427 - // ),  
428 - // ),  
429 - // );  
430 - // );  
431 - return SizedBox(  
432 - width: double.infinity,  
433 - child: Column(  
434 - mainAxisSize: MainAxisSize.min,  
435 - children: [  
436 - CalendarDatePicker2(  
437 - config: config,  
438 - value: _multiDatePickerValueWithDefaultValue,  
439 - onValueChanged: (dates) =>  
440 - setState(() => _multiDatePickerValueWithDefaultValue = dates),  
441 - ),  
442 - const SizedBox(height: 10),  
443 - Wrap(  
444 - children: [  
445 - const Text('Selection(s): '),  
446 - const SizedBox(width: 10),  
447 - Text(  
448 - _getValueText(  
449 - config.calendarType,  
450 - _multiDatePickerValueWithDefaultValue,  
451 - ),  
452 - overflow: TextOverflow.ellipsis,  
453 - maxLines: 10,  
454 - softWrap: false,  
455 - ),  
456 - ],  
457 - ),  
458 - const SizedBox(height: 25),  
459 - ],  
460 - ),  
461 - );  
462 - }  
463 -  
464 ///时间选择 145 ///时间选择
465 Widget _select1(String title, GestureTapCallback onTap) { 146 Widget _select1(String title, GestureTapCallback onTap) {
466 return InkWell( 147 return InkWell(
467 onTap: onTap, 148 onTap: onTap,
468 child: Container( 149 child: Container(
469 - padding: EdgeInsets.only(left: w(16)), 150 + padding: EdgeInsets.only(left: w(16), top: w(7), bottom: w(12)),
470 child: Row( 151 child: Row(
471 crossAxisAlignment: CrossAxisAlignment.center, 152 crossAxisAlignment: CrossAxisAlignment.center,
472 mainAxisAlignment: MainAxisAlignment.center, 153 mainAxisAlignment: MainAxisAlignment.center,
473 children: [ 154 children: [
474 - Container( 155 + Expanded(
  156 + child: Container(
475 // height: ScreenUtil().setWidth(40), 157 // height: ScreenUtil().setWidth(40),
476 // color: Colors.red, 158 // color: Colors.red,
477 child: Text( 159 child: Text(
478 title, 160 title,
  161 + maxLines: 10,
479 style: TextStyle( 162 style: TextStyle(
480 height: 1.5, 163 height: 1.5,
481 color: title == '点击选择日期(可多选)' 164 color: title == '点击选择日期(可多选)'
@@ -483,9 +166,9 @@ class _BookTimeSettingEditPageState extends State<BookTimeSettingEditPage> { @@ -483,9 +166,9 @@ class _BookTimeSettingEditPageState extends State<BookTimeSettingEditPage> {
483 : MyColours.color_515151, 166 : MyColours.color_515151,
484 fontSize: font(16)), 167 fontSize: font(16)),
485 ), 168 ),
486 - ), 169 + )),
487 // HEmptyView(20), 170 // HEmptyView(20),
488 - Spacer(), 171 + // Spacer(),
489 // Text(hintText, 172 // Text(hintText,
490 // style: TextStyle( 173 // style: TextStyle(
491 // color: hintText == '点击设置开始日期' || hintText == '点击设置结束日期' 174 // color: hintText == '点击设置开始日期' || hintText == '点击设置结束日期'
@@ -505,6 +188,386 @@ class _BookTimeSettingEditPageState extends State<BookTimeSettingEditPage> { @@ -505,6 +188,386 @@ class _BookTimeSettingEditPageState extends State<BookTimeSettingEditPage> {
505 ); 188 );
506 } 189 }
507 190
  191 + Widget _itemMorningNoonAngNight(int tag, TextEditingController booktimes) {
  192 + return Row(
  193 + mainAxisAlignment: MainAxisAlignment.spaceBetween,
  194 + children: [
  195 + swichState[tag]
  196 + ? Expanded(
  197 + child: Container(
  198 + // height: ScreenUtil().setWidth(50),
  199 + // padding: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(24)),
  200 + decoration: BoxDecoration(
  201 + color: MyColours.color_ffffff,
  202 + borderRadius: BorderRadius.circular(r(14))),
  203 + child: TextField(
  204 + controller: booktimes,
  205 + maxLines: 1,
  206 + // inputFormatters: [
  207 + // LengthLimitingTextInputFormatter(
  208 + // 15),
  209 + // // FilteringTextInputFormatter.digitsOnly
  210 + // ],
  211 +
  212 + // //光标颜色
  213 + // cursorColor:
  214 + // widget.isSelect ? Colors.white : MyColours.color_199095,
  215 + //输入文本的样式
  216 + style: TextStyle(
  217 + fontSize: font(14), color: MyColours.color_515151),
  218 + // focusNode: _phoneFocusNode,
  219 + decoration: InputDecoration(
  220 + border: OutlineInputBorder(borderSide: BorderSide.none),
  221 + hintText: '请输入餐段名称',
  222 + hintStyle: TextStyle(
  223 + color: MyColours.color_BFC4D4,
  224 + fontSize: font(14),
  225 + ),
  226 + contentPadding: EdgeInsets.zero,
  227 + isCollapsed: true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
  228 + enabledBorder: new UnderlineInputBorder(
  229 + borderSide: BorderSide.none,
  230 + ),
  231 +
  232 + focusedBorder: new UnderlineInputBorder(
  233 + borderSide: BorderSide.none,
  234 + ),
  235 + ),
  236 + onChanged: (value) {
  237 + // if (editingController == _nameController) {
  238 + // _nameController.text = value;
  239 + // }
  240 + },
  241 + onEditingComplete: () {
  242 + FocusScope.of(context)
  243 + .requestFocus(FocusNode()); //点击空白处隐藏键盘
  244 + },
  245 + keyboardType: TextInputType.text,
  246 + ),
  247 + ))
  248 + : Spacer(),
  249 + // Text(title,
  250 + // style: TextStyle(
  251 + // fontSize: ScreenUtil().setSp(28),
  252 + // color: MyColours.color_999999)),
  253 + InkWell(
  254 + onTap: () {
  255 + setState(() {
  256 + swichState[tag] = !swichState[tag];
  257 + });
  258 + },
  259 + child: Image.asset(
  260 + Utils.getImgPath(
  261 + swichState[tag] ? 'store_swich_on' : 'store_swich_off'),
  262 + width: w(38))),
  263 + ],
  264 + );
  265 + }
  266 +
  267 + ///从时间选择器中获取分钟数字符串 00 or 30
  268 + String _getMinuteStrFromPickerBookTime(List data, List value) {
  269 + // if (data.length == 1) {
  270 + // return '30';
  271 + // } else {
  272 + Map map = data[value[0]];
  273 +
  274 + int minute = map.values.last[value[1]];
  275 + if (minute == 0) {
  276 + return '00';
  277 + }
  278 + return '${minute}';
  279 + // if (value[1] == 0) {
  280 + // return '00';
  281 + // } else if (value[1] == 1) {
  282 + // return '15';
  283 + // } else if (value[1] == 2) {
  284 + // return '30';
  285 + // } else {
  286 + // return '45';
  287 + // }
  288 + // }
  289 + }
  290 +
  291 + Widget _itemBookTime(String start, String end, int tag) {
  292 + return Row(
  293 + children: [
  294 + Expanded(
  295 + child: InkWell(
  296 + onTap: () {
  297 + if (swichState[tag]) {
  298 + List data = SetTimeWidget.dateData;
  299 + if (tag == 0) {
  300 + //早市
  301 + data = SetTimeWidget.dateData;
  302 + } else if (tag == 1) {
  303 + //午市
  304 + data = Utils.getPickerData(
  305 + morning.end, SetTimeWidget.dateData);
  306 + } else if (tag == 2) {
  307 + //晚市
  308 + data =
  309 + Utils.getPickerData(noon.end, SetTimeWidget.dateData);
  310 + }
  311 +
  312 + SetTimeWidget().showTimeSelector(context, data, start,
  313 + (value) {
  314 + if (value != null) {
  315 + String tempMinute =
  316 + _getMinuteStrFromPickerBookTime(data, value);
  317 + print(data[value[0]].keys.first);
  318 + String time = Utils.getTimeString(
  319 + Utils.getHourFromTitle(data[value[0]].keys.first),
  320 + tempMinute);
  321 + setState(() {
  322 + if (tag == 0) {
  323 + //早市
  324 + morning.start = time;
  325 + setState(() {
  326 + Utils.compareDateTime(morning.end, time,
  327 + (needChange) {
  328 + if (needChange) {
  329 + morning.end = time;
  330 + }
  331 + });
  332 + Utils.compareDateTime(noon.start, time,
  333 + (needChange) {
  334 + if (needChange) {
  335 + noon.start = time;
  336 + }
  337 + });
  338 + Utils.compareDateTime(noon.end, time,
  339 + (needChange) {
  340 + if (needChange) {
  341 + noon.end = time;
  342 + }
  343 + });
  344 + Utils.compareDateTime(night.start, time,
  345 + (needChange) {
  346 + if (needChange) {
  347 + night.start = time;
  348 + }
  349 + });
  350 + Utils.compareDateTime(night.end, time,
  351 + (needChange) {
  352 + if (needChange) {
  353 + night.end = time;
  354 + }
  355 + });
  356 + });
  357 + } else if (tag == 1) {
  358 + //午市
  359 + noon.start = time;
  360 + setState(() {
  361 + Utils.compareDateTime(noon.end, time,
  362 + (needChange) {
  363 + if (needChange) {
  364 + noon.end = time;
  365 + }
  366 + });
  367 + Utils.compareDateTime(night.start, time,
  368 + (needChange) {
  369 + if (needChange) {
  370 + night.start = time;
  371 + }
  372 + });
  373 + Utils.compareDateTime(night.end, time,
  374 + (needChange) {
  375 + if (needChange) {
  376 + night.end = time;
  377 + }
  378 + });
  379 + });
  380 + } else if (tag == 2) {
  381 + //晚市
  382 + night.start = time;
  383 + setState(() {
  384 + Utils.compareDateTime(night.end, time,
  385 + (needChange) {
  386 + if (needChange) {
  387 + night.end = time;
  388 + }
  389 + });
  390 + });
  391 + }
  392 + });
  393 + print(value);
  394 + }
  395 + });
  396 + }
  397 + },
  398 + child: Container(
  399 + height: w(34),
  400 + alignment: Alignment.center,
  401 + decoration: BoxDecoration(
  402 + borderRadius: BorderRadius.circular(r(5)),
  403 + border: Border.all(
  404 + width: w(1), color: MyColours.color_438E93)),
  405 + child: start == '' || start == null || start == 'null'
  406 + ? RichText(
  407 + text: TextSpan(
  408 + style: TextStyle(
  409 + fontSize: font(12),
  410 + ),
  411 + children: [
  412 + // const TextSpan(text: '('),
  413 + TextSpan(
  414 + text: '选择开始时间',
  415 + style: TextStyle(
  416 + color: MyColours.color_438E93)),
  417 + TextSpan(
  418 + text: '*',
  419 + style: TextStyle(
  420 + color: MyColours.color_E34D59)),
  421 + ]))
  422 + : Text(
  423 + start,
  424 + style: TextStyle(
  425 + color: MyColours.color_438E93,
  426 + fontSize: font(12),
  427 + ),
  428 + )))),
  429 + HEmptyView(52),
  430 + Text('至',
  431 + style:
  432 + TextStyle(fontSize: font(12), color: MyColours.color_515151)),
  433 + HEmptyView(52),
  434 + Expanded(
  435 + child: InkWell(
  436 + onTap: () {
  437 + if (swichState[tag]) {
  438 + List data = SetTimeWidget.dateData;
  439 + if (tag == 0) {
  440 + //早市
  441 + data = Utils.getPickerData(
  442 + morning.start, SetTimeWidget.dateData);
  443 + } else if (tag == 1) {
  444 + //午市
  445 + data =
  446 + Utils.getPickerData(noon.start, SetTimeWidget.dateData);
  447 + } else if (tag == 2) {
  448 + //晚市
  449 + data = Utils.getPickerData(
  450 + night.start, SetTimeWidget.dateData);
  451 + }
  452 + SetTimeWidget().showTimeSelector(context, data, end, (value) {
  453 + if (value != null) {
  454 + String tempMinute =
  455 + _getMinuteStrFromPickerBookTime(data, value);
  456 + String time = Utils.getTimeString(
  457 + Utils.getHourFromTitle(data[value[0]].keys.first),
  458 + tempMinute);
  459 + setState(() {
  460 + if (tag == 0) {
  461 + //早市
  462 + morning.end = time;
  463 +
  464 + setState(() {
  465 + Utils.compareDateTime(time, morning.start,
  466 + (needChange) {
  467 + if (needChange) {
  468 + morning.start = time;
  469 + }
  470 + });
  471 + Utils.compareDateTime(noon.start, time,
  472 + (needChange) {
  473 + if (needChange) {
  474 + noon.start = time;
  475 + }
  476 + });
  477 +
  478 + Utils.compareDateTime(noon.end, time, (needChange) {
  479 + if (needChange) {
  480 + noon.end = time;
  481 + }
  482 + });
  483 + Utils.compareDateTime(night.start, time,
  484 + (needChange) {
  485 + if (needChange) {
  486 + night.start = time;
  487 + }
  488 + });
  489 +
  490 + Utils.compareDateTime(night.end, time,
  491 + (needChange) {
  492 + if (needChange) {
  493 + night.end = time;
  494 + }
  495 + });
  496 + });
  497 + } else if (tag == 1) {
  498 + //午市
  499 + noon.end = time;
  500 + setState(() {
  501 + Utils.compareDateTime(noon.end, noon.start,
  502 + (needChange) {
  503 + if (needChange) {
  504 + noon.start = noon.end;
  505 + }
  506 + });
  507 + Utils.compareDateTime(night.start, time,
  508 + (needChange) {
  509 + if (needChange) {
  510 + night.start = time;
  511 + }
  512 + });
  513 + Utils.compareDateTime(night.end, time,
  514 + (needChange) {
  515 + if (needChange) {
  516 + night.end = time;
  517 + }
  518 + });
  519 + });
  520 + } else if (tag == 2) {
  521 + //晚市
  522 + night.end = time;
  523 + setState(() {
  524 + Utils.compareDateTime(night.end, night.start,
  525 + (needChange) {
  526 + if (needChange) {
  527 + night.start = night.end;
  528 + }
  529 + });
  530 + });
  531 + }
  532 + });
  533 + print(value);
  534 + }
  535 + });
  536 + }
  537 + },
  538 + child: Container(
  539 + height: w(34),
  540 + alignment: Alignment.center,
  541 + decoration: BoxDecoration(
  542 + borderRadius: BorderRadius.circular(r(5)),
  543 + border: Border.all(
  544 + width: w(1), color: MyColours.color_438E93)),
  545 + child: end == '' || end == null || end == 'null'
  546 + ? RichText(
  547 + text: TextSpan(
  548 + style: TextStyle(fontSize: font(12)),
  549 + children: [
  550 + // const TextSpan(text: '('),
  551 + TextSpan(
  552 + text: '选择结束时间',
  553 + style:
  554 + TextStyle(color: MyColours.color_438E93)),
  555 + TextSpan(
  556 + text: '*',
  557 + style:
  558 + TextStyle(color: MyColours.color_E34D59)),
  559 + ]))
  560 + : Text(
  561 + end,
  562 + style: TextStyle(
  563 + color: MyColours.color_438E93,
  564 + fontSize: font(12)),
  565 + ))),
  566 + ),
  567 + ],
  568 + );
  569 + }
  570 +
508 @override 571 @override
509 Widget build(BuildContext context) { 572 Widget build(BuildContext context) {
510 return Scaffold( 573 return Scaffold(
@@ -559,15 +622,9 @@ class _BookTimeSettingEditPageState extends State<BookTimeSettingEditPage> { @@ -559,15 +622,9 @@ class _BookTimeSettingEditPageState extends State<BookTimeSettingEditPage> {
559 HEmptyView(30), 622 HEmptyView(30),
560 ], 623 ],
561 ), 624 ),
562 - VEmptyView(30), 625 + VEmptyView(16),
563 _select1(weekShow, () async { 626 _select1(weekShow, () async {
564 if (isWeek) { 627 if (isWeek) {
565 - FocusScope.of(context)  
566 - .requestFocus(FocusNode()); //点击空白处隐藏键盘  
567 - //弹出时间选择器  
568 - // showPickerDateTime(context);  
569 - // showDateSelWidget = false;  
570 -  
571 List<FilterBtnModel> data = 628 List<FilterBtnModel> data =
572 await DialogUtil.openWeekSelectModalBottomSheet( 629 await DialogUtil.openWeekSelectModalBottomSheet(
573 context, weekData); 630 context, weekData);
@@ -593,29 +650,19 @@ class _BookTimeSettingEditPageState extends State<BookTimeSettingEditPage> { @@ -593,29 +650,19 @@ class _BookTimeSettingEditPageState extends State<BookTimeSettingEditPage> {
593 setState(() {}); 650 setState(() {});
594 } 651 }
595 } else { 652 } else {
596 - showCalendarDialogMultiple(context);  
597 - // _buildMultiDatePickerWithValue();  
598 - // DateTime dateTime = DateTime.now();  
599 - // DialogUtil.showCalendarDialogMultiple(context, dateTime)  
600 - // .then((day) async {  
601 - // if (day != null) {  
602 - // // createDateText1(context, day);  
603 - // // bool success =  
604 - // // await tableManagerModel.getTableListOrReserve(  
605 - // // context,  
606 - // // currTimeIndex,  
607 - // // dateTime,  
608 - // // selectNumber,  
609 - // // showLoading: true,  
610 - // // );  
611 - // }  
612 - // }); 653 + DialogUtil.showCalendarDialogMultiple(
  654 + context, _selectPickerValues, (value) {
  655 + _selectPickerValues = value;
  656 + weekShow = _getValueText(
  657 + value,
  658 + );
  659 + setState(() {});
  660 + });
613 } 661 }
614 }), 662 }),
615 ], 663 ],
616 ), 664 ),
617 ), 665 ),
618 - VEmptyView(24),  
619 Padding( 666 Padding(
620 padding: EdgeInsets.only(left: w(16)), 667 padding: EdgeInsets.only(left: w(16)),
621 child: MyDivider( 668 child: MyDivider(
@@ -623,7 +670,53 @@ class _BookTimeSettingEditPageState extends State<BookTimeSettingEditPage> { @@ -623,7 +670,53 @@ class _BookTimeSettingEditPageState extends State<BookTimeSettingEditPage> {
623 w(1), 670 w(1),
624 color: MyColours.color_DBDBDB, 671 color: MyColours.color_DBDBDB,
625 ), 672 ),
626 - ) 673 + ),
  674 + VEmptyView(26),
  675 + Padding(
  676 + padding: EdgeInsets.only(left: w(12)),
  677 + child: Text('可预订时段',
  678 + style: TextStyle(
  679 + fontSize: font(16),
  680 + color: MyColours.color_515151))),
  681 + VEmptyView(36),
  682 + Padding(
  683 + padding: EdgeInsets.symmetric(
  684 + horizontal: w(24),
  685 + ),
  686 + child: Column(
  687 + children: [
  688 + _itemMorningNoonAngNight(0, _booktime1),
  689 + VEmptyView(34),
  690 + swichState[0]
  691 + ? _itemBookTime(morning.start, morning.end, 0)
  692 + : SizedBox(),
  693 + VEmptyView(32),
  694 + _itemMorningNoonAngNight(1, _booktime2),
  695 + VEmptyView(34),
  696 + swichState[1]
  697 + ? _itemBookTime(noon.start, noon.end, 1)
  698 + : SizedBox(),
  699 + VEmptyView(32),
  700 + _itemMorningNoonAngNight(2, _booktime3),
  701 + VEmptyView(34),
  702 + swichState[2]
  703 + ? _itemBookTime(night.start, night.end, 2)
  704 + : SizedBox(),
  705 + VEmptyView(32),
  706 + _itemMorningNoonAngNight(3, _booktime4),
  707 + VEmptyView(34),
  708 + swichState[3]
  709 + ? _itemBookTime(night.start, night.end, 3)
  710 + : SizedBox(),
  711 + VEmptyView(32),
  712 + _itemMorningNoonAngNight(4, _booktime5),
  713 + VEmptyView(34),
  714 + swichState[4]
  715 + ? _itemBookTime(night.start, night.end, 4)
  716 + : SizedBox(),
  717 + ],
  718 + )),
  719 + VEmptyView(34),
627 ], 720 ],
628 ), 721 ),
629 )), 722 )),
@@ -1311,58 +1311,62 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> { @@ -1311,58 +1311,62 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> {
1311 return Row( 1311 return Row(
1312 mainAxisAlignment: MainAxisAlignment.spaceBetween, 1312 mainAxisAlignment: MainAxisAlignment.spaceBetween,
1313 children: [ 1313 children: [
1314 - Expanded(  
1315 - child: Container(  
1316 - // height: ScreenUtil().setWidth(50),  
1317 - // padding: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(24)),  
1318 - decoration: BoxDecoration(  
1319 - color: MyColours.color_F8F9FD,  
1320 - borderRadius: BorderRadius.circular(ScreenUtil().setWidth(28))),  
1321 - child: TextField(  
1322 - controller: booktimes,  
1323 - maxLines: 1,  
1324 - // inputFormatters: [  
1325 - // LengthLimitingTextInputFormatter(  
1326 - // 15),  
1327 - // // FilteringTextInputFormatter.digitsOnly  
1328 - // ],  
1329 -  
1330 - // //光标颜色  
1331 - // cursorColor:  
1332 - // widget.isSelect ? Colors.white : MyColours.color_199095,  
1333 - //输入文本的样式  
1334 - style: TextStyle(  
1335 - fontSize: ScreenUtil().setSp(28),  
1336 - color: MyColours.color_515151),  
1337 - focusNode: _phoneFocusNode,  
1338 - decoration: InputDecoration(  
1339 - border: OutlineInputBorder(borderSide: BorderSide.none),  
1340 - hintText: '请输入餐段名称',  
1341 - hintStyle: TextStyle(  
1342 - color: MyColours.color_BFC4D4,  
1343 - fontSize: ScreenUtil().setSp(28),  
1344 - ),  
1345 - contentPadding: EdgeInsets.zero,  
1346 - isCollapsed: true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度  
1347 - enabledBorder: new UnderlineInputBorder(  
1348 - borderSide: BorderSide.none,  
1349 - ),  
1350 -  
1351 - focusedBorder: new UnderlineInputBorder(  
1352 - borderSide: BorderSide.none,  
1353 - ),  
1354 - ),  
1355 - onChanged: (value) {  
1356 - // if (editingController == _nameController) {  
1357 - // _nameController.text = value;  
1358 - // }  
1359 - },  
1360 - onEditingComplete: () {  
1361 - FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘  
1362 - },  
1363 - keyboardType: TextInputType.text,  
1364 - ),  
1365 - )), 1314 + swichState[tag]
  1315 + ? Expanded(
  1316 + child: Container(
  1317 + // height: ScreenUtil().setWidth(50),
  1318 + // padding: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(24)),
  1319 + decoration: BoxDecoration(
  1320 + color: MyColours.color_F8F9FD,
  1321 + borderRadius:
  1322 + BorderRadius.circular(ScreenUtil().setWidth(28))),
  1323 + child: TextField(
  1324 + controller: booktimes,
  1325 + maxLines: 1,
  1326 + // inputFormatters: [
  1327 + // LengthLimitingTextInputFormatter(
  1328 + // 15),
  1329 + // // FilteringTextInputFormatter.digitsOnly
  1330 + // ],
  1331 +
  1332 + // //光标颜色
  1333 + // cursorColor:
  1334 + // widget.isSelect ? Colors.white : MyColours.color_199095,
  1335 + //输入文本的样式
  1336 + style: TextStyle(
  1337 + fontSize: ScreenUtil().setSp(28),
  1338 + color: MyColours.color_515151),
  1339 + // focusNode: _phoneFocusNode,
  1340 + decoration: InputDecoration(
  1341 + border: OutlineInputBorder(borderSide: BorderSide.none),
  1342 + hintText: '请输入餐段名称',
  1343 + hintStyle: TextStyle(
  1344 + color: MyColours.color_BFC4D4,
  1345 + fontSize: ScreenUtil().setSp(28),
  1346 + ),
  1347 + contentPadding: EdgeInsets.zero,
  1348 + isCollapsed: true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
  1349 + enabledBorder: new UnderlineInputBorder(
  1350 + borderSide: BorderSide.none,
  1351 + ),
  1352 +
  1353 + focusedBorder: new UnderlineInputBorder(
  1354 + borderSide: BorderSide.none,
  1355 + ),
  1356 + ),
  1357 + onChanged: (value) {
  1358 + // if (editingController == _nameController) {
  1359 + // _nameController.text = value;
  1360 + // }
  1361 + },
  1362 + onEditingComplete: () {
  1363 + FocusScope.of(context)
  1364 + .requestFocus(FocusNode()); //点击空白处隐藏键盘
  1365 + },
  1366 + keyboardType: TextInputType.text,
  1367 + ),
  1368 + ))
  1369 + : Spacer(),
1366 // Text(title, 1370 // Text(title,
1367 // style: TextStyle( 1371 // style: TextStyle(
1368 // fontSize: ScreenUtil().setSp(28), 1372 // fontSize: ScreenUtil().setSp(28),
@@ -3,6 +3,7 @@ import 'dart:convert'; @@ -3,6 +3,7 @@ import 'dart:convert';
3 import 'dart:ui'; 3 import 'dart:ui';
4 4
5 import 'package:cached_network_image/cached_network_image.dart'; 5 import 'package:cached_network_image/cached_network_image.dart';
  6 +import 'package:calendar_date_picker2/calendar_date_picker2.dart';
6 import 'package:common_utils/common_utils.dart'; 7 import 'package:common_utils/common_utils.dart';
7 import 'package:flutter/cupertino.dart'; 8 import 'package:flutter/cupertino.dart';
8 import 'package:flutter/material.dart'; 9 import 'package:flutter/material.dart';
@@ -7255,22 +7256,135 @@ class DialogUtil { @@ -7255,22 +7256,135 @@ class DialogUtil {
7255 } 7256 }
7256 } 7257 }
7257 7258
7258 - //显示日历弹框 7259 + static String intToWeek(int week) {
  7260 + String str = '';
  7261 + switch (week) {
  7262 + case 0:
  7263 + str = '周日';
  7264 + break;
  7265 + case 1:
  7266 + str = '周一';
  7267 + break;
  7268 + case 2:
  7269 + str = '周二';
  7270 + break;
  7271 + case 3:
  7272 + str = '周三';
  7273 + break;
  7274 + case 4:
  7275 + str = '周四';
  7276 + break;
  7277 + case 5:
  7278 + str = '周五';
  7279 + break;
  7280 + case 6:
  7281 + str = '周六';
  7282 + break;
  7283 + }
  7284 + return str;
  7285 + }
  7286 +
  7287 + static Widget _buildMultiDatePickerWithValue(
  7288 + List<DateTime> _multiDatePickerValueWithDefaultValue,
  7289 + ValueChanged valueChanged) {
  7290 + final config = CalendarDatePicker2Config(
  7291 + disableMonthPicker: true,
  7292 + calendarType: CalendarDatePicker2Type.multi,
  7293 + currentDate: DateTime.now(),
  7294 + dynamicCalendarRows: true,
  7295 + centerAlignModePicker: true,
  7296 + controlsTextStyle: TextStyle(color: MyColours.color_F8F9FD),
  7297 + lastMonthIcon: Image.asset(
  7298 + Utils.getImgPath('date_m_l'),
  7299 + width: w(8),
  7300 + ),
  7301 + nextMonthIcon: Image.asset(
  7302 + Utils.getImgPath('date_m_r'),
  7303 + width: w(8),
  7304 + ),
  7305 + selectedDayHighlightColor: MyColours.color_438E93,
  7306 + weekdayLabelBuilder: ({isScrollViewTopHeader, weekday}) {
  7307 + return Container(
  7308 + color: MyColours.color_438E93,
  7309 + alignment: Alignment.center,
  7310 + margin: EdgeInsets.only(
  7311 + bottom: ScreenUtil().setWidth(30), right: weekday == 6 ? 0 : 1),
  7312 + child: Text(
  7313 + intToWeek(weekday),
  7314 + style: TextStyle(
  7315 + color: MyColours.color_F8F9FD,
  7316 + fontSize: ScreenUtil().setSp(28)),
  7317 + ),
  7318 + );
  7319 + },
  7320 + dayMaxWidth: w(51),
  7321 + dayBorderRadius: BorderRadius.circular(r(5)),
  7322 + dayBuilder: ((
  7323 + {date, decoration, isDisabled, isSelected, isToday, textStyle}) {
  7324 + return Container(
  7325 + margin: EdgeInsets.all(w(4)),
  7326 + decoration: BoxDecoration(
  7327 + borderRadius: BorderRadius.circular(r(5)),
  7328 + color: isSelected
  7329 + ? MyColours.color_438E93
  7330 + : isToday
  7331 + ? MyColours.color_2bb5b7
  7332 + : MyColours.color_ffffff),
  7333 + child: Column(
  7334 + mainAxisAlignment: MainAxisAlignment.center,
  7335 + children: [
  7336 + Text('${Utils.addZeroNumber(date.day)}',
  7337 + style: TextStyle().copyWith(
  7338 + fontSize: ScreenUtil().setSp(32),
  7339 + color: isSelected
  7340 + ? MyColours.color_F8F9FD
  7341 + : isToday
  7342 + ? MyColours.color_F8F9FD
  7343 + : MyColours.color_353535,
  7344 + fontWeight: FontWeight.bold)),
  7345 + Text(
  7346 + _parseDateDay(date),
  7347 + textAlign: TextAlign.center,
  7348 + maxLines: 1,
  7349 + overflow: TextOverflow.ellipsis,
  7350 + style: TextStyle().copyWith(
  7351 + fontSize: ScreenUtil().setSp(18),
  7352 + color: isSelected
  7353 + ? MyColours.color_F8F9FD
  7354 + : isToday
  7355 + ? MyColours.color_F8F9FD
  7356 + : MyColours.color_353535),
  7357 + ),
  7358 + ],
  7359 + ),
  7360 + );
  7361 + }),
  7362 + );
  7363 +
  7364 + return SizedBox(
  7365 + width: double.infinity,
  7366 + child: Column(
  7367 + mainAxisSize: MainAxisSize.min,
  7368 + children: [
  7369 + CalendarDatePicker2(
  7370 + config: config,
  7371 + value: _multiDatePickerValueWithDefaultValue,
  7372 + onValueChanged: (dates) {
  7373 + _multiDatePickerValueWithDefaultValue = dates;
  7374 + valueChanged(_multiDatePickerValueWithDefaultValue);
  7375 + }),
  7376 + ],
  7377 + ),
  7378 + );
  7379 + }
  7380 +
  7381 + //显示日历弹框 (可多选,可单选)
7259 static Future<DateTime> showCalendarDialogMultiple( 7382 static Future<DateTime> showCalendarDialogMultiple(
7260 - BuildContext context, DateTime selectDateTime) {  
7261 - CalendarController _calendarController = CalendarController();  
7262 - final _selectedDay = DateTime.now();  
7263 - Map<DateTime, List> _events = {  
7264 - _selectedDay: ['Event A7', 'Event B7', 'Event C7', 'Event D7'],  
7265 - _selectedDay.add(Duration(days: 1)): [  
7266 - 'Event A8',  
7267 - 'Event B8',  
7268 - 'Event C8',  
7269 - 'Event D8'  
7270 - ],  
7271 - _selectedDay.add(Duration(days: 2)):  
7272 - Set.from(['Event A9', 'Event A9', 'Event B9']).toList(),  
7273 - }; 7383 + BuildContext context,
  7384 + List<DateTime> selectDates,
  7385 + ValueChanged valueChanged,
  7386 + ) {
  7387 + List<DateTime> _multiDatePickerValueWithDefaultValue = selectDates; //日历使用
7274 return showModalBottomSheet<DateTime>( 7388 return showModalBottomSheet<DateTime>(
7275 context: context, 7389 context: context,
7276 isScrollControlled: true, 7390 isScrollControlled: true,
@@ -7278,334 +7392,59 @@ class DialogUtil { @@ -7278,334 +7392,59 @@ class DialogUtil {
7278 BuildContext dialogContext = context; 7392 BuildContext dialogContext = context;
7279 Widget widget = StatefulBuilder(builder: (context, _setState) { 7393 Widget widget = StatefulBuilder(builder: (context, _setState) {
7280 return Container( 7394 return Container(
7281 - color: MyColours.color_ffffff,  
7282 - child: Column(  
7283 - mainAxisSize: MainAxisSize.min,  
7284 - children: <Widget>[  
7285 - TableCalendar(  
7286 - // rowHeight: ScreenUtil().setWidth(100),  
7287 - calendarController: _calendarController,  
7288 - initialSelectedDay: _selectedDay,  
7289 - onDaySelected: (day, events, holidays) {  
7290 - Navigator.of(dialogContext).pop(day);  
7291 - },  
7292 - // holidays: _holidays,  
7293 - availableGestures: AvailableGestures.none,  
7294 - events: _events,  
7295 - locale: "zh_CN",  
7296 - initialCalendarFormat: CalendarFormat.month,  
7297 - headerStyle: HeaderStyle(  
7298 - decoration:  
7299 - BoxDecoration(color: MyColours.color_2bb5b7),  
7300 - headerPadding: EdgeInsets.zero,  
7301 - formatButtonVisible: false,  
7302 - centerHeaderTitle: false,  
7303 - titleTextBuilder: (dateTime, _) {  
7304 - return dateTime.year.toString() +  
7305 - "年-" +  
7306 - Utils.addZeroNumber(dateTime.month) +  
7307 - "月";  
7308 - },  
7309 - titleTextStyle: TextStyle(  
7310 - color: MyColours.color_ffffff,  
7311 - fontSize: ScreenUtil().setSp(30)),  
7312 - leftChevronIcon: const Icon(Icons.chevron_left,  
7313 - color: Colors.white),  
7314 - rightChevronIcon: const Icon(Icons.chevron_right,  
7315 - color: Colors.white),  
7316 - ),  
7317 - calendarStyle: CalendarStyle(  
7318 - contentPadding: EdgeInsets.only(  
7319 - bottom: ScreenUtil().setWidth(8)),  
7320 - weekdayStyle: TextStyle(  
7321 - color: MyColours.color_2bb5b7,  
7322 - fontSize: ScreenUtil().setSp(32)),  
7323 - weekendStyle: TextStyle(  
7324 - color: MyColours.color_f49a5e,  
7325 - fontSize: ScreenUtil().setSp(32)),  
7326 - selectedColor: MyColours.color_2bb5b7,  
7327 - outsideDaysVisible: false,  
7328 - ),  
7329 - builders: CalendarBuilders(  
7330 - dowWeekdayBuilder: (context, weekday) {  
7331 - return Container(  
7332 - color: MyColours.color_2bb5b7,  
7333 - alignment: Alignment.center,  
7334 - margin: EdgeInsets.only(  
7335 - bottom: ScreenUtil().setWidth(30)),  
7336 - padding: EdgeInsets.symmetric(  
7337 - vertical: ScreenUtil().setWidth(15)),  
7338 - child: Text(  
7339 - weekday,  
7340 - style: TextStyle(  
7341 - color: MyColours.color_97e9ea,  
7342 - fontSize: ScreenUtil().setSp(28)),  
7343 - ),  
7344 - );  
7345 - },  
7346 - dayBuilder: (context, date, _) {  
7347 - return Container(  
7348 - // height: ScreenUtil().setWidth(210),  
7349 - decoration: BoxDecoration(  
7350 - // shape: BoxShape.circle,  
7351 - // color: Colors.blue,  
7352 - ),  
7353 - // alignment: Alignment.center,  
7354 - // margin: EdgeInsets.fromLTRB(  
7355 - // ScreenUtil().setWidth(12),  
7356 - // ScreenUtil().setWidth(12),  
7357 - // ScreenUtil().setWidth(12),  
7358 - // ScreenUtil().setWidth(10)),  
7359 - // padding: EdgeInsets.symmetric(  
7360 - // // horizontal: ScreenUtil().setWidth(12),  
7361 - // vertical: ScreenUtil().setWidth(8),  
7362 - // ),  
7363 - child: Column(  
7364 - mainAxisAlignment: MainAxisAlignment.center,  
7365 - children: [  
7366 - Text(  
7367 - // "${_parseDateDay(date)}",  
7368 - '${Utils.addZeroNumber(date.day)}',  
7369 - style: TextStyle().copyWith(  
7370 - fontSize: ScreenUtil().setSp(32),  
7371 - color: MyColours.color_353535,  
7372 - fontWeight: FontWeight.bold)),  
7373 - // Text(  
7374 - // // "${_parseDateDay(date)}",  
7375 - // '${Utils.getLunarSpecialDate(date)}',  
7376 - // style: TextStyle().copyWith(  
7377 - // fontSize: ScreenUtil().setSp(22),  
7378 - // color: MyColours.color_353535),  
7379 - // ),  
7380 - Text(  
7381 - "${_parseDateDay(date)}",  
7382 - style: TextStyle().copyWith(  
7383 - fontSize: ScreenUtil().setSp(18),  
7384 - color: MyColours.color_353535),  
7385 - ),  
7386 - ],  
7387 - ),  
7388 - );  
7389 - },  
7390 - selectedDayBuilder: (context, date, _) {  
7391 - return Container(  
7392 - // alignment: Alignment.center,  
7393 - // margin: EdgeInsets.fromLTRB(  
7394 - // ScreenUtil().setWidth(12),  
7395 - // ScreenUtil().setWidth(12),  
7396 - // ScreenUtil().setWidth(12),  
7397 - // ScreenUtil().setWidth(32)),  
7398 - padding: EdgeInsets.only(  
7399 - bottom: ScreenUtil().setWidth(10),  
7400 - left: ScreenUtil().setWidth(5),  
7401 - right: ScreenUtil().setWidth(5),  
7402 - top: ScreenUtil().setWidth(10)),  
7403 - child: Container(  
7404 - decoration: BoxDecoration(  
7405 - borderRadius: BorderRadius.circular(  
7406 - ScreenUtil().setWidth(10)),  
7407 - color: Color.fromRGBO(42, 110, 109, 1)),  
7408 - child: Column(  
7409 - mainAxisAlignment: MainAxisAlignment.center,  
7410 - children: [  
7411 - Text(  
7412 - // "${_parseDateDay(date)}",  
7413 - '${Utils.addZeroNumber(date.day)}',  
7414 - style: TextStyle().copyWith(  
7415 - color: MyColours.color_ffffff,  
7416 - fontSize: ScreenUtil().setSp(32),  
7417 - fontWeight: FontWeight.bold),  
7418 - ),  
7419 - Text(  
7420 - "${_parseDateDay(date)}",  
7421 - // '${Utils.lunarCalendarHolidaysShow(date)}',  
7422 - style: TextStyle().copyWith(  
7423 - fontSize: ScreenUtil().setSp(22),  
7424 - color: MyColours.color_ffffff),  
7425 - )  
7426 - ],  
7427 - ),  
7428 - ),  
7429 - );  
7430 - },  
7431 - todayDayBuilder: (context, date, _) {  
7432 - return Container(  
7433 - // alignment: Alignment.center,  
7434 - // margin: EdgeInsets.fromLTRB(  
7435 - // ScreenUtil().setWidth(12),  
7436 - // ScreenUtil().setWidth(12),  
7437 - // ScreenUtil().setWidth(12),  
7438 - // ScreenUtil().setWidth(32)),  
7439 - padding: EdgeInsets.only(  
7440 - bottom: ScreenUtil().setWidth(10),  
7441 - left: ScreenUtil().setWidth(5),  
7442 - right: ScreenUtil().setWidth(5),  
7443 - top: ScreenUtil().setWidth(10)),  
7444 - child: Container(  
7445 - decoration: BoxDecoration(  
7446 - borderRadius: BorderRadius.circular(  
7447 - ScreenUtil().setWidth(10)),  
7448 - color: MyColours.color_2bb5b7),  
7449 - child: Column(  
7450 - mainAxisAlignment: MainAxisAlignment.center,  
7451 - children: [  
7452 - Text(  
7453 - // "${_parseDateDay(date)}",  
7454 - '${Utils.addZeroNumber(date.day)}',  
7455 - style: TextStyle().copyWith(  
7456 - color: MyColours.color_ffffff,  
7457 - fontSize: ScreenUtil().setSp(32),  
7458 - fontWeight: FontWeight.bold),  
7459 - ),  
7460 - Text(  
7461 - "${_parseDateDay(date)}",  
7462 - // '${Utils.lunarCalendarHolidaysShow(date)}',  
7463 - style: TextStyle().copyWith(  
7464 - fontSize: ScreenUtil().setSp(22),  
7465 - color: MyColours.color_ffffff),  
7466 - )  
7467 - ],  
7468 - ),  
7469 - ),  
7470 - );  
7471 - // return Container(  
7472 - // decoration: BoxDecoration(  
7473 - // shape: BoxShape.circle,  
7474 - // border: Border.all(  
7475 - // color: MyColours.color_2bb5b7,  
7476 - // width: ScreenUtil().setWidth(2))),  
7477 - // alignment: Alignment.center,  
7478 - // margin: EdgeInsets.fromLTRB(  
7479 - // ScreenUtil().setWidth(12),  
7480 - // ScreenUtil().setWidth(12),  
7481 - // ScreenUtil().setWidth(12),  
7482 - // ScreenUtil().setWidth(32)),  
7483 - // padding: EdgeInsets.only(  
7484 - // bottom: ScreenUtil().setWidth(8),  
7485 - // left: ScreenUtil().setWidth(16),  
7486 - // right: ScreenUtil().setWidth(16),  
7487 - // top: ScreenUtil().setWidth(8)),  
7488 - // child: Text(  
7489 - // // '今',  
7490 - // '${Utils.addZeroNumber(date.day)}',  
7491 - // style: TextStyle().copyWith(  
7492 - // fontSize: ScreenUtil().setSp(32),  
7493 - // color: MyColours.color_2bb5b7),  
7494 - // ),  
7495 - // );  
7496 - },  
7497 - markersBuilder: (context, date, events, holidays) {  
7498 - final children = <Widget>[];  
7499 -  
7500 - // if (events.isNotEmpty) {  
7501 - // children.add(  
7502 - // Positioned(  
7503 - // right: 1,  
7504 - // bottom: 1,  
7505 - // child: _buildEventsMarker(date, events),  
7506 - // ),  
7507 - // );  
7508 - // }  
7509 -  
7510 - // if (holidays.isNotEmpty) {  
7511 - // children.add(  
7512 - // Positioned(  
7513 - // right: ScreenUtil().setWidth(27),  
7514 - // bottom: 0,  
7515 - // top: ScreenUtil().setWidth(30),  
7516 - // child: buildMarker(date)),  
7517 - // Align(  
7518 - // alignment: Alignment.bottomCenter,  
7519 - // child: buildMarker(date),  
7520 - // )  
7521 - // );  
7522 - // }  
7523 -  
7524 - return [];  
7525 - },  
7526 - // singleMarkerBuilder: (context, dateTime, event) {  
7527 - // return Container(  
7528 - // width: ScreenUtil().setWidth(6),  
7529 - // height: ScreenUtil().setWidth(6),  
7530 - // margin:  
7531 - // const EdgeInsets.symmetric(horizontal: 0.3),  
7532 - // decoration: BoxDecoration(  
7533 - // shape: BoxShape.circle,  
7534 - // color: MyColours.color_ff0000,  
7535 - // ),  
7536 - // );  
7537 - // },  
7538 - ),  
7539 - ),  
7540 - VEmptyView(4),  
7541 - Row(  
7542 - mainAxisAlignment: MainAxisAlignment.spaceEvenly,  
7543 - children: [  
7544 - RoundButton(  
7545 - onPressed: () async {  
7546 - _calendarController  
7547 - .setSelectedDay(DateTime.now());  
7548 - _setState(() {});  
7549 - },  
7550 - text: '回到今天',  
7551 - fontSize: 28,  
7552 - isBold: false,  
7553 - height: ScreenUtil().setWidth(70),  
7554 - width: ScreenUtil().setWidth(220),  
7555 - gradientStart: MyColours.color_2bb5b7,  
7556 - gradientEnd: MyColours.color_2bb5b7,  
7557 - radius: ScreenUtil().setWidth(10),  
7558 - ),  
7559 - RoundButton(  
7560 - onPressed: () async {  
7561 - Navigator.pop(context);  
7562 - },  
7563 - text: '取消',  
7564 - fontSize: 28,  
7565 - isBold: false,  
7566 - textColor: MyColours.color_333333,  
7567 - borderColor: Color.fromRGBO(119, 119, 119, 1),  
7568 - height: ScreenUtil().setWidth(70),  
7569 - width: ScreenUtil().setWidth(220),  
7570 - gradientStart: Colors.transparent,  
7571 - gradientEnd: Colors.transparent,  
7572 - radius: ScreenUtil().setWidth(10),  
7573 - )  
7574 - ], 7395 + color: MyColours.color_ffffff,
  7396 + child: Column(
  7397 + mainAxisSize: MainAxisSize.min,
  7398 + children: <Widget>[
  7399 + _buildMultiDatePickerWithValue(
  7400 + _multiDatePickerValueWithDefaultValue, (value) {
  7401 + _multiDatePickerValueWithDefaultValue = value;
  7402 + }),
  7403 + VEmptyView(120),
  7404 + Row(
  7405 + mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  7406 + children: [
  7407 + RoundButton(
  7408 + onPressed: () async {
  7409 + // _calendarController
  7410 + // .setSelectedDay(DateTime.now());
  7411 + Navigator.pop(context);
  7412 + // _multiDatePickerValueWithDefaultValue =
  7413 + // _selectPickerValues;
  7414 + _setState(() {});
  7415 + },
  7416 + text: '取消',
  7417 + fontSize: 28,
  7418 + isBold: false,
  7419 + borderColor: MyColours.color_438E93,
  7420 + height: ScreenUtil().setWidth(70),
  7421 + width: w(160),
  7422 + gradientStart: MyColours.color_ffffff,
  7423 + gradientEnd: MyColours.color_ffffff,
  7424 + radius: ScreenUtil().setWidth(10),
  7425 + textColor: MyColours.color_438E93,
7575 ), 7426 ),
7576 - VEmptyView(40) 7427 + RoundButton(
  7428 + onPressed: () async {
  7429 + Navigator.pop(context);
  7430 + valueChanged(_multiDatePickerValueWithDefaultValue);
  7431 + },
  7432 + text: '确定',
  7433 + fontSize: 28,
  7434 + isBold: false,
  7435 + textColor: MyColours.color_F8F9FD,
  7436 + borderColor: MyColours.color_438E93,
  7437 + height: ScreenUtil().setWidth(70),
  7438 + width: w(160),
  7439 + gradientStart: MyColours.color_438E93,
  7440 + gradientEnd: MyColours.color_438E93,
  7441 + radius: ScreenUtil().setWidth(10),
  7442 + )
7577 ], 7443 ],
7578 - ))  
7579 -  
7580 - // Positioned(  
7581 - // right: ScreenUtil().setWidth(62),  
7582 - // bottom: ScreenUtil().setHeight(20),  
7583 - // child: Container(  
7584 - // child: GestureDetector(  
7585 - // onTap: () {  
7586 - // _calendarController.setSelectedDay(DateTime.now());  
7587 - // _setState(() {});  
7588 - // },  
7589 - // child: Container(  
7590 - // child: ClipOval(  
7591 - // child: Container(  
7592 - // width: ScreenUtil().setWidth(100),  
7593 - // height: ScreenUtil().setWidth(100),  
7594 - // alignment: Alignment.center,  
7595 - // color: MyColours.color_2bb5b7,  
7596 - // child: Text(  
7597 - // "回到\n今天",  
7598 - // style: TextStyle(  
7599 - // color: MyColours.color_ffffff,  
7600 - // fontSize: ScreenUtil().setSp(26)),  
7601 - // ),  
7602 - // )),  
7603 - // ),  
7604 - // ),  
7605 - // ),  
7606 - // )  
7607 - // ],  
7608 - ; 7444 + ),
  7445 + VEmptyView(40)
  7446 + ],
  7447 + ));
7609 }); 7448 });
7610 return SizedBox( 7449 return SizedBox(
7611 width: double.infinity, 7450 width: double.infinity,
@@ -386,7 +386,7 @@ class _CalendarViewState extends State<_CalendarView> { @@ -386,7 +386,7 @@ class _CalendarViewState extends State<_CalendarView> {
386 // color: Colors.red, 386 // color: Colors.red,
387 child: Image.asset( 387 child: Image.asset(
388 'assets/date_y_r.png', 388 'assets/date_y_r.png',
389 - width: 12, 389 + width: 10,
390 height: 45, 390 height: 45,
391 ))), 391 ))),
392 ], 392 ],
@@ -451,10 +451,10 @@ class _CalendarDatePicker2State extends State<CalendarDatePicker2> { @@ -451,10 +451,10 @@ class _CalendarDatePicker2State extends State<CalendarDatePicker2> {
451 Positioned( 451 Positioned(
452 // left: 150, 452 // left: 150,
453 top: ((widget.config.controlsHeight ?? _subHeaderHeight) - 453 top: ((widget.config.controlsHeight ?? _subHeaderHeight) -
454 - 20) / 454 + 23) /
455 2, 455 2,
456 child: Container( 456 child: Container(
457 - height: 20, 457 + height: 23,
458 child: Text(_currentDisplayedMonthDate.year.toString() + 458 child: Text(_currentDisplayedMonthDate.year.toString() +
459 '年' + 459 '年' +
460 _currentDisplayedMonthDate.month.toString() + 460 _currentDisplayedMonthDate.month.toString() +