Commit 1d07d5c6ea273ffdad3099ecf503f6fdffd24e14

Authored by wdn127929
1 parent 4403468a

日历和早餐、晚餐、午餐

@@ -11,14 +11,14 @@ if (flutterRoot == null) { @@ -11,14 +11,14 @@ if (flutterRoot == null) {
11 throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 11 throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12 } 12 }
13 13
14 -def flutterVersionCode = "303" 14 +def flutterVersionCode = "310"
15 if (flutterVersionCode == null) { 15 if (flutterVersionCode == null) {
16 - flutterVersionCode = '303' 16 + flutterVersionCode = '310'
17 } 17 }
18 18
19 -def flutterVersionName = "3.0.3" 19 +def flutterVersionName = "3.1.0"
20 if (flutterVersionName == null) { 20 if (flutterVersionName == null) {
21 - flutterVersionName = '3.0.3' 21 + flutterVersionName = '3.1.0'
22 } 22 }
23 23
24 apply plugin: 'com.android.application' 24 apply plugin: 'com.android.application'
@@ -177,7 +177,6 @@ class MyAppState extends State<MyApp> { @@ -177,7 +177,6 @@ class MyAppState extends State<MyApp> {
177 177
178 @override 178 @override
179 Widget build(BuildContext context) { 179 Widget build(BuildContext context) {
180 -  
181 // TODO: implement build 180 // TODO: implement build
182 return MaterialApp( 181 return MaterialApp(
183 debugShowCheckedModeBanner: false, 182 debugShowCheckedModeBanner: false,
@@ -191,7 +190,7 @@ class MyAppState extends State<MyApp> { @@ -191,7 +190,7 @@ class MyAppState extends State<MyApp> {
191 TextTheme(overline: TextStyle(decoration: TextDecoration.none)), 190 TextTheme(overline: TextStyle(decoration: TextDecoration.none)),
192 tooltipTheme: TooltipThemeData(verticalOffset: -100000)), 191 tooltipTheme: TooltipThemeData(verticalOffset: -100000)),
193 home: isLogin 192 home: isLogin
194 - ? HomePage(initialIndex: 2) 193 + ? HomePage(initialIndex: 1)
195 : ChangeNotifierProvider<OtherLoginProvider>( 194 : ChangeNotifierProvider<OtherLoginProvider>(
196 create: (_) => OtherLoginProvider(), child: LoginPage()), 195 create: (_) => OtherLoginProvider(), child: LoginPage()),
197 onGenerateRoute: App.router.generator, 196 onGenerateRoute: App.router.generator,
@@ -6,21 +6,18 @@ import 'package:flutter/cupertino.dart'; @@ -6,21 +6,18 @@ import 'package:flutter/cupertino.dart';
6 import 'package:flutter/material.dart'; 6 import 'package:flutter/material.dart';
7 import 'package:flutter_app_update/azhon_app_update.dart'; 7 import 'package:flutter_app_update/azhon_app_update.dart';
8 import 'package:flutter_screenutil/flutter_screenutil.dart'; 8 import 'package:flutter_screenutil/flutter_screenutil.dart';
9 -import 'package:one_key/app.dart';  
10 -import 'package:one_key/pages/home_enter_order/home_enter_order.dart';  
11 9
12 import 'package:one_key/pages/message/message_page.dart'; 10 import 'package:one_key/pages/message/message_page.dart';
13 import 'package:one_key/pages/my/my_page.dart'; 11 import 'package:one_key/pages/my/my_page.dart';
14 import 'package:one_key/pages/notebook/notebook_page.dart'; 12 import 'package:one_key/pages/notebook/notebook_page.dart';
15 import 'package:one_key/pages/table/table_manager_page.dart'; 13 import 'package:one_key/pages/table/table_manager_page.dart';
16 import 'package:one_key/provider/contact_model.dart'; 14 import 'package:one_key/provider/contact_model.dart';
17 -import 'package:one_key/provider/enter_model.dart';  
18 -import 'package:one_key/provider/home_enter_model.dart'; 15 +
19 import 'package:one_key/provider/message_dialog_model.dart'; 16 import 'package:one_key/provider/message_dialog_model.dart';
20 import 'package:one_key/provider/message_model.dart'; 17 import 'package:one_key/provider/message_model.dart';
21 import 'package:one_key/provider/my_model.dart'; 18 import 'package:one_key/provider/my_model.dart';
22 import 'package:one_key/provider/notebook_model.dart'; 19 import 'package:one_key/provider/notebook_model.dart';
23 -import 'package:one_key/provider/remark_manager_model.dart'; 20 +
24 import 'package:one_key/provider/table_manager_model.dart'; 21 import 'package:one_key/provider/table_manager_model.dart';
25 import 'package:one_key/provider/tools.dart'; 22 import 'package:one_key/provider/tools.dart';
26 import 'package:one_key/provider/update_model.dart'; 23 import 'package:one_key/provider/update_model.dart';
@@ -38,7 +35,7 @@ import 'package:one_key/models/message.dart'; @@ -38,7 +35,7 @@ import 'package:one_key/models/message.dart';
38 class HomePage extends StatefulWidget { 35 class HomePage extends StatefulWidget {
39 final int initialIndex; //初始tab 36 final int initialIndex; //初始tab
40 37
41 - HomePage({this.initialIndex = 2}); 38 + HomePage({this.initialIndex = 1});
42 39
43 @override 40 @override
44 State<StatefulWidget> createState() { 41 State<StatefulWidget> createState() {
@@ -49,7 +46,7 @@ class HomePage extends StatefulWidget { @@ -49,7 +46,7 @@ class HomePage extends StatefulWidget {
49 46
50 class HomePageState extends State<HomePage> with WidgetsBindingObserver { 47 class HomePageState extends State<HomePage> with WidgetsBindingObserver {
51 List<Widget> pages = List<Widget>(); 48 List<Widget> pages = List<Widget>();
52 - int _currIndex = 2; 49 + int _currIndex = 1;
53 Color _activeColor = MyColours.color_199095; 50 Color _activeColor = MyColours.color_199095;
54 Color _defaultColor = MyColours.color_999999; 51 Color _defaultColor = MyColours.color_999999;
55 int numPush = 0; //推送消息个数 52 int numPush = 0; //推送消息个数
@@ -75,12 +72,12 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -75,12 +72,12 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
75 _currIndex = widget.initialIndex; 72 _currIndex = widget.initialIndex;
76 _pageController = PageController(initialPage: _currIndex); 73 _pageController = PageController(initialPage: _currIndex);
77 pages 74 pages
78 - ..add(ChangeNotifierProvider<HomeEnterModel>(  
79 - create: (_) => HomeEnterModel(),  
80 - child: ChangeNotifierProvider<RemarkManagerModel>(  
81 - create: (_) => RemarkManagerModel(),  
82 - child: SafeArea(child: HomeEnterPage()),  
83 - ))) 75 + // ..add(ChangeNotifierProvider<HomeEnterModel>(
  76 + // create: (_) => HomeEnterModel(),
  77 + // child: ChangeNotifierProvider<RemarkManagerModel>(
  78 + // create: (_) => RemarkManagerModel(),
  79 + // child: SafeArea(child: HomeEnterPage()),
  80 + // )))
84 ..add(SafeArea( 81 ..add(SafeArea(
85 child: MessagePage(), 82 child: MessagePage(),
86 )) 83 ))
@@ -496,24 +493,24 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -496,24 +493,24 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
496 selectedFontSize: ScreenUtil().setSp(22), 493 selectedFontSize: ScreenUtil().setSp(22),
497 backgroundColor: MyColours.color_ffffff, 494 backgroundColor: MyColours.color_ffffff,
498 items: [ 495 items: [
499 - BottomNavigationBarItem(  
500 - icon: Image(  
501 - image: AssetImage("assets/enter_order_n.png"),  
502 - width: ScreenUtil().setWidth(48),  
503 - height: ScreenUtil().setWidth(48),  
504 - ),  
505 - activeIcon: Image(  
506 - image: AssetImage("assets/enter_order_s.png"),  
507 - width: ScreenUtil().setWidth(48),  
508 - height: ScreenUtil().setWidth(48),  
509 - ),  
510 - title: Text(  
511 - "录入预订",  
512 - style: TextStyle(  
513 - color: _currIndex == 0 ? _activeColor : _defaultColor,  
514 - fontSize: ScreenUtil().setSp(22)),  
515 - ),  
516 - ), 496 + // BottomNavigationBarItem(
  497 + // icon: Image(
  498 + // image: AssetImage("assets/enter_order_n.png"),
  499 + // width: ScreenUtil().setWidth(48),
  500 + // height: ScreenUtil().setWidth(48),
  501 + // ),
  502 + // activeIcon: Image(
  503 + // image: AssetImage("assets/enter_order_s.png"),
  504 + // width: ScreenUtil().setWidth(48),
  505 + // height: ScreenUtil().setWidth(48),
  506 + // ),
  507 + // title: Text(
  508 + // "录入预订",
  509 + // style: TextStyle(
  510 + // color: _currIndex == 0 ? _activeColor : _defaultColor,
  511 + // fontSize: ScreenUtil().setSp(22)),
  512 + // ),
  513 + // ),
517 BottomNavigationBarItem( 514 BottomNavigationBarItem(
518 icon: Stack( 515 icon: Stack(
519 children: [ 516 children: [
@@ -564,7 +561,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -564,7 +561,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
564 title: Text( 561 title: Text(
565 "消息中心", 562 "消息中心",
566 style: TextStyle( 563 style: TextStyle(
567 - color: _currIndex == 1 ? _activeColor : _defaultColor, 564 + color: _currIndex == 0 ? _activeColor : _defaultColor,
568 fontSize: ScreenUtil().setSp(22)), 565 fontSize: ScreenUtil().setSp(22)),
569 ), 566 ),
570 ), 567 ),
@@ -600,7 +597,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -600,7 +597,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
600 title: Text( 597 title: Text(
601 "已预订", 598 "已预订",
602 style: TextStyle( 599 style: TextStyle(
603 - color: _currIndex == 2 ? _activeColor : _defaultColor, 600 + color: _currIndex == 1 ? _activeColor : _defaultColor,
604 fontSize: ScreenUtil().setSp(22)), 601 fontSize: ScreenUtil().setSp(22)),
605 ), 602 ),
606 ), 603 ),
@@ -618,7 +615,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -618,7 +615,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
618 title: Text( 615 title: Text(
619 "桌位", 616 "桌位",
620 style: TextStyle( 617 style: TextStyle(
621 - color: _currIndex == 3 ? _activeColor : _defaultColor, 618 + color: _currIndex == 2 ? _activeColor : _defaultColor,
622 fontSize: ScreenUtil().setSp(22)), 619 fontSize: ScreenUtil().setSp(22)),
623 ), 620 ),
624 ), 621 ),
@@ -636,7 +633,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -636,7 +633,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
636 title: Text( 633 title: Text(
637 "我的", 634 "我的",
638 style: TextStyle( 635 style: TextStyle(
639 - color: _currIndex == 4 ? _activeColor : _defaultColor, 636 + color: _currIndex == 3 ? _activeColor : _defaultColor,
640 fontSize: ScreenUtil().setSp(22)), 637 fontSize: ScreenUtil().setSp(22)),
641 ), 638 ),
642 ), 639 ),
@@ -649,7 +646,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -649,7 +646,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
649 _currIndex = index; 646 _currIndex = index;
650 _pageController.jumpToPage(index); 647 _pageController.jumpToPage(index);
651 }); 648 });
652 - if (_currIndex == 5) { 649 + if (_currIndex == 3) {
653 Utils.changeStatusColor(color: MyColours.color_199095); 650 Utils.changeStatusColor(color: MyColours.color_199095);
654 } else { 651 } else {
655 Utils.changeStatusColor(color: Colors.white); 652 Utils.changeStatusColor(color: Colors.white);
@@ -20,6 +20,8 @@ import 'package:one_key/widgets/MyDivider.dart'; @@ -20,6 +20,8 @@ import 'package:one_key/widgets/MyDivider.dart';
20 import 'package:one_key/widgets/app_bar.dart'; 20 import 'package:one_key/widgets/app_bar.dart';
21 import 'package:one_key/widgets/area_item.dart'; 21 import 'package:one_key/widgets/area_item.dart';
22 import 'package:one_key/widgets/common_button.dart'; 22 import 'package:one_key/widgets/common_button.dart';
  23 +import 'package:one_key/widgets/common_button_flat.dart';
  24 +import 'package:one_key/widgets/h_empty_view.dart';
23 import 'package:one_key/widgets/page_exception.dart'; 25 import 'package:one_key/widgets/page_exception.dart';
24 import 'package:one_key/widgets/system_app_bar.dart'; 26 import 'package:one_key/widgets/system_app_bar.dart';
25 import 'package:one_key/widgets/table_item.dart'; 27 import 'package:one_key/widgets/table_item.dart';
@@ -339,124 +341,167 @@ class TableManagerPageState extends State<TableManagerPage> { @@ -339,124 +341,167 @@ class TableManagerPageState extends State<TableManagerPage> {
339 Widget build(BuildContext context) { 341 Widget build(BuildContext context) {
340 return Consumer<TableManagerModel>( 342 return Consumer<TableManagerModel>(
341 builder: (context, model, child) { 343 builder: (context, model, child) {
  344 + int sum = 3;
  345 + int hide = 0;
  346 + int btnNum = 0;
  347 + if (tableManagerModel.morning == "00:00-00:00") {
  348 + hide++;
  349 + }
  350 + if (tableManagerModel.noon == "00:00-00:00") {
  351 + hide++;
  352 + }
  353 + if (tableManagerModel.night == "00:00-00:00") {
  354 + hide++;
  355 + }
  356 + btnNum = sum - hide;
342 return Column( 357 return Column(
343 children: <Widget>[ 358 children: <Widget>[
344 SystemAppBar("桌位", showLeading: false), 359 SystemAppBar("桌位", showLeading: false),
345 Container( 360 Container(
346 color: MyColours.color_ffffff, 361 color: MyColours.color_ffffff,
347 - width: double.infinity,  
348 padding: 362 padding:
349 - EdgeInsets.symmetric(vertical: ScreenUtil().setHeight(16)), 363 + EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(15)),
350 child: Row( 364 child: Row(
351 - crossAxisAlignment: CrossAxisAlignment.center,  
352 children: <Widget>[ 365 children: <Widget>[
353 Expanded( 366 Expanded(
354 - child: Center(  
355 child: GestureDetector( 367 child: GestureDetector(
356 - onTap: () {  
357 - DialogUtil.showCalendarDialog(  
358 - context, tableManagerModel.dateTime)  
359 - .then((day) {  
360 - if (day != null) {  
361 - tableManagerModel.createDateText(context, day);  
362 - }  
363 - });  
364 - },  
365 - child: Container(  
366 - child: Text(  
367 - tableManagerModel.dateText,  
368 - style: TextStyle(  
369 - color: MyColours.color_199095,  
370 - fontSize: ScreenUtil().setSp(34)),  
371 - ),  
372 - ),  
373 - ),  
374 - ),  
375 - ),  
376 - MyDivider(  
377 - ScreenUtil().setWidth(2),  
378 - ScreenUtil().setHeight(68),  
379 - color: MyColours.color_E0E0E0,  
380 - ),  
381 - Expanded(  
382 - child: Padding(  
383 - padding: EdgeInsets.symmetric(  
384 - horizontal: ScreenUtil().setWidth(30)),  
385 - child: Row(  
386 - mainAxisAlignment: MainAxisAlignment.center,  
387 - crossAxisAlignment: CrossAxisAlignment.center,  
388 - children: <Widget>[  
389 - Offstage(  
390 - offstage:  
391 - tableManagerModel.morning == "00:00-00:00"  
392 - ? true  
393 - : false,  
394 - child: Padding(  
395 - padding: EdgeInsets.only(  
396 - right: ScreenUtil().setWidth(18)),  
397 - child: CommonButton(  
398 - content: "早市",  
399 - state: tableManagerModel.currTimeIndex == 1  
400 - ? 1  
401 - : 0,  
402 - width: 92,  
403 - height: 48,  
404 - fontSize: 32,  
405 - onPress: () {  
406 - if (tableManagerModel.currTimeIndex == 1)  
407 - return;  
408 - tableManagerModel.currTimeIndex = 1;  
409 - tableManagerModel.getReserveList(context);  
410 - },  
411 - ))),  
412 - Offstage(  
413 - offstage: tableManagerModel.noon == "00:00-00:00" 368 + onTap: () {
  369 + DialogUtil.showCalendarDialog(
  370 + context, tableManagerModel.dateTime)
  371 + .then((day) {
  372 + if (day != null) {
  373 + tableManagerModel.createDateText(context, day);
  374 + }
  375 + });
  376 + },
  377 + child: Container(
  378 + // height: ScreenUtil().setWidth(80),
  379 + padding: EdgeInsets.symmetric(
  380 + horizontal: ScreenUtil().setWidth(15),
  381 + vertical: ScreenUtil().setWidth(20)),
  382 + decoration: BoxDecoration(
  383 + color: MyColours.color_199095,
  384 + borderRadius: BorderRadius.circular(
  385 + ScreenUtil().setWidth(20))),
  386 + child: Row(
  387 + children: [
  388 + Expanded(
  389 + child: Text(
  390 + tableManagerModel.dateText,
  391 + style: TextStyle(
  392 + color: MyColours.color_ffffff,
  393 + fontSize: ScreenUtil().setSp(28)),
  394 + )),
  395 + HEmptyView(10),
  396 + Image.asset(
  397 + Utils.getImgPath('f_arrow_right'),
  398 + width: ScreenUtil().setWidth(25),
  399 + // height: ScreenUtil().setWidth(10),
  400 + )
  401 + ],
  402 + )),
  403 + )),
  404 +
  405 + // MyDivider(
  406 + // ScreenUtil().setWidth(2),
  407 + // ScreenUtil().setHeight(68),
  408 + // color: MyColours.color_E0E0E0,
  409 + // ),
  410 + HEmptyView(20),
  411 + Container(
  412 + width: ScreenUtil().setWidth(206),
  413 + height: ScreenUtil().setWidth(74),
  414 + decoration: BoxDecoration(
  415 + color: Color.fromRGBO(232, 232, 232, 1),
  416 + borderRadius: BorderRadius.circular(
  417 + ScreenUtil().setWidth(20),
  418 + )),
  419 + child: Row(
  420 + // mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  421 + // crossAxisAlignment: CrossAxisAlignment.center,
  422 + children: <Widget>[
  423 + Offstage(
  424 + offstage: tableManagerModel.morning == "00:00-00:00"
  425 + ? true
  426 + : false,
  427 + child: CommonButtonFlat(
  428 + content: "早市",
  429 + state:
  430 + tableManagerModel.currTimeIndex == 1 ? 1 : 0,
  431 + fontSize: 28,
  432 + right: tableManagerModel.noon == "00:00-00:00" &&
  433 + tableManagerModel.night == "00:00-00:00"
414 ? true 434 ? true
415 : false, 435 : false,
416 - child: Padding(  
417 - padding: EdgeInsets.only(  
418 - right: ScreenUtil().setWidth(18)),  
419 - child: CommonButton(  
420 - content: "午市",  
421 - state: tableManagerModel.currTimeIndex == 2  
422 - ? 1  
423 - : 0,  
424 - width: 92,  
425 - height: 48,  
426 - fontSize: 32,  
427 - onPress: () {  
428 - if (tableManagerModel.currTimeIndex == 2)  
429 - return;  
430 - tableManagerModel.currTimeIndex = 2;  
431 - tableManagerModel.getReserveList(context);  
432 - },  
433 - ))),  
434 - Offstage(  
435 - offstage: tableManagerModel.night == "00:00-00:00" 436 + width: ScreenUtil().setWidth(200) / btnNum,
  437 + onPress: () {
  438 + if (tableManagerModel.currTimeIndex == 1)
  439 + return;
  440 + tableManagerModel.currTimeIndex = 1;
  441 + tableManagerModel.getReserveList(context);
  442 + },
  443 + )),
  444 + btnNum == 3 && tableManagerModel.currTimeIndex == 3
  445 + ? MyDivider(
  446 + ScreenUtil().setWidth(4),
  447 + ScreenUtil().setWidth(46),
  448 + color: MyColours.color_dfdfdf,
  449 + )
  450 + : SizedBox(),
  451 + Offstage(
  452 + offstage: tableManagerModel.noon == "00:00-00:00"
436 ? true 453 ? true
437 : false, 454 : false,
438 - child: Container(  
439 - // padding: EdgeInsets.symmetric(  
440 - // horizontal: ScreenUtil().setWidth(10)),  
441 - child: CommonButton(  
442 - content: "晚市", 455 + child: CommonButtonFlat(
  456 + content: "午市",
443 state: 457 state:
444 - tableManagerModel.currTimeIndex == 3 ? 1 : 0,  
445 - width: 92,  
446 - height: 48,  
447 - fontSize: 32, 458 + tableManagerModel.currTimeIndex == 2 ? 1 : 0,
  459 + fontSize: 28,
  460 + width: ScreenUtil().setWidth(200) / btnNum,
  461 + left: tableManagerModel.morning == "00:00-00:00"
  462 + ? true
  463 + : false,
  464 + right: tableManagerModel.night == "00:00-00:00"
  465 + ? true
  466 + : false,
448 onPress: () { 467 onPress: () {
449 - if (tableManagerModel.currTimeIndex == 3) 468 + if (tableManagerModel.currTimeIndex == 2)
450 return; 469 return;
451 - tableManagerModel.currTimeIndex = 3; 470 + tableManagerModel.currTimeIndex = 2;
452 tableManagerModel.getReserveList(context); 471 tableManagerModel.getReserveList(context);
453 }, 472 },
454 )), 473 )),
455 - ),  
456 - ],  
457 - ), 474 + btnNum == 3 && tableManagerModel.currTimeIndex == 1
  475 + ? MyDivider(
  476 + ScreenUtil().setWidth(4),
  477 + ScreenUtil().setWidth(46),
  478 + color: MyColours.color_dfdfdf,
  479 + )
  480 + : SizedBox(),
  481 + Offstage(
  482 + offstage: tableManagerModel.night == "00:00-00:00"
  483 + ? true
  484 + : false,
  485 + child: Container(
  486 + child: CommonButtonFlat(
  487 + content: "晚市",
  488 + left: tableManagerModel.morning == "00:00-00:00" &&
  489 + tableManagerModel.noon == "00:00-00:00"
  490 + ? true
  491 + : false,
  492 + state: tableManagerModel.currTimeIndex == 3 ? 1 : 0,
  493 + fontSize: 28,
  494 + width: ScreenUtil().setWidth(200) / btnNum,
  495 + onPress: () {
  496 + if (tableManagerModel.currTimeIndex == 3) return;
  497 + tableManagerModel.currTimeIndex = 3;
  498 + tableManagerModel.getReserveList(context);
  499 + },
  500 + )),
  501 + ),
  502 + ],
458 ), 503 ),
459 - ) 504 + ),
460 ], 505 ],
461 ), 506 ),
462 ), 507 ),
@@ -13,6 +13,7 @@ import 'package:one_key/net/http_url.dart'; @@ -13,6 +13,7 @@ import 'package:one_key/net/http_url.dart';
13 import 'package:one_key/models/table.dart' as t; 13 import 'package:one_key/models/table.dart' as t;
14 import 'package:one_key/provider/user_model.dart'; 14 import 'package:one_key/provider/user_model.dart';
15 import 'package:one_key/route/navigator_util.dart'; 15 import 'package:one_key/route/navigator_util.dart';
  16 +import 'package:one_key/utils/lunar_calendar.dart';
16 import 'package:one_key/utils/utils.dart'; 17 import 'package:one_key/utils/utils.dart';
17 import 'package:provider/provider.dart'; 18 import 'package:provider/provider.dart';
18 19
@@ -50,12 +51,7 @@ class TableManagerModel with ChangeNotifier { @@ -50,12 +51,7 @@ class TableManagerModel with ChangeNotifier {
50 initTime(BuildContext context) async { 51 initTime(BuildContext context) async {
51 userModel = Provider.of<UserModel>(context, listen: false); 52 userModel = Provider.of<UserModel>(context, listen: false);
52 dateTime = DateTime.now(); 53 dateTime = DateTime.now();
53 - dateText = "${dateTime.year}年 " +  
54 - Utils.addZeroNumber(dateTime.month) +  
55 - "月" +  
56 - Utils.addZeroNumber(dateTime.day) +  
57 - "日" +  
58 - " 今天"; 54 + dateText = _returnDate(dateTime);
59 morning = 55 morning =
60 userModel.user.morning.isEmpty ? "00:00-00:00" : userModel.user.morning; 56 userModel.user.morning.isEmpty ? "00:00-00:00" : userModel.user.morning;
61 noon = userModel.user.noon.isEmpty ? "00:00-00:00" : userModel.user.noon; 57 noon = userModel.user.noon.isEmpty ? "00:00-00:00" : userModel.user.noon;
@@ -326,7 +322,7 @@ class TableManagerModel with ChangeNotifier { @@ -326,7 +322,7 @@ class TableManagerModel with ChangeNotifier {
326 "keywords": "", 322 "keywords": "",
327 "sort": "1" 323 "sort": "1"
328 }; 324 };
329 - if ( needLoading) { 325 + if (needLoading) {
330 pageState = PageState.Loading; 326 pageState = PageState.Loading;
331 notifyListeners(); 327 notifyListeners();
332 } 328 }
@@ -459,23 +455,34 @@ class TableManagerModel with ChangeNotifier { @@ -459,23 +455,34 @@ class TableManagerModel with ChangeNotifier {
459 //生成日期文本 455 //生成日期文本
460 createDateText(BuildContext context, DateTime day) { 456 createDateText(BuildContext context, DateTime day) {
461 if (Utils.isOneDay(day, dateTime)) return; //日期没变 457 if (Utils.isOneDay(day, dateTime)) return; //日期没变
  458 + dateText = _returnDate(day);
  459 + dateTime = day;
  460 + getReserveList(context);
  461 + }
  462 +
  463 + _returnDate(DateTime day) {
  464 + String date = '';
462 DateTime dateNow = DateTime.now(); 465 DateTime dateNow = DateTime.now();
463 - dateText = "${day.year}年 " + 466 + String ymd = "${day.year}-" +
464 Utils.addZeroNumber(day.month) + 467 Utils.addZeroNumber(day.month) +
465 - "月" +  
466 - Utils.addZeroNumber(day.day) +  
467 - "日"; 468 + "-" +
  469 + Utils.addZeroNumber(day.day);
  470 +
468 if (Utils.isOneDay(day, dateNow)) { 471 if (Utils.isOneDay(day, dateNow)) {
469 - dateText += " 今天"; 472 + date += "今天 ";
470 } else if (Utils.isOneDay(day, dateNow.add(Duration(days: 1)))) { 473 } else if (Utils.isOneDay(day, dateNow.add(Duration(days: 1)))) {
471 - dateText += " 明天"; 474 + date += "明天 ";
472 } else if (Utils.isOneDay(day, dateNow.add(Duration(days: 2)))) { 475 } else if (Utils.isOneDay(day, dateNow.add(Duration(days: 2)))) {
473 - dateText += " 后天";  
474 - } else {  
475 - dateText += " 周${Utils.formatWeekDayNum(day.weekday)}"; 476 + date += "后天 ";
476 } 477 }
477 - dateTime = day;  
478 - getReserveList(context); 478 + date += ymd;
  479 + date += " 星期${Utils.formatWeekDayNum(day.weekday)}";
  480 +
  481 + LunarCalendar lunarCalendar = LunarCalendar(day);
  482 + String time =
  483 + '${lunarCalendar.getChinaMonthString()}月${LunarCalendar.getChinaDayString(lunarCalendar.day)}';
  484 + date += ' ${time}';
  485 + return date;
479 } 486 }
480 487
481 //获取桌位数据 488 //获取桌位数据
@@ -10,7 +10,6 @@ import 'package:flutter_picker/flutter_picker.dart'; @@ -10,7 +10,6 @@ import 'package:flutter_picker/flutter_picker.dart';
10 import 'package:flutter_screenutil/flutter_screenutil.dart'; 10 import 'package:flutter_screenutil/flutter_screenutil.dart';
11 import 'package:one_key/constant/constant.dart'; 11 import 'package:one_key/constant/constant.dart';
12 import 'package:one_key/models/remark.dart'; 12 import 'package:one_key/models/remark.dart';
13 -import 'package:one_key/pages/home_enter_order/home_enter_order.dart';  
14 import 'package:one_key/pages/message/message_dialog_item.dart'; 13 import 'package:one_key/pages/message/message_dialog_item.dart';
15 import 'package:one_key/provider/message_dialog_model.dart'; 14 import 'package:one_key/provider/message_dialog_model.dart';
16 import 'package:one_key/provider/table_manager_model.dart'; 15 import 'package:one_key/provider/table_manager_model.dart';
@@ -33,6 +32,8 @@ import 'package:url_launcher/url_launcher.dart'; @@ -33,6 +32,8 @@ import 'package:url_launcher/url_launcher.dart';
33 typedef CustomCallBack = void Function(Object object); 32 typedef CustomCallBack = void Function(Object object);
34 typedef CustomCallBackMap = void Function(Map<String, String> object); 33 typedef CustomCallBackMap = void Function(Map<String, String> object);
35 34
  35 +typedef ClickCallback = void Function(String value);
  36 +
36 class DialogUtil { 37 class DialogUtil {
37 ///添加图片UI弹出 38 ///添加图片UI弹出
38 static openImageModalBottomSheet(context, 39 static openImageModalBottomSheet(context,
  1 +import 'package:intl/intl.dart';
  2 +
  3 +class LunarCalendar {
  4 + //农历年
  5 + int year;
  6 +
  7 + int month;
  8 +
  9 + int day;
  10 +
  11 + bool leap;
  12 +
  13 + ///中文月名称
  14 + static List<String> chineseNumber = [
  15 + "一",
  16 + "二",
  17 + "三",
  18 + "四",
  19 + "五",
  20 + "六",
  21 + "七",
  22 + "八",
  23 + "九",
  24 + "十",
  25 + "十一",
  26 + "十二"
  27 + ];
  28 +
  29 + ///中文日期格式
  30 + static DateFormat chineseDateFormat = new DateFormat("yyyy年MM月dd日");
  31 +
  32 + ///农历数据, 1901 ~ 2100 年之间正确
  33 + static List<int> lunarInfo = [
  34 + 0x04bd8,
  35 + 0x04ae0,
  36 + 0x0a570,
  37 + 0x054d5,
  38 + 0x0d260,
  39 + 0x0d950,
  40 + 0x16554,
  41 + 0x056a0,
  42 + 0x09ad0,
  43 + 0x055d2,
  44 + 0x04ae0,
  45 + 0x0a5b6,
  46 + 0x0a4d0,
  47 + 0x0d250,
  48 + 0x1d255,
  49 + 0x0b540,
  50 + 0x0d6a0,
  51 + 0x0ada2,
  52 + 0x095b0,
  53 + 0x14977,
  54 + 0x04970,
  55 + 0x0a4b0,
  56 + 0x0b4b5,
  57 + 0x06a50,
  58 + 0x06d40,
  59 + 0x1ab54,
  60 + 0x02b60,
  61 + 0x09570,
  62 + 0x052f2,
  63 + 0x04970,
  64 + 0x06566,
  65 + 0x0d4a0,
  66 + 0x0ea50,
  67 + 0x06e95,
  68 + 0x05ad0,
  69 + 0x02b60,
  70 + 0x186e3,
  71 + 0x092e0,
  72 + 0x1c8d7,
  73 + 0x0c950,
  74 + 0x0d4a0,
  75 + 0x1d8a6,
  76 + 0x0b550,
  77 + 0x056a0,
  78 + 0x1a5b4,
  79 + 0x025d0,
  80 + 0x092d0,
  81 + 0x0d2b2,
  82 + 0x0a950,
  83 + 0x0b557,
  84 + 0x06ca0,
  85 + 0x0b550,
  86 + 0x15355,
  87 + 0x04da0,
  88 + 0x0a5d0,
  89 + 0x14573,
  90 + 0x052d0,
  91 + 0x0a9a8,
  92 + 0x0e950,
  93 + 0x06aa0,
  94 + 0x0aea6,
  95 + 0x0ab50,
  96 + 0x04b60,
  97 + 0x0aae4,
  98 + 0x0a570,
  99 + 0x05260,
  100 + 0x0f263,
  101 + 0x0d950,
  102 + 0x05b57,
  103 + 0x056a0,
  104 + 0x096d0,
  105 + 0x04dd5,
  106 + 0x04ad0,
  107 + 0x0a4d0,
  108 + 0x0d4d4,
  109 + 0x0d250,
  110 + 0x0d558,
  111 + 0x0b540,
  112 + 0x0b5a0,
  113 + 0x195a6,
  114 + 0x095b0,
  115 + 0x049b0,
  116 + 0x0a974,
  117 + 0x0a4b0,
  118 + 0x0b27a,
  119 + 0x06a50,
  120 + 0x06d40,
  121 + 0x0af46,
  122 + 0x0ab60,
  123 + 0x09570,
  124 + 0x04af5,
  125 + 0x04970,
  126 + 0x064b0,
  127 + 0x074a3,
  128 + 0x0ea50,
  129 + 0x06b58,
  130 + 0x055c0,
  131 + 0x0ab60,
  132 + 0x096d5,
  133 + 0x092e0,
  134 + 0x0c960,
  135 + 0x0d954,
  136 + 0x0d4a0,
  137 + 0x0da50,
  138 + 0x07552,
  139 + 0x056a0,
  140 + 0x0abb7,
  141 + 0x025d0,
  142 + 0x092d0,
  143 + 0x0cab5,
  144 + 0x0a950,
  145 + 0x0b4a0,
  146 + 0x0baa4,
  147 + 0x0ad50,
  148 + 0x055d9,
  149 + 0x04ba0,
  150 + 0x0a5b0,
  151 + 0x15176,
  152 + 0x052b0,
  153 + 0x0a930,
  154 + 0x07954,
  155 + 0x06aa0,
  156 + 0x0ad50,
  157 + 0x05b52,
  158 + 0x04b60,
  159 + 0x0a6e6,
  160 + 0x0a4e0,
  161 + 0x0d260,
  162 + 0x0ea65,
  163 + 0x0d530,
  164 + 0x05aa0,
  165 + 0x076a3,
  166 + 0x096d0,
  167 + 0x04bd7,
  168 + 0x04ad0,
  169 + 0x0a4d0,
  170 + 0x1d0b6,
  171 + 0x0d250,
  172 + 0x0d520,
  173 + 0x0dd45,
  174 + 0x0b5a0,
  175 + 0x056d0,
  176 + 0x055b2,
  177 + 0x049b0,
  178 + 0x0a577,
  179 + 0x0a4b0,
  180 + 0x0aa50,
  181 + 0x1b255,
  182 + 0x06d20,
  183 + 0x0ada0
  184 + ];
  185 +
  186 + // 传回农历 y年的总天数
  187 + static int yearDays(int y) {
  188 + int i, sum = 348;
  189 + for (i = 0x8000; i > 0x8; i >>= 1) {
  190 + if ((lunarInfo[y - 1900] & i) != 0) sum += 1;
  191 + }
  192 + return (sum + leapDays(y));
  193 + }
  194 +
  195 + // 传回农历 y年闰月的天数
  196 + static int leapDays(int y) {
  197 + if (leapMonthM(y) != 0) {
  198 + if ((lunarInfo[y - 1900] & 0x10000) != 0)
  199 + return 30;
  200 + else
  201 + return 29;
  202 + } else
  203 + return 0;
  204 + }
  205 +
  206 + // 传回农历 y年闰哪个月 1-12 , 没闰传回 0
  207 + static int leapMonthM(int y) {
  208 + print('$y');
  209 + return (lunarInfo[y - 1900] & 0xf);
  210 + }
  211 +
  212 + // 传回农历 y年m月的总天数
  213 + static int monthDays(int y, int m) {
  214 + if ((lunarInfo[y - 1900] & (0x10000 >> m)) == 0)
  215 + return 29;
  216 + else
  217 + return 30;
  218 + }
  219 +
  220 + // 传回农历 y年的生肖
  221 + String animalsYear() {
  222 + final List<String> Animals = [
  223 + "鼠",
  224 + "牛",
  225 + "虎",
  226 + "兔",
  227 + "龙",
  228 + "蛇",
  229 + "马",
  230 + "羊",
  231 + "猴",
  232 + "鸡",
  233 + "狗",
  234 + "猪"
  235 + ];
  236 + return Animals[(year - 4) % 12];
  237 + }
  238 +
  239 + // 传入 月日的offset 传回干支, 0=甲子
  240 + static String cyclicalm(int num) {
  241 + final List<String> Gan = ["甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"];
  242 + final List<String> Zhi = [
  243 + "子",
  244 + "丑",
  245 + "寅",
  246 + "卯",
  247 + "辰",
  248 + "巳",
  249 + "午",
  250 + "未",
  251 + "申",
  252 + "酉",
  253 + "戌",
  254 + "亥"
  255 + ];
  256 + return (Gan[num % 10] + Zhi[num % 12]);
  257 + }
  258 +
  259 + // 传入 offset 传回干支, 0=甲子
  260 + String cyclical() {
  261 + int num = year - 1900 + 36;
  262 + return (cyclicalm(num));
  263 + }
  264 +
  265 + static String getChinaDayString(int day) {
  266 + List<String> chineseTen = ["初", "十", "廿", "卅"];
  267 + int n = day % 10 == 0 ? 9 : day % 10 - 1;
  268 + if (day > 30) return "";
  269 + if (day == 10)
  270 + return "初十";
  271 + else
  272 + return chineseTen[day ~/ 10] + chineseNumber[n];
  273 + }
  274 +
  275 + String getChinaMonthString() {
  276 + return chineseNumber[month - 1];
  277 + }
  278 +
  279 + String toString() {
  280 + return "$year" +
  281 + "年" +
  282 + (leap ? "闰" : "") +
  283 + chineseNumber[month - 1] +
  284 + "月" +
  285 + getChinaDayString(day);
  286 + }
  287 +
  288 + ///使用指定日历日期构造一个农历日历
  289 + LunarCalendar(DateTime cal) {
  290 + int yearCyl, monCyl, dayCyl;
  291 + int leapMonth = 0;
  292 + DateTime baseDate = null;
  293 + try {
  294 + baseDate = chineseDateFormat.parse("1900年1月31日");
  295 + } catch (e) {}
  296 +
  297 + // 求出和1900年1月31日相差的天数, 注意此处毫秒,除以86400000000
  298 + int offset =
  299 + ((cal.microsecondsSinceEpoch - baseDate.microsecondsSinceEpoch) ~/
  300 + 86400000000);
  301 + dayCyl = offset + 40;
  302 + monCyl = 14;
  303 +
  304 + // 用offset减去每农历年的天数
  305 + // 计算当天是农历第几天
  306 + // i最终结果是农历的年份
  307 + // offset是当年的第几天
  308 + int iYear, daysOfYear = 0;
  309 + for (iYear = 1900; iYear < 2050 && offset > 0; iYear++) {
  310 + daysOfYear = yearDays(iYear);
  311 + offset -= daysOfYear;
  312 + monCyl += 12;
  313 + }
  314 + if (offset < 0) {
  315 + offset += daysOfYear;
  316 + iYear--;
  317 + monCyl -= 12;
  318 + }
  319 + // 农历年份
  320 + year = iYear;
  321 +
  322 + yearCyl = iYear - 1864;
  323 + leapMonth = leapMonthM(iYear); // 闰哪个月,1-12
  324 + leap = false;
  325 +
  326 + // 用当年的天数offset,逐个减去每月(农历)的天数,求出当天是本月的第几天
  327 + int iMonth, daysOfMonth = 0;
  328 + for (iMonth = 1; iMonth < 13 && offset > 0; iMonth++) {
  329 + // 闰月
  330 + if (leapMonth > 0 && iMonth == (leapMonth + 1) && !leap) {
  331 + --iMonth;
  332 + leap = true;
  333 + daysOfMonth = leapDays(year);
  334 + } else
  335 + daysOfMonth = monthDays(year, iMonth);
  336 +
  337 + offset -= daysOfMonth;
  338 + // 解除闰月
  339 + if (leap && iMonth == (leapMonth + 1)) leap = false;
  340 + if (!leap) monCyl++;
  341 + }
  342 + // offset为0时,并且刚才计算的月份是闰月,要校正
  343 + if (offset == 0 && leapMonth > 0 && iMonth == leapMonth + 1) {
  344 + if (leap) {
  345 + leap = false;
  346 + } else {
  347 + leap = true;
  348 + --iMonth;
  349 + --monCyl;
  350 + }
  351 + }
  352 + // offset小于0时,也要校正
  353 + if (offset < 0) {
  354 + offset += daysOfMonth;
  355 + --iMonth;
  356 + --monCyl;
  357 + }
  358 + month = iMonth;
  359 + day = offset + 1;
  360 + }
  361 +}
  1 +import 'package:flutter/material.dart';
  2 +import 'package:flutter_screenutil/flutter_screenutil.dart';
  3 +import 'package:one_key/res/colors.dart';
  4 +
  5 +class CommonButtonFlat extends StatelessWidget {
  6 + final VoidCallback onPress;
  7 + final String content;
  8 + final double width;
  9 + final double height;
  10 + final double fontSize;
  11 + final int state; //-1 不可用 0 默认 1 选中
  12 + final FontWeight fontWeight;
  13 + final bool left;
  14 + final bool right;
  15 + CommonButtonFlat(
  16 + {this.onPress,
  17 + this.content,
  18 + this.state = 0,
  19 + this.width = 250,
  20 + this.height = 50,
  21 + this.fontSize = 18,
  22 + this.fontWeight = FontWeight.normal,
  23 + this.left = true,
  24 + this.right = true});
  25 +
  26 + @override
  27 + Widget build(BuildContext context) {
  28 + BoxDecoration boxDecoration;
  29 + Color fontColor;
  30 + switch (state) {
  31 + // case -1:
  32 + // boxDecoration = BoxDecoration(
  33 + // // color: MyColours.color_74BBBE,
  34 + // borderRadius: BorderRadius.only(
  35 + // topLeft: left
  36 + // ? Radius.circular(ScreenUtil().setWidth(20))
  37 + // : Radius.circular(0),
  38 + // bottomLeft: left
  39 + // ? Radius.circular(ScreenUtil().setWidth(20))
  40 + // : Radius.circular(0),
  41 + // topRight: right
  42 + // ? Radius.circular(ScreenUtil().setWidth(20))
  43 + // : Radius.circular(0),
  44 + // bottomRight: right
  45 + // ? Radius.circular(ScreenUtil().setWidth(20))
  46 + // : Radius.circular(0),
  47 + // ),
  48 + // );
  49 + // fontColor = MyColours.color_ffffff;
  50 + // break;
  51 + case 0:
  52 + boxDecoration = BoxDecoration(
  53 + color: Color.fromRGBO(232, 232, 232, 1),
  54 + // border: Border.all(
  55 + // color: MyColours.color_199095, width: ScreenUtil().setWidth(2)),
  56 + borderRadius: BorderRadius.only(
  57 + topLeft: left
  58 + ? Radius.circular(ScreenUtil().setWidth(20))
  59 + : Radius.circular(0),
  60 + bottomLeft: left
  61 + ? Radius.circular(ScreenUtil().setWidth(20))
  62 + : Radius.circular(0),
  63 + topRight: right
  64 + ? Radius.circular(ScreenUtil().setWidth(20))
  65 + : Radius.circular(0),
  66 + bottomRight: right
  67 + ? Radius.circular(ScreenUtil().setWidth(20))
  68 + : Radius.circular(0),
  69 + ));
  70 + fontColor = MyColours.color_199095;
  71 + break;
  72 + case 1:
  73 + boxDecoration = BoxDecoration(
  74 + color: MyColours.color_199095,
  75 + // gradient: LinearGradient(
  76 + // colors: [Color(0xff199095), Color(0xff36C3C7)],
  77 + // begin: Alignment.topCenter,
  78 + // end: Alignment.bottomCenter),
  79 + borderRadius: BorderRadius.only(
  80 + topLeft: left
  81 + ? Radius.circular(ScreenUtil().setWidth(20))
  82 + : Radius.circular(0),
  83 + bottomLeft: left
  84 + ? Radius.circular(ScreenUtil().setWidth(20))
  85 + : Radius.circular(0),
  86 + topRight: right
  87 + ? Radius.circular(ScreenUtil().setWidth(20))
  88 + : Radius.circular(0),
  89 + bottomRight: right
  90 + ? Radius.circular(ScreenUtil().setWidth(20))
  91 + : Radius.circular(0),
  92 + ));
  93 + fontColor = MyColours.color_fefefe;
  94 + break;
  95 + // case 2:
  96 + // boxDecoration = BoxDecoration(
  97 + // color: MyColours.color_199095,
  98 + // borderRadius: BorderRadius.only(
  99 + // topLeft: left
  100 + // ? Radius.circular(ScreenUtil().setWidth(20))
  101 + // : Radius.circular(0),
  102 + // bottomLeft: left
  103 + // ? Radius.circular(ScreenUtil().setWidth(20))
  104 + // : Radius.circular(0),
  105 + // topRight: right
  106 + // ? Radius.circular(ScreenUtil().setWidth(20))
  107 + // : Radius.circular(0),
  108 + // bottomRight: right
  109 + // ? Radius.circular(ScreenUtil().setWidth(20))
  110 + // : Radius.circular(0),
  111 + // ));
  112 + // fontColor = MyColours.color_fefefe;
  113 + // break;
  114 + // case -2:
  115 + // boxDecoration = BoxDecoration(
  116 + // color: Color.fromRGBO(232, 232, 232, 1),
  117 + // borderRadius: BorderRadius.only(
  118 + // topLeft: left
  119 + // ? Radius.circular(ScreenUtil().setWidth(20))
  120 + // : Radius.circular(0),
  121 + // bottomLeft: left
  122 + // ? Radius.circular(ScreenUtil().setWidth(20))
  123 + // : Radius.circular(0),
  124 + // topRight: right
  125 + // ? Radius.circular(ScreenUtil().setWidth(20))
  126 + // : Radius.circular(0),
  127 + // bottomRight: right
  128 + // ? Radius.circular(ScreenUtil().setWidth(20))
  129 + // : Radius.circular(0),
  130 + // ));
  131 + // fontColor = MyColours.color_fefefe;
  132 + // break;
  133 + default:
  134 + boxDecoration = BoxDecoration(
  135 + border: Border.all(color: MyColours.color_199095),
  136 + borderRadius: BorderRadius.only(
  137 + topLeft: left
  138 + ? Radius.circular(ScreenUtil().setWidth(20))
  139 + : Radius.circular(0),
  140 + bottomLeft: left
  141 + ? Radius.circular(ScreenUtil().setWidth(20))
  142 + : Radius.circular(0),
  143 + topRight: right
  144 + ? Radius.circular(ScreenUtil().setWidth(20))
  145 + : Radius.circular(0),
  146 + bottomRight: right
  147 + ? Radius.circular(ScreenUtil().setWidth(20))
  148 + : Radius.circular(0),
  149 + ));
  150 + fontColor = MyColours.color_fefefe;
  151 + break;
  152 + break;
  153 + }
  154 + return Material(
  155 + child: Ink(
  156 + child: InkWell(
  157 + onTap: onPress,
  158 + child: Container(
  159 + width: width,
  160 + // height: ScreenUtil().setWidth(height),
  161 +
  162 + decoration: boxDecoration,
  163 + child: Align(
  164 + alignment: Alignment.center,
  165 + child: Text(
  166 + content,
  167 + style: TextStyle(
  168 + color: fontColor,
  169 + fontWeight: fontWeight,
  170 + fontSize: ScreenUtil().setSp(fontSize)),
  171 + ),
  172 + ),
  173 + ),
  174 + ),
  175 + ),
  176 + );
  177 + }
  178 +}