diff --git a/assets/mhlangs/zh_CN.json b/assets/mhlangs/zh_CN.json index 25c0184..9f59b40 100644 --- a/assets/mhlangs/zh_CN.json +++ b/assets/mhlangs/zh_CN.json @@ -78,13 +78,92 @@ "蓝牙连接成功":"蓝牙连接成功", "蓝牙连接失败":"蓝牙连接失败,请重试", "绑定失败请重试":"绑定失败请重试", - "无法绑定":"无法绑定!", + "无法绑定":"无法绑定!", + "无法绑定1":"检测到该设备", + "无法绑定2":"已被绑定", + "无法绑定3":",绑定前请先进行解绑,有疑问请联系客服", + "蓝牙绑定":{ + "标题":"蓝牙绑定", + "扫描":"扫描蓝牙设备中…", + "信号":"最小信号强度", + "搜索提示":"检索设备", + "搜索":"搜索", + "匹配":"匹配出的外围设备", + "信号强度":"信号强度", + "SN":"SN", + "蓝牙地址":"蓝牙地址", + "mac":"mac", + "网络":"网络", + "在线":"在线", + "离线":"离线", + "版本":"版本", + "默认设备名称":"未知设备", + "传感器":"传感器", + "可绑定":"可绑定", + "已被绑定":"已被绑定", + "双人版绑定标题":"该设备为双人版,请选择", + "绑定全部":"绑定全部", + "主设备":"主设备:", + "从设备":"从设备:", + "确定":"确定", + "取消":"取消", + "无法绑定":"无法绑定!", "无法绑定1":"检测到该设备", "无法绑定2":"已被绑定", - "无法绑定3":",绑定前请先进行解绑,有疑问请联系客服" - - - - - + "无法绑定3":",绑定前请先进行解绑,有疑问请联系客服", + "知道了":"知道了", + "是":"是", + "否":"否", + "确定绑定提示":"确定绑定该设备吗?", + "连接成功":"蓝牙连接成功", + "连接异常":"蓝牙连接异常", + "连接":"连接", + "输入wifi密码":"请输入wifi密码", + "显示密码":"显示", + "不显示密码":"不显示" + }, + "wifi页":{ + "标题":"WIFI配置", + "跳过":"下一步", + "WLAN":"网络", + "未连接":"未连接", + "已连接":"已连接", + "可用WLAN":"可用WLAN", + "刷新":"刷新", + "密码为空":"密码不能为空", + "配网成功":"配网成功", + "配网失败":"配网失败", + "配网中":"配网中", + "需配网":"请给设备配置网络!" + }, + "设备校准":"设备校准", + "离床校准":"离床校准", + "未完成":"未完成", + "已完成":"已完成", + "位置校准":"位置校准", + "床头":"床头", + "离床校准提示":"请校准人员暂时离开床铺且在校准期间保持周围安静", + "位置校准提示":"请校准人员到箭头指定一侧 平躺后点击开始,保持10秒", + "开始校准":"开始校准", + "校准完成":"校准完成!", + "绑定成功":{ + "标题":"绑定完成", + "绑定成功":"配置成功! ", + "分享标题":"是否进行分享?", + "分享内容":"设备绑定成功后,如需对朋友或家人共享我的睡眠情况,可以进行立即分享,分享成功后,对方即可享受查看该设备权限,可以收到该设备的睡眠报告。", + "立即分享":"立即分享", + "返回":"返回" + }, + "设置页":{ + "标题":"设置", + "主题模式":"主题模式", + "选择语言":"选择语言", + "关于我们":"关于我们", + "用户协议":"用户协议", + "隐私协议":"隐私协议", + "退出登录":"退出登录", + "注销账号":"注销账号", + "退出成功":"退出成功", + "退出失败":"退出失败" + } } \ No newline at end of file diff --git a/lib/common/color/ServiceConstant.dart b/lib/common/color/ServiceConstant.dart index ec1d3be..dd2002f 100644 --- a/lib/common/color/ServiceConstant.dart +++ b/lib/common/color/ServiceConstant.dart @@ -39,6 +39,7 @@ class ServiceConstant { static const String user_register = "/api/user/register";//用户注册 static const String user_forgot = "/api/user/forgot";//找回密码 static const String user_changePassword = "/api/user/changePassword";//修改密码 + static const String personnel_info = "/api/personnel/info";//人员信息列表 diff --git a/lib/common/color/appConstants.dart b/lib/common/color/appConstants.dart index 874fe5c..daf78d3 100644 --- a/lib/common/color/appConstants.dart +++ b/lib/common/color/appConstants.dart @@ -38,4 +38,10 @@ class AppConstants { stringToColor("D9F0E9"), // 浅蓝 stringToColor("CEECE3"), // 浅蓝 ]; + + List mhtNormalButton = [ + stringToColor("1592AA"), // 浅蓝 + stringToColor("0C83A7"), // 浅蓝 + stringToColor("006FA3"), // 浅蓝 + ]; } diff --git a/lib/component/base/SleepCalendarWidget.dart b/lib/component/base/SleepCalendarWidget.dart index b23fcf3..06d920a 100644 --- a/lib/component/base/SleepCalendarWidget.dart +++ b/lib/component/base/SleepCalendarWidget.dart @@ -123,7 +123,8 @@ class _SleepCalendarWidgetState extends State { constraints: BoxConstraints(minHeight: 720.rpx), decoration: const BoxDecoration(color: Color(0xFF242835)), child: Padding( - padding: EdgeInsetsDirectional.fromSTEB(65.rpx, 13.rpx, 65.rpx, 38.rpx), + // padding: EdgeInsetsDirectional.fromSTEB(65.rpx, 13.rpx, 65.rpx, 38.rpx), + padding: EdgeInsetsDirectional.fromSTEB(65.rpx, 0.rpx, 65.rpx, 0.rpx), child: Obx(() { final daysInMonth = calendarController.getDaysInMonth(); final calendarRows = calendarController.getCalendarRows(daysInMonth); diff --git a/lib/main.dart b/lib/main.dart index bb31a4b..3946ff4 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -341,6 +341,8 @@ class MyApp extends StatelessWidget { Get.lazyPut(() => MHTBlueToothController()), Get.lazyPut(() => MHTHomeController()), Get.lazyPut(() => MHTDeviceCalibrationController()), + Get.lazyPut(() => SleepReportController()), + Get.lazyPut(() => CalendarController()), ])); } diff --git a/lib/pages/mh_page/component/mht_bind_dialog.dart b/lib/pages/mh_page/component/mht_bind_dialog.dart index 1c22538..5a4a5ba 100644 --- a/lib/pages/mh_page/component/mht_bind_dialog.dart +++ b/lib/pages/mh_page/component/mht_bind_dialog.dart @@ -834,8 +834,8 @@ void showWifiDialog( Get.back(); }, child: Padding( - padding: - EdgeInsetsDirectional.fromSTEB(0, 33.rpx, 0, 0.rpx), + padding: EdgeInsetsDirectional.fromSTEB( + 20.rpx, 33.rpx, 20.rpx, 20.rpx), child: SvgPicture.asset( 'assets/img/icon/close.svg', width: 25.rpx, @@ -851,7 +851,7 @@ void showWifiDialog( alignment: AlignmentDirectional(0, 0), child: Padding( padding: - EdgeInsetsDirectional.fromSTEB(0.rpx, 40.rpx, 0, 0), + EdgeInsetsDirectional.fromSTEB(0.rpx, 20.rpx, 0, 0), child: Text( title, style: FlutterFlowTheme.of(context).bodyMedium.override( @@ -870,7 +870,7 @@ void showWifiDialog( mainAxisAlignment: MainAxisAlignment.center, children: [ CustomCard( - borderRadius: AppConstants().button_container_radius, + borderRadius: AppConstants().normal_container_radius, onTap: () { if (blueteethBindController.model.wifiPass == null || blueteethBindController.model.wifiPass!.isEmpty) { @@ -884,10 +884,8 @@ void showWifiDialog( Get.back(); } }, - colors: [ - themeController.currentColor.sc1, - themeController.currentColor.sc2, - ], + colors: AppConstants().mhtNormalButton, + gradientDirection: GradientDirection.vertical, child: Container( width: MediaQuery.sizeOf(context).width * 0.115, height: MediaQuery.sizeOf(context).height * 0.055, @@ -904,7 +902,7 @@ void showWifiDialog( style: FlutterFlowTheme.of(context) .bodyMedium .override( - color: stringToColor("#333333"), + color: Colors.white, fontFamily: 'Inter', fontSize: AppConstants().normal_text_fontSize, diff --git a/lib/pages/mh_page/device/component/DeviceComponentWidget.dart b/lib/pages/mh_page/device/component/DeviceComponentWidget.dart index 9582e67..4ec3b05 100644 --- a/lib/pages/mh_page/device/component/DeviceComponentWidget.dart +++ b/lib/pages/mh_page/device/component/DeviceComponentWidget.dart @@ -1,11 +1,9 @@ import 'dart:async'; import 'package:EasyDartModule/EasyDartModule.dart' as edm; -import 'package:EasyDartModule/base/logger/Logger.dart'; import 'package:easydevice/easydevice.dart'; import 'package:ef/ef.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:flutterflow_ui/flutterflow_ui.dart'; import 'package:vbvs_app/common/color/ServiceConstant.dart'; import 'package:vbvs_app/common/color/app_uri_status.dart'; @@ -16,7 +14,6 @@ import 'package:vbvs_app/common/util/requestWithLog.dart'; import 'package:vbvs_app/component/tool/ClickableContainer.dart'; import 'package:vbvs_app/component/tool/CustomCard.dart'; import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; -import 'package:vbvs_app/component/tool/cmd.dart'; import 'package:vbvs_app/controller/theme_controller/ThemeController.dart'; import 'package:vbvs_app/model/BleDeviceData.dart'; import 'package:vbvs_app/model/api_response.dart'; @@ -473,7 +470,6 @@ class _DeviceComponentWidgetState extends State { var read = bledevice.getresource('fff0/fff1'); await read!.characteristic.setNotifyValue(true); - var write = bledevice.getresource('fff0/fff2'); for (int attempt = 0; attempt < maxRetries; attempt++) { diff --git a/lib/pages/mh_page/device/component/mht_device_calibration_controller.dart b/lib/pages/mh_page/device/component/mht_device_calibration_controller.dart index 80a4b26..ce17d26 100644 --- a/lib/pages/mh_page/device/component/mht_device_calibration_controller.dart +++ b/lib/pages/mh_page/device/component/mht_device_calibration_controller.dart @@ -32,6 +32,7 @@ class MHTDeviceCalibrationController RxString tips = "".obs; RxInt flag = 0.obs; //0没有开始 1:校准中 2.校准完成 3.校准失败 RxString statusContext = "".obs; + RxBool another = false.obs; RxInt cd = 10000.obs; diff --git a/lib/pages/mh_page/device/mht_bind_device_type.dart b/lib/pages/mh_page/device/mht_bind_device_type.dart index 887f66b..7ceb25d 100644 --- a/lib/pages/mh_page/device/mht_bind_device_type.dart +++ b/lib/pages/mh_page/device/mht_bind_device_type.dart @@ -158,18 +158,25 @@ class _MHTBindDeviceTypePageState extends State { } Map data = { - "reg":reg, - "type":type, + "reg": reg, + "type": type, }; return CustomCard( borderRadius: 20.rpx, onTap: () { + if (type == 2) { + TopSlideNotification.show( + context, + text: "当前类型不支持绑定".tr, + ); + return; + } MHTBlueToothController mhtBlueToothController = Get.find(); mhtBlueToothController.model.deviceType = type.toInt(); Get.toNamed("/mHTBlueteethDevicePage", arguments: data); }, colors: [Colors.white], - child: Container( + child: Container( width: double.infinity, height: MediaQuery.sizeOf(context).height * 0.135, constraints: BoxConstraints(minHeight: 220.rpx), diff --git a/lib/pages/mh_page/device/mht_device_calibration copy.dart b/lib/pages/mh_page/device/mht_device_calibration copy.dart new file mode 100644 index 0000000..41df839 --- /dev/null +++ b/lib/pages/mh_page/device/mht_device_calibration copy.dart @@ -0,0 +1,1057 @@ +import 'dart:async'; + +import 'package:ef/ef.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:flutterflow_ui/flutterflow_ui.dart'; +import 'package:vbvs_app/common/color/ServiceConstant.dart'; +import 'package:vbvs_app/common/color/appConstants.dart'; +import 'package:vbvs_app/common/util/FitTool.dart'; +import 'package:vbvs_app/common/util/MyUtils.dart'; +import 'package:vbvs_app/common/util/requestWithLog.dart'; +import 'package:vbvs_app/component/tool/ClickableContainer.dart'; +import 'package:vbvs_app/component/tool/CustomCard.dart'; +import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; +import 'package:vbvs_app/pages/device_bind/componnet/CalibrationProgressWidget.dart'; +import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart'; +import 'package:vbvs_app/pages/mh_page/device/component/mht_device_calibration_controller.dart'; +import 'package:vbvs_app/pages/mh_page/device/controller/mht_bluetooth_controller.dart'; + +class MHTCalibrationPageCopy extends StatefulWidget { + MHTCalibrationPageCopy({super.key}); + + @override + State createState() => _MHTCalibrationPageCopyState(); +} + +class _MHTCalibrationPageCopyState extends State { + MHTDeviceCalibrationController deviceCalibrationController = Get.find(); + MHTBlueToothController blueteethBindController = Get.find(); + final ValueNotifier progressNotifier = ValueNotifier(0.0); + final ValueNotifier failureNotifier = ValueNotifier(false); + Timer? _pollingTimer; + + bool exit = false; + @override + void initState() { + super.initState(); + deviceCalibrationController.process.value = 0; + deviceCalibrationController.cd.value = 10000; + deviceCalibrationController.flag.value = 0; + deviceCalibrationController.bed_calibration.value = 0; + deviceCalibrationController.position_calibration.value = 0; + blueteethBindController.cid!.value = ""; + deviceCalibrationController.motionTips.value = 0; + deviceCalibrationController.inBedTips.value = 0; + deviceCalibrationController.statusContext.value = ""; + deviceCalibrationController.bed_type.value = + (blueteethBindController.currentFullDevice?.macA?.isNotEmpty == true && + blueteethBindController.currentFullDevice?.macB?.isNotEmpty == + true) + ? 1 + : 0; + } + + @override + void dispose() { + _pollingTimer?.cancel(); + blueteethBindController.cid!.value = ""; + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return WillPopScope( + child: LayoutBuilder( + builder: (context, bodySize) => GestureDetector( + onTap: () => FocusScope.of(context).unfocus(), + child: Container( + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/images/new_background.png'), + fit: BoxFit.fill, + ), + ), + child: Scaffold( + backgroundColor: Colors.transparent, + appBar: AppBar( + backgroundColor: Colors.transparent, + automaticallyImplyLeading: false, + iconTheme: + IconThemeData(color: themeController.currentColor.sc3), + titleSpacing: 0, + title: Container( + width: double.infinity, + height: 180.rpx, + child: Stack( + alignment: Alignment.center, + children: [ + Text( + '设备校准'.tr, + style: TextStyle( + fontFamily: 'Readex Pro', + color: themeController.currentColor.sc3, + letterSpacing: 0, + fontSize: 30.rpx, + ), + ), + Positioned( + left: 0, + child: returnIconButtomAddCallback(() { + if (deviceCalibrationController.flag.value != 2) { + try { + showConfirmDialog( + context, Container(), "校准未完成提示".tr, + onConfirm: () async { + exit = true; + deviceCalibrationController.process.value = 0; + deviceCalibrationController + .bed_calibration.value = 0; + deviceCalibrationController + .position_calibration.value = 0; + blueteethBindController.cid!.value = ""; + Get.back(); + }, onCancel: () { + exit = false; + }); + } catch (e) { + print(e); + } + } else { + exit = true; + } + if (exit) { + Get.back(); + } + }, enableBack: exit), + ), + Positioned( + right: 20.rpx, + child: CustomCard( + borderRadius: 20.rpx, + onTap: () async { + if (deviceCalibrationController.flag.value != 2) { + showConfirmDialog( + context, Container(), "校准未完成提示".tr, + onConfirm: () async { + // await Get.toNamed("/personPage"); + Get.offNamed("/bindDeviceSuccess"); + deviceCalibrationController.process.value = 0; + deviceCalibrationController + .bed_calibration.value = 0; + deviceCalibrationController + .position_calibration.value = 0; + blueteethBindController.cid!.value = ""; + }, onCancel: () {}); + } else { + // await Get.toNamed("/personPage"); + Get.offNamed("/bindDeviceSuccess"); + deviceCalibrationController.process.value = 0; + deviceCalibrationController + .bed_calibration.value = 0; + deviceCalibrationController + .position_calibration.value = 0; + blueteethBindController.cid!.value = ""; + } + }, + colors: AppConstants().mhtButtongradientColors, + gradientDirection: GradientDirection.vertical, + child: Container( + width: 140.rpx, + height: 60.rpx, + alignment: Alignment.center, + padding: EdgeInsetsDirectional.fromSTEB( + 16.rpx, 0, 16.rpx, 0), + child: Text( + '下一步'.tr, + style: TextStyle( + fontFamily: 'Inter Tight', + color: stringToColor("#003058"), + letterSpacing: 0.0, + ), + ), + ), + ), + ), + ], + ), + ), + actions: [], + centerTitle: false, + ), + body: SafeArea( + top: true, + // child: Container(), + child: Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 30.rpx, 0.rpx, 30.rpx, 0.rpx), + child: Column( + mainAxisSize: MainAxisSize.max, + children: [ + Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 0.rpx, 30.rpx, 0, 0), + child: Container( + width: double.infinity, + decoration: BoxDecoration( + color: stringToColor("#003058"), + borderRadius: BorderRadius.circular(16.rpx), + ), + child: Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 10.rpx, 20.rpx, 34.rpx, 20.rpx), + child: Column( + mainAxisSize: MainAxisSize.max, + children: [ + ClickableContainer( + backgroundColor: Colors.transparent, + highlightColor: + themeController.currentColor.sc21, + borderRadius: 0, // 可按需设置圆角 + padding: EdgeInsets.symmetric( + vertical: 10.rpx), // 可自定义内边距 + onTap: () { + // deviceCalibrationController.process.value = 0; + // deviceCalibrationController.updateAll(); + }, + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Obx(() { + return Visibility( + maintainState: true, + maintainAnimation: true, + maintainSize: true, + visible: + deviceCalibrationController + .process.value == + 0, + child: SvgPicture.asset( + 'assets/img/icon/select_arrow.svg', + width: 17.rpx, + height: 17.rpx, + color: themeController + .currentColor.sc9, + ), + ); + }), + SizedBox(width: 8.rpx), + Text( + '离床校准'.tr, + style: TextStyle( + fontSize: 30.rpx, + letterSpacing: 0.0, + color: themeController + .currentColor.sc3, + ), + ), + ], + ), + Obx(() { + return Text( + deviceCalibrationController + .bed_calibration + .value == + 0 + ? '未完成'.tr + : "已完成".tr, + style: TextStyle( + fontSize: 26.rpx, + letterSpacing: 0.0, + color: deviceCalibrationController + .bed_calibration + .value == + 0 + ? themeController + .currentColor.sc3 + : themeController + .currentColor.sc1, + ), + ); + }), + ], + ), + ), + SizedBox(height: 41.rpx), + ClickableContainer( + backgroundColor: Colors.transparent, + highlightColor: + themeController.currentColor.sc21, + borderRadius: 0, // 可根据需要设为圆角 + padding: EdgeInsets.symmetric( + vertical: 10.rpx), // 可根据需要调整上下内边距 + onTap: () { + // deviceCalibrationController.process.value = 1; + // deviceCalibrationController.updateAll(); + }, + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Obx(() { + return Visibility( + maintainState: true, + maintainAnimation: true, + maintainSize: true, + visible: + deviceCalibrationController + .process.value == + 1, + child: SvgPicture.asset( + 'assets/img/icon/select_arrow.svg', + width: 17.rpx, + height: 17.rpx, + color: themeController + .currentColor.sc9, + ), + ); + }), + SizedBox(width: 8.rpx), + Text( + '位置校准'.tr, + style: TextStyle( + fontSize: 30.rpx, + letterSpacing: 0.0, + color: themeController + .currentColor.sc3, + ), + ), + ], + ), + Obx(() { + return Text( + deviceCalibrationController + .position_calibration + .value == + 0 + ? '未完成'.tr + : "已完成".tr, + style: TextStyle( + fontSize: 26.rpx, + letterSpacing: 0.0, + color: deviceCalibrationController + .position_calibration + .value == + 0 + ? themeController + .currentColor.sc3 + : themeController + .currentColor.sc1, + ), + ); + }), + ], + ), + ), + ], + ), + ), + ), + ), + Obx(() { + return Expanded( + child: SizedBox( + width: double.infinity, + child: Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 100.rpx, 55.rpx, 100.rpx, 0), + child: Stack( + clipBehavior: Clip.none, + children: [ + Container( + width: MediaQuery.sizeOf(context).width * + 0.65, + height: + MediaQuery.sizeOf(context).height * + 0.3, + child: Stack( + children: [ + Image.asset( + deviceCalibrationController + .process.value == + 1 && + deviceCalibrationController + .position_calibration + .value == + 1 + ? (deviceCalibrationController + .bed_type.value == + 0 + ? "assets/img/single_person.png" + : "assets/img/double_person.png") + : (deviceCalibrationController + .bed_type.value == + 0 + ? "assets/img/single_pillow.png" + : "assets/img/double_pillow.png"), + width: double.infinity, + height: double.infinity, + fit: BoxFit.contain, + ), + + // 床头文字 + Positioned( + top: 23.rpx, + left: (MediaQuery.sizeOf(context) + .width * + 0.65) / + 2 - + 26.rpx, + child: Text( + '床头'.tr, + style: TextStyle( + fontSize: 26.rpx, + color: themeController + .currentColor.sc4, + ), + ), + ), + ], + ), + ), + Obx(() { + final double centerLeft = + (bodySize.maxWidth * 0.56) / 2; + if (deviceCalibrationController + .bed_type.value == + 0 && + deviceCalibrationController + .process.value == + 1) { + //单人床位置校准 + return Positioned( + top: -40.rpx, + left: centerLeft - 0.rpx, + child: Container( + width: bodySize.maxWidth * 0.087, + height: bodySize.maxHeight * 0.06, + constraints: BoxConstraints( + minWidth: 65.rpx, + minHeight: 76.rpx, + ), + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage( + 'assets/img/tip_arrow.gif'), + fit: BoxFit.cover, + ), + ), + ), + ); + } + if (deviceCalibrationController + .bed_type.value == + 1 && + deviceCalibrationController + .process.value == + 1) { + //双人人床位置校准 + return Positioned( + top: -40.rpx, + left: (MediaQuery.sizeOf(context) + .width * + 0.65) * + 0.22 - + 0.rpx, + child: Container( + width: bodySize.maxWidth * 0.087, + height: bodySize.maxHeight * 0.06, + constraints: BoxConstraints( + minWidth: 65.rpx, + minHeight: 76.rpx, + ), + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage( + 'assets/img/tip_arrow.gif'), + fit: BoxFit.cover, + ), + ), + ), + ); + } + + return Container(); + }), + Positioned( + top: MediaQuery.sizeOf(context).height * + 0.3 + + 82.rpx, + left: 0, + right: 0, + child: Obx(() { + return Column( + children: [ + getBodyMontion(), + SizedBox( + height: 10.rpx, + ), + getInBedMontion(), + SizedBox( + height: 10.rpx, + ), + Text( + (deviceCalibrationController + .cd.value == + 10000) + ? ((deviceCalibrationController + .process + .value == + 0 && + deviceCalibrationController + .bed_calibration + .value == + 1) || + (deviceCalibrationController + .process + .value == + 1 && + deviceCalibrationController + .position_calibration + .value == + 1) + ? (deviceCalibrationController + .flag.value == + 2 + ? '校准完成'.tr + : "校准失败".tr) + : deviceCalibrationController + .statusContext + .value + .isEmpty == + true + ? (deviceCalibrationController + .process + .value == + 0 + ? '离床校准提示'.tr + : '位置校准提示'.tr) + : deviceCalibrationController + .statusContext + .value) + : "${deviceCalibrationController.cd.value}" + + "s后超时".tr, + style: TextStyle( + fontSize: 38.rpx, + letterSpacing: 0.0, + color: ((deviceCalibrationController + .process + .value == + 0 && + deviceCalibrationController + .bed_calibration + .value == + 1) || + (deviceCalibrationController + .process + .value == + 1 && + deviceCalibrationController + .position_calibration + .value == + 1)) && + (deviceCalibrationController + .flag.value == + 2) + ? themeController + .currentColor.sc1 + : themeController + .currentColor.sc9, + ), + ), + ], + ); + }), + ), + ], + ), + ), + ), + ); + }), + Obx(() { + if (deviceCalibrationController.flag.value == 1) { + return Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 100.rpx, 0.rpx, 100.rpx, 60.rpx), + child: CalibrationProgressWidget( + progressNotifier: progressNotifier, + failureNotifier: failureNotifier, + ), + ); + } + return Container(); + }), + Obx(() { + if (deviceCalibrationController.flag.value != 1) { + return Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 100.rpx, 0.rpx, 100.rpx, 60.rpx), + child: CustomCard( + borderRadius: AppConstants() + .normal_container_radius, + onTap: () async { + if (deviceCalibrationController.flag.value == + 2) { + deviceCalibrationController + .statusContext.value = ""; + deviceCalibrationController.flag.value = 1; + progressNotifier.value = 0; + failureNotifier.value = false; + deviceCalibrationController.process.value = + 0; + deviceCalibrationController + .bed_calibration.value = 0; + deviceCalibrationController + .position_calibration.value = 0; + + blueteethBindController.cid!.value = ""; + + deviceCalibrationController.process.value = + 0; + deviceCalibrationController + .bed_calibration.value = 0; + deviceCalibrationController + .position_calibration.value = 0; + blueteethBindController.cid!.value = ""; + String serviceAddress = + "https://caibration.he-info.cn"; + String calibrationApi = + ServiceConstant.start_calibration; + String progressApi = + ServiceConstant.calibration_process; + + String queryUrl = + "$serviceAddress$calibrationApi"; + + Timer? pollingTimer; + + Map data = { + "macA": blueteethBindController + .currentFullDevice!.macA, + }; + + // 是否是二次点击(有cid表示进行第二阶段) + bool isSecondStep = blueteethBindController + .cid?.value.isNotEmpty ?? + false; + + if (isSecondStep) { + data["id"] = + blueteethBindController.cid!.value; + } + + // 发起校准请求 + requestWithLog( + logTitle: "设备校准", + method: MyHttpMethod.post, + queryUrl: queryUrl, + data: data, + onSuccess: (res) { + if (!isSecondStep) { + // 保存第一次获取的 cid + String cid = + res.rawResponse.data['cid']; + blueteethBindController.cid!.value = + cid; + } + _startPollingProgress(serviceAddress, + progressApi, isSecondStep); + }, + onFailure: (res) { + deviceCalibrationController.flag.value = + 0; + blueteethBindController.cid!.value = ""; + blueteethBindController.updateAll(); + failureNotifier.value = true; + TopSlideNotification.show( + context, + text: res.msg ?? "服务器.失败".tr, + textColor: + themeController.currentColor.sc9, + ); + }, + ); + } else { + deviceCalibrationController.flag.value = 1; + progressNotifier.value = 0; + failureNotifier.value = false; + _pollingTimer?.cancel(); + String serviceAddress = + "https://caibration.he-info.cn"; + String calibrationApi = + ServiceConstant.start_calibration; + String progressApi = + ServiceConstant.calibration_process; + + String queryUrl = + "$serviceAddress$calibrationApi"; + + Map data = { + "macA": blueteethBindController + .currentFullDevice!.macA, + }; + + // 是否是二次点击(有cid表示进行第二阶段) + bool isSecondStep = blueteethBindController + .cid?.value.isNotEmpty ?? + false; + + if (isSecondStep) { + data["id"] = + blueteethBindController.cid!.value; + } else { + data["cancel"] = true; + } + + // 发起校准请求 + requestWithLog( + logTitle: "设备校准", + method: MyHttpMethod.post, + queryUrl: queryUrl, + data: data, + onSuccess: (res) { + if (!isSecondStep) { + // 保存第一次获取的 cid + String cid = + res.rawResponse.data['cid']; + blueteethBindController.cid!.value = + cid; + } + _startPollingProgress(serviceAddress, + progressApi, isSecondStep); + }, + onFailure: (res) { + deviceCalibrationController.flag.value = + 0; + blueteethBindController.cid!.value = ""; + blueteethBindController.updateAll(); + _pollingTimer?.cancel(); + failureNotifier.value = true; + TopSlideNotification.show( + context, + text: res.msg ?? "服务器.失败".tr, + textColor: + themeController.currentColor.sc9, + ); + }, + ); + } + }, + colors: AppConstants().mhtButtongradientColors, + gradientDirection: GradientDirection.vertical, + child: Container( + width: bodySize.maxWidth, + height: + MediaQuery.sizeOf(context).height * 0.055, + constraints: BoxConstraints( + minWidth: 500.rpx, + minHeight: 90.rpx, + ), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Obx(() { + if (deviceCalibrationController + .flag.value == + 0) { + return Text( + '开始校准'.tr, + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + color: + stringToColor("#003058"), + fontFamily: 'Inter', + fontSize: AppConstants() + .normal_text_fontSize, + letterSpacing: 0.0, + ), + ); + } + if (deviceCalibrationController + .flag.value == + 1) { + deviceCalibrationController + .statusContext.value = ""; + return Text( + '开始校准'.tr, + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + color: themeController + .currentColor.sc3, + fontFamily: 'Inter', + fontSize: AppConstants() + .normal_text_fontSize, + letterSpacing: 0.0, + ), + ); + } + if (deviceCalibrationController + .flag.value == + 2) { + return Text( + '重新校准'.tr, + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + color: themeController + .currentColor.sc3, + fontFamily: 'Inter', + fontSize: AppConstants() + .normal_text_fontSize, + letterSpacing: 0.0, + ), + ); + } + return Container(); + }), + ].divide(SizedBox( + width: 17.rpx, + )), + ), + ), + ), + ); + } + return Container(); + }), + ], + ), + ), + ), + ), + ), + ), + ), + onWillPop: () async { + bool exit = false; + if (deviceCalibrationController.flag.value != 2) { + showConfirmDialog(context, Container(), "校准未完成提示".tr, + onConfirm: () async { + exit = true; + // await Get.toNamed("/personPage"); + // print("object"); + deviceCalibrationController.process.value = 0; + deviceCalibrationController.bed_calibration.value = 0; + deviceCalibrationController.position_calibration.value = 0; + blueteethBindController.cid!.value = ""; + }, onCancel: () { + exit = false; + }); + } else { + exit = true; + } + return exit; + }); + } + + void _startPollingProgress( + String serviceAddress, String progressApi, bool isSecondStep) { + // 立即请求一次 + _requestProgress(serviceAddress, progressApi, isSecondStep); + + // 设置定时器每2秒请求一次 + _pollingTimer = Timer.periodic(Duration(seconds: 1), (_) { + _requestProgress(serviceAddress, progressApi, isSecondStep); + }); + } + + void _requestProgress( + String serviceAddress, String progressApi, bool isSecondStep) { + String cid = blueteethBindController.cid!.value; + String progressUrl = "$serviceAddress$progressApi?id=$cid"; + + requestWithLog( + logTitle: "设备校准进度", + method: MyHttpMethod.get, + queryUrl: progressUrl, + onSuccess: (res) { + final data = res.data; + double per = (data['per'] ?? 0).toDouble(); + int currStep = data['currStep'] ?? -1; + String tips = data['statusText'] ?? ''; + try { + if (data['mattress'] != null) { + deviceCalibrationController.inBedTips.value = + data['mattress']['inBed']; + deviceCalibrationController.motionTips.value = + data['mattress']['bm']; + } + } catch (e) { + print(e); + } + + if (data['status'] == null) { + //当前进程执行中,执行倒计时 + if (data['cd'] != null) { + int cd = data['cd'] ?? 0; + deviceCalibrationController.cd.value = cd; + deviceCalibrationController.statusContext.value = ""; + } + } else { + if (data['status'] == true) { + //当前步骤执行成功 + deviceCalibrationController.tips.value = ""; + deviceCalibrationController.cd.value = 10000; + if (isSecondStep) { + deviceCalibrationController.statusContext.value = + data['statusText']; + deviceCalibrationController.updateAll(); + } + } else { + deviceCalibrationController.statusContext.value = ""; + //当前步骤执行失败 + deviceCalibrationController.bed_calibration.value == 0; + _pollingTimer?.cancel(); + blueteethBindController.cid?.value = ""; + deviceCalibrationController.process.value = 0; + deviceCalibrationController.flag.value = 0; + deviceCalibrationController.tips.value = ""; + deviceCalibrationController.cd.value = 10000; + deviceCalibrationController.updateAll(); + TopSlideNotification.show( + context, + text: tips, + textColor: themeController.currentColor.sc9, + ); + return; + } + } + bool status = data['status'] ?? false; + + // 更新进度 + progressNotifier.value = per; + if (per != 100 && per != 20) { + deviceCalibrationController.tips.value = tips; + } else { + deviceCalibrationController.tips.value = ""; + } + deviceCalibrationController.updateAll(); + + if (!isSecondStep && per >= 20) { + // 第一步完成 + _pollingTimer?.cancel(); + progressNotifier.value = 100; + TopSlideNotification.show(context, text: tips); + deviceCalibrationController.process.value = 1; + deviceCalibrationController.bed_calibration.value = 1; + deviceCalibrationController.flag.value = 0; // 重置标志允许再次点击 + } else if (isSecondStep && per >= 100 && currStep == 5 && status) { + // 第二步完成 + _pollingTimer?.cancel(); + TopSlideNotification.show(context, text: "设备校准完成".tr); + deviceCalibrationController.bed_calibration.value = 1; + deviceCalibrationController.position_calibration.value = 1; + deviceCalibrationController.process.value = 1; + deviceCalibrationController.flag.value = 2; + progressNotifier.value = 0; // 重置进度条 + failureNotifier.value = false; // 重置失败状态 + updateDeviceBindStatus( + blueteethBindController.currentDeviceMac!.value); + } + }, + onFailure: (res) { + deviceCalibrationController.flag.value = 0; + _pollingTimer?.cancel(); + blueteethBindController.cid!.value = ""; + failureNotifier.value = true; + deviceCalibrationController.flag.value = 0; + deviceCalibrationController.cd.value = 10000; + TopSlideNotification.show( + context, + text: res.msg ?? "服务器.失败".tr, + textColor: themeController.currentColor.sc9, + ); + }, + ); + } + + getInBedMontion() { + if (deviceCalibrationController.cd.value == 10000) { + return Container(); + } + + if (deviceCalibrationController.process.value == 1) { + if (deviceCalibrationController.inBedTips.value == 0) { + return Text( + "请校准人员保持在床状态".tr, + style: TextStyle( + fontSize: AppConstants().normal_text_fontSize, + color: themeController.currentColor.sc9), + ); + } + } else { + if (deviceCalibrationController.inBedTips.value != 0) { + return Text( + "请校准人员暂时离开床铺".tr, + style: TextStyle( + fontSize: AppConstants().normal_text_fontSize, + color: themeController.currentColor.sc9), + ); + } + } + + return Container(); + } + + getBodyMontion() { + if (deviceCalibrationController.cd.value == 10000) { + return Container(); + } + if (deviceCalibrationController.process.value == 1) { + if (deviceCalibrationController.motionTips.value != 0) { + return Text( + "请保持身体静止".tr, + style: TextStyle( + fontSize: AppConstants().normal_text_fontSize, + color: themeController.currentColor.sc9), + ); + } + } + + return Container(); + } + + //更新设备绑定状态 + void updateDeviceBindStatus(String mac) { + String serviceAddress = ServiceConstant.service_address; + String serviceName = ServiceConstant.server_service; + String serviceApi = ServiceConstant.user_setting; + String type = "device_bind_status_$mac"; + String queryUrl = + "${serviceAddress}${serviceName}${serviceApi}?type=${type}"; + requestWithLog( + logTitle: "查询绑定流程", + method: MyHttpMethod.get, + queryUrl: queryUrl, + onSuccess: (res) { + print(res); + Map data = { + "type": type, + "mac": mac, + "wifi": res.data['wifi'], + "celibration": true, + "person_info": false, + "time": DateTime.now().millisecondsSinceEpoch, + }; + requestWithLog( + logTitle: "更新绑定流程", + method: MyHttpMethod.put, + queryUrl: queryUrl, + data: data, + onSuccess: (res) {}, + onFailure: (res) {}, + ); + }, + onFailure: (res) {}, + ); + } +} diff --git a/lib/pages/mh_page/device/mht_device_calibration.dart b/lib/pages/mh_page/device/mht_device_calibration.dart index e7f742d..3c2b807 100644 --- a/lib/pages/mh_page/device/mht_device_calibration.dart +++ b/lib/pages/mh_page/device/mht_device_calibration.dart @@ -18,32 +18,26 @@ import 'package:vbvs_app/pages/mh_page/device/component/mht_device_calibration_c import 'package:vbvs_app/pages/mh_page/device/controller/mht_bluetooth_controller.dart'; class MHTCalibrationPage extends StatefulWidget { - MHTCalibrationPage({super.key}); + const MHTCalibrationPage({super.key}); @override State createState() => _MHTCalibrationPageState(); } class _MHTCalibrationPageState extends State { - MHTDeviceCalibrationController deviceCalibrationController = Get.find(); - MHTBlueToothController blueteethBindController = Get.find(); + final MHTDeviceCalibrationController deviceCalibrationController = Get.find(); + final MHTBlueToothController blueteethBindController = Get.find(); final ValueNotifier progressNotifier = ValueNotifier(0.0); final ValueNotifier failureNotifier = ValueNotifier(false); Timer? _pollingTimer; bool exit = false; + final currentCalibrationStep = 0.obs; // 0:离床校准 1:A侧位置校准 2:B侧位置校准 + @override void initState() { super.initState(); - deviceCalibrationController.process.value = 0; - deviceCalibrationController.cd.value = 10000; - deviceCalibrationController.flag.value = 0; - deviceCalibrationController.bed_calibration.value = 0; - deviceCalibrationController.position_calibration.value = 0; - blueteethBindController.cid!.value = ""; - deviceCalibrationController.motionTips.value = 0; - deviceCalibrationController.inBedTips.value = 0; - deviceCalibrationController.statusContext.value = ""; + _resetCalibrationState(); deviceCalibrationController.bed_type.value = (blueteethBindController.currentFullDevice?.macA?.isNotEmpty == true && blueteethBindController.currentFullDevice?.macB?.isNotEmpty == @@ -59,809 +53,695 @@ class _MHTCalibrationPageState extends State { super.dispose(); } + void _resetCalibrationState() { + deviceCalibrationController.process.value = 0; + deviceCalibrationController.cd.value = 10000; + deviceCalibrationController.flag.value = 0; + deviceCalibrationController.bed_calibration.value = 0; + deviceCalibrationController.position_calibration.value = 0; + blueteethBindController.cid!.value = ""; + deviceCalibrationController.motionTips.value = 0; + deviceCalibrationController.inBedTips.value = 0; + deviceCalibrationController.statusContext.value = ""; + currentCalibrationStep.value = 0; + deviceCalibrationController.another.value = false; + deviceCalibrationController.updateAll(); + } + @override Widget build(BuildContext context) { return WillPopScope( - child: LayoutBuilder( - builder: (context, bodySize) => GestureDetector( - onTap: () => FocusScope.of(context).unfocus(), - child: Container( - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage('assets/images/new_background.png'), - fit: BoxFit.fill, - ), + child: LayoutBuilder( + builder: (context, bodySize) => GestureDetector( + onTap: () => FocusScope.of(context).unfocus(), + child: Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/images/new_background.png'), + fit: BoxFit.fill, ), - child: Scaffold( + ), + child: Scaffold( + backgroundColor: Colors.transparent, + appBar: AppBar( backgroundColor: Colors.transparent, - appBar: AppBar( - backgroundColor: Colors.transparent, - automaticallyImplyLeading: false, - iconTheme: - IconThemeData(color: themeController.currentColor.sc3), - titleSpacing: 0, - title: Container( - width: double.infinity, - height: 180.rpx, - child: Stack( - alignment: Alignment.center, - children: [ - Text( - '设备校准'.tr, - style: TextStyle( - fontFamily: 'Readex Pro', - color: themeController.currentColor.sc3, - letterSpacing: 0, - fontSize: 30.rpx, - ), + automaticallyImplyLeading: false, + iconTheme: + IconThemeData(color: themeController.currentColor.sc3), + titleSpacing: 0, + title: Container( + width: double.infinity, + height: 180.rpx, + child: Stack( + alignment: Alignment.center, + children: [ + Text( + '设备校准'.tr, + style: TextStyle( + fontFamily: 'Readex Pro', + color: themeController.currentColor.sc3, + letterSpacing: 0, + fontSize: 30.rpx, ), - Positioned( - left: 0, - child: returnIconButtomAddCallback(() { + ), + Positioned( + left: 0, + child: returnIconButtomAddCallback(() { + if (deviceCalibrationController.flag.value != 2) { + try { + showConfirmDialog( + context, Container(), "校准未完成提示".tr, + onConfirm: () async { + exit = true; + _resetCalibrationState(); + Get.back(); + }, onCancel: () { + exit = false; + }); + } catch (e) { + print(e); + } + } else { + exit = true; + } + if (exit) { + Get.back(); + } + }, enableBack: exit), + ), + Positioned( + right: 20.rpx, + child: CustomCard( + borderRadius: 20.rpx, + onTap: () async { if (deviceCalibrationController.flag.value != 2) { - try { - showConfirmDialog( - context, Container(), "校准未完成提示".tr, - onConfirm: () async { - exit = true; - deviceCalibrationController.process.value = 0; - deviceCalibrationController - .bed_calibration.value = 0; - deviceCalibrationController - .position_calibration.value = 0; - blueteethBindController.cid!.value = ""; - Get.back(); - }, onCancel: () { - exit = false; - }); - } catch (e) { - print(e); - } - } else { - exit = true; - } - if (exit) { - Get.back(); - } - }, enableBack: exit), - ), - Positioned( - right: 20.rpx, - child: CustomCard( - borderRadius: 20.rpx, - onTap: () async { - if (deviceCalibrationController.flag.value != 2) { - showConfirmDialog( - context, Container(), "校准未完成提示".tr, - onConfirm: () async { - // await Get.toNamed("/personPage"); - Get.offNamed("/bindDeviceSuccess"); - deviceCalibrationController.process.value = 0; - deviceCalibrationController - .bed_calibration.value = 0; - deviceCalibrationController - .position_calibration.value = 0; - blueteethBindController.cid!.value = ""; - }, onCancel: () {}); - } else { - // await Get.toNamed("/personPage"); + showConfirmDialog( + context, Container(), "校准未完成提示".tr, + onConfirm: () async { Get.offNamed("/bindDeviceSuccess"); - deviceCalibrationController.process.value = 0; - deviceCalibrationController - .bed_calibration.value = 0; - deviceCalibrationController - .position_calibration.value = 0; - blueteethBindController.cid!.value = ""; - } - }, - colors: [ - stringToColor("#84F5FF"), - ], - child: Container( - width: 140.rpx, - height: 60.rpx, - alignment: Alignment.center, - padding: EdgeInsetsDirectional.fromSTEB( - 16.rpx, 0, 16.rpx, 0), - child: Text( - '下一步'.tr, - style: TextStyle( - fontFamily: 'Inter Tight', - color: stringToColor("#011D33"), - letterSpacing: 0.0, - ), - ), - ), - ), - ), - ], - ), - ), - actions: [], - centerTitle: false, - ), - body: SafeArea( - top: true, - // child: Container(), - child: Padding( - padding: EdgeInsetsDirectional.fromSTEB( - 30.rpx, 0.rpx, 30.rpx, 0.rpx), - child: Column( - mainAxisSize: MainAxisSize.max, - children: [ - Padding( - padding: EdgeInsetsDirectional.fromSTEB( - 0.rpx, 30.rpx, 0, 0), + _resetCalibrationState(); + }, onCancel: () {}); + } else { + Get.offNamed("/bindDeviceSuccess"); + _resetCalibrationState(); + } + }, + colors: AppConstants().mhtButtongradientColors, + gradientDirection: GradientDirection.vertical, child: Container( - width: double.infinity, - decoration: BoxDecoration( - color: stringToColor("#003058"), - borderRadius: BorderRadius.circular(16.rpx), - ), - child: Padding( - padding: EdgeInsetsDirectional.fromSTEB( - 10.rpx, 20.rpx, 34.rpx, 20.rpx), - child: Column( - mainAxisSize: MainAxisSize.max, - children: [ - ClickableContainer( - backgroundColor: Colors.transparent, - highlightColor: - themeController.currentColor.sc21, - borderRadius: 0, // 可按需设置圆角 - padding: EdgeInsets.symmetric( - vertical: 10.rpx), // 可自定义内边距 - onTap: () { - // deviceCalibrationController.process.value = 0; - // deviceCalibrationController.updateAll(); - }, - child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - Obx(() { - return Visibility( - maintainState: true, - maintainAnimation: true, - maintainSize: true, - visible: - deviceCalibrationController - .process.value == - 0, - child: SvgPicture.asset( - 'assets/img/icon/select_arrow.svg', - width: 17.rpx, - height: 17.rpx, - color: themeController - .currentColor.sc9, - ), - ); - }), - SizedBox(width: 8.rpx), - Text( - '离床校准'.tr, - style: TextStyle( - fontSize: 30.rpx, - letterSpacing: 0.0, - color: themeController - .currentColor.sc3, - ), - ), - ], - ), - Obx(() { - return Text( - deviceCalibrationController - .bed_calibration - .value == - 0 - ? '未完成'.tr - : "已完成".tr, - style: TextStyle( - fontSize: 26.rpx, - letterSpacing: 0.0, - color: deviceCalibrationController - .bed_calibration - .value == - 0 - ? themeController - .currentColor.sc3 - : themeController - .currentColor.sc1, - ), - ); - }), - ], - ), - ), - SizedBox(height: 41.rpx), - ClickableContainer( - backgroundColor: Colors.transparent, - highlightColor: - themeController.currentColor.sc21, - borderRadius: 0, // 可根据需要设为圆角 - padding: EdgeInsets.symmetric( - vertical: 10.rpx), // 可根据需要调整上下内边距 - onTap: () { - // deviceCalibrationController.process.value = 1; - // deviceCalibrationController.updateAll(); - }, - child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - Obx(() { - return Visibility( - maintainState: true, - maintainAnimation: true, - maintainSize: true, - visible: - deviceCalibrationController - .process.value == - 1, - child: SvgPicture.asset( - 'assets/img/icon/select_arrow.svg', - width: 17.rpx, - height: 17.rpx, - color: themeController - .currentColor.sc9, - ), - ); - }), - SizedBox(width: 8.rpx), - Text( - '位置校准'.tr, - style: TextStyle( - fontSize: 30.rpx, - letterSpacing: 0.0, - color: themeController - .currentColor.sc3, - ), - ), - ], - ), - Obx(() { - return Text( - deviceCalibrationController - .position_calibration - .value == - 0 - ? '未完成'.tr - : "已完成".tr, - style: TextStyle( - fontSize: 26.rpx, - letterSpacing: 0.0, - color: deviceCalibrationController - .position_calibration - .value == - 0 - ? themeController - .currentColor.sc3 - : themeController - .currentColor.sc1, - ), - ); - }), - ], - ), - ), - ], + width: 140.rpx, + height: 60.rpx, + alignment: Alignment.center, + padding: EdgeInsetsDirectional.fromSTEB( + 16.rpx, 0, 16.rpx, 0), + child: Text( + '下一步'.tr, + style: TextStyle( + fontFamily: 'Inter Tight', + color: stringToColor("#003058"), + letterSpacing: 0.0, ), ), ), ), - Obx(() { - return Expanded( - child: SizedBox( - width: double.infinity, - child: Padding( - padding: EdgeInsetsDirectional.fromSTEB( - 100.rpx, 55.rpx, 100.rpx, 0), - child: Stack( - clipBehavior: Clip.none, - children: [ - Container( - width: MediaQuery.sizeOf(context).width * - 0.65, - height: - MediaQuery.sizeOf(context).height * - 0.3, - child: Stack( + ), + ], + ), + ), + actions: [], + centerTitle: false, + ), + body: SafeArea( + top: true, + child: Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 30.rpx, 0.rpx, 30.rpx, 0.rpx), + child: Column( + mainAxisSize: MainAxisSize.max, + children: [ + Padding( + padding: + EdgeInsetsDirectional.fromSTEB(0.rpx, 30.rpx, 0, 0), + child: Container( + width: double.infinity, + decoration: BoxDecoration( + color: stringToColor("#003058"), + borderRadius: BorderRadius.circular(16.rpx), + ), + child: Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 10.rpx, 20.rpx, 34.rpx, 20.rpx), + child: Column( + mainAxisSize: MainAxisSize.max, + children: [ + ClickableContainer( + backgroundColor: Colors.transparent, + highlightColor: + themeController.currentColor.sc21, + borderRadius: 0, + padding: + EdgeInsets.symmetric(vertical: 10.rpx), + onTap: () {}, + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Row( children: [ - Image.asset( - deviceCalibrationController - .process.value == - 1 && - deviceCalibrationController - .position_calibration - .value == - 1 - ? (deviceCalibrationController - .bed_type.value == - 0 - ? "assets/img/single_person.png" - : "assets/img/double_person.png") - : (deviceCalibrationController - .bed_type.value == - 0 - ? "assets/img/single_pillow.png" - : "assets/img/double_pillow.png"), - width: double.infinity, - height: double.infinity, - fit: BoxFit.contain, - ), - - // 床头文字 - Positioned( - top: 23.rpx, - left: (MediaQuery.sizeOf(context) - .width * - 0.65) / - 2 - - 26.rpx, - child: Text( - '床头'.tr, - style: TextStyle( - fontSize: 26.rpx, + Obx(() { + return Visibility( + maintainState: true, + maintainAnimation: true, + maintainSize: true, + visible: + deviceCalibrationController + .process.value == + 0, + child: SvgPicture.asset( + 'assets/img/icon/select_arrow.svg', + width: 17.rpx, + height: 17.rpx, color: themeController - .currentColor.sc4, + .currentColor.sc9, ), + ); + }), + SizedBox(width: 8.rpx), + Text( + '离床校准'.tr, + style: TextStyle( + fontSize: 30.rpx, + letterSpacing: 0.0, + color: themeController + .currentColor.sc3, ), ), ], ), - ), - Obx(() { - final double centerLeft = - (bodySize.maxWidth * 0.56) / 2; - if (deviceCalibrationController - .bed_type.value == - 0 && + Obx(() { + return Text( deviceCalibrationController - .process.value == - 1) { - //单人床位置校准 - return Positioned( - top: -40.rpx, - left: centerLeft - 0.rpx, - child: Container( - width: bodySize.maxWidth * 0.087, - height: bodySize.maxHeight * 0.06, - constraints: BoxConstraints( - minWidth: 65.rpx, - minHeight: 76.rpx, - ), - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage( - 'assets/img/tip_arrow.gif'), - fit: BoxFit.cover, - ), - ), + .bed_calibration.value == + 0 + ? '未完成'.tr + : "已完成".tr, + style: TextStyle( + fontSize: 26.rpx, + letterSpacing: 0.0, + color: deviceCalibrationController + .bed_calibration + .value == + 0 + ? themeController + .currentColor.sc3 + : themeController + .currentColor.sc1, ), ); - } - if (deviceCalibrationController - .bed_type.value == - 1 && - deviceCalibrationController - .process.value == - 1) { - //双人人床位置校准 - return Positioned( - top: -40.rpx, - left: (MediaQuery.sizeOf(context) - .width * - 0.65) * - 0.22 - - 0.rpx, - child: Container( - width: bodySize.maxWidth * 0.087, - height: bodySize.maxHeight * 0.06, - constraints: BoxConstraints( - minWidth: 65.rpx, - minHeight: 76.rpx, - ), - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage( - 'assets/img/tip_arrow.gif'), - fit: BoxFit.cover, - ), - ), - ), - ); - } - - return Container(); - }), - Positioned( - top: MediaQuery.sizeOf(context).height * - 0.3 + - 82.rpx, - left: 0, - right: 0, - child: Obx(() { - return Column( - children: [ - getBodyMontion(), - SizedBox( - height: 10.rpx, - ), - getInBedMontion(), - SizedBox( - height: 10.rpx, - ), - Text( - (deviceCalibrationController - .cd.value == - 10000) - ? ((deviceCalibrationController - .process - .value == - 0 && - deviceCalibrationController - .bed_calibration - .value == - 1) || - (deviceCalibrationController - .process - .value == - 1 && - deviceCalibrationController - .position_calibration - .value == - 1) - ? (deviceCalibrationController - .flag.value == - 2 - ? '校准完成'.tr - : "校准失败".tr) - : deviceCalibrationController - .statusContext - .value - .isEmpty == - true - ? (deviceCalibrationController - .process - .value == - 0 - ? '离床校准提示'.tr - : '位置校准提示'.tr) - : deviceCalibrationController - .statusContext - .value) - : "${deviceCalibrationController.cd.value}" + - "s后超时".tr, - style: TextStyle( - fontSize: 38.rpx, - letterSpacing: 0.0, - color: ((deviceCalibrationController - .process - .value == - 0 && - deviceCalibrationController - .bed_calibration - .value == - 1) || - (deviceCalibrationController - .process - .value == - 1 && - deviceCalibrationController - .position_calibration - .value == - 1)) && - (deviceCalibrationController - .flag.value == - 2) - ? themeController - .currentColor.sc1 - : themeController - .currentColor.sc9, - ), - ), - ], - ); }), + ], + ), + ), + SizedBox(height: 41.rpx), + ClickableContainer( + backgroundColor: Colors.transparent, + highlightColor: + themeController.currentColor.sc21, + borderRadius: 0, + padding: + EdgeInsets.symmetric(vertical: 10.rpx), + onTap: () {}, + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Obx(() { + return Visibility( + maintainState: true, + maintainAnimation: true, + maintainSize: true, + visible: + deviceCalibrationController + .process.value == + 1, + child: SvgPicture.asset( + 'assets/img/icon/select_arrow.svg', + width: 17.rpx, + height: 17.rpx, + color: themeController + .currentColor.sc9, + ), + ); + }), + SizedBox(width: 8.rpx), + Text( + '位置校准'.tr, + style: TextStyle( + fontSize: 30.rpx, + letterSpacing: 0.0, + color: themeController + .currentColor.sc3, + ), + ), + ], + ), + Obx(() { + return Text( + deviceCalibrationController + .position_calibration + .value == + 0 + ? '未完成'.tr + : "已完成".tr, + style: TextStyle( + fontSize: 26.rpx, + letterSpacing: 0.0, + color: deviceCalibrationController + .position_calibration + .value == + 0 + ? themeController + .currentColor.sc3 + : themeController + .currentColor.sc1, + ), + ); + }), + ], + ), + ), + ], + ), + ), + ), + ), + Obx(() { + return Expanded( + child: SizedBox( + width: double.infinity, + child: Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 100.rpx, 55.rpx, 100.rpx, 0), + child: Stack( + clipBehavior: Clip.none, + children: [ + Container( + width: + MediaQuery.sizeOf(context).width * 0.65, + height: + MediaQuery.sizeOf(context).height * 0.3, + child: Stack( + children: [ + Image.asset( + deviceCalibrationController + .process.value == + 1 && + deviceCalibrationController + .position_calibration + .value == + 1 + ? (deviceCalibrationController + .bed_type.value == + 0 + ? "assets/img/single_person.png" + : "assets/img/double_person.png") + : (deviceCalibrationController + .bed_type.value == + 0 + ? "assets/img/single_pillow.png" + : "assets/img/double_pillow.png"), + width: double.infinity, + height: double.infinity, + fit: BoxFit.contain, + ), + Positioned( + top: 23.rpx, + left: (MediaQuery.sizeOf(context) + .width * + 0.65) / + 2 - + 26.rpx, + child: Text( + '床头'.tr, + style: TextStyle( + fontSize: 26.rpx, + color: themeController + .currentColor.sc4, + ), + ), + ), + ], ), - ], + ), + Obx(() { + final double centerLeft = + (bodySize.maxWidth * 0.56) / 2; + if (deviceCalibrationController + .bed_type.value == + 0 && + deviceCalibrationController + .process.value == + 1) { + return Positioned( + top: -40.rpx, + left: centerLeft - 0.rpx, + child: Container( + width: bodySize.maxWidth * 0.087, + height: bodySize.maxHeight * 0.06, + constraints: BoxConstraints( + minWidth: 65.rpx, + minHeight: 76.rpx, + ), + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage( + 'assets/img/tip_arrow.gif'), + fit: BoxFit.cover, + ), + ), + ), + ); + } + if (deviceCalibrationController + .bed_type.value == + 1 && + deviceCalibrationController + .process.value == + 1 && + deviceCalibrationController + .another.value == + false) { + return Positioned( + top: -40.rpx, + left: + (MediaQuery.sizeOf(context).width * + 0.65) * + 0.22 - + 0.rpx, + child: Container( + width: bodySize.maxWidth * 0.087, + height: bodySize.maxHeight * 0.06, + constraints: BoxConstraints( + minWidth: 65.rpx, + minHeight: 76.rpx, + ), + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage( + 'assets/img/tip_arrow.gif'), + fit: BoxFit.cover, + ), + ), + ), + ); + } + if (deviceCalibrationController + .bed_type.value == + 1 && + deviceCalibrationController + .process.value == + 1 && + deviceCalibrationController + .another.value == + true) { + return Positioned( + top: -40.rpx, + left: + (MediaQuery.sizeOf(context).width * + 0.65) * + 0.22 * + 3 - + 0.rpx, + child: Container( + width: bodySize.maxWidth * 0.087, + height: bodySize.maxHeight * 0.06, + constraints: BoxConstraints( + minWidth: 65.rpx, + minHeight: 76.rpx, + ), + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage( + 'assets/img/tip_arrow.gif'), + fit: BoxFit.cover, + ), + ), + ), + ); + } + return Container(); + }), + Positioned( + top: MediaQuery.sizeOf(context).height * + 0.3 + + 82.rpx, + left: 0, + right: 0, + child: Obx(() { + return Column( + children: [ + getBodyMontion(), + SizedBox(height: 10.rpx), + getInBedMontion(), + SizedBox(height: 10.rpx), + Text( + (deviceCalibrationController.cd.value == + 10000) + ? ((deviceCalibrationController.process.value == 0 && + deviceCalibrationController + .bed_calibration + .value == + 1) || + (deviceCalibrationController + .process + .value == + 1 && + deviceCalibrationController + .position_calibration + .value == + 1) + ? (deviceCalibrationController.flag.value == 2 + ? '校准完成'.tr + : (deviceCalibrationController.bed_type.value == 1 && currentCalibrationStep.value == 2 + ? '请开始B侧校准'.tr + : "校准失败".tr)) + : deviceCalibrationController + .statusContext + .value + .isEmpty == + true + ? (deviceCalibrationController.process.value == 0 + ? '离床校准提示'.tr + : (deviceCalibrationController.bed_type.value == 1 && currentCalibrationStep.value == 1 + ? '请校准人员到箭头指定一侧平躺 保持静止后点击开始,保持10秒' + .tr + : '位置校准提示'.tr)) + : deviceCalibrationController + .statusContext + .value) + : "${deviceCalibrationController.cd.value}" + + "s后超时".tr, + style: TextStyle( + fontSize: 38.rpx, + letterSpacing: 0.0, + color: ((deviceCalibrationController + .process + .value == + 0 && + deviceCalibrationController + .bed_calibration.value == + 1) || + (deviceCalibrationController + .process + .value == + 1 && + deviceCalibrationController + .position_calibration + .value == + 1)) + ? (deviceCalibrationController + .flag.value == + 2 + ? themeController + .currentColor.sc1 + : themeController + .currentColor.sc9) + : themeController + .currentColor.sc9, + ), + ), + ], + ); + }), + ), + ], + ), + ), + ), + ); + }), + Obx(() { + if (deviceCalibrationController.flag.value == 1) { + return Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 100.rpx, 0.rpx, 100.rpx, 60.rpx), + child: CalibrationProgressWidget( + progressNotifier: progressNotifier, + failureNotifier: failureNotifier, + ), + ); + } + return Container(); + }), + Obx(() { + if (deviceCalibrationController.flag.value != 1) { + return Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 100.rpx, 0.rpx, 100.rpx, 60.rpx), + child: CustomCard( + borderRadius: + AppConstants().normal_container_radius, + onTap: () async { + if (deviceCalibrationController.flag.value == + 2) { + _resetCalibrationState(); + deviceCalibrationController.flag.value = 1; + _startCalibration(false); + } else { + deviceCalibrationController.flag.value = 1; + progressNotifier.value = 0; + failureNotifier.value = false; + _pollingTimer?.cancel(); + _startCalibration(blueteethBindController + .cid?.value.isNotEmpty ?? + false); + } + }, + colors: AppConstants().mhtButtongradientColors, + gradientDirection: GradientDirection.vertical, + child: Container( + width: bodySize.maxWidth, + height: + MediaQuery.sizeOf(context).height * 0.055, + constraints: BoxConstraints( + minWidth: 500.rpx, + minHeight: 90.rpx, + ), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Obx(() { + if (deviceCalibrationController + .flag.value == + 0) { + if (deviceCalibrationController + .bed_type.value == + 1 && + currentCalibrationStep.value == 2) { + return Text( + '开始另外一侧校准'.tr, + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + color: + stringToColor("#003058"), + fontFamily: 'Inter', + fontSize: AppConstants() + .normal_text_fontSize, + letterSpacing: 0.0, + ), + ); + } + return Text( + '开始校准'.tr, + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + color: stringToColor("#003058"), + fontFamily: 'Inter', + fontSize: AppConstants() + .normal_text_fontSize, + letterSpacing: 0.0, + ), + ); + } + if (deviceCalibrationController + .flag.value == + 1) { + deviceCalibrationController + .statusContext.value = ""; + return Text( + '校准中...'.tr, + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + color: themeController + .currentColor.sc3, + fontFamily: 'Inter', + fontSize: AppConstants() + .normal_text_fontSize, + letterSpacing: 0.0, + ), + ); + } + if (deviceCalibrationController + .flag.value == + 2) { + return Text( + '重新校准'.tr, + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + color: stringToColor("#003058"), + fontFamily: 'Inter', + fontSize: AppConstants() + .normal_text_fontSize, + letterSpacing: 0.0, + ), + ); + } + return Container(); + }), + ].divide(SizedBox(width: 17.rpx)), ), ), ), ); - }), - Obx(() { - if (deviceCalibrationController.flag.value == 1) { - return Padding( - padding: EdgeInsetsDirectional.fromSTEB( - 100.rpx, 0.rpx, 100.rpx, 60.rpx), - child: CalibrationProgressWidget( - progressNotifier: progressNotifier, - failureNotifier: failureNotifier, - ), - ); - } - return Container(); - }), - Obx(() { - if (deviceCalibrationController.flag.value != 1) { - return Padding( - padding: EdgeInsetsDirectional.fromSTEB( - 100.rpx, 0.rpx, 100.rpx, 60.rpx), - child: CustomCard( - borderRadius: AppConstants() - .button_container_radius, // 圆角半径 - onTap: () async { - if (deviceCalibrationController.flag.value == - 2) { - deviceCalibrationController - .statusContext.value = ""; - deviceCalibrationController.flag.value = 1; - progressNotifier.value = 0; - failureNotifier.value = false; - deviceCalibrationController.process.value = - 0; - deviceCalibrationController - .bed_calibration.value = 0; - deviceCalibrationController - .position_calibration.value = 0; - - blueteethBindController.cid!.value = ""; - - deviceCalibrationController.process.value = - 0; - deviceCalibrationController - .bed_calibration.value = 0; - deviceCalibrationController - .position_calibration.value = 0; - blueteethBindController.cid!.value = ""; - String serviceAddress = - "https://caibration.he-info.cn"; - String calibrationApi = - ServiceConstant.start_calibration; - String progressApi = - ServiceConstant.calibration_process; - - String queryUrl = - "$serviceAddress$calibrationApi"; - - Timer? pollingTimer; - - Map data = { - "macA": blueteethBindController - .currentFullDevice!.macA, - }; - - // 是否是二次点击(有cid表示进行第二阶段) - bool isSecondStep = blueteethBindController - .cid?.value.isNotEmpty ?? - false; - - if (isSecondStep) { - data["id"] = - blueteethBindController.cid!.value; - } - - // 发起校准请求 - requestWithLog( - logTitle: "设备校准", - method: MyHttpMethod.post, - queryUrl: queryUrl, - data: data, - onSuccess: (res) { - if (!isSecondStep) { - // 保存第一次获取的 cid - String cid = - res.rawResponse.data['cid']; - blueteethBindController.cid!.value = - cid; - } - _startPollingProgress(serviceAddress, - progressApi, isSecondStep); - }, - onFailure: (res) { - deviceCalibrationController.flag.value = - 0; - blueteethBindController.cid!.value = ""; - blueteethBindController.updateAll(); - failureNotifier.value = true; - TopSlideNotification.show( - context, - text: res.msg ?? "服务器.失败".tr, - textColor: - themeController.currentColor.sc9, - ); - }, - ); - } else { - deviceCalibrationController.flag.value = 1; - progressNotifier.value = 0; - failureNotifier.value = false; - _pollingTimer?.cancel(); - String serviceAddress = - "https://caibration.he-info.cn"; - String calibrationApi = - ServiceConstant.start_calibration; - String progressApi = - ServiceConstant.calibration_process; - - String queryUrl = - "$serviceAddress$calibrationApi"; - - Map data = { - "macA": blueteethBindController - .currentFullDevice!.macA, - }; - - // 是否是二次点击(有cid表示进行第二阶段) - bool isSecondStep = blueteethBindController - .cid?.value.isNotEmpty ?? - false; - - if (isSecondStep) { - data["id"] = - blueteethBindController.cid!.value; - } else { - data["cancel"] = true; - } - - // 发起校准请求 - requestWithLog( - logTitle: "设备校准", - method: MyHttpMethod.post, - queryUrl: queryUrl, - data: data, - onSuccess: (res) { - if (!isSecondStep) { - // 保存第一次获取的 cid - String cid = - res.rawResponse.data['cid']; - blueteethBindController.cid!.value = - cid; - } - _startPollingProgress(serviceAddress, - progressApi, isSecondStep); - }, - onFailure: (res) { - deviceCalibrationController.flag.value = - 0; - blueteethBindController.cid!.value = ""; - blueteethBindController.updateAll(); - _pollingTimer?.cancel(); - failureNotifier.value = true; - TopSlideNotification.show( - context, - text: res.msg ?? "服务器.失败".tr, - textColor: - themeController.currentColor.sc9, - ); - }, - ); - } - }, - colors: [ - themeController.currentColor.sc1, - themeController.currentColor.sc2, - ], - child: Container( - width: bodySize.maxWidth, - height: - MediaQuery.sizeOf(context).height * 0.055, - constraints: BoxConstraints( - minWidth: 500.rpx, - minHeight: 90.rpx, - ), - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Obx(() { - if (deviceCalibrationController - .flag.value == - 0) { - return Text( - '开始校准'.tr, - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - color: themeController - .currentColor.sc3, - fontFamily: 'Inter', - fontSize: AppConstants() - .normal_text_fontSize, - letterSpacing: 0.0, - ), - ); - } - if (deviceCalibrationController - .flag.value == - 1) { - deviceCalibrationController - .statusContext.value = ""; - return Text( - '开始校准'.tr, - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - color: themeController - .currentColor.sc3, - fontFamily: 'Inter', - fontSize: AppConstants() - .normal_text_fontSize, - letterSpacing: 0.0, - ), - ); - } - if (deviceCalibrationController - .flag.value == - 2) { - return Text( - '重新校准'.tr, - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - color: themeController - .currentColor.sc3, - fontFamily: 'Inter', - fontSize: AppConstants() - .normal_text_fontSize, - letterSpacing: 0.0, - ), - ); - } - return Container(); - }), - ].divide(SizedBox( - width: 17.rpx, - )), - ), - ), - ), - ); - } - return Container(); - }), - ], - ), + } + return Container(); + }), + ], ), ), ), ), ), ), - onWillPop: () async { - bool exit = false; - if (deviceCalibrationController.flag.value != 2) { - showConfirmDialog(context, Container(), "校准未完成提示".tr, - onConfirm: () async { - exit = true; - // await Get.toNamed("/personPage"); - // print("object"); - deviceCalibrationController.process.value = 0; - deviceCalibrationController.bed_calibration.value = 0; - deviceCalibrationController.position_calibration.value = 0; - blueteethBindController.cid!.value = ""; - }, onCancel: () { - exit = false; - }); - } else { + ), + onWillPop: () async { + bool exit = false; + if (deviceCalibrationController.flag.value != 2) { + showConfirmDialog(context, Container(), "校准未完成提示".tr, + onConfirm: () async { exit = true; - } - return exit; - }); + _resetCalibrationState(); + }, onCancel: () { + exit = false; + }); + } else { + exit = true; + } + return exit; + }, + ); } void _startPollingProgress( String serviceAddress, String progressApi, bool isSecondStep) { - // 立即请求一次 _requestProgress(serviceAddress, progressApi, isSecondStep); - - // 设置定时器每2秒请求一次 _pollingTimer = Timer.periodic(Duration(seconds: 1), (_) { _requestProgress(serviceAddress, progressApi, isSecondStep); }); @@ -881,6 +761,7 @@ class _MHTCalibrationPageState extends State { double per = (data['per'] ?? 0).toDouble(); int currStep = data['currStep'] ?? -1; String tips = data['statusText'] ?? ''; + try { if (data['mattress'] != null) { deviceCalibrationController.inBedTips.value = @@ -893,7 +774,6 @@ class _MHTCalibrationPageState extends State { } if (data['status'] == null) { - //当前进程执行中,执行倒计时 if (data['cd'] != null) { int cd = data['cd'] ?? 0; deviceCalibrationController.cd.value = cd; @@ -901,7 +781,6 @@ class _MHTCalibrationPageState extends State { } } else { if (data['status'] == true) { - //当前步骤执行成功 deviceCalibrationController.tips.value = ""; deviceCalibrationController.cd.value = 10000; if (isSecondStep) { @@ -910,74 +789,148 @@ class _MHTCalibrationPageState extends State { deviceCalibrationController.updateAll(); } } else { - deviceCalibrationController.statusContext.value = ""; - //当前步骤执行失败 - deviceCalibrationController.bed_calibration.value == 0; - _pollingTimer?.cancel(); - blueteethBindController.cid?.value = ""; - deviceCalibrationController.process.value = 0; - deviceCalibrationController.flag.value = 0; - deviceCalibrationController.tips.value = ""; - deviceCalibrationController.cd.value = 10000; - deviceCalibrationController.updateAll(); - TopSlideNotification.show( - context, - text: tips, - textColor: themeController.currentColor.sc9, - ); + _handleCalibrationFailure(tips); return; } } - bool status = data['status'] ?? false; - // 更新进度 + bool status = data['status'] ?? false; progressNotifier.value = per; - if (per != 100 && per != 20) { + + if (per != 100 && per != 20 && per != 40) { deviceCalibrationController.tips.value = tips; } else { deviceCalibrationController.tips.value = ""; } deviceCalibrationController.updateAll(); - if (!isSecondStep && per >= 20) { - // 第一步完成 - _pollingTimer?.cancel(); - progressNotifier.value = 100; - TopSlideNotification.show(context, text: tips); - deviceCalibrationController.process.value = 1; - deviceCalibrationController.bed_calibration.value = 1; - deviceCalibrationController.flag.value = 0; // 重置标志允许再次点击 - } else if (isSecondStep && per >= 100 && currStep == 5 && status) { - // 第二步完成 - _pollingTimer?.cancel(); - TopSlideNotification.show(context, text: "设备校准完成".tr); - deviceCalibrationController.bed_calibration.value = 1; - deviceCalibrationController.position_calibration.value = 1; - deviceCalibrationController.process.value = 1; - deviceCalibrationController.flag.value = 2; - progressNotifier.value = 0; // 重置进度条 - failureNotifier.value = false; // 重置失败状态 - updateDeviceBindStatus( - blueteethBindController.currentDeviceMac!.value); + if (deviceCalibrationController.bed_type.value == 0) { + _handleSingleBedProgress(isSecondStep, per, currStep, status, tips); + } else { + _handleDoubleBedProgress(isSecondStep, per, currStep, status, tips); } }, onFailure: (res) { - deviceCalibrationController.flag.value = 0; - _pollingTimer?.cancel(); - blueteethBindController.cid!.value = ""; - failureNotifier.value = true; - deviceCalibrationController.flag.value = 0; - deviceCalibrationController.cd.value = 10000; - TopSlideNotification.show( - context, - text: res.msg ?? "服务器.失败".tr, - textColor: themeController.currentColor.sc9, - ); + _handleCalibrationFailure(res.msg ?? "服务器.失败".tr); }, ); } - getInBedMontion() { + void _handleSingleBedProgress( + bool isSecondStep, double per, int currStep, bool status, String tips) { + if (!isSecondStep && per >= 20) { + _pollingTimer?.cancel(); + progressNotifier.value = 100; + TopSlideNotification.show(context, text: tips); + deviceCalibrationController.process.value = 1; + deviceCalibrationController.bed_calibration.value = 1; + deviceCalibrationController.flag.value = 0; + currentCalibrationStep.value = 1; + } else if (isSecondStep && per >= 100 && currStep == 5 && status) { + _completeCalibration(); + } + } + + void _handleDoubleBedProgress( + bool isSecondStep, double per, int currStep, bool status, String tips) { + if (!isSecondStep && per >= 20) { + _pollingTimer?.cancel(); + progressNotifier.value = 100; + TopSlideNotification.show(context, text: tips); + deviceCalibrationController.process.value = 1; + deviceCalibrationController.bed_calibration.value = 1; + deviceCalibrationController.flag.value = 0; + currentCalibrationStep.value = 1; + } else if (isSecondStep && per >= 40 && currentCalibrationStep.value == 1) { + _pollingTimer?.cancel(); + TopSlideNotification.show(context, text: "单侧校准完成,请移动到另外一侧".tr); + deviceCalibrationController.flag.value = 0; + currentCalibrationStep.value = 2; + progressNotifier.value = 0; + failureNotifier.value = false; + deviceCalibrationController.another.value = true; + } else if (isSecondStep && + per >= 100 && + currStep == 5 && + status && + currentCalibrationStep.value == 2) { + _completeCalibration(); + } + } + + void _completeCalibration() { + _pollingTimer?.cancel(); + TopSlideNotification.show(context, text: "设备校准完成".tr); + deviceCalibrationController.bed_calibration.value = 1; + deviceCalibrationController.position_calibration.value = 1; + deviceCalibrationController.process.value = 1; + deviceCalibrationController.flag.value = 2; + deviceCalibrationController.another.value = false; + progressNotifier.value = 0; + failureNotifier.value = false; + updateDeviceBindStatus(blueteethBindController.currentDeviceMac!.value); + } + + void _handleCalibrationFailure(String message) { + _pollingTimer?.cancel(); + deviceCalibrationController.statusContext.value = ""; + deviceCalibrationController.bed_calibration.value == 0; + blueteethBindController.cid?.value = ""; + deviceCalibrationController.process.value = 0; + deviceCalibrationController.flag.value = 0; + deviceCalibrationController.tips.value = ""; + deviceCalibrationController.cd.value = 10000; + deviceCalibrationController.updateAll(); + failureNotifier.value = true; + TopSlideNotification.show( + context, + text: message, + textColor: themeController.currentColor.sc9, + ); + } + + void _startCalibration(bool isSecondStep) { + String serviceAddress = "https://caibration.he-info.cn"; + String calibrationApi = ServiceConstant.start_calibration; + String progressApi = ServiceConstant.calibration_process; + + String queryUrl = "$serviceAddress$calibrationApi"; + + Map data = { + "macA": blueteethBindController.currentFullDevice!.macA, + }; + + if (deviceCalibrationController.bed_type.value == 1) { + data["macB"] = + blueteethBindController.currentFullDevice!.macB.toUpperCase(); + } + + if (isSecondStep) { + data["id"] = blueteethBindController.cid!.value; + if (deviceCalibrationController.bed_type.value == 1) { + data["side"] = currentCalibrationStep.value == 1 ? "A" : "B"; + } + } + + requestWithLog( + logTitle: "设备校准", + method: MyHttpMethod.post, + queryUrl: queryUrl, + data: data, + onSuccess: (res) { + if (!isSecondStep) { + String cid = res.rawResponse.data['cid']; + blueteethBindController.cid!.value = cid; + } + _startPollingProgress(serviceAddress, progressApi, isSecondStep); + }, + onFailure: (res) { + _handleCalibrationFailure(res.msg ?? "服务器.失败".tr); + }, + ); + } + + Widget getInBedMontion() { if (deviceCalibrationController.cd.value == 10000) { return Container(); } @@ -987,8 +940,9 @@ class _MHTCalibrationPageState extends State { return Text( "请校准人员保持在床状态".tr, style: TextStyle( - fontSize: AppConstants().normal_text_fontSize, - color: themeController.currentColor.sc9), + fontSize: AppConstants().normal_text_fontSize, + color: themeController.currentColor.sc9, + ), ); } } else { @@ -996,8 +950,9 @@ class _MHTCalibrationPageState extends State { return Text( "请校准人员暂时离开床铺".tr, style: TextStyle( - fontSize: AppConstants().normal_text_fontSize, - color: themeController.currentColor.sc9), + fontSize: AppConstants().normal_text_fontSize, + color: themeController.currentColor.sc9, + ), ); } } @@ -1005,7 +960,7 @@ class _MHTCalibrationPageState extends State { return Container(); } - getBodyMontion() { + Widget getBodyMontion() { if (deviceCalibrationController.cd.value == 10000) { return Container(); } @@ -1014,16 +969,15 @@ class _MHTCalibrationPageState extends State { return Text( "请保持身体静止".tr, style: TextStyle( - fontSize: AppConstants().normal_text_fontSize, - color: themeController.currentColor.sc9), + fontSize: AppConstants().normal_text_fontSize, + color: themeController.currentColor.sc9, + ), ); } } - return Container(); } - //更新设备绑定状态 void updateDeviceBindStatus(String mac) { String serviceAddress = ServiceConstant.service_address; String serviceName = ServiceConstant.server_service; @@ -1031,12 +985,12 @@ class _MHTCalibrationPageState extends State { String type = "device_bind_status_$mac"; String queryUrl = "${serviceAddress}${serviceName}${serviceApi}?type=${type}"; + requestWithLog( logTitle: "查询绑定流程", method: MyHttpMethod.get, queryUrl: queryUrl, onSuccess: (res) { - print(res); Map data = { "type": type, "mac": mac, diff --git a/lib/pages/mh_page/device/mht_wifi_page.dart b/lib/pages/mh_page/device/mht_wifi_page.dart index 77899b8..e2a5d95 100644 --- a/lib/pages/mh_page/device/mht_wifi_page.dart +++ b/lib/pages/mh_page/device/mht_wifi_page.dart @@ -205,11 +205,10 @@ class _MHTWifiPageState extends State { Positioned( right: 20.rpx, child: CustomCard( + gradientDirection: GradientDirection.vertical, borderRadius: 20.rpx, onTap: _navigateToNextPage, - colors: [ - stringToColor("#84F5FF"), - ], + colors: AppConstants().mhtButtongradientColors, child: Container( width: 130.rpx, height: 60.rpx, @@ -222,7 +221,7 @@ class _MHTWifiPageState extends State { .titleSmall .override( fontFamily: 'Inter Tight', - color: stringToColor("#011D33"), + color: stringToColor("#003058"), letterSpacing: 0.0, ), ), diff --git a/lib/pages/mh_page/homepage/controller/mht_home_controller.dart b/lib/pages/mh_page/homepage/controller/mht_home_controller.dart index 93011f9..68cd1ac 100644 --- a/lib/pages/mh_page/homepage/controller/mht_home_controller.dart +++ b/lib/pages/mh_page/homepage/controller/mht_home_controller.dart @@ -8,6 +8,7 @@ import 'package:vbvs_app/common/color/ServiceConstant.dart'; import 'package:vbvs_app/common/color/app_uri_status.dart'; import 'package:vbvs_app/common/util/DailyLogUtils.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; +import 'package:vbvs_app/common/util/requestWithLog.dart'; import 'package:vbvs_app/model/api_response.dart'; part 'mht_home_controller.g.dart'; // 由json_serializable自动生成的部分 @@ -38,11 +39,14 @@ class MHTHomeController extends GetControllerEx { RxInt bindDeviceNum = 0.obs; //设备数量 RxMap deviceList = {}.obs; //设备列表 - RxMap> sleepReportData = >{}.obs; + RxMap> sleepReportData = + >{}.obs; //睡眠报告 + RxList personnelList = [].obs; //人员信息列表 RxString keyWord = "".obs; String wifiMac = ""; + var sleepDays = [].obs; Future getDeviceNum() async { try { @@ -194,95 +198,95 @@ class MHTHomeController extends GetControllerEx { return ApiResponse(code: -1, msg: "未知错误".tr); // Default return statement } - Future getSleepReport() async { - try { - sleepReportData.value = {}; - ApiResponse>> apiResponse = ApiResponse( - code: -1, - msg: "请求失败".tr, - ); + // Future getSleepReport() async { + // try { + // sleepReportData.value = {}; + // ApiResponse>> apiResponse = ApiResponse( + // code: -1, + // msg: "请求失败".tr, + // ); - if (deviceList.value.isEmpty) { - return ApiResponse( - code: HttpStatusCodes.ok, - msg: "请求成功".tr, - ); - } + // if (deviceList.value.isEmpty) { + // return ApiResponse( + // code: HttpStatusCodes.ok, + // msg: "请求成功".tr, + // ); + // } - String serviceAddress = ServiceConstant.service_address; - String serviceName = ServiceConstant.server_service; - String serviceApi = ServiceConstant.sleep_report; + // String serviceAddress = ServiceConstant.service_address; + // String serviceName = ServiceConstant.server_service; + // String serviceApi = ServiceConstant.sleep_report; - // for (var device in deviceList.value) { - // String mac = device['mac'] ?? ""; - // if (mac.isEmpty) continue; + // // for (var device in deviceList.value) { + // // String mac = device['mac'] ?? ""; + // // if (mac.isEmpty) continue; - // sleepReportData[mac] = []; // 初始化当前设备的数据列表 + // // sleepReportData[mac] = []; // 初始化当前设备的数据列表 - // String queryUrl = - // "$serviceAddress$serviceName$serviceApi?mac=$mac&time=${DateTime.now().millisecondsSinceEpoch}"; + // // String queryUrl = + // // "$serviceAddress$serviceName$serviceApi?mac=$mac&time=${DateTime.now().millisecondsSinceEpoch}"; - // try { - // String? language = ""; - // if (languageController.selectLanguage != null) { - // language = languageController.selectLanguage.value!.language_code; - // } - // if (language != null && language.isNotEmpty) { - // if (queryUrl.contains("?")) { - // queryUrl += "&lang=$language"; - // } else { - // queryUrl += "?lang=$language"; - // } - // } - // var response = await EasyDartModule.dio.get(queryUrl); - // if (response != null) { - // var responseData = response.data is String - // ? jsonDecode(response.data) - // : response.data; + // // try { + // // String? language = ""; + // // if (languageController.selectLanguage != null) { + // // language = languageController.selectLanguage.value!.language_code; + // // } + // // if (language != null && language.isNotEmpty) { + // // if (queryUrl.contains("?")) { + // // queryUrl += "&lang=$language"; + // // } else { + // // queryUrl += "?lang=$language"; + // // } + // // } + // // var response = await EasyDartModule.dio.get(queryUrl); + // // if (response != null) { + // // var responseData = response.data is String + // // ? jsonDecode(response.data) + // // : response.data; - // ApiResponse res = - // ApiResponse.fromJson(responseData, (object) => object); + // // ApiResponse res = + // // ApiResponse.fromJson(responseData, (object) => object); - // if (res.code == HttpStatusCodes.ok && res.data != null) { - // // 确保数据是一个列表 - // if (res.data is List) { - // sleepReportData[mac] = List.from(res.data); - // } else { - // sleepReportData[mac] = [res.data]; - // } - // } - // } - // } catch (e) { - // EasyDartModule.logger.warning("请求设备 $mac 的睡眠数据失败: $e"); - // } - // } - if (sleepReportData.value.isNotEmpty) { - // 遍历 Map 中的每一个键值对 - sleepReportData.value.forEach((key, report) { - // 确保 report 列表不为空 - if (report.isNotEmpty) { - // 获取该列表的最后一个元素 - var lastElement = report.last; + // // if (res.code == HttpStatusCodes.ok && res.data != null) { + // // // 确保数据是一个列表 + // // if (res.data is List) { + // // sleepReportData[mac] = List.from(res.data); + // // } else { + // // sleepReportData[mac] = [res.data]; + // // } + // // } + // // } + // // } catch (e) { + // // EasyDartModule.logger.warning("请求设备 $mac 的睡眠数据失败: $e"); + // // } + // // } + // if (sleepReportData.value.isNotEmpty) { + // // 遍历 Map 中的每一个键值对 + // sleepReportData.value.forEach((key, report) { + // // 确保 report 列表不为空 + // if (report.isNotEmpty) { + // // 获取该列表的最后一个元素 + // var lastElement = report.last; - // 给最后一个元素添加 selected 属性 - lastElement['selected'] = true; // 假设每个元素是一个 Map 类型 - } - }); - } + // // 给最后一个元素添加 selected 属性 + // lastElement['selected'] = true; // 假设每个元素是一个 Map 类型 + // } + // }); + // } - updateAll(); + // updateAll(); - return ApiResponse( - code: HttpStatusCodes.ok, - msg: "请求成功".tr, - data: sleepReportData, - ); - } catch (e) { - EasyDartModule.logger.info("设备请求列表异常: $e"); - DailyLogUtils.writeLog("设备请求列表异常: $e"); - return ApiResponse(code: -1, msg: "未知错误".tr, data: {}); - } - } + // return ApiResponse( + // code: HttpStatusCodes.ok, + // msg: "请求成功".tr, + // data: sleepReportData, + // ); + // } catch (e) { + // EasyDartModule.logger.info("设备请求列表异常: $e"); + // DailyLogUtils.writeLog("设备请求列表异常: $e"); + // return ApiResponse(code: -1, msg: "未知错误".tr, data: {}); + // } + // } updateDeviceShow(device) async { try { @@ -327,4 +331,94 @@ class MHTHomeController extends GetControllerEx { } return ApiResponse(code: -1, msg: "未知错误".tr); // Default return statement } + + //查询人员信息列表 + Future getPersonList() async { + ApiResponse apiResponse = ApiResponse(code: -1, msg: "设备.设备列表请求失败".tr); + String serviceAddress = ServiceConstant.service_address; + String serviceName = ServiceConstant.server_service; + String serviceApi = ServiceConstant.personnel_info; + + // 初始URL + String queryUrl = "$serviceAddress$serviceName$serviceApi"; + await requestWithLog( + logTitle: "请求人员信息列表", + method: MyHttpMethod.get, + queryUrl: queryUrl, + onSuccess: (res) { + personnelList.value = res.data ?? []; + }, + onFailure: (res) { + EasyDartModule.logger.warning("请求人员信息列表失败: ${res.msg}"); + }, + ); + } + + Future getSleeps(String? mac) async { + String serviceAddress = ServiceConstant.service_address; + String serviceName = ServiceConstant.server_service; + String serviceApi = ServiceConstant.sleep_report; + String queryUrl = "$serviceAddress$serviceName$serviceApi"; + + // 当前时间的毫秒时间戳 + int timestamp = DateTime.now().millisecondsSinceEpoch; + + // 拼接参数 + List queryParams = []; + + if (mac != null && mac.isNotEmpty) { + queryParams.add("mac=$mac"); + } + queryParams.add("time=$timestamp"); + + if (queryParams.isNotEmpty) { + queryUrl += "?${queryParams.join("&")}"; + } + + await requestWithLog( + logTitle: "请求睡眠信息列表", + method: MyHttpMethod.get, + queryUrl: queryUrl, + onSuccess: (res) { + if (res.data != null && res.data is List) { + List rawList = res.data; + List> processedList = + rawList.map>((item) { + Map map = Map.from(item); + + // 取出 time + String? timeStr = map['time']; + int? timeMillis = timeStr != null ? int.tryParse(timeStr) : null; + + if (timeMillis != null) { + DateTime dateTime = + DateTime.fromMillisecondsSinceEpoch(timeMillis); + + // 格式化 week 和 date + String week = MyUtils.formatDateTimeWeek(dateTime); + String date = MyUtils.formatDateTimeDay(dateTime); + + // 添加到 map 中 + map['week'] = week; + map['date'] = date; + } + + return map; + }).toList(); + + // 赋值给 sleepDays + sleepDays.value = processedList; + } else { + // 为空时直接赋空数组 + sleepDays.value = []; + } + + // 更新UI + updateAll(); + }, + onFailure: (res) { + EasyDartModule.logger.warning("请求睡眠信息列表失败: ${res.msg}"); + }, + ); + } } diff --git a/lib/pages/mh_page/homepage/new_Home_page.dart b/lib/pages/mh_page/homepage/new_Home_page.dart index ca47b7f..272106c 100644 --- a/lib/pages/mh_page/homepage/new_Home_page.dart +++ b/lib/pages/mh_page/homepage/new_Home_page.dart @@ -28,36 +28,20 @@ class _NewHomePageState extends State { double borderRadius = 16.rpx; var formFieldController = FormFieldController(null); + var personInfo = {}.obs; GlobalController gloablController = Get.find(); WeatherModelController weatherModelController = Get.find(); - - var sleepDays = [].obs; - - var sleep_mac = "".obs; - - Map scoreColor = { - "-1": "#d3d3d3", - "1": "#4e8408", - "2": "#7bbb33", - "3": "#e15b8d", - "4": "#ff0000", - }; - - Map scoreName = { - "-1": "暂无", - "1": "优秀", - "2": "良好", - "3": "合格", - "4": "注意", - }; + var selectedDayIndex = (6).obs; @override void initState() { super.initState(); if (userInfoController.model.login == 1) { + //查询人员信息列表 + deviceController.getPersonList(); //请求绑定设备列表 - homeController.getSleepReport(); + // homeController.getSleepReport(); deviceController.getDeviceNum().then((apiResponse) { if (apiResponse.code != HttpStatusCodes.ok) { TopSlideNotification.show( @@ -76,10 +60,15 @@ class _NewHomePageState extends State { ); } else { //请求睡眠报告 - deviceController.getSleepReport(); + // deviceController.getSleepReport(); } }); } + WidgetsBinding.instance.addPostFrameCallback((_) { + if (homeController.sleepDays.value.isNotEmpty) { + selectedDayIndex.value = homeController.sleepDays.value.length - 1; + } + }); } getWeekName(int i) { @@ -121,7 +110,7 @@ class _NewHomePageState extends State { ); } else { //请求睡眠报告 - deviceController.getSleepReport(); + // deviceController.getSleepReport(); } }); int login = userInfoController.model.login!; @@ -242,502 +231,6 @@ class _NewHomePageState extends State { ), ), ), - // Obx(() { - // return Container( - // padding: EdgeInsets.only(left: 30.rpx, right: 30.rpx), - // child: Column( - // children: [ - // if (gloablController.model.deviceList.length > 0) - // Container( - // child: Column( - // children: [ - // Container( - // width: MediaQuery.sizeOf(context).width, - // decoration: BoxDecoration( - // color: Colors.white, - // borderRadius: BorderRadius.circular( - // borderRadius), - // ), - // child: Column( - // mainAxisSize: MainAxisSize.max, - // children: [ - // Padding( - // padding: EdgeInsetsDirectional - // .fromSTEB(30.rpx, 16.rpx, - // 16.rpx, 8.rpx), - // child: Container( - // width: - // MediaQuery.sizeOf(context) - // .width, - // height: - // MediaQuery.sizeOf(context) - // .height * - // 0.065, - // decoration: BoxDecoration( - // color: FlutterFlowTheme.of( - // context) - // .secondaryBackground, - // ), - // child: Row( - // mainAxisSize: - // MainAxisSize.max, - // mainAxisAlignment: - // MainAxisAlignment - // .spaceBetween, - // children: [ - // ValueListenableBuilder( - // valueListenable: - // formFieldController, - // builder: (c, a, s) => - // FlutterFlowDropDown< - // String>( - // controller: - // formFieldController, - // options: gloablController - // .model.JunheDevices - // .map((d) => - // "${d["mac"]}") - // .toList(), - // optionLabels: - // gloablController - // .model - // .JunheDevices - // .map( - // (d) { - // var s = d["name"] ?? - // d["mac"]; - // if (s == null) { - // return ""; - // } else { - // return "$s"; - // } - // }).toList(), - // onChanged: (val) { - // // print("$val"); - // // if (val == null) { - // // sleepDays.value = []; - // // } else { - // // getSleeps( - // // formFieldController - // // .value); - // // } - // // // sleep_mac.value = val!; - // }, - // width: 360.rpx, - // height: 72.rpx, - // maxHeight: 200.rpx, - // textStyle: TextStyle( - // fontSize: 28.rpx, - // overflow: - // TextOverflow - // .ellipsis), - // hintText: '', - // icon: Icon( - // Icons - // .keyboard_arrow_down_rounded, - // color: FlutterFlowTheme - // .of(context) - // .secondaryText, - // size: 48.rpx, - // ), - // fillColor: - // stringToColor( - // "#F3F5F6"), - // elevation: 2, - // borderColor: - // stringToColor( - // "#F3F5F6"), - // borderWidth: 2, - // borderRadius: 18, - // margin: - // EdgeInsetsDirectional - // .fromSTEB( - // 32.rpx, - // 8.rpx, - // 32.rpx, - // 8.rpx), - // hidesUnderline: true, - // isOverButton: false, - // isSearchable: false, - // isMultiSelect: false, - // ), - // ), - // InkWell( - // onTap: () { - // // if (formFieldController - // // .value != - // // null) { - // // Get.toNamed( - // // "/sleepWebview", - // // arguments: [ - // // formFieldController - // // .value - // // ]); - // // } - // }, - // child: Row( - // mainAxisSize: - // MainAxisSize.max, - // children: [ - // Text( - // '睡眠报告', - // style: FlutterFlowTheme - // .of(context) - // .bodyMedium - // .override( - // fontFamily: - // 'Readex Pro', - // letterSpacing: - // 0, - // fontSize: - // 30.rpx), - // ), - // SizedBox( - // width: 12.rpx, - // ), - // SvgPicture.asset( - // "assets/images/table.svg", - // width: 28.rpx, - // height: 28.rpx), - // SizedBox( - // width: 20.rpx, - // ), - // ], - // ), - // ), - // ], - // ), - // ), - // ), - // Container( - // padding: EdgeInsets.only( - // top: 0.rpx, - // bottom: 20.rpx, - // left: 16.rpx, - // right: 16.rpx), - // width: double.infinity, - // decoration: BoxDecoration(), - // child: Row( - // mainAxisSize: MainAxisSize.max, - // crossAxisAlignment: - // CrossAxisAlignment.start, - // children: [ - // ...List.generate( - // sleepDays.value.length, - // (index) { - // var day = sleepDays[index]; - // return Expanded( - // child: Container( - // padding: - // EdgeInsets.only( - // top: 10.rpx, - // bottom: 20.rpx), - // width: 100, - // // decoration: BoxDecoration( - // // color: index == 2 - // // ? stringToColor("#F3F5F6") - // // : Colors.white, - // // borderRadius: - // // BorderRadius.circular( - // // borderRadius), - // // ), - // 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, - // ), - // ), - // Text( - // day['date'], - // style: FlutterFlowTheme - // .of(context) - // .bodyMedium - // .override( - // fontFamily: - // 'Readex Pro', - // letterSpacing: - // 0, - // fontSize: - // 24.rpx, - // ), - // ), - // SizedBox( - // height: 6.rpx, - // ), - // Column( - // children: [ - // Row( - // mainAxisSize: - // MainAxisSize - // .max, - // mainAxisAlignment: - // MainAxisAlignment - // .center, - // children: [ - // Text( - // '${day['score'] ?? "-"}', - // style: FlutterFlowTheme.of( - // context) - // .bodyMedium - // .override( - // fontFamily: - // 'Readex Pro', - // fontSize: - // 48.rpx, - // letterSpacing: - // 0, - // ), - // ), - // if (day['score'] != - // null) - // SizedBox( - // width: 2 - // .rpx, - // ), - // if (day['score'] != - // null) - // Text( - // '分', - // style: FlutterFlowTheme.of(context) - // .bodyMedium - // .override( - // fontFamily: 'Readex Pro', - // letterSpacing: 0, - // fontSize: 26.rpx, - // ), - // ), - // ], - // ), - // Container( - // width: - // 120.rpx, - // height: - // 52.rpx, - // decoration: - // BoxDecoration( - // color: stringToColor( - // day['scoreColor'] ?? - // "#f3f5f6"), - // borderRadius: - // BorderRadius.circular( - // 26.rpx), - // shape: BoxShape - // .rectangle, - // ), - // alignment: - // Alignment - // .center, - // child: Text( - // '${day['scoreType'] ?? "暂无"}', - // style: FlutterFlowTheme.of( - // context) - // .bodyMedium - // .override( - // fontFamily: - // 'Readex Pro', - // color: day['scoreType'] != null - // ? Colors.white - // : stringToColor("#ced1d7"), - // letterSpacing: - // 0, - // fontSize: - // 28.rpx, - // ), - // ), - // ) - // ], - // ) - // ], - // ), - // ), - // ); - // }) - // ], - // ), - // ), - // ], - // ), - // ), - // ...List.generate( - // gloablController.model.deviceList - // .length, (index) { - // var device = gloablController - // .model.deviceList[index]; - // String rname = device['roomName']; - // if (index != 0) { - // String lrname = gloablController - // .model.deviceList[index - 1] - // ["roomName"]; - // if (lrname == rname) { - // rname = ""; - // } - // } - // return Column(children: [ - // Padding( - // padding: - // EdgeInsetsDirectional.fromSTEB( - // 20.rpx, 20.rpx, 0, 0), - // child: Container( - // decoration: BoxDecoration(), - // alignment: - // AlignmentDirectional(-1, 0), - // child: rname.isNotEmpty - // ? Text( - // "$rname", - // style: FlutterFlowTheme - // .of(context) - // .bodyMedium - // .override( - // fontFamily: - // 'Readex Pro', - // color: Colors.white, - // fontSize: 32.rpx, - // letterSpacing: 0, - // ), - // ) - // : SizedBox( - // height: 10.rpx, - // ), - // ), - // ), - // // getDeviceList(context, device) - // ]); - // }), - // Padding( - // padding: EdgeInsetsDirectional.fromSTEB( - // 0, 40.rpx, 0, 100.rpx), - // child: Container( - // width: - // MediaQuery.sizeOf(context).width, - // height: 84.rpx, - // decoration: BoxDecoration(), - // child: FFButtonWidget( - // onPressed: () { - // // print('Button pressed ...'); - // // Get.toNamed("/homeDeviceType"); - // }, - // text: '添加新设备'.tr, - // icon: Icon( - // Icons.add, - // size: 60.rpx, - // ), - // options: FFButtonOptions( - // height: 80.rpx, - // padding: EdgeInsetsDirectional - // .fromSTEB( - // 48.rpx, 0, 48.rpx, 0), - // iconPadding: EdgeInsetsDirectional - // .fromSTEB(0, 0, 0, 0), - // color: stringToColor("#182B7C"), - // textStyle: - // FlutterFlowTheme.of(context) - // .titleSmall - // .override( - // fontFamily: - // 'Readex Pro', - // color: Colors.white, - // letterSpacing: 0, - // fontSize: 30.rpx), - // elevation: 3, - // borderSide: BorderSide( - // color: Colors.transparent, - // width: 1, - // ), - // borderRadius: - // BorderRadius.circular( - // borderRadius), - // ), - // ), - // ), - // ), - // ], - // ), - // ), - // if (gloablController.model.deviceList.length == 0) - // Padding( - // padding: EdgeInsetsDirectional.fromSTEB( - // 0, 0, 0, 80.rpx), - // child: ClickableContainer( - // backgroundColor: Colors.transparent, - // highlightColor: Colors.transparent, - // padding: EdgeInsets.all(0), - // onTap: () { - // if (userInfoController.model.login == - // null || - // userInfoController.model.login == 0) { - // TopSlideNotification.show(context, - // text: "请先登录".tr, - // textColor: themeController - // .currentColor.sc9); - // Get.toNamed("/loginPage"); - // } else { - // Get.toNamed("/mHTDeviceTypePage"); - // } - // }, - // child: Container( - // width: MediaQuery.sizeOf(context).width, - // height: 302.rpx, - // padding: EdgeInsets.only( - // top: 90.rpx, bottom: 80.rpx), - // decoration: BoxDecoration( - // borderRadius: - // BorderRadius.circular(borderRadius), - // border: Border.all( - // color: - // stringToColor("#85F5FF"), // 边框颜色 - // width: 1.rpx, // 边框宽度 - // ), - // ), - // child: Column( - // mainAxisSize: MainAxisSize.max, - // mainAxisAlignment: - // MainAxisAlignment.center, - // children: [ - // SvgPicture.asset( - // 'assets/images/icon/add.svg', - // width: 42.rpx, - // height: 42.rpx, - // ), - // SizedBox( - // height: 32.rpx, - // ), - // Text( - // '添加一台新设备'.tr, - // style: TextStyle( - // color: stringToColor("#85F5FF"), - // fontSize: AppConstants() - // .normal_text_fontSize, - // letterSpacing: 0, - // ), - // ), - // ], - // ), - // ), - // ), - // ), - // ], - // ), - // ); - // }), - //未登录 Obx(() { if (userInfoController.model.login! == null || @@ -807,9 +300,343 @@ class _NewHomePageState extends State { Obx(() { if (userInfoController.model.login! != null && userInfoController.model.login! == 1) { + final list = deviceController.personnelList.value; + + // 当数据第一次到达时自动赋值 + if (list.isNotEmpty && + formFieldController.value == null) { + formFieldController.value = list[0]["mac"]; + personInfo.value = list[0]; + deviceController + .getSleeps(formFieldController.value); + } return SingleChildScrollView( child: Column( children: [ + if (homeController.personnelList.value.length != + 0) + Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 30.rpx, 40.rpx, 30.rpx, 10.rpx), + child: Container( + width: MediaQuery.sizeOf(context).width, + height: + MediaQuery.sizeOf(context).height * + 0.184, + constraints: BoxConstraints( + minHeight: 350.rpx, + ), + decoration: BoxDecoration( + color: stringToColor("#003058"), + borderRadius: + BorderRadius.circular(20.rpx), + ), + child: Column( + mainAxisSize: MainAxisSize.max, + children: [ + Padding( + padding: + EdgeInsetsDirectional.fromSTEB( + 30.rpx, + 16.rpx, + 16.rpx, + 25.rpx), + child: Container( + width: MediaQuery.sizeOf(context) + .width, + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + ScrollbarTheme( + data: ScrollbarThemeData( + thumbColor: + MaterialStateProperty + .all(Colors + .transparent), + trackColor: + MaterialStateProperty + .all(Colors + .transparent), + trackBorderColor: + MaterialStateProperty + .all(Colors + .transparent), + ), + child: + ValueListenableBuilder( + valueListenable: + formFieldController, + builder: (c, a, s) => + FlutterFlowDropDown< + String>( + controller: + formFieldController, + options: deviceController + .personnelList.value + .map((d) => + "${d["mac"]}") + .toList(), + optionLabels: + deviceController + .personnelList + .value + .map( + (d) { + var s = d["name"] ?? + d["mac"]; + if (s == null) { + return ""; + } else { + return "$s"; + } + }).toList(), + onChanged: (val) { + final list = + deviceController + .personnelList + .value; + final selectedPerson = + list.firstWhere( + (element) => + element[ + 'mac'] == + val, + orElse: () => + null, // 防止找不到时报错 + ); + + personInfo.value = + selectedPerson; + + selectedDayIndex = + (6).obs; + print("$val"); + if (val == null) { + homeController + .sleepDays + .value = []; + } else { + deviceController + .getSleeps( + formFieldController + .value); + } + }, + width: 300.rpx, + height: 81.rpx, + maxHeight: 300.rpx, + textStyle: TextStyle( + fontSize: 28.rpx, + overflow: TextOverflow + .ellipsis, + color: Colors.white, + ), + hintText: '', + icon: Icon( + Icons + .keyboard_arrow_down_rounded, + color: stringToColor( + "#FFFFFF"), + size: 30.rpx, + ), + fillColor: + stringToColor( + "#184468"), + elevation: 2, + borderColor: + Colors.transparent, + borderWidth: 2, + borderRadius: 18, + margin: + EdgeInsetsDirectional + .fromSTEB( + 32.rpx, + 8.rpx, + 32.rpx, + 8.rpx), + hidesUnderline: true, + isOverButton: false, + isSearchable: false, + isMultiSelect: false, + ), + ), + ), + InkWell( + onTap: () { + if (formFieldController + .value != + null) { + Get.toNamed( + "/sleepWebview", + arguments: [ + formFieldController + .value + ]); + } + }, + child: Row( + mainAxisSize: + MainAxisSize.max, + children: [ + SizedBox( + width: 12.rpx, + ), + SvgPicture.asset( + "assets/images/table.svg", + width: 28.rpx, + height: 28.rpx, + color: stringToColor( + "#FFFFFF"), + ), + SizedBox( + width: 20.rpx, + ), + ], + ), + ), + ], + ), + ), + ), + 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 = + selectedDayIndex + .value == + index; + return Expanded( + child: GestureDetector( + onTap: () { + 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.bindDeviceNum.value != 0) Padding( padding: EdgeInsetsDirectional.fromSTEB( @@ -1011,6 +838,40 @@ class _NewHomePageState extends State { ], ); } + + Widget buildScoreOrIcon(dynamic score) { + return SizedBox( + width: 50.rpx, + height: 50.rpx, + child: Center( + child: (score != null) + ? FittedBox( + child: Text( + '${score['socre']}', + style: TextStyle( + fontFamily: 'Readex Pro', + fontSize: 40.rpx, + letterSpacing: 0, + color: Colors.white, + ), + ), + ) + : SvgPicture.asset( + 'assets/img/icon/close.svg', + width: 25.rpx, + height: 25.rpx, + color: themeController.currentColor.sc3, + ), + ), + ); + } + + int? parseToInt(dynamic value) { + if (value == null) return null; + if (value is int) return value; + if (value is String) return int.tryParse(value); + return null; + } } class ScoreItem { diff --git a/lib/pages/sleep_report/chart/AdviceComponnetWidget.dart b/lib/pages/sleep_report/chart/AdviceComponnetWidget.dart index 1542737..6ca02a6 100644 --- a/lib/pages/sleep_report/chart/AdviceComponnetWidget.dart +++ b/lib/pages/sleep_report/chart/AdviceComponnetWidget.dart @@ -46,7 +46,7 @@ class _AdviceComponnetWidgetState extends State { Container( width: double.infinity, decoration: BoxDecoration( - color: stringToColor("#313541"), + color: stringToColor("#313541").withOpacity(0.6), borderRadius: BorderRadius.circular(20.rpx), ), child: Padding( diff --git a/lib/pages/sleep_report/chart/SleepRadarChart.dart b/lib/pages/sleep_report/chart/SleepRadarChart.dart index 78782fe..849989b 100644 --- a/lib/pages/sleep_report/chart/SleepRadarChart.dart +++ b/lib/pages/sleep_report/chart/SleepRadarChart.dart @@ -6,9 +6,9 @@ import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; class SleepRadarChart extends StatelessWidget { -final List> data; + final List> data; -const SleepRadarChart({Key? key, required this.data}) : super(key: key); + const SleepRadarChart({Key? key, required this.data}) : super(key: key); // const SleepRadarChart({ // Key? key, @@ -30,48 +30,52 @@ const SleepRadarChart({Key? key, required this.data}) : super(key: key); } Widget _buildRadarChart() { - return AspectRatio( - aspectRatio: 1.3, - child: RadarChart( - RadarChartData( - dataSets: [ - // 今日数据 - RadarDataSet( - dataEntries: data.map((e) => RadarEntry(value: (e['t'] as num).toDouble())).toList(), - borderColor: stringToColor("#00C1AA"), - borderWidth: 2, - fillColor: Colors.transparent, - entryRadius: 0, - ), - // 昨日数据 - RadarDataSet( - dataEntries: data.map((e) => RadarEntry(value: (e['y'] as num).toDouble())).toList(), - borderColor: stringToColor("#FFD251"), - borderWidth: 2, - fillColor: Colors.transparent, - entryRadius: 0, - ), - ], - radarBackgroundColor: stringToColor("#343844"), - radarBorderData: BorderSide( - color: themeController.currentColor.sc4, width: 0.5.rpx), - radarShape: RadarShape.polygon, - titlePositionPercentageOffset: 0.2, - titleTextStyle: TextStyle( - fontSize: AppConstants().normal_text_fontSize, - color: themeController.currentColor.sc3), - getTitle: (index, angle) { - return RadarChartTitle(text: data[index]['name'] ?? '未知'.tr); - }, - tickCount: 5, - ticksTextStyle: const TextStyle(color: Colors.transparent, fontSize: 10), - gridBorderData: BorderSide(color: Colors.transparent, width: 1), - tickBorderData: BorderSide( - color: themeController.currentColor.sc4, width: 0.5.rpx), + return AspectRatio( + aspectRatio: 1.3, + child: RadarChart( + RadarChartData( + dataSets: [ + // 今日数据 + RadarDataSet( + dataEntries: data + .map((e) => RadarEntry(value: (e['t'] as num).toDouble())) + .toList(), + borderColor: stringToColor("#00C1AA"), + borderWidth: 2, + fillColor: Colors.transparent, + entryRadius: 0, + ), + // 昨日数据 + RadarDataSet( + dataEntries: data + .map((e) => RadarEntry(value: (e['y'] as num).toDouble())) + .toList(), + borderColor: stringToColor("#FFD251"), + borderWidth: 2, + fillColor: Colors.transparent, + entryRadius: 0, + ), + ], + radarBackgroundColor: stringToColor("#343844").withOpacity(0.6), + radarBorderData: BorderSide( + color: themeController.currentColor.sc4, width: 0.5.rpx), + radarShape: RadarShape.polygon, + titlePositionPercentageOffset: 0.2, + titleTextStyle: TextStyle( + fontSize: AppConstants().normal_text_fontSize, + color: themeController.currentColor.sc3), + getTitle: (index, angle) { + return RadarChartTitle(text: data[index]['name'] ?? '未知'.tr); + }, + tickCount: 5, + ticksTextStyle: + const TextStyle(color: Colors.transparent, fontSize: 10), + gridBorderData: BorderSide(color: Colors.transparent, width: 1), + tickBorderData: BorderSide( + color: themeController.currentColor.sc4, width: 0.5.rpx), + ), + swapAnimationDuration: const Duration(milliseconds: 400), ), - swapAnimationDuration: const Duration(milliseconds: 400), - ), - ); -} - + ); + } } diff --git a/lib/pages/sleep_report/new_sleep_report_page copy.dart b/lib/pages/sleep_report/new_sleep_report_page copy.dart index ae490df..fa7ce80 100644 --- a/lib/pages/sleep_report/new_sleep_report_page copy.dart +++ b/lib/pages/sleep_report/new_sleep_report_page copy.dart @@ -383,7 +383,7 @@ class _NewSleepReportPageState extends State { CrossAxisAlignment.end, children: [ Text( - '实时体征.姓名'.tr, + '姓名'.tr, style: FlutterFlowTheme.of(context) .bodyMedium @@ -396,7 +396,7 @@ class _NewSleepReportPageState extends State { ), ), Text( - '实时体征.年龄'.tr, + '年龄'.tr, style: FlutterFlowTheme.of(context) .bodyMedium @@ -463,7 +463,7 @@ class _NewSleepReportPageState extends State { CrossAxisAlignment.end, children: [ Text( - '实时体征.设备ID'.tr, + '设备ID'.tr, style: FlutterFlowTheme.of(context) .bodyMedium @@ -476,7 +476,7 @@ class _NewSleepReportPageState extends State { ), ), Text( - '实时体征.体重'.tr, + '体重'.tr, style: FlutterFlowTheme.of(context) .bodyMedium diff --git a/lib/pages/sleep_report/new_sleep_report_page.dart b/lib/pages/sleep_report/new_sleep_report_page.dart index c72259e..1135d03 100644 --- a/lib/pages/sleep_report/new_sleep_report_page.dart +++ b/lib/pages/sleep_report/new_sleep_report_page.dart @@ -108,14 +108,19 @@ class _NewSleepReportPageState extends State { child: Container( decoration: BoxDecoration( image: DecorationImage( - image: AssetImage('assets/img/bgNoImg.png'), // 本地图片 - fit: BoxFit.fill, // 填满整个 Container + image: (widget.data['backgroundImg'] != null && + widget.data['backgroundImg'].toString().isNotEmpty) + ? AssetImage(widget.data['backgroundImg']) + : AssetImage('assets/img/bgNoImg.png') as ImageProvider, + fit: BoxFit.fill, ), ), child: Scaffold( backgroundColor: Colors.transparent, // 背景透明 appBar: AppBar( - backgroundColor: themeController.currentColor.sc17, + backgroundColor: widget.data['backgroundColor'] != null + ? widget.data['backgroundColor'].withOpacity(0.8) + : themeController.currentColor.sc5, automaticallyImplyLeading: false, iconTheme: IconThemeData(color: themeController.currentColor.sc3), titleSpacing: 0, @@ -162,7 +167,10 @@ class _NewSleepReportPageState extends State { minHeight: 90.rpx, ), decoration: BoxDecoration( - color: themeController.currentColor.sc5), + color: widget.data['backgroundColor'] != null + ? widget.data['backgroundColor'] + : themeController.currentColor.sc5, + ), child: Padding( padding: EdgeInsetsDirectional.fromSTEB( 30.rpx, 15.rpx, 30.rpx, 15.rpx), @@ -377,7 +385,10 @@ class _NewSleepReportPageState extends State { padding: EdgeInsetsDirectional.fromSTEB( 30.rpx, 0.rpx, 30.rpx, 58.rpx), child: ClickableContainer( - backgroundColor: themeController.currentColor.sc5, + backgroundColor: + widget.data['backgroundColor'] != null + ? widget.data['backgroundColor'] + : themeController.currentColor.sc5, highlightColor: themeController.currentColor.sc5, // 或你希望的点击水波纹颜色 borderRadius: AppConstants() @@ -399,7 +410,7 @@ class _NewSleepReportPageState extends State { CrossAxisAlignment.end, children: [ Text( - '实时体征.姓名'.tr, + '姓名'.tr, style: FlutterFlowTheme.of(context) .bodyMedium @@ -412,7 +423,7 @@ class _NewSleepReportPageState extends State { ), ), Text( - '实时体征.年龄'.tr, + '年龄'.tr, style: FlutterFlowTheme.of(context) .bodyMedium @@ -487,7 +498,7 @@ class _NewSleepReportPageState extends State { CrossAxisAlignment.end, children: [ Text( - '实时体征.设备ID'.tr, + '设备ID'.tr, style: FlutterFlowTheme.of(context) .bodyMedium @@ -500,7 +511,7 @@ class _NewSleepReportPageState extends State { ), ), Text( - '实时体征.体重'.tr, + '体重'.tr, style: FlutterFlowTheme.of(context) .bodyMedium diff --git a/lib/routers/mh_routers.dart b/lib/routers/mh_routers.dart index 6e864eb..2311d36 100644 --- a/lib/routers/mh_routers.dart +++ b/lib/routers/mh_routers.dart @@ -16,7 +16,6 @@ import 'package:vbvs_app/pages/mh_page/device/mht_blueteeth_device_page.dart'; import 'package:vbvs_app/pages/mh_page/device/mht_device_calibration.dart'; import 'package:vbvs_app/pages/mh_page/device/mht_wifi_page.dart'; import 'package:vbvs_app/pages/mh_page/device_list.dart'; -import 'package:vbvs_app/pages/mh_page/device_people_info.dart'; import 'package:vbvs_app/pages/mh_page/device_share_page.dart'; import 'package:vbvs_app/pages/mh_page/edit_bed.dart'; import 'package:vbvs_app/pages/mh_page/user/page/edit_userinfo_page.dart'; @@ -33,8 +32,7 @@ import 'package:vbvs_app/pages/mh_page/smys.dart'; import 'package:vbvs_app/pages/mh_page/user/page/find_password_page.dart'; import 'package:vbvs_app/pages/mh_page/user/page/mht_login_page.dart'; import 'package:vbvs_app/pages/mh_page/user/page/update_password_page.dart'; - -import '../pages/mh_page/bluetooth.dart'; +import 'package:vbvs_app/pages/sleep_report/new_sleep_report_page.dart'; import '../pages/mh_page/edit_address_page.dart'; import '../pages/mh_page/message_page.dart'; import '../pages/mh_page/new_settingPage.dart'; @@ -79,6 +77,8 @@ var mhroutes = { "/mHTwifiPage": (contxt, {arguments}) => MHTWifiPage(deviceInfo: arguments), "/calibrationPage": (contxt) => MHTCalibrationPage(), "/bindDeviceSuccess": (contxt) => BindDeviceSuccess(), + "/newSleepReportPage": (contxt, {arguments}) => + NewSleepReportPage(data: arguments), }; var mhonGenerateRoute = (RouteSettings settings) { final String? name = settings.name; // 获取路由名称,如 /news 或 /search