更新
This commit is contained in:
@@ -73,6 +73,7 @@ class _DeviceDataComponentWidgetState extends State<DeviceDataComponentWidget> {
|
||||
final allTexts = [
|
||||
"体征检测设备.首页展示".tr,
|
||||
"体征检测设备.设备详情".tr,
|
||||
"WIFI配置".tr,
|
||||
"设备校准".tr,
|
||||
"分享设备".tr,
|
||||
"消息设置".tr,
|
||||
@@ -86,7 +87,7 @@ class _DeviceDataComponentWidgetState extends State<DeviceDataComponentWidget> {
|
||||
final estimatedItemHeight = 60.rpx; // 每个菜单项的估算高度
|
||||
//todo 更新菜单项,需要在此添加数量
|
||||
final itemCount =
|
||||
widget.device['bind_type'] == BindType.active.code ? 8 : 5;
|
||||
widget.device['bind_type'] == BindType.active.code ? 9 : 5;
|
||||
final estimatedPopupHeight =
|
||||
(itemCount * estimatedItemHeight) + 40.rpx; // 加上padding
|
||||
|
||||
@@ -140,12 +141,24 @@ class _DeviceDataComponentWidgetState extends State<DeviceDataComponentWidget> {
|
||||
left: popupLeft,
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: ConstrainedBox(
|
||||
child: Container(
|
||||
constraints: BoxConstraints(
|
||||
// maxWidth: popupWidth,
|
||||
maxWidth: screenWidth,
|
||||
maxHeight: actualPopupHeight,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: themeController.currentColor.sc17,
|
||||
borderRadius: BorderRadius.circular(12.rpx),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.2),
|
||||
blurRadius: 12.rpx,
|
||||
spreadRadius: 1.rpx,
|
||||
offset: Offset(0, 6.rpx),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: popupContent,
|
||||
),
|
||||
@@ -164,18 +177,18 @@ class _DeviceDataComponentWidgetState extends State<DeviceDataComponentWidget> {
|
||||
Widget _buildPopupContent() {
|
||||
final content = Container(
|
||||
padding: EdgeInsets.all(20.rpx),
|
||||
decoration: BoxDecoration(
|
||||
color: themeController.currentColor.sc17,
|
||||
borderRadius: BorderRadius.circular(12.rpx),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.2),
|
||||
blurRadius: 12.rpx,
|
||||
spreadRadius: 1.rpx,
|
||||
offset: Offset(0, 6.rpx),
|
||||
),
|
||||
],
|
||||
),
|
||||
// decoration: BoxDecoration(
|
||||
// color: themeController.currentColor.sc17,
|
||||
// borderRadius: BorderRadius.circular(12.rpx),
|
||||
// boxShadow: [
|
||||
// BoxShadow(
|
||||
// color: Colors.black.withOpacity(0.2),
|
||||
// blurRadius: 12.rpx,
|
||||
// spreadRadius: 1.rpx,
|
||||
// offset: Offset(0, 6.rpx),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: _buildMenuItems(),
|
||||
@@ -250,6 +263,14 @@ class _DeviceDataComponentWidgetState extends State<DeviceDataComponentWidget> {
|
||||
// dealWifi(widget.device['mac']);
|
||||
// },
|
||||
// ),
|
||||
_buildMenuItem(
|
||||
text: "WIFI配置".tr,
|
||||
onTap: () {
|
||||
_popupEntry?.remove();
|
||||
_popupEntry = null;
|
||||
dealWifi(widget.device['mac']);
|
||||
},
|
||||
),
|
||||
_buildMenuItem(
|
||||
text: "设备校准".tr,
|
||||
onTap: () {
|
||||
@@ -962,7 +983,6 @@ class _DeviceDataComponentWidgetState extends State<DeviceDataComponentWidget> {
|
||||
personController.currentPersonId.value =
|
||||
widget.device['_id'];
|
||||
}
|
||||
// Get.toNamed("/personPage");
|
||||
await Get.toNamed("/updatePersonPage",
|
||||
arguments: widget.device['bind_type']);
|
||||
bodyDeviceController.getDeviceList();
|
||||
@@ -1151,7 +1171,7 @@ class _DeviceDataComponentWidgetState extends State<DeviceDataComponentWidget> {
|
||||
final themeController = Get.find<ThemeController>();
|
||||
|
||||
// 显示加载对话框
|
||||
showLoadingDialog(Get.context!, title: "正在匹配设备...".tr);
|
||||
showLoadingDialog(Get.context!, title: "连接中...".tr);
|
||||
|
||||
// 设置超时定时器
|
||||
Timer? timeoutTimer;
|
||||
@@ -1204,26 +1224,27 @@ class _DeviceDataComponentWidgetState extends State<DeviceDataComponentWidget> {
|
||||
|
||||
try {
|
||||
// 连接设备
|
||||
await targetDevice.device.connect(autoConnect: false);
|
||||
|
||||
// 检查连接状态
|
||||
if (targetDevice.device.isConnected) {
|
||||
Navigator.of(Get.context!).pop(); // 关闭加载对话框
|
||||
|
||||
// 存储当前设备
|
||||
blueteethBindController.currentDevice =
|
||||
THapp(device: targetDevice.device);
|
||||
|
||||
// 跳转到WiFi配置页
|
||||
Get.toNamed("/wifiPage");
|
||||
|
||||
// await targetDevice.device.connect();
|
||||
THapp bledevice = THapp(device: targetDevice.device);
|
||||
await bledevice.device.connect();
|
||||
var res2 = bledevice.isConnected;
|
||||
if (res2) {
|
||||
Navigator.pop(context);
|
||||
TopSlideNotification.show(
|
||||
Get.context!,
|
||||
text: "设备连接成功".tr,
|
||||
context,
|
||||
text: "蓝牙绑定.连接成功".tr,
|
||||
textColor: themeController.currentColor.sc2,
|
||||
);
|
||||
blueteethBindController.currentDevice = bledevice;
|
||||
// Get.toNamed("/wifiPage", arguments: {bledevice});
|
||||
Get.toNamed("/wifiPage", arguments: 1);
|
||||
} else {
|
||||
throw Exception("连接失败");
|
||||
Navigator.pop(context);
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "蓝牙绑定.连接失败".tr,
|
||||
textColor: themeController.currentColor.sc9,
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
Navigator.of(Get.context!).pop(); // 关闭加载对话框
|
||||
@@ -1235,7 +1256,6 @@ class _DeviceDataComponentWidgetState extends State<DeviceDataComponentWidget> {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 等待扫描完成
|
||||
await Future.delayed(Duration(seconds: 20));
|
||||
} catch (e) {
|
||||
@@ -1264,8 +1284,6 @@ class _DeviceDataComponentWidgetState extends State<DeviceDataComponentWidget> {
|
||||
maxTextWidth = painter.width;
|
||||
}
|
||||
}
|
||||
|
||||
// 加上 icon 宽度(24.rpx),间距(10.rpx),padding(左右 20.rpx)
|
||||
final iconWidth = 24.rpx;
|
||||
final spacing = 10.rpx;
|
||||
final horizontalPadding = 40.rpx;
|
||||
|
||||
Reference in New Issue
Block a user