更新传感器升级

This commit is contained in:
wyf
2025-09-02 14:03:00 +08:00
parent 8761e8bf1a
commit aad3a00ac3
9 changed files with 456 additions and 36 deletions

View File

@@ -617,5 +617,13 @@
"头像限制": "Avatar image cannot exceed 5MB",
"生命体征指的是睡眠周期的整体数据。": "Vital signs refer to the overall data of the sleep cycle.",
"睡眠报告提示": "This page is not a medical standard, and the data is for reference only.",
"MAC号": "MAC Address"
"MAC号": "MAC Address",
"web控制更新": "Web Update Control",
"新版本号": "New Version Number",
"点击确认退出app重新进入": "Tap Confirm to Exit the App and Reopen",
"设备升级": "Device Upgrade",
"最新版本": "Latest Version",
"升级进度": "Upgrade Progress",
"立即升级": "Upgrade Now",
"取消升级": "Cancel Upgrade"
}

View File

@@ -616,5 +616,13 @@
"生命体征指的是睡眠周期的整体数据。": "生命体征指的是睡眠周期的整体数据。",
"头像限制": "头像图片不能超过5MB",
"睡眠报告提示":"本页内容非医疗标准,数据仅供参考",
"MAC号": "MAC号"
"MAC号": "MAC号",
"web控制更新":"web控制更新",
"新版本号": "新版本号",
"点击确认退出app重新进入": "点击确认退出app重新进入",
"设备升级": "设备升级",
"最新版本": "最新版本",
"升级进度": "升级进度",
"立即升级": "立即升级",
"取消升级": "取消升级"
}

View File

@@ -614,6 +614,14 @@
"在床时长": "在床時長",
"生命体征指的是睡眠周期的整体数据。": "生命體徵指的是睡眠週期的整體數據。",
"头像限制": "頭像圖片不能超過5MB",
"睡眠报告提示":"本頁內容非醫療標準,數據僅供參考",
"MAC号": "MAC號"
"睡眠报告提示": "本頁內容非醫療標準,數據僅供參考",
"MAC号": "MAC號",
"web控制更新": "web控制更新",
"新版本号": "新版本號",
"点击确认退出app重新进入": "點擊確認退出app重新進入",
"设备升级": "設備升級",
"最新版本": "最新版本",
"升级进度": "升級進度",
"立即升级": "立即升級",
"取消升级": "取消升級"
}

View File

@@ -1638,3 +1638,291 @@ Future<String?> showUnShareMessageDialog({
barrierDismissible: true,
);
}
//升级传感器弹窗
void showConfirmUpDialog(
BuildContext context,
Widget widget,
String title, {
required VoidCallback onConfirm,
required VoidCallback onCancel,
Color? backgroundColor, // ✅ 可选背景色
String confirmText = "", // ✅ 新增:确认按钮文字
String cancelText = "", // ✅ 新增:取消按钮文字
}) {
ThemeController themeController = Get.find();
try {
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(31.rpx, 0, 31.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(
33.rpx, 60.rpx, 33.rpx, 33.rpx),
// 如果以后要显示标题,可以在这里加回 Text(title)
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
33.rpx, 0.rpx, 33.rpx, 0.rpx),
child: widget,
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
33.rpx, 58.rpx, 33.rpx, 60.rpx),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// ✅ 确认按钮
CustomCard(
borderRadius: AppConstants().button_container_radius,
onTap: () {
Get.back();
onConfirm();
},
colors: AppConstants().mhtNormalButton,
child: Container(
// width: MediaQuery.sizeOf(context).width * 0.215,
height: MediaQuery.sizeOf(context).height * 0.055,
constraints: BoxConstraints(
minWidth: 160.rpx,
minHeight: 90.rpx,
),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
confirmText.tr, // ✅ 支持传参
style: TextStyle(
color: themeController.currentColor.sc3,
fontFamily: 'Inter',
fontSize:
AppConstants().normal_text_fontSize,
letterSpacing: 0.0,
),
),
].divide(SizedBox(width: 17.rpx)),
),
),
),
// ❌ 取消按钮
CustomCard(
borderRadius: AppConstants().button_container_radius,
onTap: () async {
Get.back();
onCancel();
},
colors: [Colors.transparent],
child: Container(
// width: MediaQuery.sizeOf(context).width * 0.115,
height: MediaQuery.sizeOf(context).height * 0.055,
decoration: BoxDecoration(
color: Colors.white, // 背景色
border: Border.all(
color: stringToColor("#929699"), // 边框颜色
width: 1.rpx, // 边框宽度
),
borderRadius: BorderRadius.circular(
AppConstants().button_container_radius), // 圆角
),
constraints: BoxConstraints(
minWidth: 160.rpx,
minHeight: 90.rpx,
),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
cancelText.tr, // ✅ 支持传参
style: TextStyle(
color: stringToColor("#333333"),
fontFamily: 'Inter',
fontSize:
AppConstants().normal_text_fontSize,
letterSpacing: 0.0,
),
),
].divide(SizedBox(width: 17.rpx)),
),
),
),
].divide(SizedBox(height: 19.rpx)),
),
),
],
),
),
),
);
},
);
} catch (e) {
print(e);
}
}
//取消升级弹窗
void showConfirmCancelDialog(
BuildContext context,
Widget widget,
String title, {
required VoidCallback onConfirm,
required VoidCallback onCancel,
Color? backgroundColor, // ✅ 整个弹窗背景色
String confirmText = "", // ✅ 确认按钮文字
String cancelText = "", // ✅ 取消按钮文字
Color? confirmButtonColor, // ✅ 新增:确认按钮背景色
Color? cancelButtonColor, // ✅ 新增:取消按钮背景色
}) {
ThemeController themeController = Get.find();
try {
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(31.rpx, 0, 31.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(
33.rpx, 60.rpx, 33.rpx, 33.rpx),
// 如果以后要显示标题,可以在这里加回 Text(title)
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
33.rpx, 0.rpx, 33.rpx, 0.rpx),
child: widget,
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
33.rpx, 58.rpx, 33.rpx, 60.rpx),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// ✅ 确认按钮
CustomCard(
borderRadius: AppConstants().button_container_radius,
onTap: () {
Get.back();
onConfirm();
},
colors: confirmButtonColor != null
? [confirmButtonColor] // 使用自定义背景
: AppConstants().mhtNormalButton, // 默认背景
child: Container(
height: MediaQuery.sizeOf(context).height * 0.055,
constraints: BoxConstraints(
minWidth: 160.rpx,
minHeight: 90.rpx,
),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
confirmText.tr,
style: TextStyle(
color: themeController.currentColor.sc3,
fontFamily: 'Inter',
fontSize:
AppConstants().normal_text_fontSize,
),
),
],
),
),
),
// ❌ 取消按钮
CustomCard(
borderRadius: AppConstants().button_container_radius,
onTap: () {
Get.back();
onCancel();
},
colors: [Colors.transparent],
child: Container(
height: MediaQuery.sizeOf(context).height * 0.055,
decoration: BoxDecoration(
color: cancelButtonColor ??
Colors.white, // ✅ 可传入自定义背景色
border: Border.all(
color: stringToColor("#929699"),
width: 1.rpx,
),
borderRadius: BorderRadius.circular(
AppConstants().button_container_radius,
),
),
constraints: BoxConstraints(
minWidth: 160.rpx,
minHeight: 90.rpx,
),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
cancelText.tr,
style: TextStyle(
color: stringToColor("#333333"),
fontFamily: 'Inter',
fontSize:
AppConstants().normal_text_fontSize,
),
),
],
),
),
),
].divide(SizedBox(height: 19.rpx)),
),
),
],
),
),
),
);
},
);
} catch (e) {
print(e);
}
}

View File

@@ -1,5 +1,6 @@
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:loading_indicator/loading_indicator.dart';
@@ -1131,3 +1132,92 @@ Future<void> showUnBindTipDialog(
},
);
}
Future<void> showTipUpgradeDialog(
BuildContext context,
Widget widget, {
Color? backgroundColor,
}) {
ThemeController themeController = Get.find();
BlueteethBindController blueteethBindController = Get.find();
return showDialog(
context: context,
barrierDismissible: false,
barrierColor: Colors.black.withOpacity(0.5),
builder: (BuildContext context) {
return WillPopScope(
child: FrostedDialog(
blurSigma: 3.0,
child: Container(
decoration: BoxDecoration(
color: backgroundColor ?? Colors.white,
borderRadius: BorderRadius.circular(8.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, 74.rpx),
child: widget,
),
),
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0, 19.rpx, 0, 60.rpx),
child: CustomCard(
gradientDirection: GradientDirection.vertical,
borderRadius: AppConstants().button_container_radius,
onTap: () {
Get.back(); // 关闭对话框
SystemNavigator.pop();
},
colors: [
stringToColor("1592AA"),
stringToColor("0C83A7"),
stringToColor("006FA3"),
],
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: TextStyle(
color: Colors.white,
fontFamily: 'Inter',
fontSize: AppConstants().normal_text_fontSize,
letterSpacing: 0.0,
),
),
].divide(SizedBox(width: 17.rpx)),
),
),
),
),
],
),
),
),
),
onWillPop: () async => false,
); // 禁止返回键关闭);
},
);
}

View File

