更新安卓通知栏提示
This commit is contained in:
@@ -40,14 +40,6 @@ class _InstantBodyPageState extends State<InstantBodyPage>
|
||||
DeviceTypeController deviceTypeController = Get.find();
|
||||
|
||||
int maxBodyMotion = 1;
|
||||
// String breathState = "否";
|
||||
// String inBed = "离床".tr;
|
||||
// String onlineState = "离线".tr;
|
||||
// Timer? _onlineTimer; // 添加 Timer 引用
|
||||
// int bodyMotion = 0;
|
||||
// int breathrate = 0;
|
||||
// String snores = "否".tr;
|
||||
// int heartrate = 0;
|
||||
String breathState = "-";
|
||||
String inBed = "-";
|
||||
String onlineState = "离线".tr;
|
||||
@@ -71,9 +63,22 @@ class _InstantBodyPageState extends State<InstantBodyPage>
|
||||
|
||||
void _initWebSocket() {
|
||||
// 发送WebSocket请求
|
||||
if (widget.personInfo['status'] != null) {
|
||||
try {
|
||||
onlineState =
|
||||
widget.personInfo['status']['status'] == 1 ? "在线".tr : "离线".tr;
|
||||
if (widget.personInfo['status']['status'] != 0) {
|
||||
inBed = widget.personInfo['status']['inBed'] == 1 ? "在床".tr : "离床".tr;
|
||||
}
|
||||
} catch (e) {
|
||||
edm.EasyDartModule.logger
|
||||
.error("[webscoekt]格式化数据错误-->${{"mac": widget.personInfo['mac']}}");
|
||||
}
|
||||
}
|
||||
edm.EasyDartModule.logger
|
||||
.info("[webscoekt]发送请求:数据-->${{"mac": widget.personInfo['mac']}}");
|
||||
DailyLogUtils.writeLog("[webscoekt]发送请求:数据-->${{"mac": widget.personInfo['mac']}}");
|
||||
DailyLogUtils.writeLog(
|
||||
"[webscoekt]发送请求:数据-->${{"mac": widget.personInfo['mac']}}");
|
||||
edm.EasyDartModule.websocket.sendData(jsonEncode(WebSocketMessage(
|
||||
path: "/vsbs/web/rt/marttress",
|
||||
type: 1,
|
||||
@@ -105,10 +110,10 @@ class _InstantBodyPageState extends State<InstantBodyPage>
|
||||
|
||||
void _startOnlineTimer() {
|
||||
_onlineTimer?.cancel(); // 取消之前的定时器
|
||||
_onlineTimer = Timer.periodic(Duration(seconds: 30), (timer) {
|
||||
_onlineTimer = Timer.periodic(Duration(seconds: 60), (timer) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
edm.EasyDartModule.logger.info("30 秒内没有接收到数据,设置为离线");
|
||||
edm.EasyDartModule.logger.info("60 秒内没有接收到数据,设置为离线");
|
||||
onlineState = "离线".tr; // 30 秒内没有接收到数据,设置为离线
|
||||
inBed = "-";
|
||||
bodyMotion = -1;
|
||||
@@ -124,35 +129,50 @@ class _InstantBodyPageState extends State<InstantBodyPage>
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Map device = widget.personInfo;
|
||||
CommonVariables.callMap["/vsbs/web/rt/marttress"] = (data) {
|
||||
inBed = data["inBed"];
|
||||
// 心率 呼吸 体动 呼吸暂停
|
||||
if ("离床".tr == inBed) {
|
||||
breathState = "否".tr;
|
||||
bodyMotion = 0;
|
||||
breathrate = 0;
|
||||
heartrate = 0;
|
||||
snores = "否".tr;
|
||||
} else {
|
||||
breathState = data["breathState"] == null || data["breathState"] == ""
|
||||
? "-"
|
||||
: data["breathState"].toString().tr;
|
||||
|
||||
bodyMotion = data['bodyMotion'] == null ? 0 : data['bodyMotion'];
|
||||
breathrate = data["breathRate"] == null ? 0 : data["breathRate"];
|
||||
heartrate = data['heartRate'] == null ? 0 : data['heartRate'];
|
||||
snores = data['snores'] == null || data['snores'] == ""
|
||||
? "否".tr
|
||||
: data['snores'].tr;
|
||||
}
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
try {
|
||||
CommonVariables.callMap["/vsbs/web/rt/marttress"] = (data) {
|
||||
if (data['status'] == "离线") {
|
||||
inBed = "-";
|
||||
bodyMotion = -1;
|
||||
heartrate = -1;
|
||||
snores = "-";
|
||||
breathrate = -1;
|
||||
breathState = "-";
|
||||
return;
|
||||
}
|
||||
inBed = data["inBed"];
|
||||
// 心率 呼吸 体动 呼吸暂停
|
||||
if ("离床".tr == inBed) {
|
||||
breathState = "否".tr;
|
||||
bodyMotion = 0;
|
||||
breathrate = 0;
|
||||
heartrate = 0;
|
||||
snores = "否".tr;
|
||||
} else {
|
||||
onlineState = "在线".tr; // 接收到数据,设置为在线
|
||||
});
|
||||
}
|
||||
_startOnlineTimer(); // 重置定时器
|
||||
};
|
||||
breathState = data["breathState"] == null || data["breathState"] == ""
|
||||
? "-"
|
||||
: data["breathState"].toString().tr;
|
||||
|
||||
bodyMotion = data['bodyMotion'] == null ? -1 : data['bodyMotion'];
|
||||
breathrate = data["breathRate"] == null ? -1 : data["breathRate"];
|
||||
heartrate = data['heartRate'] == null ? -1 : data['heartRate'];
|
||||
snores =
|
||||
data['snores'] == null || data['snores'] == "" ? "否".tr : "是".tr;
|
||||
}
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
onlineState = "在线".tr; // 接收到数据,设置为在线
|
||||
});
|
||||
}
|
||||
_startOnlineTimer(); // 重置定时器
|
||||
};
|
||||
} catch (e) {
|
||||
print(e);
|
||||
edm.EasyDartModule.logger
|
||||
.error("[webscoekt]格式化数据错误-->${{"mac": widget.personInfo['mac']}}");
|
||||
}
|
||||
|
||||
return LayoutBuilder(
|
||||
builder: (context, bodySize) => GestureDetector(
|
||||
@@ -215,20 +235,6 @@ class _InstantBodyPageState extends State<InstantBodyPage>
|
||||
top: true,
|
||||
child: Stack(
|
||||
children: [
|
||||
// 背景图只占一半高度
|
||||
// Align(
|
||||
// alignment: Alignment.center,
|
||||
// child: SizedBox(
|
||||
// height: 1000.rpx, // 你可以根据需要调整图片最大高度
|
||||
// width: 1000.rpx, // 或设置 double.infinity 占满宽度
|
||||
// child: Image.asset(
|
||||
// (onlineState == "离线".tr || inBed == '离床'.tr)
|
||||
// ? 'assets/img/black_body_still.png'
|
||||
// : 'assets/img/body_black.gif',
|
||||
// fit: BoxFit.contain, // 保持原始比例,不拉伸
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: FractionallySizedBox(
|
||||
@@ -435,16 +441,6 @@ class _InstantBodyPageState extends State<InstantBodyPage>
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
30.rpx, 0, 30.rpx, 0),
|
||||
child: Container(
|
||||
// decoration: BoxDecoration(
|
||||
// image: DecorationImage(
|
||||
// image: AssetImage(
|
||||
// onlineState == "离线".tr
|
||||
// ? 'assets/img/black_body_still.png' // 静态图
|
||||
// : 'assets/img/body_black.gif', // 动图
|
||||
// ),
|
||||
// fit: BoxFit.cover,
|
||||
// ),
|
||||
// ),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
|
||||
Reference in New Issue
Block a user