Commit 755b19275ff72b2e6e3d799067c713d296eb2117

Authored by wdn
1 parent b12d3c51

变更预订一点点布局

  1 +import 'package:flutter/material.dart';
  2 +import 'package:flutter_screenutil/screenutil.dart';
  3 +import 'package:one_key/res/colors.dart';
  4 +import 'package:one_key/utils/utils.dart';
  5 +import 'package:one_key/widgets/app_bar.dart';
  6 +import 'package:one_key/widgets/h_empty_view.dart';
  7 +import 'package:one_key/widgets/round_button.dart';
  8 +
  9 +class NoteBookChangePage extends StatefulWidget {
  10 + @override
  11 + _NoteBookChangePageState createState() => _NoteBookChangePageState();
  12 +}
  13 +
  14 +class _NoteBookChangePageState extends State<NoteBookChangePage> {
  15 + String dateText = ""; //当前显示日期时间
  16 + int currTimeIndex = 1; //当前选中时间段
  17 + String morning; //早市时间段
  18 + String noon; //午市时间段
  19 + String night; //晚市时间段
  20 +
  21 + DateTime dateTime; //当前日期
  22 +
  23 + //生成日期文本
  24 + _createDateText(DateTime day) {
  25 + if (Utils.isOneDay(day, dateTime)) return; //日期没变
  26 + setState(() {
  27 + DateTime dateNow = DateTime.now();
  28 + if (Utils.isOneDay(day, dateNow)) {
  29 + dateText = Utils.addZeroNumber(dateNow.month) +
  30 + "-" +
  31 + Utils.addZeroNumber(dateNow.day) +
  32 + " 今天";
  33 + } else {
  34 + dateText =
  35 + Utils.addZeroNumber(day.month) + "-" + Utils.addZeroNumber(day.day);
  36 + }
  37 + dateTime = day;
  38 + });
  39 + // _getReserveList();
  40 + // _reserveCountDay();
  41 + }
  42 +
  43 + //初始化时间
  44 + _initTime() {
  45 + dateTime = DateTime.now();
  46 + dateText = Utils.addZeroNumber(dateTime.month) +
  47 + "-" +
  48 + Utils.addZeroNumber(dateTime.day);
  49 + // morning =
  50 + // userModel.user.morning.isEmpty ? "00:00-00:00" : userModel.user.morning;
  51 + // noon = userModel.user.noon.isEmpty ? "00:00-00:00" : userModel.user.noon;
  52 + // night = userModel.user.night.isEmpty ? "00:00-00:00" : userModel.user.night;
  53 + // if (dateTime.isBefore(DateTime.parse(dateTime.year.toString() +
  54 + // "-" +
  55 + // Utils.addZeroNumber(dateTime.month) +
  56 + // "-" +
  57 + // Utils.addZeroNumber(dateTime.day) +
  58 + // " " +
  59 + // morning.split("-")[1] +
  60 + // ":00"))) {
  61 + // //未过早市
  62 + // currTimeIndex = 1;
  63 + // } else if (dateTime.isAfter(DateTime.parse(dateTime.year.toString() +
  64 + // "-" +
  65 + // Utils.addZeroNumber(dateTime.month) +
  66 + // "-" +
  67 + // Utils.addZeroNumber(dateTime.day) +
  68 + // " " +
  69 + // morning.split("-")[1] +
  70 + // ":00")) &&
  71 + // dateTime.isBefore(DateTime.parse(dateTime.year.toString() +
  72 + // "-" +
  73 + // Utils.addZeroNumber(dateTime.month) +
  74 + // "-" +
  75 + // Utils.addZeroNumber(dateTime.day) +
  76 + // " " +
  77 + // noon.split("-")[1] +
  78 + // ":00"))) {
  79 + // //过了早市,未过午市
  80 + // currTimeIndex = 2;
  81 + // } else if (dateTime.isAfter(DateTime.parse(dateTime.year.toString() +
  82 + // "-" +
  83 + // Utils.addZeroNumber(dateTime.month) +
  84 + // "-" +
  85 + // Utils.addZeroNumber(dateTime.day) +
  86 + // " " +
  87 + // noon.split("-")[1] +
  88 + // ":00")) &&
  89 + // dateTime.isBefore(DateTime.parse(dateTime.year.toString() +
  90 + // "-" +
  91 + // Utils.addZeroNumber(dateTime.month) +
  92 + // "-" +
  93 + // Utils.addZeroNumber(dateTime.day) +
  94 + // " " +
  95 + // night.split("-")[1] +
  96 + // ":00"))) {
  97 + // //过了午市,未过晚市
  98 + // currTimeIndex = 3;
  99 + // } else {
  100 + // //过了晚市
  101 + // currTimeIndex = 3;
  102 + // }
  103 + }
  104 +
  105 + @override
  106 + void initState() {
  107 + super.initState();
  108 + _initTime();
  109 + }
  110 +
  111 + @override
  112 + Widget build(BuildContext context) {
  113 + return Scaffold(
  114 + backgroundColor: Colors.white,
  115 + body: SingleChildScrollView(
  116 + child: Column(children: <Widget>[
  117 + SizedBox(height: ScreenUtil.statusBarHeight),
  118 + MyAppBar(
  119 + "在线预订详情",
  120 + showBack: true,
  121 + ),
  122 + //第一行
  123 + Container(
  124 + padding: EdgeInsets.all(ScreenUtil().setWidth(40)),
  125 + child: Row(
  126 + mainAxisAlignment: MainAxisAlignment.spaceBetween,
  127 + children: [
  128 + CustomButton(
  129 + dateText: dateText,
  130 + dayText: ' 今天',
  131 + isSelect: true,
  132 + ),
  133 + CustomButton(
  134 + dateText: dateText,
  135 + dayText: ' 明天',
  136 + isSelect: false,
  137 + ),
  138 + CustomButton(
  139 + dateText: '其他',
  140 + fontSize: 30,
  141 + dayText: '',
  142 + isImage: true,
  143 + isSelect: false,
  144 + )
  145 + ],
  146 + ),
  147 + ),
  148 + //第二行
  149 + Container(
  150 + padding: EdgeInsets.all(ScreenUtil().setWidth(40)),
  151 + child: Row(
  152 + mainAxisAlignment: MainAxisAlignment.spaceBetween,
  153 + children: [
  154 + CustomButton(
  155 + dateText: '早市',
  156 + dayText: '',
  157 + isSelect: true,
  158 + ),
  159 + CustomButton(
  160 + dateText: '午市',
  161 + dayText: '',
  162 + isSelect: false,
  163 + ),
  164 + CustomButton(
  165 + dateText: '晚市',
  166 + dayText: '',
  167 + isSelect: false,
  168 + )
  169 + ],
  170 + ),
  171 + ),
  172 + ]),
  173 + ),
  174 + );
  175 + }
  176 +}
  177 +
  178 +class CustomButton extends StatefulWidget {
  179 + final String dateText;
  180 + final String dayText;
  181 + final bool isSelect;
  182 + final double fontSize;
  183 + final bool isImage;
  184 +
  185 + const CustomButton(
  186 + {Key key,
  187 + this.dateText,
  188 + this.dayText,
  189 + this.isSelect,
  190 + this.fontSize = 34,
  191 + this.isImage = false})
  192 + : super(key: key);
  193 + @override
  194 + _ButtonState createState() => _ButtonState();
  195 +}
  196 +
  197 +class _ButtonState extends State<CustomButton> {
  198 + @override
  199 + Widget build(BuildContext context) {
  200 + return Container(
  201 + width: ScreenUtil().setWidth(105 * 2),
  202 + height: ScreenUtil().setWidth(25 * 2),
  203 + decoration: BoxDecoration(
  204 + color: widget.isSelect ? MyColours.color_199095 : Colors.white,
  205 + borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10)),
  206 + border: Border.all(
  207 + color: MyColours.color_199095, width: ScreenUtil().setWidth(2))),
  208 + child: Row(
  209 + mainAxisAlignment: MainAxisAlignment.center,
  210 + children: [
  211 + Text(widget.dateText,
  212 + style: TextStyle(
  213 + fontWeight: FontWeight.bold,
  214 + color: widget.isSelect
  215 + ? MyColours.color_fefefe
  216 + : MyColours.color_199095,
  217 + fontSize: ScreenUtil().setSp(widget.fontSize))),
  218 + widget.isImage ? HEmptyView(20) : Container(),
  219 + widget.isImage
  220 + ? Image.asset(
  221 + widget.isSelect
  222 + ? 'assets/message_selected.png'
  223 + : 'assets/message_default.png',
  224 + width: ScreenUtil().setWidth(36))
  225 + : Text(widget.dayText,
  226 + style: TextStyle(
  227 + fontWeight: FontWeight.bold,
  228 + color: widget.isSelect
  229 + ? MyColours.color_fefefe
  230 + : MyColours.color_199095,
  231 + fontSize: ScreenUtil().setSp(30)))
  232 + ],
  233 + ),
  234 + );
  235 + }
  236 +}