@@ -72,6 +72,9 @@ class MHTBlueToothController extends GetControllerEx<MHTBlueToothModel> {
RxMap connect_wifi = {}.obs;
RxString? cid = "".obs;
RxBool isScanning = false.obs;
Map<String, Map> localUpgradeMac = {}; //mac 进度
void startStatusPolling() {
updateDeviceStatus().then((res) {
if (res.code == HttpStatusCodes.ok) {
@@ -141,9 +144,9 @@ class MHTBlueToothController extends GetControllerEx<MHTBlueToothModel> {
}
String? language = "";
if (mhLanguageController.selectLanguage != null) {
language = mhLanguageController.selectLanguage.value!.language_code;
}
if (mhLanguageController.selectLanguage != null) {
language = mhLanguageController.selectLanguage.value!.language_code;
}
if (language != null && language.isNotEmpty) {
if (queryUrl.contains("?")) {
queryUrl += "&lang=$language";
@@ -372,8 +375,8 @@ class MHTBlueToothController extends GetControllerEx<MHTBlueToothModel> {
);
}
loadMattressTimeData(String mac,{int time = 3}) async {
String serviceAddress = ServiceConstant.service_address;
loadMattressTimeData(String mac, {int time = 3}) async {
String serviceAddress = ServiceConstant.service_address;
String serviceName = ServiceConstant.server_service;
String serviceApi = ServiceConstant.user_setting;
String type = "sleep_new_time_${mac}";

View File

@@ -63,14 +63,6 @@ class _MHTBlueteethDevicePageState extends State<MHTBlueteethDevicePage> {
mhtBlueToothController.startStatusPolling();
mhtBlueToothController.search.value = "";
mhtBlueToothController.currentDeviceMac?.value = "";
// BluetoothHelper.listenBluetoothState((isOn) {
// if (!isOn && !_isDialogShowing) {
// _isDialogShowing = true;
// _showBluetoothNotEnabledDialog().then((_) {
// _isDialogShowing = false;
// });
// }
// });
BluetoothHelper.listenBluetoothState((isOn) {
mhtBlueToothController.model.bluetooth = isOn;
mhtBlueToothController.updateAll();

View File

@@ -12,6 +12,7 @@ class BlueToothDataModel {
String? macBID;
DateTime lastSeen; // 最后可见时间
String? deviceID; // 设备ID
int? version; // ✅ 新增版本号,可为空
BlueToothDataModel({
this.name = '',
@@ -22,7 +23,8 @@ class BlueToothDataModel {
this.macA = '',
this.macB = '',
required this.lastSeen,
this.deviceID, // ✅ 加入构造函数参数
this.deviceID,
this.version, // ✅ 构造函数参数
});
factory BlueToothDataModel.fromScanResult(
@@ -31,7 +33,8 @@ class BlueToothDataModel {
bool bind = false,
String name = '',
String mac = '',
String? deviceID, // ✅ 工厂方法接收 deviceID
String? deviceID,
int? version, // ✅ 工厂方法参数
}) {
String finalName =
name.isNotEmpty ? name : (result.advertisementData.localName ?? '');
@@ -45,7 +48,8 @@ class BlueToothDataModel {
macA: '',
macB: '',
lastSeen: DateTime.now(),
deviceID: deviceID, // ✅ 赋值
deviceID: deviceID,
version: version, // ✅ 赋值
);
}
}

View File

@@ -13,7 +13,9 @@ import 'package:vbvs_app/component/NullDataComponentWidget.dart';
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
import 'package:vbvs_app/controller/user_info_controller.dart';
import 'package:vbvs_app/controller/weather/weather_controller.dart';
import 'package:vbvs_app/enum/APPPackageType.dart';
import 'package:vbvs_app/pages/mh_page/FloatingSvgIcon.dart';
import 'package:vbvs_app/pages/mh_page/component/mht_bind_dialog.dart';
import 'package:vbvs_app/pages/mh_page/homepage/component/HomeDeviceWidget.dart';
import 'package:vbvs_app/pages/mh_page/homepage/controller/mht_home_controller.dart';
@@ -75,22 +77,39 @@ class _NewHomePageState extends State<NewHomePage> {
});
try {
_newVersionSubscription =
ef.kvRoot.appmanger.onAppUpdate.stream.listen((MiniAppPkg pkg) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text("发现新版本".tr),
content: Text("新版本号:${pkg.version}"),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: Text("知道了".tr),
ef.kvRoot.appmanger.onAppUpdate.listen((MiniAppPkg pkg) {
if (AppConstants().ent_type != APPPackageType.MHT.code) {
return;
}
showTipUpgradeDialog(
context,
Column(
children: [
SizedBox(
width: 94.rpx,
height: 70.rpx,
child: SvgPicture.asset(
'assets/img/icon/upgrade.svg',
fit: BoxFit.cover,
// color: themeController.currentColor.sc3, // 若你想加颜色控制可取消注释
),
),
],
);
},
);
Text(
"web控制更新".tr,
style: TextStyle(
color: stringToColor("#333333"),
fontSize: AppConstants().title_text_fontSize,
),
),
Text("新版本号".tr +
"" +
"${pkg.version}" +
"" +
"点击确认退出app重新进入".tr),
].divide(SizedBox(
height: 37.rpx,
)),
));
});
} catch (e) {
print(e);