日报周报月报

This commit is contained in:
czz
2025-07-09 14:37:04 +08:00
parent 143e7634d9
commit b81b7c75b8
17 changed files with 619 additions and 644 deletions

View File

@@ -11,6 +11,7 @@ import 'package:vbvs_app/model/api_response.dart';
import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
import 'package:vbvs_app/pages/mh_page/homepage/controller/mht_home_controller.dart';
import 'package:vbvs_app/pages/mh_page/test/WebviewTestModel.dart';
import 'dart:ui' as ui;
class BluetoothPage extends StatefulWidget {
final Map data;
@@ -21,10 +22,41 @@ class BluetoothPage extends StatefulWidget {
class _BluetoothPageState extends State<BluetoothPage> {
late RxMap<String, dynamic> obsData;
double _textHalfWidth = 0;
@override
void initState() {
super.initState();
obsData = Map<String, dynamic>.from(widget.data).obs; // 复制成 obs
String text;
if (widget.data.containsKey('name') &&
widget.data['name'] != null &&
widget.data['name'].toString().isNotEmpty) {
text = widget.data['name'].toString();
} else {
text = '未命名'.tr;
}
_calculateTextHalfWidth(text);
}
void _calculateTextHalfWidth(String text) {
final textSpan = TextSpan(
text: text,
style: TextStyle(
fontSize: 40.rpx,
height: 1,
),
);
final textPainter = TextPainter(
text: textSpan,
textDirection: ui.TextDirection.ltr,
);
textPainter.layout(); // 计算文本宽度
setState(() {
_textHalfWidth = textPainter.width / 2;
});
}
BoxConstraints? bodysize;
@@ -85,39 +117,53 @@ class _BluetoothPageState extends State<BluetoothPage> {
children: [
Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
obsData['name']?.toString() ?? '未命名',
style: TextStyle(
color: Colors.white,
fontSize: 40.rpx,
Container(
width: double.infinity,
child: Stack(
alignment: Alignment.center,
children: [
Text(
obsData['name']?.toString() ?? '未命名',
style: TextStyle(
color: Colors.white,
fontSize: 40.rpx,
),
overflow:
TextOverflow.ellipsis, // 超出部分显示省略号
maxLines: 1, // 限制为单行
),
),
SizedBox(width: 27.rpx),
ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor: const Color(0xFF055466),
padding: EdgeInsets.only(left: 0),
onTap: () async {
var x = await Get.toNamed(
"/editBedPage",
arguments: obsData);
if (x != null) {
setState(() {
obsData.addAll(x); // 值更新后主动刷新页面
});
}
},
child: Container(
width: 42.rpx,
height: 42.rpx,
child: SvgPicture.asset(
"assets/img/icon/bluetooth_edit.svg",
color: Colors.white,
)))
],
Positioned(
left:
MediaQuery.of(context).size.width /
2 +
_textHalfWidth +
22.rpx,
top: 5.rpx,
child: ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor:
const Color(0xFF055466),
padding: EdgeInsets.only(left: 0),
onTap: () async {
var x = await Get.toNamed(
"/editBedPage",
arguments: obsData);
if (x != null) {
setState(() {
obsData
.addAll(x); // 值更新后主动刷新页面
});
}
},
child: Container(
width: 42.rpx,
height: 42.rpx,
child: SvgPicture.asset(
"assets/img/icon/bluetooth_edit.svg",
color: Colors.white,
))))
],
),
),
const SizedBox(height: 4),
@@ -156,17 +202,17 @@ class _BluetoothPageState extends State<BluetoothPage> {
),
],
),
const SizedBox(height: 24),
Expanded(
child: ListView(
padding: EdgeInsets.symmetric(horizontal: 30.rpx),
padding: EdgeInsets.only(
left: 30.rpx, right: 30.rpx, bottom: 60.rpx),
reverse: !isBind,
children: [
_buildMenuButton(
context, '详情', "/devicePeopleInfo",
arguments: obsData),
if (isBind) ...[
_buildMenuButton(
context, '详情', "/devicePeopleInfo",
arguments: obsData),
_buildMenuButton(
context,
'人员资料',
@@ -185,164 +231,28 @@ class _BluetoothPageState extends State<BluetoothPage> {
context, '分享设备', "/deviceSharePage",
arguments: obsData),
],
_buildMenuButton(
context,
obsData['bind_type'] == 1 ? '解绑' : '删除',
"",
onTap: () {
if (obsData['bind_type'] == 1) {
// 解绑弹窗
showUnbindConfirmDialog(
context: context,
title: "是否进行解绑?",
onConfirm: () async {
await deviceListController
.unbindDevice(obsData);
await deviceListController
.getDeviceList();
MHTHomeController homeController =
Get.find();
homeController.selectDevcie.value =
"";
try {
WebviewTestController
webviewTestController =
Get.find();
webviewTestController
.web.jsbridge?.dart
.unBindDevice();
} catch (e) {
ef.log("[h5]通知列表更新报错:$e");
}
Get.toNamed("/mianPageBottomChange");
// 执行解绑逻辑
},
onCancel: () {
// 点击取消后的逻辑
},
);
} else if (obsData['bind_type'] == 2) {
// 删除弹窗
showDeleteDeviceConfirmDialog(
context: context,
title: "是否进行删除?",
onConfirm: () async {
await deviceListController
.unbindDevice(
obsData,
);
await deviceListController
.getDeviceList();
Get.toNamed("/mianPageBottomChange");
},
onCancel: () {
// 点击取消后的逻辑
},
);
}
},
),
if (!isBind) ...[
_buildMenuButton(
context,
obsData['bind_type'] == 1 ? '解绑' : '删除',
"",
onTap: () {/*...*/},
),
_buildMenuButton(
context, '详情', "/devicePeopleInfo",
arguments: obsData),
],
if (isBind) ...[
_buildMenuButton(
context,
obsData['bind_type'] == 1 ? '解绑' : '删除',
"",
onTap: () {/*...*/},
),
],
],
),
),
// Expanded(
// child: Align(
// alignment: Alignment.bottomCenter,
// child: SingleChildScrollView(
// reverse: true, // 👈 optional如果你想要滚动时内容从底部弹出
// child: Column(
// crossAxisAlignment:
// CrossAxisAlignment.stretch,
// mainAxisSize: MainAxisSize.min,
// children: [
// _buildMenuButton(
// context, '详情', "/devicePeopleInfo",
// arguments: obsData),
// if (isBind) ...[
// _buildMenuButton(
// context,
// '人员资料',
// "/peopleInfoPage",
// arguments: obsData,
// ),
// _buildMenuButton(
// context, '房间选择', "/roomPickerPage",
// arguments: obsData),
// _buildMenuButton(context, '设备校准', ""),
// _buildMenuButton(context, '体征传感器', ""),
// _buildMenuButton(context, 'WIFI配置', ""),
// _buildMenuButton(
// context, '睡眠习惯', "/sleepHabitPage"),
// _buildMenuButton(
// context, '分享设备', "/deviceSharePage",
// arguments: obsData),
// ],
// _buildMenuButton(
// context,
// obsData['bind_type'] == 1 ? '解绑' : '删除',
// "",
// onTap: () {
// if (obsData['bind_type'] == 1) {
// // 解绑弹窗
// showUnbindConfirmDialog(
// context: context,
// title: "是否进行解绑?",
// onConfirm: () async {
// await deviceListController
// .unbindDevice(obsData);
// await deviceListController
// .getDeviceList();
// MHTHomeController homeController =
// Get.find();
// homeController
// .selectDevcie.value = "";
// try {
// WebviewTestController
// webviewTestController =
// Get.find();
// webviewTestController
// .web.jsbridge?.dart
// .unBindDevice();
// } catch (e) {
// ef.log("[h5]通知列表更新报错:$e");
// }
// Get.toNamed(
// "/mianPageBottomChange");
// // 执行解绑逻辑
// },
// onCancel: () {
// // 点击取消后的逻辑
// },
// );
// } else if (obsData['bind_type'] == 2) {
// // 删除弹窗
// showDeleteDeviceConfirmDialog(
// context: context,
// title: "是否进行删除?",
// onConfirm: () async {
// await deviceListController
// .unbindDevice(
// obsData,
// );
// await deviceListController
// .getDeviceList();
// Get.toNamed(
// "/mianPageBottomChange");
// },
// onCancel: () {
// // 点击取消后的逻辑
// },
// );
// }
// },
// ),
// ],
// ),
// ),
// ),
// ),
],
),
)),