diff --git a/assets/img/black_body_still.png b/assets/img/black_body_still.png index ce5d7e2..f4a38f0 100644 Binary files a/assets/img/black_body_still.png and b/assets/img/black_body_still.png differ diff --git a/assets/img/body_black.gif b/assets/img/body_black.gif index f5d293e..1ac4323 100644 Binary files a/assets/img/body_black.gif and b/assets/img/body_black.gif differ diff --git a/assets/langs/en_US.json b/assets/langs/en_US.json index 4399497..35bf86d 100644 --- a/assets/langs/en_US.json +++ b/assets/langs/en_US.json @@ -420,6 +420,7 @@ "今日数据":"yesterday", "昨日数据":"today", "次":"times", - "秒":"sec" + "秒":"sec", + "暂无":"none" } \ No newline at end of file diff --git a/assets/langs/zh_CN.json b/assets/langs/zh_CN.json index 290220a..a34d48a 100644 --- a/assets/langs/zh_CN.json +++ b/assets/langs/zh_CN.json @@ -116,7 +116,7 @@ }, "绑定成功":{ "标题":"绑定完成", - "绑定成功":"绑定成功! ", + "绑定成功":"配置成功! ", "分享标题":"是否进行分享?", "分享内容":"设备绑定成功后,如需对朋友或家人共享我的睡眠情况,可以进行立即分享,分享成功后,对方即可享受查看该设备权限,可以收到该设备的睡眠报告。", "立即分享":"立即分享", @@ -428,7 +428,16 @@ "未配置网络提示":"当前设备未进行网络配置,是否确认跳过网络配置", "退出":"退出", "完成":"完成", - "时长":"时长:" + "时长":"时长:", + "继续":"继续", + "下次再说":"下次再说", + "发现":"发现!", + "检测到":"检测到", + "绑定流程未走完是否继续":"绑定流程未走完是否继续", + "暂无":"暂无", + "设备连接超时,请重试":"设备连接超时,请点击刷新重试", + "设备连接失败":"设备连接失败,请点击刷新重试" + } \ No newline at end of file diff --git a/lib/common/util/MyUtils.dart b/lib/common/util/MyUtils.dart index 97620dc..a5d4098 100644 --- a/lib/common/util/MyUtils.dart +++ b/lib/common/util/MyUtils.dart @@ -393,7 +393,7 @@ var returnIconButtomNew = ClickableContainer( // ), // ); -var returnIconButtomAddCallback = (returnCallBack) { + var returnIconButtomAddCallback = ( VoidCallback? returnCallBack, { bool enableBack = true, diff --git a/lib/controller/login/login_controller.dart b/lib/controller/login/login_controller.dart index ff082ce..5e28ef5 100644 --- a/lib/controller/login/login_controller.dart +++ b/lib/controller/login/login_controller.dart @@ -16,6 +16,7 @@ import 'package:vbvs_app/common/util/requestWithLog.dart'; import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; import 'package:vbvs_app/controller/time/countdown_controller.dart'; import 'package:vbvs_app/controller/user_info_controller.dart'; +import 'package:vbvs_app/main.dart'; import 'package:vbvs_app/model/api_response.dart'; import 'package:vbvs_app/model/user_data.dart'; part 'login_controller.g.dart'; @@ -199,10 +200,14 @@ class LoginController extends GetControllerEx { scope: 'snsapi_userinfo', state: 'wechat_sdk_theh_wxlogin', )) - .then((data) { + .then((data) async { //返回true表示成功或者false表示失败,这边没有意义从login_controller页面构造函数监听中去处理 debugPrint('msg:$data'); EasyDartModule.logger.error('msg:$data'); + if (data) { + //登陆成功 + // await dealBindProcess(); + } }); } catch (e) { debugPrint('msg:$e'); diff --git a/lib/controller/person/person_controller.dart b/lib/controller/person/person_controller.dart index ae2dd6c..b8ebaf9 100644 --- a/lib/controller/person/person_controller.dart +++ b/lib/controller/person/person_controller.dart @@ -47,6 +47,8 @@ class PersonController extends GetControllerEx { RxString height = "".obs; DateTime? dateTime = DateTime.now(); //选择时间 RxList diseaseList = [].obs; + RxString update_person_mac = "".obs; + var after_deveice; Future savePersonData() async { try { diff --git a/lib/controller/user_info_controller.dart b/lib/controller/user_info_controller.dart index c47806a..f7e2d90 100644 --- a/lib/controller/user_info_controller.dart +++ b/lib/controller/user_info_controller.dart @@ -17,7 +17,6 @@ import 'package:vbvs_app/controller/time/countdown_controller.dart'; import 'package:vbvs_app/model/api_response.dart'; import 'package:vbvs_app/model/user_data.dart'; - part 'user_info_controller.g.dart'; @JsonSerializable() @@ -59,6 +58,9 @@ class UserInfoController extends GetControllerEx { attr = GetModel(UserInfoModel()).obs; } + List device_bind_status = []; + int device_bind_flag = 0;//0。未初始化 1.已初始化 + Future uploadImg() async { EasyDartModule.logger.info("请求上传图片"); DailyLogUtils.writeLog("请求上传图片"); @@ -239,6 +241,4 @@ class UserInfoController extends GetControllerEx { countdownController.countdown.value = 0; return apiResponse; } - - } diff --git a/lib/main.dart b/lib/main.dart index 6f33c56..d18ac60 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -16,6 +16,8 @@ import 'package:vbvs_app/common/color/ServiceConstant.dart'; import 'package:vbvs_app/common/util/CheckNetwork.dart'; import 'package:vbvs_app/common/util/CommonVariables.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; +import 'package:vbvs_app/common/util/requestWithLog.dart'; +import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; import 'package:vbvs_app/controller/date/CalendarController.dart'; import 'package:vbvs_app/controller/device/blueteeth_bind_controller.dart'; import 'package:vbvs_app/controller/device/body_device_controller.dart'; @@ -56,10 +58,9 @@ import 'package:vbvs_app/controller/time/countdown_controller.dart'; import 'package:vbvs_app/controller/weather/weather_controller.dart'; import 'package:vbvs_app/language/AppLanguage.dart'; import 'package:vbvs_app/model/CustomThemeColor.dart'; +import 'package:vbvs_app/model/api_response.dart'; import 'package:vbvs_app/model/user_data.dart'; -import 'package:vbvs_app/pages/device_control/BackMovement.dart'; import 'package:vbvs_app/pages/device_control/MattressControl.dart'; -import 'package:vbvs_app/pages/device_control/people_info.dart'; import 'package:vbvs_app/pages/main_bottom/component/main_page_b_bottom_change.dart'; import 'package:vbvs_app/routers/mh_routers.dart'; @@ -208,12 +209,66 @@ Future initLogin() async { // 根据token去请求 // await userInfoController.autoLogin(token); EasyDartModule.dio.token = token; + // await dealBindProcess(); } else { // 如果没有 token,则将用户标记为未登录 userInfoController.model.login = 0; } } +//处理绑定未完成的数据 +Future dealBindProcess() async { + UserInfoController userInfoController = Get.find(); + String serviceAddress = ServiceConstant.service_address; + String serviceName = ServiceConstant.server_service; + String serviceApi = ServiceConstant.device_list; + String queryUrl = "${serviceAddress}${serviceName}${serviceApi}?bindType=1"; + userInfoController.device_bind_status = []; + + try { + final res = await requestWithLog( + logTitle: "查询设备绑定列表", + method: MyHttpMethod.get, + queryUrl: queryUrl, + ); + + List data = res.data ?? []; + if (data.isNotEmpty) { + // 使用 Future.wait 等待所有设备的查询完成 + await Future.wait( + data.map((element) async { + String mac = element['mac']; + String type = "device_bind_status_$mac"; + String queryUrl = + "${serviceAddress}${serviceName}${ServiceConstant.user_setting}?type=${type}"; + + try { + final res = await requestWithLog( + logTitle: "查询绑定流程", + method: MyHttpMethod.get, + queryUrl: queryUrl, + ); + + if (res.data != null && res.data.isNotEmpty) { + bool celibration = res.data['celibration']; + bool person_info = res.data['person_info']; + bool wifi = res.data['wifi']; + if (!celibration || !person_info || !wifi) { + res.data['device_info'] = element; + userInfoController.device_bind_status.add(res.data); + } + } + } catch (e) { + print("查询绑定流程失败: $e"); + } + }), + ); + } + } catch (e) { + print("查询设备绑定列表失败: $e"); + } +} + class MyApp extends StatelessWidget { MyApp({super.key}); final ThemeController themeController = Get.put(ThemeController()); @@ -257,7 +312,6 @@ class MyApp extends StatelessWidget { Get.lazyPut(() => DeviceShareListController()), Get.lazyPut(() => DeviceCalibrationController()), Get.lazyPut(() => RepairController()), - Get.lazyPut(() => PdfController()), ])); } @@ -286,7 +340,7 @@ class MyApp extends StatelessWidget { initialBinding: BindingsBuilder(() => [ // Get.lazyPut(() => UserInfoController()), Get.put(GlobalController()), - Get.put(WeatherModelController()), + Get.put(WeatherModelController()), Get.lazyPut(() => MainPageController()), Get.lazyPut(() => BlueteethBindController()), Get.lazyPut(() => PersonController()), @@ -299,17 +353,17 @@ class MyApp extends StatelessWidget { Get.lazyPut(() => DeviceShareListController()), Get.lazyPut(() => DeviceCalibrationController()), Get.lazyPut(() => RepairController()), - Get.lazyPut(() => UserPdfController()), - Get.lazyPut(() => PrivacyPdfController()), - Get.lazyPut(() => CalendarController()), - Get.lazyPut(() => SleepReportController()), - Get.lazyPut(() => MessageReviewController()), - Get.lazyPut(() => MessageSettingController()), - Get.lazyPut(() => CommonMessageSettingController()), + Get.lazyPut(() => UserPdfController()), + Get.lazyPut(() => PrivacyPdfController()), + Get.lazyPut(() => CalendarController()), + Get.lazyPut(() => SleepReportController()), + Get.lazyPut(() => MessageReviewController()), + Get.lazyPut(() => MessageSettingController()), + Get.lazyPut(() => CommonMessageSettingController()), ])); } - final selectapp = "mht"; + final selectapp = "th"; // This widget is the root of your application. @override Widget build(BuildContext context) { diff --git a/lib/pages/device/component/DeviceDataComponentWidget.dart b/lib/pages/device/component/DeviceDataComponentWidget.dart index 16687c1..336ad8f 100644 --- a/lib/pages/device/component/DeviceDataComponentWidget.dart +++ b/lib/pages/device/component/DeviceDataComponentWidget.dart @@ -1043,6 +1043,8 @@ class _DeviceDataComponentWidgetState extends State { widget.device['_id']; personController.name.value = widget.device['person']['name']; + personController.update_person_mac.value = + widget.device['mac']; personController.gender.value = widget.device['person']['gender'] ?? 1; personController.weight?.value = @@ -1065,8 +1067,16 @@ class _DeviceDataComponentWidgetState extends State { MyUtils.formatBirthdayTime( widget.device['person']['birthday']); } else { + personController.update_person_mac.value = + widget.device['mac']; personController.currentPersonId.value = widget.device['_id']; + personController.name.value = ""; + personController.gender.value = 1; + personController.dateTime = null; + personController.height.value = ""; + personController.weight.value = ""; + personController.diseaseList.value = []; } await Get.toNamed("/updatePersonPage", arguments: widget.device['bind_type']); @@ -1292,7 +1302,6 @@ class _DeviceDataComponentWidgetState extends State { bodyDeviceController.wifiMac = device['mac']; Get.toNamed("/wifiPagePerson", arguments: device); return; - } double _calculateMaxMenuItemWidth(List texts, TextStyle style) { diff --git a/lib/pages/device/component/DeviceStatusInfoWidget.dart b/lib/pages/device/component/DeviceStatusInfoWidget.dart index 0673389..c21b245 100644 --- a/lib/pages/device/component/DeviceStatusInfoWidget.dart +++ b/lib/pages/device/component/DeviceStatusInfoWidget.dart @@ -5,6 +5,7 @@ import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutterflow_ui/flutterflow_ui.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/component/tool/ClickableContainer.dart'; import 'package:vbvs_app/controller/theme_controller/ThemeController.dart'; @@ -24,8 +25,9 @@ class DeviceStatusInfoWidget extends StatelessWidget { @override Widget build(BuildContext context) { return ClickableContainer( - backgroundColor: themeController.currentColor.sc5, - highlightColor: themeController.currentColor.sc5, + // backgroundColor: themeController.currentColor.sc5, + backgroundColor: stringToColor("#242835").withOpacity(0.8), + highlightColor: themeController.currentColor.sc21, borderRadius: AppConstants().normal_container_radius, padding: EdgeInsets.zero, onTap: () { @@ -76,7 +78,7 @@ class DeviceStatusInfoWidget extends StatelessWidget { fontFamily: 'Inter', fontSize: 30.rpx, letterSpacing: 0.0, - color: themeController.currentColor.sc3, + color: themeController.currentColor.sc4, ), ), ].divide(SizedBox(height: 39.rpx)), diff --git a/lib/pages/device/component/MessageSetting.dart b/lib/pages/device/component/MessageSetting.dart index e8444e8..6529e59 100644 --- a/lib/pages/device/component/MessageSetting.dart +++ b/lib/pages/device/component/MessageSetting.dart @@ -169,6 +169,7 @@ class _MessageSettingPageState extends State { print(res); }, ); + } @override diff --git a/lib/pages/device/device_detail.dart b/lib/pages/device/device_detail.dart index c681766..33116cb 100644 --- a/lib/pages/device/device_detail.dart +++ b/lib/pages/device/device_detail.dart @@ -109,7 +109,7 @@ class _DeviceDetailPageState extends State { minHeight: 200.rpx, ), decoration: BoxDecoration( - color: Colors.transparent, + color: Colors.white, ), child: (widget.device['code']?.toString().isNotEmpty ?? @@ -124,6 +124,7 @@ class _DeviceDetailPageState extends State { fit: BoxFit.cover, ), ), + SizedBox(height: 20.rpx), Container( height: 50.rpx, decoration: BoxDecoration(), diff --git a/lib/pages/device/instant_body_page.dart b/lib/pages/device/instant_body_page.dart index 386466b..44af19a 100644 --- a/lib/pages/device/instant_body_page.dart +++ b/lib/pages/device/instant_body_page.dart @@ -3,6 +3,7 @@ import 'dart:async'; import 'package:EasyDartModule/EasyDartModule.dart' as edm; import 'package:ef/ef.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_svg/svg.dart'; import 'package:flutterflow_ui/flutterflow_ui.dart'; import 'package:vbvs_app/common/color/appConstants.dart'; @@ -17,6 +18,9 @@ import 'package:vbvs_app/controller/theme_controller/ThemeController.dart'; import 'package:vbvs_app/controller/user_info_controller.dart'; import 'package:vbvs_app/model/WebSocketMessage.dart'; import 'package:vbvs_app/pages/device/component/DeviceStatusInfoWidget.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/painting.dart'; +import 'dart:ui' as ui; class InstantBodyPage extends StatefulWidget { var personInfo; @@ -173,380 +177,799 @@ class _InstantBodyPageState extends State { ), body: SafeArea( top: true, - child: Container( - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage( - (onlineState == "离线".tr || inBed == '离床'.tr) - ? 'assets/img/black_body_still.png' // 静态图 - : 'assets/img/body_black.gif', // 动图 - ), - fit: BoxFit.cover, - ), - ), - child: Padding( - padding: EdgeInsetsDirectional.fromSTEB( - 0.rpx, 29.rpx, 0.rpx, 0.rpx), - child: Column( - mainAxisSize: MainAxisSize.max, - children: [ - Padding( - padding: EdgeInsetsDirectional.fromSTEB( - 30.rpx, 0.rpx, 30.rpx, 120.rpx), - child: ClickableContainer( - backgroundColor: themeController.currentColor.sc5, - highlightColor: - themeController.currentColor.sc5, // 或你希望的点击水波纹颜色 - borderRadius: AppConstants() - .normal_container_radius, // 如果你想加圆角可以设置 eg. 12.rpx - padding: EdgeInsets.zero, - onTap: () { - print('点击了体征卡片'); - }, - child: Row( - mainAxisSize: MainAxisSize.max, - children: [ - Flexible( - flex: 2, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Column( - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Text( - '实时体征.姓名'.tr, - style: - FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: 'Inter', - fontSize: 26.rpx, - letterSpacing: 0.0, - color: themeController - .currentColor.sc4, - ), - ), - Text( - '实时体征.年龄'.tr, - style: - FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: 'Inter', - fontSize: 26.rpx, - letterSpacing: 0.0, - color: themeController - .currentColor.sc4, - ), - ), - ].divide(SizedBox(height: 34.rpx)), - ), - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - '${device['person']?['name'] ?? '未命名'.tr}', - style: - FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: 'Inter', - fontSize: 26.rpx, - letterSpacing: 0.0, - color: themeController - .currentColor.sc3, - ), - ), - Text( - '${MyUtils.getAgeByDate(MyUtils.formatBirthdayTime(device['person']?['birthday'])) ?? '未知数据'.tr}', - style: - FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: 'Inter', - fontSize: 26.rpx, - letterSpacing: 0.0, - color: themeController - .currentColor.sc3, - ), - ), - ].divide(SizedBox(height: 34.rpx)), - ), - ] - .divide(SizedBox(width: 33.rpx)) - .addToStart(SizedBox(width: 37.rpx)), - ), - ] - .addToStart(SizedBox(height: 36.rpx)) - .addToEnd(SizedBox(height: 36.rpx)), - ), + // child: Container( + // decoration: BoxDecoration( + // image: DecorationImage( + // image: AssetImage( + // (onlineState == "离线".tr || inBed == '离床'.tr) + // ? 'assets/img/black_body_still.png' // 静态图 + // : 'assets/img/body_black.gif', // 动图 + // ), + // fit: BoxFit.cover, + // ), + // ), + // child: Padding( + // padding: EdgeInsetsDirectional.fromSTEB( + // 0.rpx, 29.rpx, 0.rpx, 0.rpx), + // child: Column( + // mainAxisSize: MainAxisSize.max, + // children: [ + // Padding( + // padding: EdgeInsetsDirectional.fromSTEB( + // 30.rpx, 0.rpx, 30.rpx, 120.rpx), + // child: ClickableContainer( + // backgroundColor: themeController.currentColor.sc5, + // highlightColor: + // themeController.currentColor.sc5, // 或你希望的点击水波纹颜色 + // borderRadius: AppConstants() + // .normal_container_radius, // 如果你想加圆角可以设置 eg. 12.rpx + // padding: EdgeInsets.zero, + // onTap: () { + // print('点击了体征卡片'); + // }, + // child: Row( + // mainAxisSize: MainAxisSize.max, + // children: [ + // Flexible( + // flex: 2, + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Row( + // children: [ + // Column( + // crossAxisAlignment: + // CrossAxisAlignment.end, + // children: [ + // Text( + // '实时体征.姓名'.tr, + // style: + // FlutterFlowTheme.of(context) + // .bodyMedium + // .override( + // fontFamily: 'Inter', + // fontSize: 26.rpx, + // letterSpacing: 0.0, + // color: themeController + // .currentColor.sc4, + // ), + // ), + // Text( + // '实时体征.年龄'.tr, + // style: + // FlutterFlowTheme.of(context) + // .bodyMedium + // .override( + // fontFamily: 'Inter', + // fontSize: 26.rpx, + // letterSpacing: 0.0, + // color: themeController + // .currentColor.sc4, + // ), + // ), + // ].divide(SizedBox(height: 34.rpx)), + // ), + // Column( + // crossAxisAlignment: + // CrossAxisAlignment.start, + // children: [ + // Text( + // '${device['person']?['name'] ?? '未命名'.tr}', + // style: + // FlutterFlowTheme.of(context) + // .bodyMedium + // .override( + // fontFamily: 'Inter', + // fontSize: 26.rpx, + // letterSpacing: 0.0, + // color: themeController + // .currentColor.sc3, + // ), + // ), + // Text( + // '${MyUtils.getAgeByDate(MyUtils.formatBirthdayTime(device['person']?['birthday'])) ?? '未知数据'.tr}', + // style: + // FlutterFlowTheme.of(context) + // .bodyMedium + // .override( + // fontFamily: 'Inter', + // fontSize: 26.rpx, + // letterSpacing: 0.0, + // color: themeController + // .currentColor.sc3, + // ), + // ), + // ].divide(SizedBox(height: 34.rpx)), + // ), + // ] + // .divide(SizedBox(width: 33.rpx)) + // .addToStart(SizedBox(width: 37.rpx)), + // ), + // ] + // .addToStart(SizedBox(height: 36.rpx)) + // .addToEnd(SizedBox(height: 36.rpx)), + // ), + // ), + // Flexible( + // flex: 3, + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Row( + // children: [ + // Column( + // crossAxisAlignment: + // CrossAxisAlignment.end, + // children: [ + // Text( + // '实时体征.设备ID'.tr, + // style: + // FlutterFlowTheme.of(context) + // .bodyMedium + // .override( + // fontFamily: 'Inter', + // fontSize: 26.rpx, + // letterSpacing: 0.0, + // color: themeController + // .currentColor.sc4, + // ), + // ), + // Text( + // '实时体征.体重'.tr, + // style: + // FlutterFlowTheme.of(context) + // .bodyMedium + // .override( + // fontFamily: 'Inter', + // fontSize: 26.rpx, + // letterSpacing: 0.0, + // color: themeController + // .currentColor.sc4, + // ), + // ), + // ].divide(SizedBox(height: 34.rpx)), + // ), + // Expanded( + // child: Column( + // crossAxisAlignment: + // CrossAxisAlignment.start, + // children: [ + // Text( + // '${device['code'] ?? '未知数据'.tr}', + // // "D11250300003", + // style: + // FlutterFlowTheme.of(context) + // .bodyMedium + // .override( + // fontFamily: 'Inter', + // fontSize: 26.rpx, + // letterSpacing: 0.0, + // color: themeController + // .currentColor.sc3, + // ), + // maxLines: 1, + // overflow: TextOverflow.ellipsis, + // ), + // Text( + // '${device['person']?['weight'] ?? '未知数据'.tr}kg', + // style: + // FlutterFlowTheme.of(context) + // .bodyMedium + // .override( + // fontFamily: 'Inter', + // fontSize: 26.rpx, + // letterSpacing: 0.0, + // color: themeController + // .currentColor.sc3, + // ), + // ), + // ].divide(SizedBox(height: 34.rpx)), + // ), + // ), + // ] + // .divide(SizedBox(width: 33.rpx)) + // .addToStart(SizedBox(width: 37.rpx)), + // ), + // ] + // .addToStart(SizedBox(height: 36.rpx)) + // .addToEnd(SizedBox(height: 36.rpx)), + // ), + // ), + // ], + // ), + // ), + // ), + // Expanded( + // child: SingleChildScrollView( + // child: Column( + // children: [ + // Padding( + // padding: EdgeInsetsDirectional.fromSTEB( + // 66.rpx, 0, 66.rpx, 0), + // child: Container( + // // decoration: BoxDecoration( + // // image: DecorationImage( + // // image: AssetImage( + // // onlineState == "离线".tr + // // ? 'assets/img/black_body_still.png' // 静态图 + // // : 'assets/img/body_black.gif', // 动图 + // // ), + // // fit: BoxFit.cover, + // // ), + // // ), + // child: Column( + // children: [ + // Row( + // mainAxisAlignment: + // MainAxisAlignment.spaceBetween, + // children: [ + // DeviceStatusInfoWidget( + // title: "在离床".tr, + // iconAsset: + // "assets/img/icon/bed_status.svg", + // value: inBed, + // ), + // DeviceStatusInfoWidget( + // title: "体动".tr, + // iconAsset: + // "assets/img/icon/bodymotion.svg", + // value: (bodyMotion == null || + // bodyMotion == -1) + // ? "未知数据".tr + // : "$bodyMotion", + // ), + // ], + // ), + // Row( + // mainAxisAlignment: + // MainAxisAlignment.spaceBetween, + // children: [ + // DeviceStatusInfoWidget( + // title: "心率".tr, + // iconAsset: + // "assets/img/icon/heart.svg", + // value: (heartrate == null || + // heartrate == -1) + // ? "未知数据".tr + // : "$heartrate", + // ), + // DeviceStatusInfoWidget( + // title: "打鼾".tr, + // iconAsset: + // "assets/img/icon/snore.svg", + // value: '${snores}'.tr, + // ), + // ], + // ), + // Row( + // mainAxisAlignment: + // MainAxisAlignment.spaceBetween, + // children: [ + // DeviceStatusInfoWidget( + // title: "呼吸".tr, + // iconAsset: + // "assets/img/icon/breathe.svg", + // value: (breathrate == null || + // breathrate == -1) + // ? "未知数据".tr + // : "$breathrate", + // ), + // DeviceStatusInfoWidget( + // title: "呼吸暂停".tr, + // iconAsset: + // "assets/img/icon/breathe_pause.svg", + // value: '${breathState}', + // ), + // ], + // ), + // ].divide(SizedBox(height: 49.rpx)), + // ), + // ), + // ), + // Padding( + // padding: EdgeInsetsDirectional.fromSTEB( + // 0.rpx, 67.rpx, 0.rpx, 0.rpx), + // child: Container( + // height: 40.rpx, + // child: Text( + // bodyMotion >= maxBodyMotion ? '请保持静止'.tr : "", + // style: FlutterFlowTheme.of(context) + // .bodyMedium + // .override( + // fontFamily: 'Inter', + // fontSize: 26.rpx, + // letterSpacing: 0.0, + // color: themeController.currentColor.sc9, + // ), + // ), + // ), + // ), + // // SizedBox( + // // height: 207.rpx, + // // ), + // ], + // ), + // )), + // ClickableContainer( + // backgroundColor: Colors.transparent, // 可自定义背景色 + // highlightColor: Colors.white, // 点击涟漪颜色 + // borderRadius: 16.rpx, // 圆角大小,可按需调整 + // padding: EdgeInsetsDirectional.fromSTEB( + // 30.rpx, 0.rpx, 30.rpx, 0.rpx), + // onTap: () {}, + // child: Container( + // padding: EdgeInsetsDirectional.fromSTEB( + // 26.rpx, 26.rpx, 26.rpx, 26.rpx), + // decoration: BoxDecoration( + // // color: FlutterFlowTheme.of(context) + // // .primaryBackground + // // .withOpacity(0.6), // 半透明背景 + // borderRadius: BorderRadius.circular(16.rpx), + // border: Border.all( + // color: themeController.currentColor.sc4 + // .withOpacity(0.5), + // width: 0.5.rpx, + // ), + // ), + // child: Row( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Padding( + // padding: EdgeInsetsDirectional.fromSTEB( + // 0, 8.rpx, 0, 0), + // child: Container( + // width: 23.rpx, + // height: 23.rpx, + // // width: double.infinity, + // decoration: BoxDecoration(), + // child: SvgPicture.asset( + // 'assets/img/icon/tips.svg', + // fit: BoxFit.cover, + // color: themeController.currentColor.sc4, + // ), + // ), + // ), + // Expanded( + // child: Text( + // '实时体征.提示'.tr, + // style: FlutterFlowTheme.of(context) + // .bodyMedium + // .override( + // fontFamily: 'Inter', + // letterSpacing: 0.0, + // color: themeController.currentColor.sc4, + // ), + // ), + // ), + // ].divide(SizedBox(width: 23.rpx)), + // ), + // ), + // ), + // SizedBox( + // height: 26.rpx, + // ), + // ], + // ), + // ), + + // ), + child: Stack( + children: [ + // 背景图只占一半高度 + // Align( + // alignment: Alignment.center, + // child: SizedBox( + // height: 1000.rpx, // 你可以根据需要调整图片最大高度 + // width: 1000.rpx, // 或设置 double.infinity 占满宽度 + // child: Image.asset( + // (onlineState == "离线".tr || inBed == '离床'.tr) + // ? 'assets/img/black_body_still.png' + // : 'assets/img/body_black.gif', + // fit: BoxFit.contain, // 保持原始比例,不拉伸 + // ), + // ), + // ), + Align( + alignment: Alignment.center, + child: FractionallySizedBox( + heightFactor: 0.5, + widthFactor: 0.5, + child: Opacity( + opacity: 0.7, + child: (onlineState == "离线".tr || inBed == '离床'.tr) + ? Image.asset( + 'assets/img/black_body_still.png', + fit: BoxFit.contain, + ) + : SpeedControlledGif( + 'assets/img/body_black.gif', + speedFactor: + 2, // 2.0 for 2x speed, 0.5 for half speed + fit: BoxFit.contain, ), - Flexible( - flex: 3, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Column( - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Text( - '实时体征.设备ID'.tr, - style: - FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: 'Inter', - fontSize: 26.rpx, - letterSpacing: 0.0, - color: themeController - .currentColor.sc4, - ), - ), - Text( - '实时体征.体重'.tr, - style: - FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: 'Inter', - fontSize: 26.rpx, - letterSpacing: 0.0, - color: themeController - .currentColor.sc4, - ), - ), - ].divide(SizedBox(height: 34.rpx)), - ), - Expanded( - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - '${device['code'] ?? '未知数据'.tr}', - // "D11250300003", - style: - FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: 'Inter', - fontSize: 26.rpx, - letterSpacing: 0.0, - color: themeController - .currentColor.sc3, - ), - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - Text( - '${device['person']?['weight'] ?? '未知数据'.tr}kg', - style: - FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: 'Inter', - fontSize: 26.rpx, - letterSpacing: 0.0, - color: themeController - .currentColor.sc3, - ), - ), - ].divide(SizedBox(height: 34.rpx)), - ), - ), - ] - .divide(SizedBox(width: 33.rpx)) - .addToStart(SizedBox(width: 37.rpx)), - ), - ] - .addToStart(SizedBox(height: 36.rpx)) - .addToEnd(SizedBox(height: 36.rpx)), - ), - ), - ], - ), - ), ), - Expanded( - child: SingleChildScrollView( - child: Column( - children: [ - Padding( - padding: EdgeInsetsDirectional.fromSTEB( - 66.rpx, 0, 66.rpx, 0), - child: Container( - // decoration: BoxDecoration( - // image: DecorationImage( - // image: AssetImage( - // onlineState == "离线".tr - // ? 'assets/img/black_body_still.png' // 静态图 - // : 'assets/img/body_black.gif', // 动图 - // ), - // fit: BoxFit.cover, - // ), - // ), - child: Column( - children: [ - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + ), + ), + // 其余内容放在上层 + Positioned.fill( + child: Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 0.rpx, 29.rpx, 0.rpx, 0.rpx), + child: Column( + mainAxisSize: MainAxisSize.max, + children: [ + Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 30.rpx, 0.rpx, 30.rpx, 120.rpx), + child: ClickableContainer( + backgroundColor: themeController.currentColor.sc5, + highlightColor: themeController + .currentColor.sc5, // 或你希望的点击水波纹颜色 + borderRadius: AppConstants() + .normal_container_radius, // 如果你想加圆角可以设置 eg. 12.rpx + padding: EdgeInsets.zero, + onTap: () { + print('点击了体征卡片'); + }, + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + Flexible( + flex: 2, + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, children: [ - DeviceStatusInfoWidget( - title: "在离床".tr, - iconAsset: - "assets/img/icon/bed_status.svg", - value: inBed, + Row( + children: [ + Column( + crossAxisAlignment: + CrossAxisAlignment.end, + children: [ + Text( + '实时体征.姓名'.tr, + style: FlutterFlowTheme.of( + context) + .bodyMedium + .override( + fontFamily: 'Inter', + fontSize: 26.rpx, + letterSpacing: 0.0, + color: themeController + .currentColor.sc4, + ), + ), + Text( + '实时体征.年龄'.tr, + style: FlutterFlowTheme.of( + context) + .bodyMedium + .override( + fontFamily: 'Inter', + fontSize: 26.rpx, + letterSpacing: 0.0, + color: themeController + .currentColor.sc4, + ), + ), + ].divide( + SizedBox(height: 34.rpx)), + ), + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + '${device['person']?['name'] ?? '未命名'.tr}', + style: FlutterFlowTheme.of( + context) + .bodyMedium + .override( + fontFamily: 'Inter', + fontSize: 26.rpx, + letterSpacing: 0.0, + color: themeController + .currentColor.sc3, + ), + ), + Text( + '${MyUtils.getAgeByDate(MyUtils.formatBirthdayTime(device['person']?['birthday'])) ?? '未知数据'.tr}', + style: FlutterFlowTheme.of( + context) + .bodyMedium + .override( + fontFamily: 'Inter', + fontSize: 26.rpx, + letterSpacing: 0.0, + color: themeController + .currentColor.sc3, + ), + ), + ].divide( + SizedBox(height: 34.rpx)), + ), + ] + .divide(SizedBox(width: 33.rpx)) + .addToStart( + SizedBox(width: 37.rpx)), ), - DeviceStatusInfoWidget( - title: "体动".tr, - iconAsset: - "assets/img/icon/bodymotion.svg", - value: (bodyMotion == null || - bodyMotion == -1) - ? "未知数据".tr - : "$bodyMotion", - ), - ], + ] + .addToStart(SizedBox(height: 36.rpx)) + .addToEnd(SizedBox(height: 36.rpx)), ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + ), + Flexible( + flex: 3, + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, children: [ - DeviceStatusInfoWidget( - title: "心率".tr, - iconAsset: - "assets/img/icon/heart.svg", - value: (heartrate == null || - heartrate == -1) - ? "未知数据".tr - : "$heartrate", + Row( + children: [ + Column( + crossAxisAlignment: + CrossAxisAlignment.end, + children: [ + Text( + '实时体征.设备ID'.tr, + style: FlutterFlowTheme.of( + context) + .bodyMedium + .override( + fontFamily: 'Inter', + fontSize: 26.rpx, + letterSpacing: 0.0, + color: themeController + .currentColor.sc4, + ), + ), + Text( + '实时体征.体重'.tr, + style: FlutterFlowTheme.of( + context) + .bodyMedium + .override( + fontFamily: 'Inter', + fontSize: 26.rpx, + letterSpacing: 0.0, + color: themeController + .currentColor.sc4, + ), + ), + ].divide( + SizedBox(height: 34.rpx)), + ), + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + '${device['code'] ?? '未知数据'.tr}', + // "D11250300003", + style: FlutterFlowTheme.of( + context) + .bodyMedium + .override( + fontFamily: 'Inter', + fontSize: 26.rpx, + letterSpacing: 0.0, + color: themeController + .currentColor.sc3, + ), + maxLines: 1, + overflow: + TextOverflow.ellipsis, + ), + Text( + '${device['person']?['weight'] ?? '未知数据'.tr}kg', + style: FlutterFlowTheme.of( + context) + .bodyMedium + .override( + fontFamily: 'Inter', + fontSize: 26.rpx, + letterSpacing: 0.0, + color: themeController + .currentColor.sc3, + ), + ), + ].divide( + SizedBox(height: 34.rpx)), + ), + ), + ] + .divide(SizedBox(width: 33.rpx)) + .addToStart( + SizedBox(width: 37.rpx)), ), - DeviceStatusInfoWidget( - title: "打鼾".tr, - iconAsset: - "assets/img/icon/snore.svg", - value: '${snores}'.tr, - ), - ], + ] + .addToStart(SizedBox(height: 36.rpx)) + .addToEnd(SizedBox(height: 36.rpx)), ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - DeviceStatusInfoWidget( - title: "呼吸".tr, - iconAsset: - "assets/img/icon/breathe.svg", - value: (breathrate == null || - breathrate == -1) - ? "未知数据".tr - : "$breathrate", - ), - DeviceStatusInfoWidget( - title: "呼吸暂停".tr, - iconAsset: - "assets/img/icon/breathe_pause.svg", - value: '${breathState}', - ), - ], - ), - ].divide(SizedBox(height: 49.rpx)), - ), + ), + ], ), ), - Padding( - padding: EdgeInsetsDirectional.fromSTEB( - 0.rpx, 67.rpx, 0.rpx, 0.rpx), - child: Container( - height: 40.rpx, - child: Text( - bodyMotion >= maxBodyMotion ? '请保持静止'.tr : "", - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: 'Inter', - fontSize: 26.rpx, - letterSpacing: 0.0, - color: themeController.currentColor.sc9, - ), - ), - ), - ), - // SizedBox( - // height: 207.rpx, - // ), - ], - ), - )), - ClickableContainer( - backgroundColor: Colors.transparent, // 可自定义背景色 - highlightColor: Colors.white, // 点击涟漪颜色 - borderRadius: 16.rpx, // 圆角大小,可按需调整 - padding: EdgeInsetsDirectional.fromSTEB( - 30.rpx, 0.rpx, 30.rpx, 0.rpx), - onTap: () {}, - child: Container( - padding: EdgeInsetsDirectional.fromSTEB( - 26.rpx, 26.rpx, 26.rpx, 26.rpx), - decoration: BoxDecoration( - // color: FlutterFlowTheme.of(context) - // .primaryBackground - // .withOpacity(0.6), // 半透明背景 - borderRadius: BorderRadius.circular(16.rpx), - border: Border.all( - color: themeController.currentColor.sc4 - .withOpacity(0.5), - width: 0.5.rpx, - ), ), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsetsDirectional.fromSTEB( - 0, 8.rpx, 0, 0), - child: Container( - width: 23.rpx, - height: 23.rpx, - // width: double.infinity, - decoration: BoxDecoration(), - child: SvgPicture.asset( - 'assets/img/icon/tips.svg', - fit: BoxFit.cover, - color: themeController.currentColor.sc4, + Expanded( + child: SingleChildScrollView( + child: Column( + children: [ + Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 66.rpx, 0, 66.rpx, 0), + child: Container( + // decoration: BoxDecoration( + // image: DecorationImage( + // image: AssetImage( + // onlineState == "离线".tr + // ? 'assets/img/black_body_still.png' // 静态图 + // : 'assets/img/body_black.gif', // 动图 + // ), + // fit: BoxFit.cover, + // ), + // ), + child: Column( + children: [ + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + DeviceStatusInfoWidget( + title: "在离床".tr, + iconAsset: + "assets/img/icon/bed_status.svg", + value: inBed, + ), + DeviceStatusInfoWidget( + title: "体动".tr, + iconAsset: + "assets/img/icon/bodymotion.svg", + value: (bodyMotion == null || + bodyMotion == -1) + ? "未知数据".tr + : "$bodyMotion", + ), + ], + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + DeviceStatusInfoWidget( + title: "心率".tr, + iconAsset: + "assets/img/icon/heart.svg", + value: (heartrate == null || + heartrate == -1) + ? "未知数据".tr + : "$heartrate", + ), + DeviceStatusInfoWidget( + title: "打鼾".tr, + iconAsset: + "assets/img/icon/snore.svg", + value: '${snores}'.tr, + ), + ], + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + DeviceStatusInfoWidget( + title: "呼吸".tr, + iconAsset: + "assets/img/icon/breathe.svg", + value: (breathrate == null || + breathrate == -1) + ? "未知数据".tr + : "$breathrate", + ), + DeviceStatusInfoWidget( + title: "呼吸暂停".tr, + iconAsset: + "assets/img/icon/breathe_pause.svg", + value: '${breathState}', + ), + ], + ), + ].divide(SizedBox(height: 49.rpx)), + ), ), ), - ), - Expanded( - child: Text( - '实时体征.提示'.tr, - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: 'Inter', - letterSpacing: 0.0, - color: themeController.currentColor.sc4, - ), + Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 0.rpx, 67.rpx, 0.rpx, 0.rpx), + child: Container( + height: 40.rpx, + child: Text( + bodyMotion >= maxBodyMotion + ? '请保持静止'.tr + : "", + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + fontFamily: 'Inter', + fontSize: 26.rpx, + letterSpacing: 0.0, + color: themeController + .currentColor.sc9, + ), + ), + ), + ), + // SizedBox( + // height: 207.rpx, + // ), + ], + ), + )), + ClickableContainer( + backgroundColor: Colors.transparent, // 可自定义背景色 + highlightColor: Colors.white, // 点击涟漪颜色 + borderRadius: 16.rpx, // 圆角大小,可按需调整 + padding: EdgeInsetsDirectional.fromSTEB( + 30.rpx, 0.rpx, 30.rpx, 0.rpx), + onTap: () {}, + child: Container( + padding: EdgeInsetsDirectional.fromSTEB( + 26.rpx, 26.rpx, 26.rpx, 26.rpx), + decoration: BoxDecoration( + // color: FlutterFlowTheme.of(context) + // .primaryBackground + // .withOpacity(0.6), // 半透明背景 + borderRadius: BorderRadius.circular(16.rpx), + border: Border.all( + color: themeController.currentColor.sc4 + .withOpacity(0.5), + width: 0.5.rpx, ), ), - ].divide(SizedBox(width: 23.rpx)), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 0, 8.rpx, 0, 0), + child: Container( + width: 23.rpx, + height: 23.rpx, + // width: double.infinity, + decoration: BoxDecoration(), + child: SvgPicture.asset( + 'assets/img/icon/tips.svg', + fit: BoxFit.cover, + color: themeController.currentColor.sc4, + ), + ), + ), + Expanded( + child: Text( + '实时体征.提示'.tr, + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + fontFamily: 'Inter', + letterSpacing: 0.0, + color: themeController + .currentColor.sc4, + ), + ), + ), + ].divide(SizedBox(width: 23.rpx)), + ), + ), ), - ), + SizedBox( + height: 26.rpx, + ), + ], ), - SizedBox( - height: 26.rpx, - ), - ], + ), ), - ), + ], ), ), ), @@ -555,3 +978,88 @@ class _InstantBodyPageState extends State { ); } } + +class SpeedControlledGif extends StatefulWidget { + final String assetPath; + final double speedFactor; + final BoxFit? fit; + + /// [speedFactor] 播放速度倍数,默认1.0, + /// 大于1表示加速播放,小于1表示减速播放 + const SpeedControlledGif( + this.assetPath, { + Key? key, + this.speedFactor = 1.0, + this.fit, + }) : super(key: key); + + @override + _SpeedControlledGifState createState() => _SpeedControlledGifState(); +} + +class _SpeedControlledGifState extends State { + ui.Codec? _codec; + ui.FrameInfo? _currentFrame; + Timer? _timer; + bool _isDisposed = false; + + @override + void initState() { + super.initState(); + _loadGif(); + } + + Future _loadGif() async { + final data = await rootBundle.load(widget.assetPath); + _codec = await ui.instantiateImageCodec(data.buffer.asUint8List()); + + if (_isDisposed) return; + + _showNextFrame(); + } + + Future _showNextFrame() async { + if (_isDisposed || _codec == null) return; + + _currentFrame = await _codec!.getNextFrame(); + + if (_isDisposed) return; + + if (mounted) { + setState(() {}); + } + + // 取当前帧持续时间,单位毫秒 + final baseDuration = _currentFrame?.duration.inMilliseconds ?? 100; + + // 限制最小帧间隔,防止刷新过快 + const minFrameDuration = 50; + + // 计算实际播放帧间隔,speedFactor越大速度越快 + final adjustedDuration = (baseDuration / widget.speedFactor) + .round() + .clamp(minFrameDuration, 10000); + + _timer = Timer(Duration(milliseconds: adjustedDuration), _showNextFrame); + } + + @override + void dispose() { + _isDisposed = true; + _timer?.cancel(); + _codec?.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + if (_currentFrame == null) { + // 加载中或无帧时显示空容器或占位 + return Container(); + } + return RawImage( + image: _currentFrame!.image, + fit: widget.fit, + ); + } +} diff --git a/lib/pages/device_bind/after/after_device_calibration_person.dart b/lib/pages/device_bind/after/after_device_calibration_person.dart new file mode 100644 index 0000000..4954d54 --- /dev/null +++ b/lib/pages/device_bind/after/after_device_calibration_person.dart @@ -0,0 +1,1150 @@ +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/controller/device/blueteeth_bind_controller.dart'; +import 'package:vbvs_app/controller/device/device_calibration_controller.dart'; +import 'package:vbvs_app/controller/person/person_controller.dart'; +import 'package:vbvs_app/pages/device_bind/componnet/CalibrationProgressWidget.dart'; +import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart'; + +class AfterCalibrationPersonPage extends StatefulWidget { + AfterCalibrationPersonPage({super.key}); + + @override + State createState() => + _AfterCalibrationPersonPageState(); +} + +class _AfterCalibrationPersonPageState + extends State { + DeviceCalibrationController deviceCalibrationController = Get.find(); + BlueteethBindController 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 = ""; + } + + @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/img/bgNoImg.png'), + fit: BoxFit.fill, + ), + ), + child: Scaffold( + backgroundColor: Colors.transparent, + appBar: AppBar( + backgroundColor: themeController.currentColor.sc17, + 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; + Get.back(); + return; + }, 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 { + // Get.back(); + // print("object"); + deviceCalibrationController.process.value = 0; + deviceCalibrationController + .bed_calibration.value = 0; + deviceCalibrationController + .position_calibration.value = 0; + blueteethBindController.cid!.value = ""; + PersonController personController = + Get.find(); + var data = personController.after_deveice; + if (data['person'] != null) { + personController.currentPersonId.value = + data['_id']; + personController.name.value = + data['person']['name']; + personController.update_person_mac.value = + data['mac']; + personController.gender.value = + data['person']['gender'] ?? 1; + personController.weight?.value = + data['person']['weight'] == null + ? '' + : data['person']['weight'] + .toString(); + + personController.height.value = + data['person']['height'] == null + ? '' + : data['person']['height'] + .toString(); + + personController.selectedDiseaseIds.value = + data['person']['disease'] ?? []; + personController.birthday.value = + data['person']['birthday'] ?? ''; + personController.dateTime = + MyUtils.formatBirthdayTime( + data['person']['birthday']); + } else { + personController.update_person_mac.value = + data['mac']; + personController.currentPersonId.value = + data['_id']; + personController.name.value = ""; + personController.gender.value = 1; + personController.dateTime = null; + personController.height.value = ""; + personController.weight.value = ""; + personController.diseaseList.value = []; + } + + await Get.toNamed("/afterUpdatePersonPage"); + return; + }, onCancel: () {}); + } else { + // Get.back(); + 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 = ""; + PersonController personController = Get.find(); + var data = personController.after_deveice; + if (data['person'] != null) { + personController.currentPersonId.value = + data['_id']; + personController.name.value = + data['person']['name']; + personController.update_person_mac.value = + data['mac']; + personController.gender.value = + data['person']['gender'] ?? 1; + personController.weight?.value = + data['person']['weight'] == null + ? '' + : data['person']['weight'].toString(); + + personController.height.value = + data['person']['height'] == null + ? '' + : data['person']['height'].toString(); + + personController.selectedDiseaseIds.value = + data['person']['disease'] ?? []; + personController.birthday.value = + data['person']['birthday'] ?? ''; + personController.dateTime = + MyUtils.formatBirthdayTime( + data['person']['birthday']); + } else { + personController.update_person_mac.value = + data['mac']; + personController.currentPersonId.value = + data['_id']; + personController.name.value = ""; + personController.gender.value = 1; + personController.dateTime = null; + personController.height.value = ""; + personController.weight.value = ""; + personController.diseaseList.value = []; + } + + await Get.toNamed( + "/afterUpdatePersonPage", + ); + return; + } + }, + colors: [ + themeController.currentColor.sc1, + themeController.currentColor.sc2, + ], + 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: themeController.currentColor.sc3, + 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: themeController.currentColor.sc5, + 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() + .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 + blueteethBindController = Get.find(); + 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 + .currentDeviceMac!.value, + }; + + // 是否是二次点击(有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(); + + BlueteethBindController + blueteethBindController = Get.find(); + 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 + .currentDeviceMac!.value, + }; + + // 是否是二次点击(有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(); + }), + ], + ), + ), + ), + ), + ), + ), + ), + onWillPop: () async { + bool exit = false; + if (deviceCalibrationController.flag.value != 2) { + 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 = ""; + }, 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) { + // 第二步完成 + updateDeviceBindStatus( + blueteethBindController.currentDeviceMac!.value); + _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; // 重置失败状态 + } + }, + 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": res.data['person_info'], + "time": DateTime.now().millisecondsSinceEpoch, + }; + requestWithLog( + logTitle: "更新绑定流程", + method: MyHttpMethod.put, + queryUrl: queryUrl, + data: data, + onSuccess: (res) {}, + onFailure: (res) {}, + ); + }, + onFailure: (res) {}, + ); + } +} diff --git a/lib/pages/device_bind/after/after_update_person_page.dart b/lib/pages/device_bind/after/after_update_person_page.dart new file mode 100644 index 0000000..c7efdda --- /dev/null +++ b/lib/pages/device_bind/after/after_update_person_page.dart @@ -0,0 +1,907 @@ +import 'package:ef/ef.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.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/color/app_uri_status.dart'; +import 'package:vbvs_app/common/util/FitTool.dart'; +import 'package:vbvs_app/common/util/MyUtils.dart'; +import 'package:vbvs_app/common/util/requestWithLog.dart'; +import 'package:vbvs_app/component/tool/CustomCard.dart'; +import 'package:vbvs_app/component/tool/SelectableTagButton.dart'; +import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; +import 'package:vbvs_app/controller/device/blueteeth_bind_controller.dart'; +import 'package:vbvs_app/controller/device/body_device_controller.dart'; +import 'package:vbvs_app/controller/main_bottom/global_controller.dart'; +import 'package:vbvs_app/controller/person/person_controller.dart'; +import 'package:vbvs_app/controller/theme_controller/ThemeController.dart'; +import 'package:vbvs_app/controller/user_info_controller.dart'; +import 'package:vbvs_app/model/api_response.dart'; +import 'package:vbvs_app/pages/person/select_time.dart'; + +class AfterUpdatePersonPage extends StatefulWidget { + AfterUpdatePersonPage({super.key}); + + @override + State createState() => _AfterUpdatePersonPageState(); +} + +class _AfterUpdatePersonPageState extends State { + GlobalController globalController = Get.find(); + UserInfoController userInfoController = Get.find(); + BlueteethBindController blueteethBindController = Get.find(); + PersonController personController = Get.find(); + BodyDeviceController bodyDeviceController = Get.find(); + ThemeController themeController = Get.find(); + + @override + void initState() { + super.initState(); + // personController.dateTime = null; + personController.getDiseaseData().then((apiResponse) { + if (apiResponse.code != HttpStatusCodes.ok) { + TopSlideNotification.show( + context, + text: apiResponse.msg ?? '', + textColor: themeController.currentColor.sc9, + ); + } + }); + } + + @override + Widget build(BuildContext context) { + return LayoutBuilder( + builder: (context, bodySize) => GestureDetector( + onTap: () => FocusScope.of(context).unfocus(), + child: Container( + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/img/bgNoImg.png'), // 本地图片 + fit: BoxFit.fill, // 填满整个 Container + ), + ), + child: Scaffold( + backgroundColor: Colors.transparent, // 加上这一行 + appBar: AppBar( + backgroundColor: themeController.currentColor.sc17, + automaticallyImplyLeading: false, + iconTheme: IconThemeData( + color: themeController.currentColor.sc3, + ), + titleSpacing: 0, + // leading: returnIconButtom, + title: Container( + width: double.infinity, + height: 180.rpx, + child: Stack( + alignment: Alignment.center, + children: [ + /// 居中标题 + Text( + '人员资料.标题'.tr, + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: 'Readex Pro', + color: themeController.currentColor.sc3, + letterSpacing: 0, + fontSize: 30.rpx, + ), + ), + + /// 左边返回按钮 + Positioned( + left: 0, + child: returnIconButtomAddCallback(() { + bodyDeviceController.getDeviceList(); + bodyDeviceController.updateAll(); + }), + ), + Positioned( + right: 20.rpx, + child: CustomCard( + borderRadius: 20.rpx, + onTap: () async { + ApiResponse apiRespons = + await personController.savePersonData(); + if (apiRespons.code == HttpStatusCodes.ok) { + updateDeviceBindStatus( + personController.update_person_mac.value); + TopSlideNotification.show(context, + text: apiRespons.msg!); + List device_bind_process = + userInfoController.device_bind_status; + String mac = + personController.update_person_mac.value; + device_bind_process.removeWhere( + (element) => element['mac'] == mac); + await Get.offNamed("/bindDeviceSuccess"); + } else { + TopSlideNotification.show(context, + text: apiRespons.msg!, + textColor: themeController.currentColor.sc9); + } + }, + colors: [ + themeController.currentColor.sc1, + themeController.currentColor.sc2, + ], + child: Container( + width: 140.rpx, + height: 60.rpx, + alignment: Alignment.center, + padding: EdgeInsetsDirectional.fromSTEB( + 16.rpx, 0, 16.rpx, 0), + child: Text( + '下一步'.tr, + style: FlutterFlowTheme.of(context) + .titleSmall + .override( + fontFamily: 'Inter Tight', + color: themeController.currentColor.sc3, + letterSpacing: 0.0, + ), + ), + ), + ), + ), + ], + ), + ), + + actions: [], + centerTitle: false, + ), + + body: SafeArea( + top: true, + child: Padding( + padding: EdgeInsetsDirectional.fromSTEB(30.rpx, 0, 30.rpx, 0), + child: Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Column( + mainAxisSize: MainAxisSize.max, + children: [ + Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 70.rpx, 141.rpx, 70.rpx, 0), + child: Container( + width: double.infinity, + height: 100.rpx, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(50.rpx), + border: Border.all( + color: themeController.currentColor.sc4 + .withOpacity(0.5), + width: AppConstants().border_width, + ), + ), + child: Align( + alignment: AlignmentDirectional(0, 0), + child: TextFormField( + // controller: _model.textController1, + // focusNode: _model.textFieldFocusNode1, + initialValue: personController.name.value, + onChanged: (Value) { + personController.name.value = Value; + }, + autofocus: false, + obscureText: false, + decoration: InputDecoration( + fillColor: Colors.transparent, + isDense: true, + labelStyle: FlutterFlowTheme.of(context) + .labelMedium + .override( + fontFamily: 'Inter', + letterSpacing: 0.0, + color: themeController + .currentColor.sc3, + ), + hintText: '人员资料.名字输入提示'.tr, + hintStyle: FlutterFlowTheme.of(context) + .labelMedium + .override( + fontFamily: 'Inter', + fontSize: 26.rpx, + letterSpacing: 0.0, + color: themeController + .currentColor.sc4, + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Color(0x00000000), + width: 1.rpx, + ), + borderRadius: + BorderRadius.circular(8.rpx), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Color(0x00000000), + width: 1.rpx, + ), + borderRadius: + BorderRadius.circular(8.rpx), + ), + errorBorder: OutlineInputBorder( + borderSide: BorderSide( + color: FlutterFlowTheme.of(context) + .error, + width: 1.rpx, + ), + borderRadius: + BorderRadius.circular(8.rpx), + ), + focusedErrorBorder: OutlineInputBorder( + borderSide: BorderSide( + color: FlutterFlowTheme.of(context) + .error, + width: 1.rpx, + ), + borderRadius: + BorderRadius.circular(8.rpx), + ), + filled: true, + ), + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + fontFamily: 'Inter', + letterSpacing: 0.0, + color: + themeController.currentColor.sc3, + ), + textAlign: TextAlign.center, + cursorColor: + themeController.currentColor.sc3, + // validator: _model.textController1Validator + // .asValidator(context), + ), + ), + ), + ), + Align( + alignment: AlignmentDirectional(0, 0), + child: Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 0, 90.rpx, 0, 0), + child: Container( + width: double.infinity, + decoration: BoxDecoration(), + child: Align( + alignment: AlignmentDirectional(-1, 0), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Obx( + () { + bool isMaleGreyed = + personController.gender.value == + 0; // gender == 0 时男生部分变灰 + return GestureDetector( + onTap: () { + personController.gender.value = + 1; // 点击时将 gender 设置为 1(女生部分被选中) + }, + child: Column( + mainAxisSize: MainAxisSize.max, + children: [ + Container( + width: 90.rpx, + height: 90.rpx, + child: ClipOval( + child: Opacity( + opacity: isMaleGreyed + ? 0.4 + : 1.0, // 控制透明度 + child: Image.asset( + "assets/img/man.png", + fit: BoxFit.cover, + ), + ), + ), + ), + Text( + '男'.tr, + style: FlutterFlowTheme.of( + context) + .bodyMedium + .override( + fontFamily: 'Inter', + fontSize: 26.rpx, + letterSpacing: 0.0, + color: isMaleGreyed + ? themeController + .currentColor + .sc4 + : themeController + .currentColor + .sc3, + ), + ), + ].divide( + SizedBox(height: 14.rpx)), + ), + ); + }, + ), + + // 女性部分 + Obx( + () { + bool isFemaleGreyed = + personController.gender.value == + 1; // gender == 1 时女生部分变灰 + return GestureDetector( + onTap: () { + personController.gender.value = + 0; // 点击时将 gender 设置为 0(男生部分被选中) + }, + child: Column( + mainAxisSize: MainAxisSize.max, + children: [ + Container( + width: 90.rpx, + height: 90.rpx, + child: ClipOval( + child: Opacity( + opacity: isFemaleGreyed + ? 0.4 + : 1.0, // 控制透明度 + child: Image.asset( + "assets/img/man.png", + fit: BoxFit.cover, + ), + ), + ), + ), + Text( + '女'.tr, + style: FlutterFlowTheme.of( + context) + .bodyMedium + .override( + fontFamily: 'Inter', + color: isFemaleGreyed + ? themeController + .currentColor + .sc4 + : themeController + .currentColor + .sc3, + fontSize: 26.rpx, + letterSpacing: 0.0, + ), + ), + ].divide( + SizedBox(height: 14.rpx)), + ), + ); + }, + ), + ].divide(SizedBox(width: 170.rpx)), + ), + ), + ), + ), + ), + Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 70.rpx, 50.rpx, 70.rpx, 0), + child: Container( + height: 100.rpx, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(50.rpx), + border: Border.all( + color: themeController.currentColor.sc4 + .withOpacity(0.5), + width: AppConstants().border_width, + ), + ), + child: InkWell( + onTap: () { + FocusScope.of(context) + .requestFocus(FocusNode()); + Future.delayed(Duration(milliseconds: 250), + () { + showDateSelectionDialog( + context, + checkDate: personController.dateTime ?? + DateTime.now(), + checkChange: (DateTime d) { + personController.birthday.value = + MyUtils.formatBindTime(d); + personController.dateTime = d; + personController.updateAll(); + }, + title: "生日".tr, + ); + }); + }, + child: Center( + child: Text( + personController.dateTime != null + ? DateFormat("yyyy年MM月dd日").format( + personController.dateTime!) + : '人员资料.生日输入提示'.tr, + textAlign: TextAlign.right, + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + fontFamily: 'Readex Pro', + color: personController.dateTime != + null + ? themeController + .currentColor.sc3 + : themeController + .currentColor.sc4, + fontSize: AppConstants() + .normal_text_fontSize, + letterSpacing: 0, + ), + ), + ), + ), + ), + ), + Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 70.rpx, 18.rpx, 70.rpx, 0), + child: Container( + width: double.infinity, + height: 100.rpx, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(50.rpx), + border: Border.all( + color: themeController.currentColor.sc4 + .withOpacity(0.5), + width: AppConstants().border_width, + ), + ), + child: Align( + alignment: AlignmentDirectional(0, 0), + child: Stack( + alignment: Alignment.center, + children: [ + TextFormField( + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter + .digitsOnly, + ], + initialValue: personController + .height.value + .toString(), + onChanged: (value) { + personController.height.value = value; + }, + autofocus: false, + obscureText: false, + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + fontFamily: 'Inter', + color: + Colors.transparent, // 隐藏输入文字 + letterSpacing: 0.0, + ), + textAlign: TextAlign.center, + cursorColor: + themeController.currentColor.sc3, + decoration: InputDecoration( + fillColor: Colors.transparent, + isDense: true, + hintText: '身高输入提示'.tr, + hintStyle: + FlutterFlowTheme.of(context) + .labelMedium + .override( + fontFamily: 'Inter', + color: themeController + .currentColor.sc4, + fontSize: AppConstants() + .normal_text_fontSize, + letterSpacing: 0.0, + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Color(0x00000000), + width: 1.rpx, + ), + borderRadius: + BorderRadius.circular(8.rpx), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Color(0x00000000), + width: 1.rpx, + ), + borderRadius: + BorderRadius.circular(8.rpx), + ), + errorBorder: OutlineInputBorder( + borderSide: BorderSide( + color: + FlutterFlowTheme.of(context) + .error, + width: 1.rpx, + ), + borderRadius: + BorderRadius.circular(8.rpx), + ), + focusedErrorBorder: + OutlineInputBorder( + borderSide: BorderSide( + color: + FlutterFlowTheme.of(context) + .error, + width: 1.rpx, + ), + borderRadius: + BorderRadius.circular(8.rpx), + ), + filled: true, + ), + ), + Obx(() { + final height = + personController.height.value; + return (height == null || + height.isEmpty) + ? const SizedBox.shrink() // 不显示任何内容 + : Text( + '${height}cm', + textAlign: TextAlign.center, + style: + FlutterFlowTheme.of(context) + .bodyMedium + .override( + fontFamily: 'Inter', + color: themeController + .currentColor.sc3, + fontSize: AppConstants() + .normal_text_fontSize, + ), + ); + }), + ], + ), + ), + ), + ), + Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 70.rpx, 18.rpx, 70.rpx, 0), + child: Container( + width: double.infinity, + height: 100.rpx, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(50.rpx), + border: Border.all( + color: themeController.currentColor.sc4 + .withOpacity(0.5), + width: AppConstants().border_width, + ), + ), + child: Align( + alignment: AlignmentDirectional(0, 0), + child: Stack( + alignment: Alignment.center, + children: [ + // 实际输入框(输入逻辑保留) + TextFormField( + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter + .digitsOnly, + ], + initialValue: personController + .weight.value + .toString(), + onChanged: (value) { + personController.weight.value = value; + }, + autofocus: false, + obscureText: false, + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + fontFamily: 'Inter', + color: + Colors.transparent, // 隐藏输入文字 + letterSpacing: 0.0, + ), + textAlign: TextAlign.center, + cursorColor: + themeController.currentColor.sc3, + decoration: InputDecoration( + fillColor: Colors.transparent, + isDense: true, + hintText: '人员资料.体重输入提示'.tr, + hintStyle: + FlutterFlowTheme.of(context) + .labelMedium + .override( + fontFamily: 'Inter', + color: themeController + .currentColor.sc4, + fontSize: AppConstants() + .normal_text_fontSize, + letterSpacing: 0.0, + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Color(0x00000000), + width: 1.rpx, + ), + borderRadius: + BorderRadius.circular(8.rpx), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Color(0x00000000), + width: 1.rpx, + ), + borderRadius: + BorderRadius.circular(8.rpx), + ), + errorBorder: OutlineInputBorder( + borderSide: BorderSide( + color: + FlutterFlowTheme.of(context) + .error, + width: 1.rpx, + ), + borderRadius: + BorderRadius.circular(8.rpx), + ), + focusedErrorBorder: + OutlineInputBorder( + borderSide: BorderSide( + color: + FlutterFlowTheme.of(context) + .error, + width: 1.rpx, + ), + borderRadius: + BorderRadius.circular(8.rpx), + ), + filled: true, + ), + ), + Obx(() { + final weight = + personController.weight?.value; + return (weight == null || + weight.isEmpty) + ? const SizedBox.shrink() // 不显示任何内容 + : Text( + '${weight}kg', + textAlign: TextAlign.center, + style: + FlutterFlowTheme.of(context) + .bodyMedium + .override( + fontFamily: 'Inter', + color: themeController + .currentColor.sc3, + fontSize: AppConstants() + .normal_text_fontSize, + ), + ); + }), + ], + ), + ), + ), + ), + Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 0, 117.rpx, 0, 0), + child: Container( + width: double.infinity, + decoration: BoxDecoration(), + child: Align( + alignment: AlignmentDirectional(0, 0), + child: Text( + '人员资料.疾病标题'.tr, + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + fontFamily: 'Inter', + color: Color(0xFFF3F4F5), + fontSize: 30.rpx, + letterSpacing: 0.0, + ), + ), + ), + ), + ), + Obx(() { + final selectedIds = + personController.selectedDiseaseIds; + final diseases = personController.diseaseList; + return Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 70.rpx, 70.rpx, 70.rpx, 0), + child: Wrap( + spacing: 20.rpx, + runSpacing: 20.rpx, + children: diseases.map((disease) { + final id = disease['_id']; + final name = disease['disease_type_name']; + final isSelected = selectedIds.contains(id); + return SelectableTagButton( + label: name, + selected: isSelected, + onTap: () { + if (isSelected) { + selectedIds.remove(id); + } else { + selectedIds.add(id); + } + personController.model.read = 0; + personController.updateAll(); + //切换语言 + // Get.updateLocale(Locale("en", "us")); + }, + ); + }).toList(), + ), + ); + }), + ], + ), + ), + ), + Padding( + padding: EdgeInsetsDirectional.fromSTEB(0, 52.rpx, 0, 0), + child: Container( + width: double.infinity, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20.rpx), + border: Border.all( + color: themeController.currentColor.sc4 + .withOpacity(0.5), + width: AppConstants().border_width, + ), + ), + child: Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 30.rpx, 30.rpx, 30.rpx, 30.rpx), + child: Row( + mainAxisSize: MainAxisSize.max, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 0, 8.rpx, 0, 0), + child: Container( + width: 23.rpx, + height: 23.rpx, + // width: double.infinity, + decoration: BoxDecoration(), + child: SvgPicture.asset( + 'assets/img/icon/tips.svg', + fit: BoxFit.cover, + color: themeController.currentColor.sc4, + ), + ), + ), + Expanded( + child: Text( + '人员资料.提示'.tr, + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + fontFamily: 'Inter', + color: themeController.currentColor.sc4, + fontSize: 26.rpx, + letterSpacing: 0.0, + ), + ), + ), + ].divide(SizedBox(width: 23.rpx)), + ), + ), + ), + ), + SizedBox( + height: 20.rpx, + ), + ], + ), + ), + ), + ), + ), + ), + ); + } + + Widget _buildDeviceCard(BuildContext context, + {required String title, required String imageUrl, required String type}) { + return CustomCard( + borderRadius: 20.rpx, // 圆角大小 + onTap: () { + if (type != null) { + if (type == '1') { + Get.toNamed("/blueteethDevice"); + } + } + }, + colors: [themeController.currentColor.sc17], // 背景色 + child: Container( + width: double.infinity, + height: MediaQuery.sizeOf(context).height * 0.135, + constraints: BoxConstraints( + minHeight: 220.rpx, + ), + padding: EdgeInsetsDirectional.fromSTEB(77.rpx, 0, 21.rpx, 0), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + title, + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: 'Inter', + color: const Color(0xFFC2CED7), + fontSize: 30.rpx, + letterSpacing: 0.0, + ), + ), + ClipRRect( + borderRadius: BorderRadius.circular(8.rpx), + child: Image.asset( + imageUrl, + width: 212.rpx, + height: 168.rpx, + ), + ), + ], + ), + ), + ); + } + + 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": res.data['celibration'], + "person_info": true, + "time": DateTime.now().millisecondsSinceEpoch, + }; + requestWithLog( + logTitle: "更新绑定流程", + method: MyHttpMethod.put, + queryUrl: queryUrl, + data: data, + onSuccess: (res) {}, + onFailure: (res) {}, + ); + }, + onFailure: (res) {}, + ); + } +} diff --git a/lib/pages/device_bind/after/after_wifi_page_person.dart b/lib/pages/device_bind/after/after_wifi_page_person.dart new file mode 100644 index 0000000..dad2d5e --- /dev/null +++ b/lib/pages/device_bind/after/after_wifi_page_person.dart @@ -0,0 +1,1148 @@ +import 'dart:async'; + +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: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/component/tool/cmd.dart'; +import 'package:vbvs_app/controller/device/blueteeth_bind_controller.dart'; +import 'package:vbvs_app/controller/main_bottom/global_controller.dart'; +import 'package:vbvs_app/controller/person/person_controller.dart'; +import 'package:vbvs_app/controller/theme_controller/ThemeController.dart'; +import 'package:vbvs_app/controller/user_info_controller.dart'; +import 'package:vbvs_app/model/BleDeviceData.dart'; +import 'package:vbvs_app/pages/device_bind/blueteeth_device_page.dart'; +import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart'; + +class AfterWifiPagePerson extends StatefulWidget { + var type; + AfterWifiPagePerson({super.key, required this.type}); + + @override + State createState() => _AfterWifiPagePersonState(); +} + +class _AfterWifiPagePersonState extends State { + GlobalController globalController = Get.find(); + UserInfoController userInfoController = Get.find(); + BlueteethBindController blueteethBindController = Get.find(); + PersonController personController = Get.find(); + ThemeController themeController = Get.find(); + var lisObj; + + @override + void initState() { + super.initState(); + blueteethBindController.netType.value = 0; + blueteethBindController.connectStatus.value = 0; + blueteethBindController.wifiList = [].obs; + blueteethBindController.wifiStatus = 0.obs; + blueteethBindController.connect_wifi.value = {}; + blueteethBindController.selectWifi.value = {}; + blueteethBindController.wifiStatus.value = widget.type['status']['status']; + blueteethBindController.blueConnectFlag.value = 0; + blueteethBindController.wifiConnectStatus.value = 1; + blueteethBindController.updateAll(); + dealWifi(widget.type['mac']).then((aa) { + print("object"); + }); + } + + @override + void dispose() { + super.dispose(); + if (lisObj != null) { + lisObj.cancel(); + } + blueteethBindController.currentDevice!.disconnect(); + } + + @override + Widget build(BuildContext context) { + return LayoutBuilder( + builder: (context, bodySize) => GestureDetector( + onTap: () => FocusScope.of(context).unfocus(), + child: Container( + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/img/bgNoImg.png'), // 本地图片 + fit: BoxFit.fill, // 填满整个 Container + ), + ), + child: Scaffold( + backgroundColor: Colors.transparent, // 加上这一行 + appBar: AppBar( + backgroundColor: themeController.currentColor.sc17, + automaticallyImplyLeading: false, + iconTheme: IconThemeData(color: themeController.currentColor.sc3), + titleSpacing: 0, + // leading: returnIconButtom, + title: Container( + width: double.infinity, + height: 180.rpx, + child: Stack( + alignment: Alignment.center, + children: [ + /// 居中标题 + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + 'wifi页.标题'.tr, + style: + FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: 'Readex Pro', + color: themeController.currentColor.sc3, + letterSpacing: 0, + fontSize: 30.rpx, + ), + ), + SizedBox( + width: 14.rpx, + ), + Obx(() { + if (!blueteethBindController.bluetoothStatus.value) { + return Container(); + } + if (blueteethBindController.blueConnectFlag.value == + 0) { + return SizedBox( + width: 24.rpx, + height: 24.rpx, + child: CircularProgressIndicator( + strokeWidth: 1, + valueColor: + AlwaysStoppedAnimation(Colors.white), + ), + ); + } + if (blueteethBindController.netType.value == 0) { + return SizedBox( + width: 24.rpx, + height: 24.rpx, + child: CircularProgressIndicator( + strokeWidth: 1, + valueColor: + AlwaysStoppedAnimation(Colors.white), + ), + ); + } + if (blueteethBindController.wifiConnectStatus.value == + 0) { + return SizedBox( + width: 24.rpx, + height: 24.rpx, + child: CircularProgressIndicator( + strokeWidth: 1, + valueColor: + AlwaysStoppedAnimation(Colors.white), + ), + ); + } + return Container(); + }), + ], + ), + + /// 左边返回按钮 + Positioned( + left: 0, + child: returnIconButtom, + ), + Positioned( + right: 20.rpx, + child: CustomCard( + borderRadius: 20.rpx, + onTap: () async { + BlueteethBindController blueteethBindController = + Get.find(); + await Get.toNamed( + "/afterCalibrationPersonPage", + ); + }, + colors: [ + themeController.currentColor.sc1, + themeController.currentColor.sc2, + ], + child: Container( + width: 140.rpx, + height: 60.rpx, + alignment: Alignment.center, + padding: EdgeInsetsDirectional.fromSTEB( + 16.rpx, 0, 16.rpx, 0), + child: Text( + '下一步'.tr, + style: FlutterFlowTheme.of(context) + .titleSmall + .override( + fontFamily: 'Inter Tight', + color: themeController.currentColor.sc3, + letterSpacing: 0.0, + ), + ), + ), + ), + ), + ], + ), + ), + + actions: [], + centerTitle: false, + ), + + body: SafeArea( + top: true, + child: Padding( + padding: EdgeInsetsDirectional.fromSTEB(30.rpx, 0, 30.rpx, 0), + child: SingleChildScrollView( + child: Column( + mainAxisSize: MainAxisSize.max, + children: [ + Padding( + padding: + EdgeInsetsDirectional.fromSTEB(0, 30.rpx, 0, 0), + child: Container( + width: double.infinity, + decoration: BoxDecoration( + color: Color(0xFF242835), + borderRadius: BorderRadius.circular(20.rpx), + ), + child: Column( + children: [ + Align( + alignment: AlignmentDirectional(0, 0), + child: Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 30.rpx, 30.rpx, 30.rpx, 30.rpx), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + "wifi页.WLAN".tr, + style: TextStyle( + color: themeController + .currentColor.sc3, + fontSize: AppConstants() + .title_text_fontSize, + ), + ), + Obx(() { + return Text( + blueteethBindController + .wifiStatus.value == + 0 + ? "wifi页.未连接".tr + : "wifi页.已连接".tr, + style: TextStyle( + color: blueteethBindController + .wifiStatus.value == + 0 + ? themeController + .currentColor.sc4 + : themeController + .currentColor.sc2, + fontSize: AppConstants() + .normal_text_fontSize, + ), + ); + }), + ], + ), + ), + ), + Obx(() { + if (blueteethBindController + .connect_wifi.value == + null || + blueteethBindController + .connect_wifi.value.isEmpty) { + return Container(); + } else { + return Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 30.rpx, 0.rpx, 30.rpx, 30.rpx), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + blueteethBindController.connect_wifi + .value['ssid'] ?? + '未命名'.tr, + style: TextStyle( + color: themeController + .currentColor.sc3, + fontSize: AppConstants() + .title_text_fontSize, + ), + ), + getWifiIconByRsso( + blueteethBindController + .connect_wifi.value), + ], + ), + ); + } + }) + ], + )), + ), + Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 0.rpx, 25.rpx, 0.rpx, 0.rpx), + child: Container( + width: double.infinity, + decoration: BoxDecoration( + color: themeController.currentColor.sc5, + borderRadius: BorderRadius.circular(20.rpx), + ), + child: Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 30.rpx, 30.rpx, 30.rpx, 30.rpx), + child: Container( + width: double.infinity, + decoration: BoxDecoration(), + child: Column( + mainAxisSize: MainAxisSize.max, + children: [ + Row( + mainAxisSize: MainAxisSize.max, + children: [ + Text( + '可用WLAN'.tr, + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + fontFamily: 'Inter', + fontSize: 30.rpx, + letterSpacing: 0.0, + color: themeController + .currentColor.sc3, + ), + ), + ], + ), + Obx(() { + final sortedList = [ + ...blueteethBindController.wifiList.value + ]..sort((a, b) => b['rssi'] + .compareTo(a['rssi'])); // 按 rssi 倒序 + + return Column( + mainAxisSize: MainAxisSize.max, + children: sortedList + .map((wifiItem) => ClickableContainer( + backgroundColor: + Colors.transparent, + highlightColor: themeController + .currentColor.sc3, + padding: EdgeInsets.symmetric( + vertical: 0.rpx, + horizontal: 0.rpx), + borderRadius: 16.rpx, + onTap: () { + showWifiDialog( + context, + Padding( + padding: + EdgeInsetsDirectional + .fromSTEB( + 0.rpx, + 41.rpx, + 0.rpx, + 0), + child: Container( + height: 80.rpx, + decoration: + BoxDecoration( + color: Colors.white, + borderRadius: + BorderRadius + .circular(12 + .rpx), // 加圆角 + ), + child: Align( + alignment: + AlignmentDirectional( + -1, 0), + child: Obx(() { + return TextFormField( + onChanged: + (value) { + blueteethBindController + .model + .wifiPass = + value; + }, + autofocus: + false, + obscureText: + blueteethBindController + .model + .wifiPassShow, + decoration: + InputDecoration( + isDense: + true, + labelStyle: FlutterFlowTheme.of( + context) + .labelMedium + .override( + fontFamily: + 'Inter', + fontSize: + 26.rpx, + letterSpacing: + 0.0, + ), + hintText: + '蓝牙绑定.输入wifi密码' + .tr, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: + 'Inter', + fontSize: 26 + .rpx, + letterSpacing: + 0.0, + color: themeController + .currentColor + .sc4), + enabledBorder: + OutlineInputBorder( + borderSide: + BorderSide( + color: Color( + 0x00000000), + width: 1 + .rpx, + ), + borderRadius: + BorderRadius.circular( + 8.rpx), + ), + focusedBorder: + OutlineInputBorder( + borderSide: + BorderSide( + color: Color( + 0x00000000), + width: 1 + .rpx, + ), + borderRadius: + BorderRadius.circular( + 8.rpx), + ), + errorBorder: + OutlineInputBorder( + borderSide: + BorderSide( + color: FlutterFlowTheme.of(context) + .error, + width: 1 + .rpx, + ), + borderRadius: + BorderRadius.circular( + 8.rpx), + ), + focusedErrorBorder: + OutlineInputBorder( + borderSide: + BorderSide( + color: FlutterFlowTheme.of(context) + .error, + width: 1 + .rpx, + ), + borderRadius: + BorderRadius.circular( + 8.rpx), + ), + filled: + false, + fillColor: FlutterFlowTheme.of( + context) + .secondaryBackground, + suffixIcon: + InkWell( + onTap: + () { + blueteethBindController + .model + .wifiPassShow = !blueteethBindController.model.wifiPassShow; + blueteethBindController + .updateAll(); + }, + focusNode: + FocusNode( + skipTraversal: true), + child: + Icon( + blueteethBindController.model.wifiPassShow + ? Icons.visibility_outlined + : Icons.visibility_off_outlined, + size: 30 + .rpx, + ), + ), + ), + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: + 'Inter', + fontSize: 26 + .rpx, + letterSpacing: + 0.0, + color: Colors + .black), + cursorColor: + themeController + .currentColor + .sc3, + ); + })), + ), + ), + wifiItem['ssid'] ?? + '未命名'.tr, + onConfirm: () async { + // showLoadingDialog( + // context); // 显示 loading + blueteethBindController + .selectWifi + .value = wifiItem; + bool flag = await sendWifiSetting( + wifiItem, + blueteethBindController + .model.wifiPass!, + blueteethBindController + .currentDevice!); + // Navigator.pop(context); + if (flag) { + // bool wifiStatus = + // await getWifiStatus( + // blueteethBindController + // .currentDevice!); + bool wifiStatus = false; + var aa = await getDeviceWifiStatus( + blueteethBindController + .currentDevice!, + 1); + blueteethBindController + .selectWifi + .value = {}; + if (aa != null && + aa is Map) { + wifiStatus = true; + blueteethBindController + .connect_wifi + .value = aa; + } else { + blueteethBindController + .connect_wifi + .value = {}; + } + blueteethBindController + .wifiStatus + .value = + wifiStatus == true + ? 1 + : 0; + blueteethBindController + .wifiStatus + .value = + wifiStatus == true + ? 1 + : 0; + if (wifiStatus) { + updateDeviceBindStatus( + blueteethBindController + .currentDeviceMac! + .value); + // Navigator.pop(context); + TopSlideNotification + .show( + context, + text: "wifi页.配网成功".tr, + textColor: + themeController + .currentColor + .sc2, + ); + blueteethBindController + .wifiStatus + .value = 1; + blueteethBindController + .updateAll(); + } else { + // Navigator.pop(context); + TopSlideNotification + .show( + context, + text: "wifi页.配网失败".tr, + textColor: + themeController + .currentColor + .sc9, + ); + blueteethBindController + .wifiStatus + .value = 0; + blueteethBindController + .updateAll(); + } + } else { + // Navigator.pop(context); + TopSlideNotification.show( + context, + text: "wifi页.配网失败".tr, + textColor: + themeController + .currentColor + .sc9, + ); + blueteethBindController + .wifiStatus.value = 0; + blueteethBindController + .updateAll(); + } + }); + }, + child: Row( + mainAxisSize: + MainAxisSize.max, + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Text( + wifiItem['ssid'] ?? '', + style: FlutterFlowTheme + .of(context) + .bodyMedium + .override( + fontFamily: 'Inter', + fontSize: 30.rpx, + letterSpacing: 0.0, + color: + themeController + .currentColor + .sc3, + ), + ), + if (blueteethBindController + .selectWifi.value == + wifiItem) + SizedBox( + width: 32.rpx, + height: 32.rpx, + child: + CircularProgressIndicator( + strokeWidth: 1, + valueColor: + AlwaysStoppedAnimation< + Color>( + Colors.white), + ), + ) + else + getWifiIconByRsso( + wifiItem), + ], + ), + )) + .toList() + .divide(SizedBox(height: 67.rpx)), + ); + }), + ClickableContainer( + backgroundColor: Colors.transparent, + highlightColor: Colors.white, + padding: EdgeInsets.symmetric( + horizontal: 20.rpx, vertical: 10.rpx), + borderRadius: 20.rpx, + onTap: () async { + //检测蓝牙开关 + var bluetoothState = + await FlutterBluePlus.isOn; + blueteethBindController.bluetoothStatus + .value = bluetoothState; + if (!bluetoothState) { + await _showBluetoothNotEnabledDialog(); + return; + } + //检测蓝牙连接 + if (blueteethBindController + .blueConnectFlag.value == + 0 || + blueteethBindController + .blueConnectFlag.value == + 1) { + blueteethBindController + .blueConnectFlag.value = 0; + dealWifi(widget.type['mac']).then((aa) { + print("object"); + }); + return; + } + + if (blueteethBindController + .netType.value == + 0) { + return; + } + blueteethBindController.netType.value = 0; + blueteethBindController.updateAll(); + var aa = await getDeviceNetVersion( + blueteethBindController + .currentDevice!, + 1); + if (aa == "4g") { + updateDeviceBindStatus( + blueteethBindController + .currentDeviceMac!.value); + TopSlideNotification.show( + context, + text: "4g设备配置wifi提示".tr, + textColor: + themeController.currentColor.sc2, + ); + blueteethBindController.netType.value = + 2; + blueteethBindController + .connectStatus.value = 1; + blueteethBindController.updateAll(); + Future.delayed( + const Duration(seconds: 1), () { + Get.toNamed("/calibrationPage", + arguments: 1); + }); + } else if (aa == 'unknown') { + blueteethBindController.netType.value = + 3; + blueteethBindController.updateAll(); + WidgetsBinding.instance + .addPostFrameCallback((_) { + TopSlideNotification.show( + context, + text: "获取设备网络类型失败".tr, + textColor: themeController + .currentColor.sc9, + ); + }); + } else { + blueteethBindController.netType.value = + 1; + blueteethBindController.updateAll(); + await initWifiStatusAndWifiList(); + } + }, + child: Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Container( + width: 25.rpx, + height: 25.rpx, + decoration: BoxDecoration(), + child: SvgPicture.asset( + 'assets/img/icon/refresh.svg', + fit: BoxFit.cover, + color: Colors.white, // 图标固定白色 + ), + ), + Text( + '刷新'.tr, + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + fontFamily: 'Inter', + fontSize: 30.rpx, + letterSpacing: 0.0, + color: themeController + .currentColor.sc3, + ), + ), + ].divide(SizedBox(width: 26.rpx)), + ), + ), + ].divide(SizedBox(height: 65.rpx)), + ), + ), + ), + ), + ), + ], + ), + ), + ), + ), + ), + ), + ), + ); + } + + Future initWifiStatusAndWifiList() async { + if (lisObj != null) { + lisObj!.cancel(); + } + bool wifiStatus = false; + var aa = + await getDeviceWifiStatus(blueteethBindController.currentDevice!, 0); + if (aa != null && aa is Map) { + updateDeviceBindStatus(blueteethBindController.currentDeviceMac!.value); + wifiStatus = true; + blueteethBindController.connect_wifi.value = aa; + } else { + wifiStatus = false; + } + blueteethBindController.wifiStatus.value = wifiStatus == true ? 1 : 0; + List wifiList = []; + try { + final result = await getWifiList(blueteethBindController.currentDevice!); + blueteethBindController.wifiConnectStatus.value = 1; + blueteethBindController.updateAll(); + if (result is List) { + wifiList = result; + } + } catch (e) { + print("异常: $e"); + blueteethBindController.wifiConnectStatus.value = 0; + blueteethBindController.updateAll(); + } + if (wifiList.length > 0) { + blueteethBindController.connectStatus.value = 1; + blueteethBindController.updateAll(); + // Navigator.pop(context); + TopSlideNotification.show( + context, + text: "获取wifi列表成功".tr, + textColor: themeController.currentColor.sc2, + ); + blueteethBindController.wifiList.value = wifiList; + blueteethBindController.updateAll(); + } else { + // Navigator.pop(context); + + TopSlideNotification.show( + context, + text: "获取wifi列表失败".tr, + textColor: themeController.currentColor.sc9, + ); + } + lisObj = blueteethBindController.currentDevice!.statusStream + .listen((onData) async { + if (onData.status == BleEventType.recvLineLog) { + final line = onData.val; + print("[bleee]:" + line); + } + }); + } + + getWifiIconByRsso(wifiItem) { + int? rssi = int.tryParse(wifiItem['rssi'].toString()); + + if (rssi != null) { + if (rssi >= -30) { + return Container( + width: 40.rpx, + height: 40.rpx, + clipBehavior: Clip.antiAlias, + decoration: BoxDecoration(shape: BoxShape.circle), + child: Image.asset("assets/img/wifi4.png"), + ); + } else if (rssi >= -45) { + return Container( + width: 40.rpx, + height: 40.rpx, + clipBehavior: Clip.antiAlias, + decoration: BoxDecoration(shape: BoxShape.circle), + child: Image.asset("assets/img/wifi3.png"), + ); + } else if (rssi >= -60) { + return Container( + width: 40.rpx, + height: 40.rpx, + clipBehavior: Clip.antiAlias, + decoration: BoxDecoration(shape: BoxShape.circle), + child: Image.asset("assets/img/wifi3.png"), + ); + } else { + return Container( + width: 40.rpx, + height: 40.rpx, + clipBehavior: Clip.antiAlias, + decoration: BoxDecoration(shape: BoxShape.circle), + child: Image.asset("assets/img/wifi1.png"), + ); + } + } else { + // RSSI 无法解析时的默认显示 + return Container( + width: 40.rpx, + height: 40.rpx, + clipBehavior: Clip.antiAlias, + decoration: BoxDecoration(shape: BoxShape.circle), + child: Image.asset("assets/img/wifi1.png"), + ); + } + } + + Future dealWifi(String mac) async { + final blueteethBindController = Get.find(); + final themeController = Get.find(); + + // 显示加载对话框 + // showLoadingDialog(Get.context!, title: "连接中...".tr); + + // 设置超时定时器 + Timer? timeoutTimer; + bool isConnected = false; + + try { + // 开始扫描蓝牙设备 + var bluetoothState = await FlutterBluePlus.isOn; + blueteethBindController.bluetoothStatus.value = bluetoothState; + blueteethBindController.updateAll(); + if (!bluetoothState) { + await _showBluetoothNotEnabledDialog(); + return; + } + await FlutterBluePlus.startScan(timeout: Duration(seconds: 10)); + + // 设置超时(20秒) + timeoutTimer = Timer(Duration(seconds: 20), () { + try { + if (!isConnected) { + blueteethBindController.blueConnectFlag.value = 1; + blueteethBindController.updateAll(); + // Navigator.of(context).pop(); // 先关闭 dialog + WidgetsBinding.instance.addPostFrameCallback((_) { + TopSlideNotification.show( + context, + text: "设备连接超时,请重试".tr, + textColor: themeController.currentColor.sc9, + ); + }); + FlutterBluePlus.stopScan(); + } + } catch (e) { + print(e); + } + }); + + // 监听扫描结果 + StreamSubscription>? scanSubscription; + scanSubscription = FlutterBluePlus.scanResults.listen((results) async { + // 过滤出符合条件的设备 + ScanResult? targetDevice; + + for (var r in results) { + if (r.advertisementData.manufacturerData.containsKey(0xFFED)) { + List rawData = r.advertisementData.manufacturerData[0xFFED]!; + BleDeviceData deviceData = parseBleData(rawData); + String deviceMac = + deviceData.deviceId.replaceAll(':', '').toLowerCase(); + if (deviceMac == mac.toLowerCase()) { + targetDevice = r; + break; + } + } + } + + if (targetDevice != null && !isConnected) { + isConnected = true; + FlutterBluePlus.stopScan(); + scanSubscription?.cancel(); + timeoutTimer?.cancel(); + + try { + // 连接设备 + // await targetDevice.device.connect(); + THapp bledevice = THapp(device: targetDevice.device); + await bledevice.device.connect(); + var res2 = bledevice.isConnected; + if (res2) { + // Navigator.pop(context); + blueteethBindController.blueConnectFlag.value = 2; + TopSlideNotification.show( + context, + text: "蓝牙绑定.连接成功".tr, + textColor: themeController.currentColor.sc2, + ); + blueteethBindController.currentDevice = bledevice; + if (lisObj != null) { + lisObj!.cancel(); + } + var aa; + lisObj = blueteethBindController.currentDevice!.statusStream + .listen((onData) async { + if (onData.status == BleEventType.recvLineLog) { + final line = onData.val; + print("[bleee]:" + line); + } + if (onData.status == BleEventType.ready) { + aa = await getDeviceNetVersion( + blueteethBindController.currentDevice!, 0); + if (aa == "4g") { + // TopSlideNotification.show( + // Get.context!, + // text: "4g设备配置wifi提示".tr, + // textColor: themeController.currentColor.sc9, + // ); + blueteethBindController.netType.value = 2; + blueteethBindController.updateAll(); + updateDeviceBindStatus( + blueteethBindController.currentDeviceMac!.value); + // WidgetsBinding.instance.addPostFrameCallback((_) { + // TopSlideNotification.show( + // context, + // text: "4g设备配置wifi提示".tr, + // textColor: themeController.currentColor.sc9, + // ); + // // Get.back(); + // }); + await showTipDialog( + context, + Text( + "4g设备配置wifi提示".tr, + style: TextStyle( + color: themeController.currentColor.sc3, + fontSize: AppConstants().title_text_fontSize), + )); + // return; + } else if (aa == 'unknown') { + blueteethBindController.netType.value = 3; + blueteethBindController.updateAll(); + blueteethBindController.updateAll(); + WidgetsBinding.instance.addPostFrameCallback((_) { + TopSlideNotification.show( + context, + text: "获取设备网络类型失败".tr, + textColor: themeController.currentColor.sc9, + ); + }); + } else { + blueteethBindController.netType.value = 1; + blueteethBindController.updateAll(); + // TopSlideNotification.show( + // context, + // text: "当前设备为wifi网络设备".tr, + // textColor: themeController.currentColor.sc9, + // ); + blueteethBindController.wifiConnectStatus.value = 0; + blueteethBindController.updateAll(); + await initWifiStatusAndWifiList(); + } + } + }); + } else { + // Navigator.pop(context); + TopSlideNotification.show( + context, + text: "蓝牙绑定.连接失败".tr, + textColor: themeController.currentColor.sc9, + ); + } + } catch (e) { + // Navigator.of(Get.context!).pop(); // 关闭加载对话框 + TopSlideNotification.show( + context, + text: "设备连接失败".tr, + textColor: themeController.currentColor.sc9, + ); + } + } + }); + + // 等待扫描完成 + await Future.delayed(Duration(seconds: 20)); + } catch (e) { + timeoutTimer?.cancel(); + Navigator.of(Get.context!).pop(); // 关闭加载对话框 + TopSlideNotification.show( + Get.context!, + text: "扫描过程中发生错误".tr, + textColor: themeController.currentColor.sc9, + ); + } finally { + timeoutTimer?.cancel(); + await FlutterBluePlus.stopScan(); + } + } + + _showBluetoothNotEnabledDialog() async { + await showTipDialog( + context, + Column( + children: [ + Text( + "蓝牙未开启".tr, + style: TextStyle( + fontSize: AppConstants().title_text_fontSize, + color: themeController.currentColor.sc3), + ), + SizedBox( + height: 20.rpx, + ), + Text( + "请先打开蓝牙在进行设备扫描".tr, + style: TextStyle( + fontSize: AppConstants().normal_text_fontSize, + color: themeController.currentColor.sc3), + ), + ], + )); + } + + //更新设备绑定状态 + 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": true, + "celibration": res.data['celibration'], + "person_info": res.data['person_info'], + "time": DateTime.now().millisecondsSinceEpoch, + }; + requestWithLog( + logTitle: "更新绑定流程", + method: MyHttpMethod.put, + queryUrl: queryUrl, + data: data, + onSuccess: (res) {}, + onFailure: (res) {}, + ); + }, + onFailure: (res) {}, + ); + } +} diff --git a/lib/pages/device_bind/componnet/SingleBlueteethDeviceCompoentWidget.dart b/lib/pages/device_bind/componnet/SingleBlueteethDeviceCompoentWidget.dart index e359cf4..7b070a2 100644 --- a/lib/pages/device_bind/componnet/SingleBlueteethDeviceCompoentWidget.dart +++ b/lib/pages/device_bind/componnet/SingleBlueteethDeviceCompoentWidget.dart @@ -3,9 +3,11 @@ import 'package:easydevice/easydevice.dart'; import 'package:ef/ef.dart'; import 'package:flutter/material.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'; import 'package:vbvs_app/common/util/DailyLogUtils.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; +import 'package:vbvs_app/common/util/requestWithLog.dart'; import 'package:vbvs_app/component/tool/ClickableContainer.dart'; import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; import 'package:vbvs_app/controller/device/blueteeth_bind_controller.dart'; @@ -89,12 +91,12 @@ class _SingleBlueteethDeviceCompoentWidgetState await blueteethBindController.bindDeviceAndMAC(device); TopSlideNotification.show(context, text: response.msg!); if (response.code == HttpStatusCodes.ok) { - + //更新设备绑定流程 + updateDeviceBindStatus(device); Get.toNamed("/wifiPage"); THapp bledevice = THapp(device: widget.bleDevice.device); blueteethBindController.currentDevice = bledevice; // blueteethBindController.currentDeviceMac.value = ""; - } else { blueteethBindController.currentDeviceMac.value = ""; blueteethBindController.updateAll(); @@ -252,4 +254,30 @@ class _SingleBlueteethDeviceCompoentWidgetState ), ); } + + //更新设备绑定状态 + void updateDeviceBindStatus(BleDeviceData device) { + String serviceAddress = ServiceConstant.service_address; + String serviceName = ServiceConstant.server_service; + String serviceApi = ServiceConstant.user_setting; + String mac = device.mac!; + String type = "device_bind_status_${mac}"; + String queryUrl = "${serviceAddress}${serviceName}${serviceApi}"; + Map data = { + "type": type, + "mac": mac, + "wifi": false, + "celibration": false, + "person_info": false, + "time": DateTime.now().millisecondsSinceEpoch, + }; + requestWithLog( + logTitle: "更新用户绑定流程", + method: MyHttpMethod.put, + queryUrl: queryUrl, + data: data, + onSuccess: (res) {}, + onFailure: (res) {}, + ); + } } diff --git a/lib/pages/device_bind/componnet/bind_dialog.dart b/lib/pages/device_bind/componnet/bind_dialog.dart index 9920c0d..1ac479f 100644 --- a/lib/pages/device_bind/componnet/bind_dialog.dart +++ b/lib/pages/device_bind/componnet/bind_dialog.dart @@ -437,33 +437,34 @@ void showConfirmDialog( mainAxisSize: MainAxisSize.min, children: [ // 标题 - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - ClickableContainer( - backgroundColor: Colors.transparent, // 容器背景色 - highlightColor: - themeController.currentColor.sc21, // 点击时的背景色 - padding: EdgeInsets.zero, // 这里去掉外部的 padding,避免影响点击范围 - onTap: () { - Get.back(); - onCancel(); - }, - child: Padding( - // padding: - // EdgeInsetsDirectional.fromSTEB(0, 33.rpx, 0, 0.rpx), - padding: EdgeInsetsDirectional.fromSTEB( - 33.rpx, 33.rpx, 33.rpx, 33.rpx), - child: SvgPicture.asset( - 'assets/img/icon/close.svg', - width: 25.rpx, - height: 25.rpx, // 如果 SVG 中没有固定颜色,使用 color 设置 - color: themeController.currentColor.sc3, - ), - ), - ), - ], - ), + // Row( + // mainAxisAlignment: MainAxisAlignment.end, + // children: [ + // ClickableContainer( + // backgroundColor: Colors.transparent, // 容器背景色 + // highlightColor: + // themeController.currentColor.sc21, // 点击时的背景色 + // padding: EdgeInsets.zero, // 这里去掉外部的 padding,避免影响点击范围 + // onTap: () { + // Get.back(); + // onCancel(); + // }, + // child: Padding( + // // padding: + // // EdgeInsetsDirectional.fromSTEB(0, 33.rpx, 0, 0.rpx), + // padding: EdgeInsetsDirectional.fromSTEB( + // 33.rpx, 33.rpx, 33.rpx, 33.rpx), + // child: SvgPicture.asset( + // 'assets/img/icon/close.svg', + // width: 25.rpx, + // height: 25.rpx, // 如果 SVG 中没有固定颜色,使用 color 设置 + // color: themeController.currentColor.sc3, + // ), + // ), + // ), + // ], + // ), + Align( alignment: AlignmentDirectional(0, 0), child: Padding( @@ -892,8 +893,8 @@ Future showTipDialog( Align( alignment: AlignmentDirectional(0, 0), child: Padding( - padding: - EdgeInsetsDirectional.fromSTEB(0.rpx, 93.rpx, 0, 74.rpx), + padding: EdgeInsetsDirectional.fromSTEB( + 0.rpx, 93.rpx, 0, 74.rpx), child: widget, ), ), @@ -926,8 +927,142 @@ Future showTipDialog( .override( color: themeController.currentColor.sc3, fontFamily: 'Inter', - fontSize: - AppConstants().normal_text_fontSize, + fontSize: AppConstants().normal_text_fontSize, + letterSpacing: 0.0, + ), + ), + ].divide(SizedBox(width: 17.rpx)), + ), + ), + ), + ), + ], + ), + ), + ), + ); + }, + ); +} + +Future showUnBindTipDialog( + BuildContext context, + Widget widget, { + Color? backgroundColor, + VoidCallback? onConfirm, // “继续”按钮回调 + VoidCallback? onCancel, // “下次再说”按钮回调 +}) { + ThemeController themeController = Get.find(); + BlueteethBindController blueteethBindController = Get.find(); + + return showDialog( + context: context, + barrierDismissible: true, + barrierColor: Colors.black.withOpacity(0.5), + builder: (BuildContext context) { + return FrostedDialog( + blurSigma: 3.0, + child: Container( + decoration: BoxDecoration( + color: backgroundColor ?? themeController.currentColor.sc17, + borderRadius: BorderRadius.circular(20.0), + ), + padding: EdgeInsetsDirectional.fromSTEB(64.rpx, 0, 64.rpx, 0), + child: Container( + width: double.infinity, + constraints: BoxConstraints( + maxHeight: MediaQuery.sizeOf(context).height * 0.656, + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Align( + alignment: AlignmentDirectional(0, 0), + child: Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 0.rpx, 93.rpx, 0, 30.rpx), + child: widget, + ), + ), + Padding( + padding: EdgeInsetsDirectional.fromSTEB(0, 0.rpx, 0, 10.rpx), + child: CustomCard( + borderRadius: AppConstants().button_container_radius, + onTap: () { + Get.back(); // 关闭对话框 + if (onConfirm != null) { + onConfirm(); // 调用确认回调 + } + }, + colors: [ + themeController.currentColor.sc1, + themeController.currentColor.sc2, + ], + child: Container( + width: MediaQuery.sizeOf(context).width, + height: MediaQuery.sizeOf(context).height * 0.055, + constraints: BoxConstraints( + minWidth: 500.rpx, + minHeight: 90.rpx, + ), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + '继续'.tr, + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + color: themeController.currentColor.sc3, + fontFamily: 'Inter', + fontSize: AppConstants().normal_text_fontSize, + letterSpacing: 0.0, + ), + ), + ].divide(SizedBox(width: 17.rpx)), + ), + ), + ), + ), + Padding( + padding: EdgeInsetsDirectional.fromSTEB(0, 19.rpx, 0, 60.rpx), + child: CustomCard( + borderRadius: AppConstants().button_container_radius, + onTap: () { + Get.back(); // 关闭对话框 + if (onCancel != null) { + onCancel(); // 调用取消回调 + } + }, + colors: [Colors.transparent], + child: Container( + width: MediaQuery.sizeOf(context).width, + height: MediaQuery.sizeOf(context).height * 0.055, + decoration: BoxDecoration( + border: Border.all( + color: Colors.white, + width: 0.5.rpx, + ), + borderRadius: BorderRadius.circular( + AppConstants().button_container_radius), + ), + constraints: BoxConstraints( + minWidth: 500.rpx, + minHeight: 90.rpx, + ), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + '下次再说'.tr, + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + color: themeController.currentColor.sc3, + fontFamily: 'Inter', + fontSize: AppConstants().normal_text_fontSize, letterSpacing: 0.0, ), ), diff --git a/lib/pages/device_bind/device_calibration.dart b/lib/pages/device_bind/device_calibration.dart index c922d18..3621391 100644 --- a/lib/pages/device_bind/device_calibration.dart +++ b/lib/pages/device_bind/device_calibration.dart @@ -156,11 +156,11 @@ class _CalibrationPageState extends State { themeController.currentColor.sc2, ], child: Container( - width: 130.rpx, + width: 140.rpx, height: 60.rpx, alignment: Alignment.center, padding: EdgeInsetsDirectional.fromSTEB( - 0.rpx, 0, 0.rpx, 0), + 16.rpx, 0, 16.rpx, 0), child: Text( '下一步'.tr, style: TextStyle( @@ -959,6 +959,8 @@ class _CalibrationPageState extends State { deviceCalibrationController.flag.value = 2; progressNotifier.value = 0; // 重置进度条 failureNotifier.value = false; // 重置失败状态 + updateDeviceBindStatus( + blueteethBindController.currentDeviceMac!.value); } }, onFailure: (res) { @@ -1022,4 +1024,39 @@ class _CalibrationPageState extends State { 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/device_bind/device_calibration_copy.dart b/lib/pages/device_bind/device_calibration_copy.dart index a94585f..5dcd812 100644 --- a/lib/pages/device_bind/device_calibration_copy.dart +++ b/lib/pages/device_bind/device_calibration_copy.dart @@ -149,7 +149,7 @@ class _CalibrationPageState extends State { themeController.currentColor.sc2, ], child: Container( - width: 130.rpx, + width: 140.rpx, height: 60.rpx, alignment: Alignment.center, padding: EdgeInsetsDirectional.fromSTEB( diff --git a/lib/pages/device_bind/device_calibration_person.dart b/lib/pages/device_bind/device_calibration_person.dart index 84c2075..3398f9c 100644 --- a/lib/pages/device_bind/device_calibration_person.dart +++ b/lib/pages/device_bind/device_calibration_person.dart @@ -953,6 +953,8 @@ class _CalibrationPersonPageState extends State { deviceCalibrationController.flag.value = 0; // 重置标志允许再次点击 } else if (isSecondStep && per >= 100 && currStep == 5 && status) { // 第二步完成 + updateDeviceBindStatus( + blueteethBindController.currentDeviceMac!.value); _pollingTimer?.cancel(); TopSlideNotification.show(context, text: "设备校准完成".tr); deviceCalibrationController.bed_calibration.value = 1; @@ -1024,4 +1026,38 @@ class _CalibrationPersonPageState extends State { 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": res.data['person_info'], + "time": DateTime.now().millisecondsSinceEpoch, + }; + requestWithLog( + logTitle: "更新绑定流程", + method: MyHttpMethod.put, + queryUrl: queryUrl, + data: data, + onSuccess: (res) {}, + onFailure: (res) {}, + ); + }, + onFailure: (res) {}, + ); + } } diff --git a/lib/pages/device_bind/wifi_page.dart b/lib/pages/device_bind/wifi_page.dart index addf105..15ff777 100644 --- a/lib/pages/device_bind/wifi_page.dart +++ b/lib/pages/device_bind/wifi_page.dart @@ -6,9 +6,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_blue_plus/flutter_blue_plus.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'; @@ -75,6 +77,8 @@ class _WifiPageState extends State { blueteethBindController.netType.value = 2; blueteethBindController.connectStatus.value = 1; blueteethBindController.updateAll(); + updateDeviceBindStatus( + blueteethBindController.currentDeviceMac!.value); Future.delayed(const Duration(seconds: 1), () { Get.toNamed("/calibrationPage", arguments: 1); }); @@ -224,11 +228,11 @@ class _WifiPageState extends State { themeController.currentColor.sc2, ], child: Container( - width: 130.rpx, + width: 140.rpx, height: 60.rpx, alignment: Alignment.center, padding: EdgeInsetsDirectional.fromSTEB( - 0.rpx, 0, 0.rpx, 0), + 16.rpx, 0, 16.rpx, 0), child: Text( '下一步'.tr, style: FlutterFlowTheme.of(context) @@ -618,6 +622,10 @@ class _WifiPageState extends State { ? 1 : 0; if (wifiStatus) { + updateDeviceBindStatus( + blueteethBindController + .currentDeviceMac! + .value); // Navigator.pop(context); TopSlideNotification .show( @@ -749,6 +757,9 @@ class _WifiPageState extends State { blueteethBindController .connectStatus.value = 1; blueteethBindController.updateAll(); + updateDeviceBindStatus( + blueteethBindController + .currentDeviceMac!.value); Future.delayed( const Duration(seconds: 1), () { Get.toNamed("/calibrationPage", @@ -843,6 +854,7 @@ class _WifiPageState extends State { await getDeviceWifiStatus(blueteethBindController.currentDevice!, 1); if (aa != null && aa is Map) { wifiStatus = true; + updateDeviceBindStatus(blueteethBindController.currentDeviceMac!.value); blueteethBindController.connect_wifi.value = aa; } else { wifiStatus = false; @@ -1090,6 +1102,7 @@ class _WifiPageState extends State { // text: "4g设备配置wifi提示".tr, // textColor: themeController.currentColor.sc9, // ); + updateDeviceBindStatus(blueteethBindController.currentDeviceMac!.value); WidgetsBinding.instance.addPostFrameCallback((_) { TopSlideNotification.show( context, @@ -1148,4 +1161,38 @@ class _WifiPageState extends State { await FlutterBluePlus.stopScan(); } } + + 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": true, + "celibration":res.data['celibration'], + "person_info":res.data['person_info'], + "time": DateTime.now().millisecondsSinceEpoch, + }; + requestWithLog( + logTitle: "更新绑定流程", + method: MyHttpMethod.put, + queryUrl: queryUrl, + data: data, + onSuccess: (res) {}, + onFailure: (res) {}, + ); + }, + onFailure: (res) {}, + ); + } } diff --git a/lib/pages/device_bind/wifi_page_person.dart b/lib/pages/device_bind/wifi_page_person.dart index 7630f9b..83eebc2 100644 --- a/lib/pages/device_bind/wifi_page_person.dart +++ b/lib/pages/device_bind/wifi_page_person.dart @@ -6,9 +6,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_blue_plus/flutter_blue_plus.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'; @@ -563,6 +565,10 @@ class _WifiPagePersonState extends State { ? 1 : 0; if (wifiStatus) { + updateDeviceBindStatus( + blueteethBindController + .currentDeviceMac! + .value); // Navigator.pop(context); TopSlideNotification .show( @@ -702,6 +708,9 @@ class _WifiPagePersonState extends State { .currentDevice!, 1); if (aa == "4g") { + updateDeviceBindStatus( + blueteethBindController + .currentDeviceMac!.value); TopSlideNotification.show( context, text: "4g设备配置wifi提示".tr, @@ -793,6 +802,7 @@ class _WifiPagePersonState extends State { var aa = await getDeviceWifiStatus(blueteethBindController.currentDevice!, 0); if (aa != null && aa is Map) { + updateDeviceBindStatus(blueteethBindController.currentDeviceMac!.value); wifiStatus = true; blueteethBindController.connect_wifi.value = aa; } else { @@ -994,6 +1004,8 @@ class _WifiPagePersonState extends State { // ); blueteethBindController.netType.value = 2; blueteethBindController.updateAll(); + updateDeviceBindStatus( + blueteethBindController.currentDeviceMac!.value); // WidgetsBinding.instance.addPostFrameCallback((_) { // TopSlideNotification.show( // context, @@ -1094,4 +1106,39 @@ class _WifiPagePersonState extends State { ], )); } + + //更新设备绑定状态 + 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": true, + "celibration":res.data['celibration'], + "person_info":res.data['person_info'], + "time": DateTime.now().millisecondsSinceEpoch, + }; + requestWithLog( + logTitle: "更新绑定流程", + method: MyHttpMethod.put, + queryUrl: queryUrl, + data: data, + onSuccess: (res) {}, + onFailure: (res) {}, + ); + }, + onFailure: (res) {}, + ); + } } diff --git a/lib/pages/device_control/new_Home_page.dart b/lib/pages/device_control/new_Home_page.dart index 7198c9f..e2a8173 100644 --- a/lib/pages/device_control/new_Home_page.dart +++ b/lib/pages/device_control/new_Home_page.dart @@ -497,7 +497,7 @@ class _NewHomePageState extends State { Alignment .center, child: Text( - '${day['scoreType'] ?? "暂无"}', + '${day['scoreType'] ?? "暂无".tr}', style: FlutterFlowTheme.of( context) .bodyMedium diff --git a/lib/pages/login/other_login.dart b/lib/pages/login/other_login.dart index 1aa9b51..917e171 100644 --- a/lib/pages/login/other_login.dart +++ b/lib/pages/login/other_login.dart @@ -19,6 +19,7 @@ import 'package:vbvs_app/controller/main_bottom/global_controller.dart'; import 'package:vbvs_app/controller/theme_controller/ThemeController.dart'; import 'package:vbvs_app/controller/time/countdown_controller.dart'; import 'package:vbvs_app/controller/user_info_controller.dart'; +import 'package:vbvs_app/main.dart'; import 'package:vbvs_app/model/api_response.dart'; class OtherLoginPage extends StatefulWidget { @@ -337,7 +338,7 @@ class _OtherLoginPageState extends State { alignment: AlignmentDirectional(-1, 0), child: Padding( padding: EdgeInsetsDirectional.fromSTEB( - 0, 19.rpx, 0, 0), + 0, 26.rpx, 0, 0), child: Container( height: bodysize.maxHeight * 0.056, width: double.infinity, @@ -476,7 +477,7 @@ class _OtherLoginPageState extends State { mainAxisSize: MainAxisSize.max, children: [ SizedBox( - height: 50.rpx, + height: 30.rpx, child: VerticalDivider( thickness: 2.rpx, color: themeController @@ -594,7 +595,7 @@ class _OtherLoginPageState extends State { ), Padding( padding: EdgeInsetsDirectional.fromSTEB( - 0, 35.rpx, 0, 0), + 0, 26.rpx, 0, 0), child: CustomCard( borderRadius: AppConstants() .button_container_radius, // 圆角半径 @@ -623,6 +624,7 @@ class _OtherLoginPageState extends State { .currentColor.sc9, ); } else { + // await dealBindProcess(); CountdownController countdownController = Get.find(); countdownController.countdown.value = @@ -685,7 +687,7 @@ class _OtherLoginPageState extends State { ), Padding( padding: EdgeInsetsDirectional.fromSTEB( - 25.rpx, 83.rpx, 25.rpx, 50.rpx), + 25.rpx, 42.rpx, 25.rpx, 50.rpx), child: Container( width: double.infinity, decoration: BoxDecoration(), @@ -760,7 +762,7 @@ class _OtherLoginPageState extends State { .override( fontFamily: 'Inter', letterSpacing: 0.0, - fontSize: 26.rpx, + fontSize: 20.rpx, color: themeController .currentColor.sc3, ), @@ -773,7 +775,7 @@ class _OtherLoginPageState extends State { .override( fontFamily: 'Inter', letterSpacing: 0.0, - fontSize: 26.rpx, + fontSize: 20.rpx, color: stringToColor( "#FF9F66"), ), @@ -786,7 +788,7 @@ class _OtherLoginPageState extends State { .override( fontFamily: 'Inter', letterSpacing: 0.0, - fontSize: 26.rpx, + fontSize: 20.rpx, color: themeController .currentColor.sc3, ), @@ -799,7 +801,7 @@ class _OtherLoginPageState extends State { .override( fontFamily: 'Inter', letterSpacing: 0.0, - fontSize: 26.rpx, + fontSize: 20.rpx, color: stringToColor( "#FF9F66"), ), @@ -812,7 +814,7 @@ class _OtherLoginPageState extends State { .override( fontFamily: 'Inter', letterSpacing: 0.0, - fontSize: 26.rpx, + fontSize: 20.rpx, color: themeController .currentColor.sc3, ), @@ -825,7 +827,7 @@ class _OtherLoginPageState extends State { .override( fontFamily: 'Inter', letterSpacing: 0.0, - fontSize: 26.rpx, + fontSize: 20.rpx, color: stringToColor( "#FF9F66"), ), diff --git a/lib/pages/main_bottom/component/MessageWidgetWidget.dart b/lib/pages/main_bottom/component/MessageWidgetWidget.dart index c54d559..5acc645 100644 --- a/lib/pages/main_bottom/component/MessageWidgetWidget.dart +++ b/lib/pages/main_bottom/component/MessageWidgetWidget.dart @@ -35,8 +35,8 @@ class _MessageWidgetWidgetState extends State { return Stack( children: [ ClickableContainer( - backgroundColor: Color(0xFF003058), - highlightColor: themeController.currentColor.sc3, + backgroundColor: themeController.currentColor.sc5, + highlightColor: themeController.currentColor.sc21, borderRadius: 20.rpx, padding: EdgeInsetsDirectional.fromSTEB(31.rpx, 33.rpx, 0.rpx, 33.rpx), diff --git a/lib/pages/main_bottom/home_page.dart b/lib/pages/main_bottom/home_page.dart index d81ef3e..8aca206 100644 --- a/lib/pages/main_bottom/home_page.dart +++ b/lib/pages/main_bottom/home_page.dart @@ -17,10 +17,13 @@ import 'package:vbvs_app/controller/device/blueteeth_bind_controller.dart'; import 'package:vbvs_app/controller/device/body_device_controller.dart'; import 'package:vbvs_app/controller/home/home_controller.dart'; import 'package:vbvs_app/controller/main_bottom/global_controller.dart'; +import 'package:vbvs_app/controller/person/person_controller.dart'; import 'package:vbvs_app/controller/theme_controller/ThemeController.dart'; import 'package:vbvs_app/controller/user_info_controller.dart'; import 'package:vbvs_app/controller/weather/weather_controller.dart'; import 'package:vbvs_app/enum/LoginStatus.dart'; +import 'package:vbvs_app/main.dart'; +import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart'; class HomePage extends StatefulWidget { const HomePage({super.key}); @@ -164,6 +167,18 @@ class _HomePageState extends State { _popupEntry = null; } + @override + void didChangeDependencies() { + super.didChangeDependencies(); + + // 页面返回时重新判断是否当前路由是HomePage + WidgetsBinding.instance.addPostFrameCallback((_) { + if (ModalRoute.of(context)?.isCurrent ?? false) { + checkAndShowBindProcess(); + } + }); + } + @override initState() { super.initState(); @@ -191,6 +206,152 @@ class _HomePageState extends State { } }); } + if (userInfoController.device_bind_flag == 0) { + dealBindProcess().then((value) { + WidgetsBinding.instance.addPostFrameCallback((_) { + userInfoController.device_bind_flag = 1; + checkAndShowBindProcess(); + // List device_bind_process = userInfoController.device_bind_status; + + // if (device_bind_process != null && device_bind_process.isNotEmpty) { + // int currentIndex = 0; + + // void showNextDialog() { + // if (currentIndex >= device_bind_process.length) return; + + // String code = device_bind_process[currentIndex]['mac']; + + // showUnBindTipDialog( + // context, + // Column( + // children: [ + // Text( + // "发现".tr, + // style: TextStyle( + // fontSize: AppConstants().normal_text_fontSize, + // color: themeController.currentColor.sc3, + // ), + // ), + // SizedBox(height: 20.rpx), + // Text.rich( + // TextSpan( + // children: [ + // TextSpan( + // text: "检测到".tr, + // style: TextStyle( + // fontSize: AppConstants().normal_text_fontSize, + // color: themeController.currentColor.sc3, + // ), + // ), + // TextSpan( + // text: code, + // style: TextStyle( + // fontSize: AppConstants().normal_text_fontSize, + // color: themeController.currentColor.sc8, + // ), + // ), + // TextSpan( + // text: "绑定流程未走完是否继续?".tr, + // style: TextStyle( + // fontSize: AppConstants().normal_text_fontSize, + // color: themeController.currentColor.sc3, + // ), + // ), + // ], + // ), + // ), + // ], + // ), + // onConfirm: () async { + // print("继续设备:$code"); + + // var data = device_bind_process[currentIndex]; + // BlueteethBindController blueteethBindController = Get.find(); + // blueteethBindController.currentDeviceMac?.value = data['mac']; + + // PersonController personController = Get.find(); + // personController.after_deveice = data['device_info']; + + // // 从 WiFi 开始配置 + // if (data['wifi'] == false) { + // await Get.toNamed("/afterWifiPagePerson", + // arguments: data['device_info'])! + // .then((_) { + // currentIndex++; + // showNextDialog(); // 👈 返回后继续弹窗流程 + // }); + // return; + // } + + // // 从设备校准开始配置 + // if (data['celibration'] == false) { + // await Get.toNamed("/afterCalibrationPersonPage")!.then((_) { + // currentIndex++; + // showNextDialog(); // 👈 返回后继续弹窗流程 + // }); + // return; + // } + + // // 从人员信息配置开始 + // if (data['person_info'] == false) { + // if (data['device_info']['person'] != null) { + // personController.currentPersonId.value = + // data['device_info']['_id']; + // personController.name.value = + // data['device_info']['person']['name']; + // personController.update_person_mac.value = + // data['device_info']['mac']; + // personController.gender.value = + // data['device_info']['person']['gender'] ?? 1; + // personController.weight?.value = + // data['device_info']['person']['weight']?.toString() ?? + // ''; + // personController.height.value = + // data['device_info']['person']['height']?.toString() ?? + // ''; + // personController.selectedDiseaseIds.value = + // data['device_info']['person']['disease'] ?? []; + // personController.birthday.value = + // data['device_info']['person']['birthday'] ?? ''; + // personController.dateTime = MyUtils.formatBirthdayTime( + // data['device_info']['person']['birthday']); + // } else { + // personController.update_person_mac.value = + // data['device_info']['mac']; + // personController.currentPersonId.value = + // data['device_info']['_id']; + // personController.name.value = ""; + // personController.gender.value = 1; + // personController.dateTime = null; + // personController.height.value = ""; + // personController.weight.value = ""; + // personController.diseaseList.value = []; + // } + + // await Get.toNamed("/afterUpdatePersonPage")!.then((_) { + // currentIndex++; + // showNextDialog(); // 👈 返回后继续弹窗流程 + // }); + // return; + // } + + // // 如果以上都走完了,继续下一个弹窗 + // currentIndex++; + // showNextDialog(); + // }, + // onCancel: () { + // print("跳过设备:$code"); + // device_bind_process.removeAt(currentIndex); + // showNextDialog(); + // }, + // ); + // } + + // showNextDialog(); + // } + }); + }); + } } @override @@ -1081,4 +1242,120 @@ class _HomePageState extends State { ), ); } + + void checkAndShowBindProcess() { + UserInfoController userInfoController = Get.find(); + List device_bind_process = userInfoController.device_bind_status; + if (device_bind_process != null && device_bind_process.isNotEmpty) { + int currentIndex = 0; + + void showNextDialog() { + if (currentIndex >= device_bind_process.length) return; + + String code = device_bind_process[currentIndex]['mac']; + + showUnBindTipDialog( + context, + Column( + children: [ + Text( + "发现".tr, + style: TextStyle( + fontSize: AppConstants().normal_text_fontSize, + color: themeController.currentColor.sc3, + ), + ), + SizedBox(height: 20.rpx), + Text.rich( + TextSpan( + children: [ + TextSpan( + text: "检测到".tr, + style: TextStyle( + fontSize: AppConstants().normal_text_fontSize, + color: themeController.currentColor.sc3, + ), + ), + TextSpan( + text: code, + style: TextStyle( + fontSize: AppConstants().normal_text_fontSize, + color: themeController.currentColor.sc8, + ), + ), + TextSpan( + text: "绑定流程未走完是否继续?".tr, + style: TextStyle( + fontSize: AppConstants().normal_text_fontSize, + color: themeController.currentColor.sc3, + ), + ), + ], + ), + ), + ], + ), + onConfirm: () async { + var data = device_bind_process[currentIndex]; + PersonController personController = Get.find(); + personController.after_deveice = data['device_info']; + // 判断逻辑... + if (data['wifi'] == false) { + await Get.toNamed("/afterWifiPagePerson", + arguments: data['device_info']); + return; + } + if (data['celibration'] == false) { + await Get.toNamed("/afterCalibrationPersonPage"); + return; + } + if (data['person_info'] == false) { + PersonController personController = Get.find(); + if (data['device_info']['person'] != null) { + personController.currentPersonId.value = + data['device_info']['_id']; + personController.name.value = + data['device_info']['person']['name']; + personController.update_person_mac.value = + data['device_info']['mac']; + personController.gender.value = + data['device_info']['person']['gender'] ?? 1; + personController.weight?.value = + data['device_info']['person']['weight']?.toString() ?? ''; + personController.height.value = + data['device_info']['person']['height']?.toString() ?? ''; + personController.selectedDiseaseIds.value = + data['device_info']['person']['disease'] ?? []; + personController.birthday.value = + data['device_info']['person']['birthday'] ?? ''; + personController.dateTime = MyUtils.formatBirthdayTime( + data['device_info']['person']['birthday']); + } else { + personController.update_person_mac.value = + data['device_info']['mac']; + personController.currentPersonId.value = + data['device_info']['_id']; + personController.name.value = ""; + personController.gender.value = 1; + personController.dateTime = null; + personController.height.value = ""; + personController.weight.value = ""; + personController.diseaseList.value = []; + } + await Get.toNamed("/afterUpdatePersonPage"); + return; + } + currentIndex++; + showNextDialog(); + }, + onCancel: () { + device_bind_process.removeAt(currentIndex); + showNextDialog(); + }, + ); + } + + showNextDialog(); + } + } } diff --git a/lib/pages/main_bottom/mine_page.dart b/lib/pages/main_bottom/mine_page.dart index 90483c7..d1e49ea 100644 --- a/lib/pages/main_bottom/mine_page.dart +++ b/lib/pages/main_bottom/mine_page.dart @@ -206,7 +206,7 @@ class _MinePageState extends State { ? (userInfoController.model .user!.nick_name ?? '未命名'.tr) - : "我的.未登录".tr, + : "未命名".tr, style: FlutterFlowTheme.of(context) .bodyMedium @@ -240,7 +240,7 @@ class _MinePageState extends State { return "微信用户".tr; } })() - : "我的.未登录".tr, + : "未知数据".tr, style: FlutterFlowTheme.of(context) .bodyMedium @@ -650,8 +650,12 @@ class _MinePageState extends State { // themeController.currentColor.sc2, // ); Get.toNamed("/newSleepReportPage", - arguments: {'date':DateTime.now() - .millisecondsSinceEpoch,"mac":'aaaaaaeeeeeq','type':1}); + arguments: { + 'date': DateTime.now() + .millisecondsSinceEpoch, + "mac": 'aaaaaaeeeeeq', + 'type': 1 + }); } }, child: Container( @@ -737,5 +741,4 @@ class _MinePageState extends State { ), ); } - } diff --git a/lib/pages/person/person_page.dart b/lib/pages/person/person_page.dart index 9ecd134..dcd493b 100644 --- a/lib/pages/person/person_page.dart +++ b/lib/pages/person/person_page.dart @@ -1,11 +1,14 @@ import 'package:ef/ef.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.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/color/app_uri_status.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; +import 'package:vbvs_app/common/util/requestWithLog.dart'; import 'package:vbvs_app/component/tool/CustomCard.dart'; import 'package:vbvs_app/component/tool/SelectableTagButton.dart'; import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; @@ -109,6 +112,7 @@ class _EPageState extends State { if (apiRespons.code == HttpStatusCodes.ok) { TopSlideNotification.show(context, text: apiRespons.msg!); + updateDeviceBindStatus(blueteethBindController.currentDeviceMac!.value); Get.offNamed("/bindDeviceSuccess"); } else { TopSlideNotification.show(context, @@ -768,15 +772,21 @@ class _EPageState extends State { mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Padding( - padding: EdgeInsetsDirectional.fromSTEB( - 0, 8.rpx, 0, 0), - child: Icon( - Icons.arrow_back, - color: themeController.currentColor.sc4, - size: 24.rpx, - ), - ), + Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 0, 8.rpx, 0, 0), + child: Container( + width: 23.rpx, + height: 23.rpx, + // width: double.infinity, + decoration: BoxDecoration(), + child: SvgPicture.asset( + 'assets/img/icon/tips.svg', + fit: BoxFit.cover, + color: themeController.currentColor.sc4, + ), + ), + ), Expanded( child: Text( '人员资料.提示'.tr, @@ -851,3 +861,36 @@ class _EPageState extends State { ); } } + +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": res.data['celibration'], + "person_info": true, + "time": DateTime.now().millisecondsSinceEpoch, + }; + requestWithLog( + logTitle: "更新绑定流程", + method: MyHttpMethod.put, + queryUrl: queryUrl, + data: data, + onSuccess: (res) {}, + onFailure: (res) {}, + ); + }, + onFailure: (res) {}, + ); +} diff --git a/lib/pages/person/update_person_page.dart b/lib/pages/person/update_person_page.dart index 375ea16..df545fe 100644 --- a/lib/pages/person/update_person_page.dart +++ b/lib/pages/person/update_person_page.dart @@ -1,11 +1,14 @@ import 'package:ef/ef.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.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/color/app_uri_status.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; +import 'package:vbvs_app/common/util/requestWithLog.dart'; import 'package:vbvs_app/component/tool/CustomCard.dart'; import 'package:vbvs_app/component/tool/SelectableTagButton.dart'; import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; @@ -107,6 +110,8 @@ class _UpdatePageState extends State { ApiResponse apiRespons = await personController.savePersonData(); if (apiRespons.code == HttpStatusCodes.ok) { + updateDeviceBindStatus( + personController.update_person_mac.value); TopSlideNotification.show(context, text: apiRespons.msg!); } else { @@ -775,10 +780,16 @@ class _UpdatePageState extends State { Padding( padding: EdgeInsetsDirectional.fromSTEB( 0, 8.rpx, 0, 0), - child: Icon( - Icons.arrow_back, - color: themeController.currentColor.sc4, - size: 24.rpx, + child: Container( + width: 23.rpx, + height: 23.rpx, + // width: double.infinity, + decoration: BoxDecoration(), + child: SvgPicture.asset( + 'assets/img/icon/tips.svg', + fit: BoxFit.cover, + color: themeController.currentColor.sc4, + ), ), ), Expanded( @@ -857,4 +868,38 @@ class _UpdatePageState extends State { ), ); } + + 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": res.data['celibration'], + "person_info": true, + "time": DateTime.now().millisecondsSinceEpoch, + }; + requestWithLog( + logTitle: "更新绑定流程", + method: MyHttpMethod.put, + queryUrl: queryUrl, + data: data, + onSuccess: (res) {}, + onFailure: (res) {}, + ); + }, + onFailure: (res) {}, + ); + } } diff --git a/lib/pages/user/about_us_page.dart b/lib/pages/user/about_us_page.dart index f099fb0..fd506c5 100644 --- a/lib/pages/user/about_us_page.dart +++ b/lib/pages/user/about_us_page.dart @@ -13,8 +13,6 @@ class AboutUsPage extends StatefulWidget { } class _AboutUsPageState extends State { - - @override void initState() { super.initState(); @@ -110,7 +108,7 @@ class _AboutUsPageState extends State { body: SafeArea( top: true, child: Padding( - padding: EdgeInsets.symmetric(horizontal: 30.rpx), + padding: EdgeInsets.symmetric(horizontal: 0.rpx), child: Column(children: [ Expanded( child: Container( diff --git a/lib/routers/routers.dart b/lib/routers/routers.dart index 3be65ba..90ba2ad 100644 --- a/lib/routers/routers.dart +++ b/lib/routers/routers.dart @@ -9,6 +9,9 @@ import 'package:vbvs_app/pages/device/device_detail.dart'; import 'package:vbvs_app/pages/device/instant_body_page.dart'; import 'package:vbvs_app/pages/device/message_review_page.dart'; import 'package:vbvs_app/pages/device_bind/MobileScannerTestPage.dart'; +import 'package:vbvs_app/pages/device_bind/after/after_device_calibration_person.dart'; +import 'package:vbvs_app/pages/device_bind/after/after_update_person_page.dart'; +import 'package:vbvs_app/pages/device_bind/after/after_wifi_page_person.dart'; import 'package:vbvs_app/pages/device_bind/bind_device_success.dart'; import 'package:vbvs_app/pages/device_bind/blueteeth_device_page.dart'; import 'package:vbvs_app/pages/device_bind/device_calibration.dart'; @@ -19,9 +22,7 @@ import 'package:vbvs_app/pages/device_bind/device_type.dart'; import 'package:vbvs_app/pages/device_bind/device_type_list.dart'; import 'package:vbvs_app/pages/device_bind/wifi_page.dart'; import 'package:vbvs_app/pages/device_bind/wifi_page_person.dart'; -import 'package:vbvs_app/pages/login/login.dart'; import 'package:vbvs_app/pages/login/other_login.dart'; -import 'package:vbvs_app/pages/main_bottom/component/main_page_b_bottom_change.dart'; import 'package:vbvs_app/pages/main_bottom/e_page.dart'; import 'package:vbvs_app/pages/main_bottom/follow_page.dart'; import 'package:vbvs_app/pages/main_bottom/help_page.dart'; @@ -60,7 +61,7 @@ var routes = { "/deviceType": (contxt, {arguments}) => DeviceTypePage(), "/blueteethDevice": (contxt) => BlueteethDevicePage(), "/personPage": (contxt) => PersonPage(), - "/bindDeviceSuccess": (contxt) => BindDeviceSuccess(), + "/bindDeviceSuccess": (contxt) => BindDeviceSuccess(), "/wifiPage": (contxt, {arguments}) => WifiPage(type: arguments), "/wifiPagePerson": (contxt, {arguments}) => WifiPagePerson(type: arguments), "/updateUserPage": (contxt) => UpdateUserPage(), @@ -79,7 +80,8 @@ var routes = { "/deviceShareListPage": (contxt, {arguments}) => DeviceShareListPage(device: arguments), "/calibrationPage": (contxt, {arguments}) => CalibrationPage(type: arguments), - "/calibrationPersonPage": (contxt, {arguments}) => CalibrationPersonPage(type: arguments), + "/calibrationPersonPage": (contxt, {arguments}) => + CalibrationPersonPage(type: arguments), "/applyRepairPage": (contxt) => ApplyRepairPage(), "/languageSetting": (contxt) => LanguageSetting(), "/helpPage": (contxt) => HelpPage(), @@ -96,8 +98,12 @@ var routes = { MessageReviewPage(data: arguments), "/messageSettingPage": (contxt, {arguments}) => MessageSettingPage(data: arguments), - "/commonMessageSettingPage": (contxt) => - CommonMessageSettingPage(), + "/commonMessageSettingPage": (contxt) => CommonMessageSettingPage(), + "/afterCalibrationPersonPage": (contxt) => AfterCalibrationPersonPage(), + "/afterUpdatePersonPage": (contxt) => AfterUpdatePersonPage(), + "/afterWifiPagePerson": (contxt, {arguments}) => AfterWifiPagePerson( + type: arguments, + ), }; var onGenerateRoute = (RouteSettings settings) { diff --git a/pubspec.yaml b/pubspec.yaml index 90fb92b..c963232 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -58,6 +58,7 @@ dependencies: # fl_chart: ^1.0.0 video_player: ^2.9.5 chewie: ^1.10.0 + gif: ^2.3.0 dev_dependencies: flutter_test: