430 lines
20 KiB
Dart
430 lines
20 KiB
Dart
import 'package:ef/ef.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
|
|
|
import 'package:vbvs_app/common/color/appFontsize.dart';
|
|
import 'package:vbvs_app/common/util/DailyLogUtils.dart';
|
|
import 'package:vbvs_app/common/util/FitTool.dart';
|
|
import 'package:vbvs_app/common/util/MyUtils.dart';
|
|
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
|
import 'package:vbvs_app/controller/main_bottom/global_controller.dart';
|
|
import 'package:vbvs_app/controller/mh_controller/device_list_controller.dart';
|
|
import 'package:vbvs_app/pages/main_bottom/component/main_page_b_bottom_change.dart';
|
|
import 'package:vbvs_app/pages/mh_page/homepage/component/HomeDeviceStausWidget.dart';
|
|
import 'package:vbvs_app/pages/mh_page/test/WebviewTestModel.dart';
|
|
|
|
class DeviceInfoWidget extends GetView {
|
|
int index;
|
|
DeviceListController deviceListController;
|
|
|
|
DeviceInfoWidget({required this.index, required this.deviceListController}) {}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
var device = deviceListController.model.deviceList[index];
|
|
GlobalController globalController = Get.find();
|
|
return Padding(
|
|
padding: EdgeInsetsDirectional.fromSTEB(30.rpx, 0, 30.rpx, 0),
|
|
child: Container(
|
|
// width: MediaQuery.sizeOf(context).width,
|
|
height: 381.rpx,
|
|
// constraints: BoxConstraints(
|
|
// minHeight: 140,
|
|
// ),
|
|
decoration: BoxDecoration(
|
|
color: Color(0xFF003058),
|
|
borderRadius: BorderRadius.circular(16.rpx),
|
|
),
|
|
child: Padding(
|
|
padding: EdgeInsetsDirectional.fromSTEB(26.rpx, 33.rpx, 26.rpx, 0),
|
|
child: Container(
|
|
// width: MediaQuery.sizeOf(context).width,
|
|
height: 381.rpx,
|
|
// constraints: BoxConstraints(
|
|
// minHeight: 106,
|
|
// ),
|
|
|
|
child: Container(
|
|
// width: MediaQuery.sizeOf(context).width,
|
|
height: 381.rpx,
|
|
constraints: BoxConstraints(
|
|
minHeight: 130,
|
|
),
|
|
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
deviceListController.model.deviceList[index]['name'] ??
|
|
getNameByType(
|
|
deviceListController.model.deviceList[index]),
|
|
style: TextStyle(
|
|
fontFamily: 'Readex Pro',
|
|
color: Colors.white,
|
|
fontSize: 30.rpx,
|
|
letterSpacing: 0,
|
|
),
|
|
maxLines: 1, // 限制显示一行
|
|
overflow: TextOverflow.ellipsis, // 超出部分显示省略号
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(top: 36.rpx),
|
|
width: MediaQuery.sizeOf(context).width,
|
|
// height: MediaQuery.sizeOf(context).height * 0.065,
|
|
constraints: BoxConstraints(
|
|
minHeight: 55,
|
|
),
|
|
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Expanded(
|
|
child: InkWell(
|
|
onTap: () async {
|
|
// GlobalController globalController = Get.find();
|
|
// var tmp = globalController.model.deviceMain;
|
|
// BedController bedController = Get.find();
|
|
// bedController.websocketSend(2);
|
|
// globalController.model.deviceMain = device;
|
|
// globalController.updateAll();
|
|
// bedController.websocketSend(1);
|
|
// var result = await Get.toNamed("/bodyChart");
|
|
// bedController.websocketSend(2);
|
|
// globalController.model.deviceMain = tmp;
|
|
},
|
|
child: Container(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.max,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
_buildInfoRow(
|
|
'设备ID'.tr,
|
|
deviceListController.model
|
|
.deviceList[index]["mac".tr] ??
|
|
'',
|
|
valueColor: (deviceListController
|
|
.model.deviceList[index]
|
|
["status"]?["status"]) ==
|
|
1
|
|
? Color(0xFF929699)
|
|
: null),
|
|
_buildInfoRow(
|
|
'房间'.tr,
|
|
deviceListController.model
|
|
.deviceList[index]["roomName"] ??
|
|
'未分配房间'.tr,
|
|
valueColor: (deviceListController
|
|
.model.deviceList[index]
|
|
["status"]?["status"]) ==
|
|
1
|
|
? Color(0xFF929699)
|
|
: null),
|
|
_buildInfoRow(
|
|
'设备状态'.tr,
|
|
(deviceListController
|
|
.model.deviceList[index]
|
|
["status"]?["status"]) ==
|
|
1
|
|
? '已绑定'.tr
|
|
: '已绑定'.tr,
|
|
valueColor: (deviceListController
|
|
.model.deviceList[index]
|
|
["status"]?["status"]) ==
|
|
1
|
|
? Color(0xFF6BFDAC)
|
|
: Color(0xFF6BFDAC)),
|
|
].divide(SizedBox(height: 36.rpx)),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Align(
|
|
alignment: AlignmentDirectional(0, 0),
|
|
child: Container(
|
|
width: 150.rpx,
|
|
height: 90.rpx,
|
|
child: FFButtonWidget(
|
|
onPressed: () async {
|
|
try {
|
|
WebviewTestController webviewTestController =
|
|
Get.find();
|
|
webviewTestController.web.jsbridge?.dart
|
|
.switchLanguage(mhLanguageController
|
|
.selectLanguage.value!.language_code);
|
|
await checkBlueToothPermissin();
|
|
webviewTestController.web.jsbridge?.dart
|
|
.pageActive(false);
|
|
// await Future.delayed(Duration(seconds: 1));
|
|
webviewTestController.web.jsbridge?.dart
|
|
.appToHtmlDevice(device);
|
|
MainPageBBottomChange.jumpTo(2);
|
|
Get.until((route) =>
|
|
Get.currentRoute ==
|
|
"/mianPageBottomChange");
|
|
} catch (e) {
|
|
DailyLogUtils.writeError("发生异常: $e");
|
|
}
|
|
},
|
|
text: '控制'.tr,
|
|
options: FFButtonOptions(
|
|
color: Color(0XFF85F5FF),
|
|
textStyle: TextStyle(
|
|
fontFamily: 'Readex Pro',
|
|
color: Color(0xFF011D33),
|
|
fontSize: 28.rpx,
|
|
letterSpacing: 0,
|
|
),
|
|
elevation: 0,
|
|
borderSide: BorderSide(
|
|
color: Colors.transparent,
|
|
width: 1,
|
|
),
|
|
borderRadius: BorderRadius.circular(16.rpx),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Padding(
|
|
padding: EdgeInsetsDirectional.fromSTEB(0, 36.rpx, 0, 0),
|
|
child: Container(
|
|
width: MediaQuery.sizeOf(context).width,
|
|
height: 0.5.rpx,
|
|
decoration: BoxDecoration(
|
|
color: Color(0xFF929699),
|
|
),
|
|
),
|
|
),
|
|
Flexible(
|
|
child: Container(
|
|
margin: EdgeInsets.only(right: 26.rpx),
|
|
width: MediaQuery.sizeOf(context).width,
|
|
height: MediaQuery.sizeOf(context).height * 1,
|
|
constraints: BoxConstraints(
|
|
minHeight: 60,
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
InkWell(
|
|
onTap: () async {
|
|
if (device['bind_type'] == 1) {
|
|
await Get.toNamed("/deviceSharePage",
|
|
arguments: deviceListController
|
|
.model.deviceList[index]);
|
|
}
|
|
// if (device['type'] == 1) {
|
|
// globalController.model.deviceMain = device;
|
|
// await Get.toNamed("/deviceSharePage");
|
|
// globalController.getDeviceList();
|
|
// }
|
|
},
|
|
child: Container(
|
|
height: MediaQuery.sizeOf(context).height * 0.1,
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Align(
|
|
alignment: AlignmentDirectional(1, 0),
|
|
child: Container(
|
|
width: 42.rpx,
|
|
height: 42.rpx,
|
|
child: SvgPicture.asset(
|
|
'assets/images/group.svg',
|
|
color: Color(0xFF85F5FF),
|
|
),
|
|
)),
|
|
Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
if (device['bind_type'] == 1)
|
|
Text(
|
|
'已分享:'.tr,
|
|
style: TextStyle(
|
|
fontFamily: 'Readex Pro',
|
|
fontSize: 21.rpx,
|
|
letterSpacing: 0,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
if (device['bind_type'] == 1)
|
|
Padding(
|
|
padding:
|
|
EdgeInsetsDirectional.fromSTEB(
|
|
5, 0, 5, 0),
|
|
child: Text(
|
|
(deviceListController.model
|
|
.deviceList[index]
|
|
['shareNum'] ??
|
|
0)
|
|
.toString(),
|
|
style: TextStyle(
|
|
fontFamily: 'Readex Pro',
|
|
color: Color(0xFF85F5FF),
|
|
fontSize: 21.rpx,
|
|
letterSpacing: 0,
|
|
),
|
|
),
|
|
),
|
|
if (device['bind_type'] == 1)
|
|
Text(
|
|
'人'.tr,
|
|
style: TextStyle(
|
|
fontFamily: 'Readex Pro',
|
|
fontSize: 21.rpx,
|
|
letterSpacing: 0,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
if (device['bind_type'] == 2)
|
|
Text(
|
|
'来自'.tr,
|
|
style: TextStyle(
|
|
fontFamily: 'Readex Pro',
|
|
fontSize: 21.rpx,
|
|
letterSpacing: 0,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
if (device['bind_type'] == 2)
|
|
Padding(
|
|
padding:
|
|
EdgeInsetsDirectional.fromSTEB(
|
|
5, 0, 5, 0),
|
|
child: Text(
|
|
'${device['source']?.length > 5 ? device['source'].substring(0, 5) + '...' : device['source']}',
|
|
style: TextStyle(
|
|
fontFamily: 'Readex Pro',
|
|
color: Color(0xFF85F5FF),
|
|
fontSize: 21.rpx,
|
|
letterSpacing: 0,
|
|
),
|
|
),
|
|
),
|
|
if (device['bind_type'] == 2)
|
|
Text(
|
|
'的分享'.tr,
|
|
style: TextStyle(
|
|
fontFamily: 'Readex Pro',
|
|
fontSize: 21.rpx,
|
|
letterSpacing: 0,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
].divide(SizedBox(width: 6)),
|
|
),
|
|
),
|
|
),
|
|
InkWell(
|
|
onTap: () {
|
|
// TopSlideNotification.show(
|
|
// context,
|
|
// text: "功能开发中...",
|
|
// );
|
|
// var a = [device["bindMacA"]];
|
|
// if ("${device["bindMacB"]}".length > 6) {
|
|
// a.add(device["bindMacB"]);
|
|
// }
|
|
// Get.toNamed("/sleepWebview", arguments: a);
|
|
Get.toNamed("/mhtSleepReportReturnPage",
|
|
arguments: device);
|
|
},
|
|
child: Container(
|
|
height: MediaQuery.sizeOf(context).height * 0.1,
|
|
constraints: BoxConstraints(
|
|
minHeight: 25,
|
|
),
|
|
alignment: Alignment.center,
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment:
|
|
MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Align(
|
|
alignment: AlignmentDirectional(0, 0),
|
|
child: SvgPicture.asset(
|
|
"assets/images/table.svg",
|
|
width: 24.rpx,
|
|
height: 24.rpx,
|
|
color: Color(0xFF85F5FF),
|
|
),
|
|
),
|
|
SizedBox(width: 5),
|
|
Text(
|
|
'睡眠报告'.tr,
|
|
style: TextStyle(
|
|
fontFamily: 'Readex Pro',
|
|
color: Colors.white,
|
|
fontSize: 21.rpx,
|
|
letterSpacing: 0,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildInfoRow(String label, String value, {Color? valueColor}) {
|
|
return Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Container(
|
|
constraints: BoxConstraints(
|
|
minWidth: 140.rpx, // 最小宽度
|
|
),
|
|
alignment: Alignment.centerLeft,
|
|
child: Text(
|
|
'$label ',
|
|
style: TextStyle(
|
|
color: Color(0XFF929699), fontSize: 26.rpx, height: 1),
|
|
),
|
|
),
|
|
Flexible(
|
|
child: Text(
|
|
value,
|
|
style: TextStyle(
|
|
color: valueColor ?? Colors.white, fontSize: 26.rpx, height: 1),
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
getNameByType(device) {
|
|
if (device['device_type'] == null) {
|
|
return '未知类型设备'.tr;
|
|
}
|
|
if (device['device_type'] == 2) {
|
|
return '智能电动床'.tr;
|
|
}
|
|
if (device['device_type'] == 3) {
|
|
return '律动智能床垫'.tr;
|
|
}
|
|
}
|