From 87c41341fd2199f673abe3b344aaf066f8dbae30 Mon Sep 17 00:00:00 2001 From: GYJ <1157756119@qq.com> Date: Fri, 22 Nov 2024 18:03:56 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BA=A6=E5=AE=9A=20=E9=A1=B6=E9=83=A8=20?= =?UTF-8?q?=E7=83=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- images/reserve/date.png | Bin 0 -> 617 bytes images/reserve/lock.png | Bin 0 -> 1531 bytes images/reserve/phone.png | Bin 0 -> 1078 bytes lib/home/home_view.dart | 42 +++---- lib/home/reserve_view.dart | 209 ++++++++++++++++++++++++++++++- lib/home/reserve_view_model.dart | 35 +++++- pubspec.yaml | 2 + 7 files changed, 263 insertions(+), 25 deletions(-) create mode 100644 images/reserve/date.png create mode 100644 images/reserve/lock.png create mode 100644 images/reserve/phone.png diff --git a/images/reserve/date.png b/images/reserve/date.png new file mode 100644 index 0000000000000000000000000000000000000000..4bf51b2c4f65265cbfec64048419dce219d09de0 GIT binary patch literal 617 zcmeAS@N?(olHy`uVBq!ia0vp^u0ZU_!3HGTWisu76lZ})WHAGSq6G*ux=u4p017e| z2e~^jtUD+363Agmcl32+VA$Bt{U?zXDEH6P#WAFU@$GEiphFGJ@>wlsWQ~n!f8c2rOImIn-*VAHPz|j|7!T z?Vdm1<>^1)tp0MM$j2B@6}Qw|zgC57YCh6zk#W#$XwE)W5!L5%c5YW(H~ZVmp}irO zlox)KFw7498K-yeS#{8{$)CJK+=>paIFU8o?(y+YPcOAzxv}}lwgNLXC#kaSDb=^` z?6T%E4E~s)9M#%$+BL)G-HyAaN0;^Qvi}uxW{+Cg!pB7uA6Zm*vjuQ91Tjou>d@o( zz3=uGPeK1JQ~0fQr!h`cl3T_Pl$!hUa$QsDH;dqXewq(BuN^(`g)x9@fpKk{+5Z#0 z(W>QMlDGaSn{V@4w{8ARI|eVHB-p$KA`D9zG*|`xPRR7Wo4BR+_Uv_kV_&=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MM|8-NH@{W6icf6$K( zNcQnX_me@FoLgI}9@hrhbLrj3x{9#aE79YU$v8z_tEk*3CX5gg)*9EFWHxxCJ`JyK zShI+bOEMkN2HkNs5=56WO%KU-n2%UA+HMIq_hE2S7@QOaCxyXDVQ^9y9;lRT7fEC+ zMb7p{uh)csqa5XN3g&eReE5iG=v`gQ5$$EYiX@{O><=5)&@wnF3{DDzmg0ls8X~<2 zihF3>=t79TPAzXTQeCn3Cg!o%4Q_sSNHaMqwaDaZWuzn4t=oOYK zZbn)R5tc7At!^#WUQokqAxPiFE5PXB6GHiBQW5*)Vl@{jlMr(lPRt(Rvi|TX?buWw hzTy4Ve*bws@Baw6EdJl-{^kGx002ovPDHLkV1jTBzEA)F literal 0 HcmV?d00001 diff --git a/images/reserve/phone.png b/images/reserve/phone.png new file mode 100644 index 0000000000000000000000000000000000000000..4dbc55de686d4c91dc045d291261eb68212e2b07 GIT binary patch literal 1078 zcmeAS@N?(olHy`uVBq!ia0vp^Q6S901|%(3I5Gh#&H|6fVg?393lL^>oo1K-6l5$8 za(7}_cTVOdki(Mh=%f+ zBUgE#AA@e_ozx&lKY>#vis~Jfjy|5E7Xv@Im%Myra$(nk!x2CCp465|OWN@L?Jc3- zXET;aYRt1+JO3K@X6cCrmGjig%gZJ8wyRI}lyeR2dfg&+n!~+w>y*&Yxp6TuJRUPT zT0S&=FI2AHQnB&8Vau1rWxMa%TU$#{Vo+LSZf;&)@XPPC{tr!O8TO73%3MC(Ow1?S zEozT`Y@87@vG0U#_xbgGzzfO(p z>u~h(Irg})f0p*miAM_0+!MOFXrlW5AjV?Vc!OY*DIF&y`%oic@?9;ylqiy?_aKC58b=7cH`$4nmn(R zZa%yoH9;V0(Z<{RvyUMesvb{y1H{-sD*c9TnTJdfF< z7o2n6dZcI{-YW)-n<^W*-OFY6L>$rF=rzUau2^MV-8n9;X&K*z4k__z+7wTXVD+9` zn{-HT<<2Xo_PWuKSN3>&iGSZu$FobslP080c$uGPb?eou ztfm*QgPI*oJ~Gw%ueUHsXo^)eXf+zY}QG?C;aJT5-f32PvIB1`R?re;NC+0 z3XgvtjGT7GVw?OGfAi}ZbF9C*U&i4BNA^A5t+6(0J2Kc)rfX|!ACK5_TI^D)_&b)z zUs!J*eRuWh)Dv5Hr|zGj#Cpe#>sj0S^c^c(-FJyw9|?R=)$ll~>eI#e7n=fReE7aF R4VcXtJYD@<);T3K0RW=i;aLCx literal 0 HcmV?d00001 diff --git a/lib/home/home_view.dart b/lib/home/home_view.dart index 315644c..bfbc414 100644 --- a/lib/home/home_view.dart +++ b/lib/home/home_view.dart @@ -40,7 +40,7 @@ class HomeView extends BaseUI { Widget _buildLeftBar(BuildContext context) { HomeViewModel provider = getProvider(context, listen: false) as HomeViewModel; - const double leftBarWidth = 120; + const double leftBarWidth = 100; double itemHeight = (MediaQuery.of(context).size.height - leftBarWidth - MediaQuery.of(context).padding.top) / @@ -60,26 +60,26 @@ class HomeView extends BaseUI { } Widget _buildRightContainer(BuildContext context) { - HomeViewModel provider = - getProvider(context, listen: false) as HomeViewModel; + getProvider(context, listen: false) as HomeViewModel; return Expanded( child: Container( color: Colors.amber, - child: MultiProvider( - providers: [ - ChangeNotifierProvider( - create: (_) => ReserveViewModel(), - ), - ChangeNotifierProvider( - create: (_) => OrderViewModel(), - ), - ], - child: PageView( - controller: provider.pageController, - children: _buildPageViews(context, provider), - ), + child: MultiProvider( + providers: [ + ChangeNotifierProvider( + create: (_) => ReserveViewModel(), ), + ChangeNotifierProvider( + create: (_) => OrderViewModel(), + ), + ], + child: PageView( + physics: const NeverScrollableScrollPhysics(), + controller: provider.pageController, + children: _buildPageViews(context, provider), + ), + ), )); } @@ -137,15 +137,15 @@ class HomeView extends BaseUI { provider.currentIndex == index ? "images/tabbar/${provider.tabIcons[index]}_select.png" : "images/tabbar/${provider.tabIcons[index]}_normal.png", - width: 23, - height: 27, + width: 20, + height: 23, ), - const SizedBox(height: 5), + const SizedBox(height: 3), Text( provider.tabTitles[index], style: provider.currentIndex == index - ? const TextStyle(color: Colors.white, fontSize: 14) - : const TextStyle(color: Colors.grey, fontSize: 14), + ? const TextStyle(color: Colors.white, fontSize: 12) + : const TextStyle(color: Colors.grey, fontSize: 12), ) ], ), diff --git a/lib/home/reserve_view.dart b/lib/home/reserve_view.dart index 60677d6..205bcc9 100644 --- a/lib/home/reserve_view.dart +++ b/lib/home/reserve_view.dart @@ -7,8 +7,13 @@ import '../common/base/provider.dart'; class ReserveView extends BaseUI { @override Widget buildBody(BuildContext context) { - return Center( - child: Text("Reserve"), + ReserveViewModel provider = + getProvider(context, listen: false) as ReserveViewModel; + return Column( + children: [ + _buildTopDateBar(context, provider), + Expanded(child: _buildContentView(context, provider)), + ], ); } @@ -26,4 +31,202 @@ class ReserveView extends BaseUI { AppBar? getAppBar(BuildContext context) { return null; } -} \ No newline at end of file + + Widget _buildTopDateBar(BuildContext context, ReserveViewModel provider) { + return Padding( + padding: const EdgeInsets.fromLTRB(15, 5, 15, 5), + child: Row( + children: [ + _buildDateItem(context, provider), + _buildDateSelectContent(context, provider), + const SizedBox( + width: 15, + ), + InkWell( + onTap: () {}, + child: SizedBox( + width: 40, + height: 40, + child: Center( + child: Image.asset( + "images/reserve/lock.png", + width: 24, + height: 24, + ), + ), + ), + ), + const SizedBox( + width: 5, + ), + InkWell( + onTap: () {}, + child: SizedBox( + width: 40, + height: 40, + child: Center( + child: Image.asset( + "images/reserve/phone.png", + width: 24, + height: 24, + ), + ), + ), + ), + const SizedBox( + width: 5, + ), + InkWell( + onTap: () {}, + child: const SizedBox( + width: 40, + height: 40, + child: Center( + child: Text("刷新", style: TextStyle(fontSize: 15, color: Colors.blue),), + ), + ), + ), + ], + ), + ); + } + + Widget _buildContentView(BuildContext context, ReserveViewModel provider) { + return Row( + children: [], + ); + } + + Widget _buildDateItem(BuildContext context, ReserveViewModel provider) { + return Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + border: Border.all(color: const Color(0xffafafaf), width: 1), + ), + height: 40, + padding: const EdgeInsets.fromLTRB(10, 0, 10, 0), + child: Row( + children: [ + Image.asset( + "images/reserve/date.png", + width: 24, + height: 24, + ), + const SizedBox(width: 7), + Text( + provider.getCurrentDate(), + style: const TextStyle(color: Color(0xff333333), fontSize: 14), + ) + ], + ), + ); + } + + // Widget _buildCallRecordListWidget(BuildContext context, ReserveViewModel provider) { + // return ListView.builder( + // itemCount: provider.callRecordList.length, + // itemBuilder: (context, index) { + // return _buildCallRecordItem(context, provider.callRecordList[index]); + // }, + // ); + // } + + Widget _buildDateSelectContent( + BuildContext context, ReserveViewModel provider) { + return Row( + children: [ + _buildDateSelectItem(context, + day: provider.getOffsetDay(0), + week: provider.getOffsetWeekday(0), + isToday: true), + _buildDateSelectItem(context, + day: provider.getOffsetDay(1), week: provider.getOffsetWeekday(1)), + _buildDateSelectItem(context, + day: provider.getOffsetDay(2), week: provider.getOffsetWeekday(2)), + ], + ); + } + + Widget _buildDateSelectItem( + BuildContext context, { + String day = "", + String week = "", + isToday = false, + }) { + const double itemHeight = 45; + const double btnWidth = 60; + return Container( + height: itemHeight, + margin: const EdgeInsets.only(left: 15), + padding: const EdgeInsets.fromLTRB(10, 0, 6, 0), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + border: Border.all( + color: + isToday ? const Color(0xff318AFE) : const Color(0xffafafaf), + width: 1), + ), + child: Row( + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + day, + style: TextStyle( + color: isToday + ? const Color(0xff6A8DC6) + : const Color(0xff333333), + fontSize: 13, + ), + ), + Text( + week, + style: TextStyle( + color: isToday + ? const Color(0xff6A8DC6) + : const Color(0xff333333), + fontSize: 13, + ), + ), + ], + ), + const SizedBox(width: 10), + Container( + width: 1, + height: itemHeight, + color: const Color(0xffafafaf), + ), + InkWell( + onTap: () {}, + child: const SizedBox( + width: btnWidth, + child: Center( + child: Text( + "午餐", + style: TextStyle(fontSize: 16, color: Color(0xff333333)), + ), + ), + ), + ), + Container( + width: 1, + height: itemHeight, + color: const Color(0xffafafaf), + ), + InkWell( + onTap: () {}, + child: const SizedBox( + width: btnWidth, + child: Center( + child: Text( + "晚餐", + style: TextStyle(fontSize: 16, color: Color(0xff333333)), + ), + ), + ), + ), + ], + )); + } +} diff --git a/lib/home/reserve_view_model.dart b/lib/home/reserve_view_model.dart index 3097f3e..692e627 100644 --- a/lib/home/reserve_view_model.dart +++ b/lib/home/reserve_view_model.dart @@ -1,3 +1,36 @@ import 'package:cashier_reserve/common/base/ui_model.dart'; -class ReserveViewModel extends BaseUIModel {} \ No newline at end of file +class ReserveViewModel extends BaseUIModel { + Map weekdayMap = { + 1: "星期一", + 2: "星期二", + 3: "星期三", + 4: "星期四", + 5: "星期五", + 6: "星期六", + 7: "星期日", + }; + + Map dayInfoMap = { + 0: "今", + 1: "明", + 2: "后", + }; + + String getCurrentDate() { + DateTime now = DateTime.now(); + return "${now.year}/${now.month}/${now.day}"; + } + + String getOffsetDay(int offset) { + DateTime now = DateTime.now(); + DateTime offsetDay = now.add(Duration(days: offset)); + return "${dayInfoMap[offset]}/${offsetDay.day}"; + } + + String getOffsetWeekday(int offset) { + DateTime now = DateTime.now(); + DateTime offsetDay = now.add(Duration(days: offset)); + return weekdayMap[offsetDay.weekday] ?? ""; + } +} \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index 054f6b7..773dc49 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -73,6 +73,8 @@ flutter: - images/tabbar/ + - images/reserve/ + # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/to/resolution-aware-images