@@ -615,6 +615,7 @@ class NotebookDetailPageState extends State<NotebookDetailPage> { @@ -615,6 +615,7 @@ class NotebookDetailPageState extends State<NotebookDetailPage> {
615 Expanded( 615 Expanded(
616 child: _cancelAndChangeBtn(() { 616 child: _cancelAndChangeBtn(() {
617 print('点击变更预订'); 617 print('点击变更预订');
  618 + NavigatorUtil.goNoteBookChangePage(context);
618 }, '变更预订')), 619 }, '变更预订')),
619 MyDivider( 620 MyDivider(
620 ScreenUtil().setWidth(2), 621 ScreenUtil().setWidth(2),
1 import 'package:fluro/fluro.dart'; 1 import 'package:fluro/fluro.dart';
2 import 'package:flutter/material.dart'; 2 import 'package:flutter/material.dart';
3 import 'package:one_key/models/notebook.dart'; 3 import 'package:one_key/models/notebook.dart';
  4 +import 'package:one_key/pages/detail/notebook_detail_change_page.dart';
4 import 'package:one_key/pages/home/home_page.dart'; 5 import 'package:one_key/pages/home/home_page.dart';
5 import 'package:one_key/pages/invicate/invitation_page.dart'; 6 import 'package:one_key/pages/invicate/invitation_page.dart';
6 import 'package:one_key/pages/login/login_page.dart'; 7 import 'package:one_key/pages/login/login_page.dart';
@@ -73,3 +74,11 @@ var handleWebviewHandler = new Handler( @@ -73,3 +74,11 @@ var handleWebviewHandler = new Handler(
73 return WebViewPage(); 74 return WebViewPage();
74 }); 75 });
75 76
  77 + // 跳转到变更预订
  78 +var handleChangeDetailHandler = new Handler(
  79 + handlerFunc: (BuildContext context, Map<String, List<Object>> params) {
  80 + // String rid=params['rid'].first;
  81 + // String mid=params["mid"].first;
  82 + return NoteBookChangePage();
  83 + });
  84 +
@@ -14,6 +14,7 @@ class Routes { @@ -14,6 +14,7 @@ class Routes {
14 static String invication="/invication";//邀请函 14 static String invication="/invication";//邀请函
15 static String sms="/sms";//发短信 15 static String sms="/sms";//发短信
16 static String webview="/webview";//网页 16 static String webview="/webview";//网页
  17 + static String change_detail="/change_detail";//变更预订
17 18
18 19
19 static void configureRoutes(Router router) { 20 static void configureRoutes(Router router) {
@@ -30,5 +31,6 @@ class Routes { @@ -30,5 +31,6 @@ class Routes {
30 router.define(invication, handler: handleInvicationHandler); 31 router.define(invication, handler: handleInvicationHandler);
31 router.define(sms, handler: handleSmsHandler); 32 router.define(sms, handler: handleSmsHandler);
32 router.define(webview, handler: handleWebviewHandler); 33 router.define(webview, handler: handleWebviewHandler);
  34 + router.define(change_detail, handler: handleChangeDetailHandler);
33 } 35 }
34 } 36 }
@@ -63,4 +63,9 @@ class NavigatorUtil { @@ -63,4 +63,9 @@ class NavigatorUtil {
63 static void goWebviewPage(BuildContext context) { 63 static void goWebviewPage(BuildContext context) {
64 _navigateTo(context,"${Routes.webview}"); 64 _navigateTo(context,"${Routes.webview}");
65 } 65 }
  66 +
  67 + /// 变更预订
  68 + static void goNoteBookChangePage(BuildContext context,{replace=false}) {
  69 + _navigateTo(context,"${Routes.change_detail}",replace: replace);
  70 + }
66 } 71 }