diff --git a/lib/pages/mh_page/device/device.dart b/lib/pages/mh_page/device/device.dart index 25013b0..de59fb3 100644 --- a/lib/pages/mh_page/device/device.dart +++ b/lib/pages/mh_page/device/device.dart @@ -211,7 +211,7 @@ class DeviceInfoWidget extends GetView { webviewTestController.web.jsbridge?.dart .pageActive(false); - await Future.delayed(Duration(seconds: 1)); + // await Future.delayed(Duration(seconds: 1)); webviewTestController.web.jsbridge?.dart .appToHtmlDevice(device); MainPageBBottomChange.jumpTo(2); diff --git a/lib/pages/mh_page/homepage/component/HomeDeviceStausWidget.dart b/lib/pages/mh_page/homepage/component/HomeDeviceStausWidget.dart index ddfc4f3..625effd 100644 --- a/lib/pages/mh_page/homepage/component/HomeDeviceStausWidget.dart +++ b/lib/pages/mh_page/homepage/component/HomeDeviceStausWidget.dart @@ -33,32 +33,39 @@ class _HomeDeviceStausWidgetState extends State { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - width: 170.rpx, - height: 81.rpx, - child: ClipRRect( - borderRadius: BorderRadius.circular(8.rpx), - child: Image.network( - widget.deviceStatus['device_image'], // 从DeviceStatus获取图片 - width: 200.rpx, - height: 200.rpx, - fit: BoxFit.cover, + Flexible( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 170.rpx, + height: 81.rpx, + child: ClipRRect( + borderRadius: BorderRadius.circular(8.rpx), + child: Image.network( + widget + .deviceStatus['device_image'], // 从DeviceStatus获取图片 + width: 200.rpx, + height: 200.rpx, + fit: BoxFit.cover, + ), ), ), - ), - Text( - '${(widget.deviceStatus['name'] ?? '').isEmpty ? '未命名'.tr : widget.deviceStatus['name']}', - style: TextStyle( - color: Colors.white, - fontSize: 26.rpx, - letterSpacing: 0.0.rpx, + Text( + '${(widget.deviceStatus['name'] ?? '').isEmpty ? '未命名'.tr : widget.deviceStatus['name']}', + style: TextStyle( + color: Colors.white, + fontSize: 26.rpx, + letterSpacing: 0.0.rpx, + ), + maxLines: 1, + overflow: TextOverflow.ellipsis, ), - ), - ].divide(SizedBox(height: 26.rpx)), + ].divide(SizedBox(height: 26.rpx)), + ), ), + SizedBox(width: 26.rpx), Column( mainAxisAlignment: MainAxisAlignment.center, children: [ diff --git a/lib/pages/mh_page/homepage/mht_sleep_report_page.dart b/lib/pages/mh_page/homepage/mht_sleep_report_page.dart index de65810..f020e14 100644 --- a/lib/pages/mh_page/homepage/mht_sleep_report_page.dart +++ b/lib/pages/mh_page/homepage/mht_sleep_report_page.dart @@ -282,7 +282,7 @@ class _MhtSleepReportPageState extends State { borderColor: Colors.transparent, borderWidth: 2, - borderRadius: 0.rpx, + borderRadius: 100.rpx, margin: EdgeInsetsDirectional .fromSTEB( diff --git a/lib/pages/mh_page/homepage/new_Home_page.dart b/lib/pages/mh_page/homepage/new_Home_page.dart index 1541314..9ddffac 100644 --- a/lib/pages/mh_page/homepage/new_Home_page.dart +++ b/lib/pages/mh_page/homepage/new_Home_page.dart @@ -540,7 +540,7 @@ class _NewHomePageState extends State { borderColor: Colors.transparent, borderWidth: 2, - borderRadius: 18, + borderRadius: 100.rpx, margin: EdgeInsetsDirectional .fromSTEB( diff --git a/lib/pages/sleep_report/new_sleep_report_page.dart b/lib/pages/sleep_report/new_sleep_report_page.dart index da93ccc..661423c 100644 --- a/lib/pages/sleep_report/new_sleep_report_page.dart +++ b/lib/pages/sleep_report/new_sleep_report_page.dart @@ -155,15 +155,6 @@ class _NewSleepReportPageState extends State { builder: (context, bodySize) => GestureDetector( onTap: () => FocusScope.of(context).unfocus(), child: Container( - // decoration: BoxDecoration( - // image: DecorationImage( - // image: (widget.data['backgroundImg'] != null && - // widget.data['backgroundImg'].toString().isNotEmpty) - // ? AssetImage(widget.data['backgroundImg']) - // : AssetImage('assets/img/bgNoImg.png') as ImageProvider, - // fit: BoxFit.fill, - // ), - // ), decoration: BoxDecoration( image: (widget.data['noBackImg'] != null && widget.data['noBackImg'] == true) @@ -176,7 +167,6 @@ class _NewSleepReportPageState extends State { fit: BoxFit.fill, ), ), - child: Scaffold( backgroundColor: Colors.transparent, // 背景透明 // appBar: AppBar( @@ -252,13 +242,12 @@ class _NewSleepReportPageState extends State { ), ), ), - body: SafeArea( top: true, - child: SingleChildScrollView( - child: Obx(() { - var sleepReport = sleepReportController.sleepReport; - print(sleepReport); + child: Obx(() { + var sleepReport = sleepReportController.sleepReport; + print(sleepReport); + if (sleepReport.isEmpty || sleepReport.isEmpty) { return Column( children: [ Padding( @@ -767,7 +756,7 @@ class _NewSleepReportPageState extends State { ), (sleepReport.value == null || sleepReport.value.isEmpty) ? Container( - child: NullDataWidget(), + child: Expanded(child: NullDataWidget()), ) : (sleepReportController.model.type == 1 ? DailyDataWidget(sleepReport, sleepCardKey, @@ -782,8 +771,561 @@ class _NewSleepReportPageState extends State { height: 25.rpx, )), ); - }), - ), + } else { + return SingleChildScrollView( + child: Column( + children: [ + Padding( + padding: + EdgeInsetsDirectional.fromSTEB(0, 30.rpx, 0, 0), + child: Container( + width: double.infinity, + constraints: BoxConstraints( + minHeight: 90.rpx, + ), + decoration: BoxDecoration( + color: widget.data['backgroundColor'] != null + ? widget.data['backgroundColor'] + : themeController.currentColor.sc5, + ), + child: Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 30.rpx, 15.rpx, 30.rpx, 15.rpx), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Stack( + alignment: Alignment.bottomLeft, + children: [ + Row( + mainAxisSize: MainAxisSize.max, + children: [ + ClickableContainer( + backgroundColor: Colors.transparent, + highlightColor: themeController + .currentColor.sc3, + borderRadius: 8.rpx, + padding: EdgeInsets.all(0), + onTap: () async { + sleepReportController.model.type = + 1; + + String data = MyUtils.formatDate( + calendarController + .selectedDate.value!); + await requestWithLog( + logTitle: "查询睡眠报告", + method: MyHttpMethod.get, + queryUrl: + "https://sleepdata.he-info.com/api/analysis/sleep/analysis?mac=${widget.data['mac']}&time=${data}&type=${sleepReportController.model.type}", + onSuccess: (res) { + print(res); + sleepReportController + .sleepReport + .value = res.data; + sleepReportController + .updateAll(); + }, + onFailure: (res) { + if (MainPageBBottomChange + .getCurrentIndex() != + null) { + if (MainPageBBottomChange + .getCurrentIndex() == + 1) { + TopSlideNotification.show( + context, + text: res.msg!, + textColor: + themeController + .currentColor + .sc9); + } + } else { + TopSlideNotification.show( + context, + text: res.msg!, + textColor: + themeController + .currentColor + .sc9); + } + sleepReportController + .sleepReport.value = {}; + sleepReportController + .updateAll(); + print(res); + }); + sleepReportController.updateAll(); + }, + child: Column( + mainAxisSize: MainAxisSize.max, + children: [ + Container( + width: + 115.rpx, // 固定宽度为 160.rpx + alignment: + Alignment.center, // 文字居中 + child: Text( + '日报'.tr, + style: TextStyle( + fontFamily: 'Inter', + fontSize: AppConstants() + .title_text_fontSize, + letterSpacing: 0.0, + color: sleepReportController + .model.type == + 1 + ? themeController + .currentColor.sc2 + : themeController + .currentColor.sc3, + ), + ), + ), + SizedBox(height: 10.rpx), + ], + ), + ), + Obx(() { + return ClickableContainer( + backgroundColor: + Colors.transparent, + highlightColor: themeController + .currentColor.sc3, + borderRadius: 8.rpx, + padding: EdgeInsets.all(0), + onTap: () async { + sleepReportController + .model.type = 2; + String data = + MyUtils.formatDate( + calendarController + .selectedDate + .value!); + await requestWithLog( + logTitle: "查询睡眠报告", + method: MyHttpMethod.get, + queryUrl: + "https://sleepdata.he-info.com/api/analysis/sleep/analysis?mac=${widget.data['mac']}&time=${data}&type=${sleepReportController.model.type}", + onSuccess: (res) { + print(res); + sleepReportController + .sleepReport + .value = res.data; + sleepReportController + .updateAll(); + }, + onFailure: (res) { + if (MainPageBBottomChange + .getCurrentIndex() != + null) { + if (MainPageBBottomChange + .getCurrentIndex() == + 1) { + TopSlideNotification.show( + context, + text: res.msg!, + textColor: + themeController + .currentColor + .sc9); + } + } else { + TopSlideNotification.show( + context, + text: res.msg!, + textColor: + themeController + .currentColor + .sc9); + } + sleepReportController + .sleepReport + .value = {}; + sleepReportController + .updateAll(); + print(res); + }); + sleepReportController + .updateAll(); + }, + child: Column( + mainAxisSize: MainAxisSize.max, + children: [ + Container( + width: 115 + .rpx, // 固定宽度为 160.rpx + alignment: Alignment + .center, // 文字居中 + child: Text('周报'.tr, + style: TextStyle( + fontFamily: 'Inter', + fontSize: AppConstants() + .title_text_fontSize, + letterSpacing: 0.0, + color: sleepReportController + .model + .type == + 2 + ? themeController + .currentColor + .sc2 + : themeController + .currentColor + .sc3, + )), + ), + SizedBox(height: 10.rpx), + ], + ), + ); + }), + Obx(() { + return ClickableContainer( + backgroundColor: + Colors.transparent, + highlightColor: themeController + .currentColor.sc3, + borderRadius: 8.rpx, + padding: EdgeInsets.all(0), + onTap: () async { + sleepReportController + .model.type = 3; + String data = + MyUtils.formatDate( + calendarController + .selectedDate + .value!); + await requestWithLog( + logTitle: "查询睡眠报告", + method: MyHttpMethod.get, + queryUrl: + "https://sleepdata.he-info.com/api/analysis/sleep/analysis?mac=${widget.data['mac']}&time=${data}&type=${sleepReportController.model.type}", + onSuccess: (res) { + print(res); + sleepReportController + .sleepReport + .value = res.data; + sleepReportController + .updateAll(); + }, + onFailure: (res) { + if (MainPageBBottomChange + .getCurrentIndex() != + null) { + if (MainPageBBottomChange + .getCurrentIndex() == + 1) { + TopSlideNotification.show( + context, + text: res.msg!, + textColor: + themeController + .currentColor + .sc9); + } + } else { + TopSlideNotification.show( + context, + text: res.msg!, + textColor: + themeController + .currentColor + .sc9); + } + sleepReportController + .sleepReport + .value = {}; + sleepReportController + .updateAll(); + print(res); + }); + + sleepReportController + .updateAll(); + }, + child: Column( + mainAxisSize: MainAxisSize.max, + children: [ + Container( + width: 115 + .rpx, // 固定宽度为 160.rpx + alignment: Alignment + .center, // 文字居中 + child: Text( + '月报'.tr, + style: TextStyle( + fontFamily: 'Inter', + fontSize: AppConstants() + .title_text_fontSize, + letterSpacing: 0.0, + color: + sleepReportController + .model + .type == + 3 + ? themeController + .currentColor + .sc2 + : themeController + .currentColor + .sc3, + ), + ), + ), + SizedBox(height: 10.rpx), + ], + ), + ); + }), + ], + ), + AnimatedPositioned( + duration: Duration(milliseconds: 300), + curve: Curves.easeInOut, + bottom: 0, + left: + sleepReportController.model.type == + 1 + ? 0 + : sleepReportController + .model.type == + 2 + ? 115.rpx + : 230.rpx, + child: Container( + width: lineWidth, + height: 4.rpx, + decoration: BoxDecoration( + color: themeController + .currentColor.sc2, + borderRadius: + BorderRadius.circular(2.rpx), + ), + ), + ), + ], + ), + ], + ), + ), + ), + ), + Container( + width: double.infinity, + child: Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 30.rpx, 32.rpx, 30.rpx, 32.rpx), + child: getTimeWidget(), + ), + ), + if (widget.data['person_show'] == null || + widget.data['person_show'] != false) + Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 30.rpx, 0.rpx, 30.rpx, 51.rpx), + child: ClickableContainer( + backgroundColor: + widget.data['backgroundColor'] != null + ? widget.data['backgroundColor'] + : themeController.currentColor.sc5, + highlightColor: themeController + .currentColor.sc5, // 或你希望的点击水波纹颜色 + borderRadius: AppConstants() + .normal_container_radius, // 如果你想加圆角可以设置 eg. 12.rpx + padding: EdgeInsets.zero, + onTap: () {}, + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + Flexible( + flex: 2, + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row( + children: [ + Column( + crossAxisAlignment: + CrossAxisAlignment.end, + children: [ + Text( + '姓名'.tr, + style: TextStyle( + fontFamily: 'Inter', + fontSize: 26.rpx, + letterSpacing: 0.0, + color: themeController + .currentColor.sc4, + ), + ), + Text( + '年龄'.tr, + style: TextStyle( + fontFamily: 'Inter', + fontSize: 26.rpx, + letterSpacing: 0.0, + color: themeController + .currentColor.sc4, + ), + ), + ].divide( + SizedBox(height: 34.rpx)), + ), + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + (widget.data['person'] + ?['name'] + ?.toString() + .trim() + .isNotEmpty ?? + false) + ? widget.data['person']![ + 'name'] + .toString() + : '未知数据'.tr, + style: TextStyle( + fontFamily: 'Inter', + fontSize: 26.rpx, + letterSpacing: 0.0, + color: themeController + .currentColor.sc3, + ), + ), + Text( + '${MyUtils.getAgeByDate(MyUtils.formatBirthdayTime(widget.data['person']?['birthday'])) ?? '未知数据'.tr}', + style: TextStyle( + fontFamily: 'Inter', + fontSize: 26.rpx, + letterSpacing: 0.0, + color: themeController + .currentColor.sc3, + ), + ), + ].divide( + SizedBox(height: 34.rpx)), + ), + ] + .divide(SizedBox(width: 33.rpx)) + .addToStart( + SizedBox(width: 37.rpx)), + ), + ] + .addToStart(SizedBox(height: 36.rpx)) + .addToEnd(SizedBox(height: 36.rpx)), + ), + ), + Flexible( + flex: 3, + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row( + children: [ + Column( + crossAxisAlignment: + CrossAxisAlignment.end, + children: [ + Text( + '设备ID'.tr, + style: TextStyle( + fontFamily: 'Inter', + fontSize: 26.rpx, + letterSpacing: 0.0, + color: themeController + .currentColor.sc4, + ), + ), + Text( + '体重'.tr, + style: TextStyle( + fontFamily: 'Inter', + fontSize: 26.rpx, + letterSpacing: 0.0, + color: themeController + .currentColor.sc4, + ), + ), + ].divide( + SizedBox(height: 34.rpx)), + ), + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + '${widget.data['code'] ?? '未知数据'.tr}', + // "D11250300003", + style: TextStyle( + fontFamily: 'Inter', + fontSize: 26.rpx, + letterSpacing: 0.0, + color: themeController + .currentColor.sc3, + ), + maxLines: 1, + overflow: + TextOverflow.ellipsis, + ), + Text( + '${widget.data['person']?['weight'] ?? '未知数据'.tr}kg', + style: TextStyle( + fontFamily: 'Inter', + fontSize: 26.rpx, + letterSpacing: 0.0, + color: themeController + .currentColor.sc3, + ), + ), + ].divide( + SizedBox(height: 34.rpx)), + ), + ] + .divide(SizedBox(width: 33.rpx)) + .addToStart( + SizedBox(width: 37.rpx)), + ), + ] + .addToStart(SizedBox(height: 36.rpx)) + .addToEnd(SizedBox(height: 36.rpx)), + ), + ), + ], + ), + ), + ), + (sleepReport.value == null || sleepReport.value.isEmpty) + ? Container( + child: NullDataWidget(), + ) + : (sleepReportController.model.type == 1 + ? DailyDataWidget( + sleepReport, + sleepCardKey, + heartRateCardKey, + breatheCardKey, + widget.data) + : sleepReportController.model.type == 2 + ? WeekDataWidget(sleepReport, widget.data) + : sleepReportController.model.type == 3 + ? MonthDataWidget( + sleepReport, widget.data) + : NullDataWidget()), + ].divide(SizedBox( + height: 25.rpx, + )), + ), + ); + } + }), ), ), ),