From 441bc828ca1eafa7797a6a24204e5609e96163ef Mon Sep 17 00:00:00 2001 From: wyf <494641114@qq.com> Date: Tue, 17 Jun 2025 09:06:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=A6=96=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/mh_page/homepage/new_Home_page.dart | 298 ++++++++++-------- 1 file changed, 161 insertions(+), 137 deletions(-) diff --git a/lib/pages/mh_page/homepage/new_Home_page.dart b/lib/pages/mh_page/homepage/new_Home_page.dart index 32e9dc2..9e504bc 100644 --- a/lib/pages/mh_page/homepage/new_Home_page.dart +++ b/lib/pages/mh_page/homepage/new_Home_page.dart @@ -6,6 +6,7 @@ import 'package:vbvs_app/common/color/appConstants.dart'; import 'package:vbvs_app/common/color/app_uri_status.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; +import 'package:vbvs_app/component/NullDataComponentWidget.dart'; import 'package:vbvs_app/component/tool/ClickableContainer.dart'; import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; import 'package:vbvs_app/controller/main_bottom/global_controller.dart'; @@ -66,7 +67,8 @@ class _NewHomePageState extends State { } WidgetsBinding.instance.addPostFrameCallback((_) { if (homeController.sleepDays.value.isNotEmpty) { - homeController.selectedDayIndex.value = homeController.sleepDays.value.length - 1; + homeController.selectedDayIndex.value = + homeController.sleepDays.value.length - 1; } }); } @@ -411,7 +413,8 @@ class _NewHomePageState extends State { personInfo.value = selectedPerson; - homeController.selectedDayIndex = + homeController + .selectedDayIndex = (6).obs; print("$val"); if (val == null) { @@ -470,11 +473,18 @@ class _NewHomePageState extends State { .value != null) { Get.toNamed( - "/sleepWebview", - arguments: [ - formFieldController - .value - ]); + "/newSleepReportPage", + arguments: { + 'mac': + formFieldController + .value!, + 'type': 1, + "person": personInfo + .value, + 'backgroundImg': + 'assets/images/new_background.png', + }, + ); } }, child: Row( @@ -501,138 +511,152 @@ class _NewHomePageState extends State { ), ), ), - Container( - padding: EdgeInsets.only( - top: 0.rpx, - bottom: 20.rpx, - left: 16.rpx, - right: 16.rpx, - ), - width: double.infinity, - decoration: BoxDecoration(), - child: Obx(() => Row( - mainAxisSize: - MainAxisSize.max, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - ...List.generate( - homeController - .sleepDays - .value - .length, (index) { - var day = homeController - .sleepDays[index]; - bool isSelected = - homeController.selectedDayIndex - .value == - index; - return Expanded( - child: GestureDetector( - onTap: () { - homeController.selectedDayIndex - .value = index; - int? timeMillis = - parseToInt(day[ - 'time']); // 使用我们刚才封装的安全转换函数 - Get.toNamed( - "/newSleepReportPage", - arguments: { - 'date': - timeMillis, - 'mac': - formFieldController - .value!, - 'type': 1, - "person": - personInfo - .value, - 'backgroundImg': - 'assets/images/new_background.png', - // 'backgroundColor':stringToColor("#003058"), - }, - ); - }, - child: Container( - padding: - EdgeInsets.only( - top: 10.rpx, - bottom: 20.rpx, - ), - width: 90.rpx, - decoration: - BoxDecoration( - color: isSelected - ? stringToColor( - "#184468") - : Colors - .transparent, - borderRadius: - BorderRadius - .circular( - 8.rpx), - ), - child: Column( - mainAxisSize: - MainAxisSize - .max, - mainAxisAlignment: - MainAxisAlignment - .start, - crossAxisAlignment: - CrossAxisAlignment - .center, - children: [ - Text( - day['week'], - style: FlutterFlowTheme.of( - context) - .bodyMedium - .override( - fontFamily: - 'Readex Pro', - fontSize: - 30.rpx, - letterSpacing: - 0, - color: stringToColor( - "#FFFFFF"), - ), - ), - SizedBox( - height: - 12.rpx), - Text( - day['date'], - // "哈哈", - style: FlutterFlowTheme.of( - context) - .bodyMedium - .override( - fontFamily: - 'Readex Pro', - letterSpacing: - 0, - fontSize: - 22.rpx, - color: stringToColor( - "#929699"), - ), - ), - SizedBox( - height: - 39.rpx), - buildScoreOrIcon( - day['score']), - ], + if (homeController + .sleepDays.value.length == + 0) + Expanded(child: NullDataWidget()), + if (homeController + .sleepDays.value.length != + 0) + Container( + padding: EdgeInsets.only( + top: 0.rpx, + bottom: 20.rpx, + left: 16.rpx, + right: 16.rpx, + ), + width: double.infinity, + decoration: BoxDecoration(), + child: Obx(() => Row( + mainAxisSize: + MainAxisSize.max, + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + ...List.generate( + homeController + .sleepDays + .value + .length, (index) { + var day = homeController + .sleepDays[index]; + bool isSelected = + homeController + .selectedDayIndex + .value == + index; + return Expanded( + child: + GestureDetector( + onTap: () { + homeController + .selectedDayIndex + .value = index; + int? timeMillis = + parseToInt(day[ + 'time']); // 使用我们刚才封装的安全转换函数 + Get.toNamed( + "/newSleepReportPage", + arguments: { + 'date': + timeMillis, + 'mac': + formFieldController + .value!, + 'type': 1, + "person": + personInfo + .value, + 'backgroundImg': + 'assets/images/new_background.png', + 'date': + timeMillis, + // 'backgroundColor':stringToColor("#003058"), + }, + ); + }, + child: Container( + padding: + EdgeInsets + .only( + top: 10.rpx, + bottom: 20.rpx, + ), + width: 90.rpx, + decoration: + BoxDecoration( + color: isSelected + ? stringToColor( + "#184468") + : Colors + .transparent, + borderRadius: + BorderRadius + .circular( + 8.rpx), + ), + child: Column( + mainAxisSize: + MainAxisSize + .max, + mainAxisAlignment: + MainAxisAlignment + .start, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + day['week'], + style: FlutterFlowTheme.of( + context) + .bodyMedium + .override( + fontFamily: + 'Readex Pro', + fontSize: + 30.rpx, + letterSpacing: + 0, + color: + stringToColor("#FFFFFF"), + ), + ), + SizedBox( + height: 12 + .rpx), + Text( + day['date'], + // "哈哈", + style: FlutterFlowTheme.of( + context) + .bodyMedium + .override( + fontFamily: + 'Readex Pro', + letterSpacing: + 0, + fontSize: + 22.rpx, + color: + stringToColor("#929699"), + ), + ), + SizedBox( + height: 39 + .rpx), + buildScoreOrIcon( + day['score']), + ], + ), ), ), - ), - ); - }) - ], - )), - ), + ); + }) + ], + )), + ), ], ), ),