修改设备信息 其他页面刷新
This commit is contained in:
@@ -11,13 +11,23 @@ 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/test/WebviewTestModel.dart';
|
||||
|
||||
class BluetoothPage extends GetView {
|
||||
Map data;
|
||||
BluetoothPage({required this.data});
|
||||
class BluetoothPage extends StatefulWidget {
|
||||
final Map data;
|
||||
BluetoothPage({Key? key, required this.data});
|
||||
@override
|
||||
_BluetoothPageState createState() => _BluetoothPageState();
|
||||
}
|
||||
|
||||
class _BluetoothPageState extends State<BluetoothPage> {
|
||||
late RxMap<String, dynamic> obsData;
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
obsData = Map<String, dynamic>.from(widget.data).obs; // 复制成 obs
|
||||
}
|
||||
|
||||
BoxConstraints? bodysize;
|
||||
DeviceListController deviceListController = Get.find();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(builder: (context, cc) {
|
||||
@@ -77,7 +87,7 @@ class BluetoothPage extends GetView {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
data['name']?.toString() ?? '未命名',
|
||||
obsData['name']?.toString() ?? '未命名',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 40.rpx,
|
||||
@@ -88,9 +98,15 @@ class BluetoothPage extends GetView {
|
||||
backgroundColor: Colors.transparent,
|
||||
highlightColor: const Color(0xFF055466),
|
||||
padding: EdgeInsets.only(left: 0),
|
||||
onTap: () {
|
||||
Get.toNamed("/editBedPage",
|
||||
arguments: data);
|
||||
onTap: () async {
|
||||
var x = await Get.toNamed(
|
||||
"/editBedPage",
|
||||
arguments: obsData);
|
||||
if (x != null) {
|
||||
setState(() {
|
||||
obsData.addAll(x); // 值更新后主动刷新页面
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
width: 42.rpx,
|
||||
@@ -103,7 +119,7 @@ class BluetoothPage extends GetView {
|
||||
),
|
||||
|
||||
const SizedBox(height: 4),
|
||||
Text(data['mac']?.toString() ?? '未命名',
|
||||
Text(obsData['mac']?.toString() ?? '未命名',
|
||||
style: TextStyle(
|
||||
color: Colors.white70, fontSize: 26.rpx)),
|
||||
|
||||
@@ -112,7 +128,7 @@ class BluetoothPage extends GetView {
|
||||
// 蓝牙连接状态
|
||||
Column(
|
||||
children: [
|
||||
data['blueToothStatus'] == 1
|
||||
obsData['blueToothStatus'] == 1
|
||||
? SvgPicture.asset(
|
||||
'assets/img/icon/blue_fail.svg',
|
||||
width: 68.rpx,
|
||||
@@ -126,11 +142,11 @@ class BluetoothPage extends GetView {
|
||||
SizedBox(height: 4),
|
||||
//下面文字和颜色也根据上面变化
|
||||
Text(
|
||||
data['blueToothStatus'] == 1
|
||||
obsData['blueToothStatus'] == 1
|
||||
? '未连接'
|
||||
: '已连接',
|
||||
style: TextStyle(
|
||||
color: data['blueToothStatus'] == 1
|
||||
color: obsData['blueToothStatus'] == 1
|
||||
? Color(0xFFFF7159)
|
||||
: Color(0xFF6BFDAC),
|
||||
fontSize: 26.rpx)),
|
||||
@@ -148,13 +164,13 @@ class BluetoothPage extends GetView {
|
||||
children: [
|
||||
_buildMenuButton(
|
||||
context, '详情', "/devicePeopleInfo",
|
||||
arguments: data),
|
||||
arguments: obsData),
|
||||
_buildMenuButton(
|
||||
context, '人员资料', "/peopleInfoPage",
|
||||
arguments: data),
|
||||
arguments: obsData,),
|
||||
_buildMenuButton(
|
||||
context, '房间选择', "/roomPickerPage",
|
||||
arguments: data),
|
||||
arguments: obsData),
|
||||
_buildMenuButton(context, '设备校准', ""),
|
||||
_buildMenuButton(context, '体征传感器', ""),
|
||||
_buildMenuButton(context, 'WIFI配置', ""),
|
||||
@@ -162,20 +178,20 @@ class BluetoothPage extends GetView {
|
||||
context, '睡眠习惯', "/sleepHabitPage"),
|
||||
_buildMenuButton(
|
||||
context, '分享设备', "/deviceSharePage",
|
||||
arguments: data),
|
||||
arguments: obsData),
|
||||
_buildMenuButton(
|
||||
context,
|
||||
data['bind_type'] == 1 ? '解绑' : '删除',
|
||||
obsData['bind_type'] == 1 ? '解绑' : '删除',
|
||||
"",
|
||||
onTap: () {
|
||||
if (data['bind_type'] == 1) {
|
||||
if (obsData['bind_type'] == 1) {
|
||||
// 解绑弹窗
|
||||
showUnbindConfirmDialog(
|
||||
context: context,
|
||||
title: "是否进行解绑?",
|
||||
onConfirm: () async {
|
||||
await deviceListController
|
||||
.unbindDevice(data);
|
||||
.unbindDevice(obsData);
|
||||
await deviceListController
|
||||
.getDeviceList();
|
||||
try {
|
||||
@@ -195,7 +211,7 @@ class BluetoothPage extends GetView {
|
||||
// 点击取消后的逻辑
|
||||
},
|
||||
);
|
||||
} else if (data['bind_type'] == 2) {
|
||||
} else if (obsData['bind_type'] == 2) {
|
||||
// 删除弹窗
|
||||
showDeleteDeviceConfirmDialog(
|
||||
context: context,
|
||||
@@ -203,7 +219,7 @@ class BluetoothPage extends GetView {
|
||||
onConfirm: () async {
|
||||
await deviceListController
|
||||
.unbindDevice(
|
||||
data,
|
||||
obsData,
|
||||
);
|
||||
await deviceListController
|
||||
.getDeviceList();
|
||||
|
||||
Reference in New Issue
Block a user