更新
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
@@ -26,6 +28,7 @@ class _BodyDevicePageState extends State<BodyDeviceWidget> {
|
||||
final BodyDeviceController bodyDeviceController = Get.find();
|
||||
final GlobalKey addIconKey = GlobalKey();
|
||||
OverlayEntry? _popupEntry;
|
||||
Timer? _timer;
|
||||
|
||||
void _showPopup() {
|
||||
final renderBox =
|
||||
@@ -95,7 +98,7 @@ class _BodyDevicePageState extends State<BodyDeviceWidget> {
|
||||
width: double.infinity,
|
||||
child: Center(
|
||||
child: Text(
|
||||
'扫一扫'.tr,
|
||||
'扫一扫.标题'.tr,
|
||||
style: TextStyle(
|
||||
fontSize: AppConstants().normal_text_fontSize,
|
||||
color: themeController.currentColor.sc3,
|
||||
@@ -119,7 +122,7 @@ class _BodyDevicePageState extends State<BodyDeviceWidget> {
|
||||
width: double.infinity,
|
||||
child: Center(
|
||||
child: Text(
|
||||
'蓝牙绑定'.tr,
|
||||
'蓝牙绑定.标题'.tr,
|
||||
style: TextStyle(
|
||||
fontSize: AppConstants().normal_text_fontSize,
|
||||
color: themeController.currentColor.sc3,
|
||||
@@ -151,6 +154,16 @@ class _BodyDevicePageState extends State<BodyDeviceWidget> {
|
||||
void initState() {
|
||||
bodyDeviceController.keyWord.value = "";
|
||||
super.initState();
|
||||
// 初次请求一次
|
||||
_fetchDeviceList();
|
||||
|
||||
// 每 5 秒定时请求一次
|
||||
_timer = Timer.periodic(Duration(seconds: 5), (timer) {
|
||||
_fetchDeviceList();
|
||||
});
|
||||
}
|
||||
|
||||
void _fetchDeviceList() {
|
||||
bodyDeviceController.getDeviceList().then((apiResponse) {
|
||||
if (apiResponse.code != HttpStatusCodes.ok) {
|
||||
TopSlideNotification.show(
|
||||
@@ -162,6 +175,12 @@ class _BodyDevicePageState extends State<BodyDeviceWidget> {
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_timer?.cancel(); // 页面销毁时取消定时器
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
@@ -265,127 +284,6 @@ class _BodyDevicePageState extends State<BodyDeviceWidget> {
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
// Row(
|
||||
// mainAxisSize: MainAxisSize.max,
|
||||
// children: [
|
||||
// Obx(() {
|
||||
// return ClickableContainer(
|
||||
// backgroundColor:
|
||||
// Colors.transparent, // 或者你想设置的背景色
|
||||
// highlightColor: themeController
|
||||
// .currentColor.sc3, // 点击涟漪颜色
|
||||
// borderRadius: 8.rpx, // 自定义圆角
|
||||
// padding: EdgeInsets.all(
|
||||
// 0), // 外部已经排版,这里不用加内边距
|
||||
// onTap: () async {
|
||||
// // 点击事件处理逻辑
|
||||
// bodyDeviceController.model.type = 1;
|
||||
// await bodyDeviceController
|
||||
// .getDeviceList();
|
||||
// bodyDeviceController.updateAll();
|
||||
// },
|
||||
// child: Column(
|
||||
// mainAxisSize: MainAxisSize.max,
|
||||
// children: [
|
||||
// Text(
|
||||
// '体征检测设备.我的e护'.tr,
|
||||
// style:
|
||||
// FlutterFlowTheme.of(context)
|
||||
// .bodyMedium
|
||||
// .override(
|
||||
// fontFamily: 'Inter',
|
||||
// fontSize: AppConstants()
|
||||
// .title_text_fontSize,
|
||||
// letterSpacing: 0.0,
|
||||
// color:
|
||||
// bodyDeviceController
|
||||
// .model
|
||||
// .type ==
|
||||
// 2
|
||||
// ? themeController
|
||||
// .currentColor
|
||||
// .sc3
|
||||
// : themeController
|
||||
// .currentColor
|
||||
// .sc2,
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(
|
||||
// width: 100.rpx,
|
||||
// child: Divider(
|
||||
// height: 1.rpx,
|
||||
// thickness: 2.rpx,
|
||||
// color: bodyDeviceController
|
||||
// .model.type ==
|
||||
// 2
|
||||
// ? Colors.transparent
|
||||
// : themeController
|
||||
// .currentColor.sc2,
|
||||
// ),
|
||||
// ),
|
||||
// ].divide(SizedBox(height: 10.rpx)),
|
||||
// ),
|
||||
// );
|
||||
// }),
|
||||
// Obx(() {
|
||||
// return ClickableContainer(
|
||||
// backgroundColor: Colors.transparent,
|
||||
// highlightColor:
|
||||
// themeController.currentColor.sc3,
|
||||
// borderRadius: 8.rpx,
|
||||
// padding: EdgeInsets.all(0),
|
||||
// onTap: () async {
|
||||
// // 这里写你的点击逻辑
|
||||
// bodyDeviceController.model.type = 2;
|
||||
// await bodyDeviceController
|
||||
// .getDeviceList();
|
||||
// bodyDeviceController.updateAll();
|
||||
// },
|
||||
// child: Column(
|
||||
// mainAxisSize: MainAxisSize.max,
|
||||
// children: [
|
||||
// Text(
|
||||
// '体征检测设备.云关爱'.tr,
|
||||
// style:
|
||||
// FlutterFlowTheme.of(context)
|
||||
// .bodyMedium
|
||||
// .override(
|
||||
// fontFamily: 'Inter',
|
||||
// fontSize: 30.rpx,
|
||||
// letterSpacing: 0.0,
|
||||
// color:
|
||||
// bodyDeviceController
|
||||
// .model
|
||||
// .type ==
|
||||
// 1
|
||||
// ? themeController
|
||||
// .currentColor
|
||||
// .sc3
|
||||
// : themeController
|
||||
// .currentColor
|
||||
// .sc2,
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(
|
||||
// width: 100.rpx,
|
||||
// child: Divider(
|
||||
// height: 1.rpx,
|
||||
// thickness: 2.rpx,
|
||||
// color: bodyDeviceController
|
||||
// .model.type ==
|
||||
// 1
|
||||
// ? Colors.transparent
|
||||
// : themeController
|
||||
// .currentColor.sc2,
|
||||
// ),
|
||||
// ),
|
||||
// ].divide(SizedBox(height: 10.rpx)),
|
||||
// ),
|
||||
// );
|
||||
// }),
|
||||
// ].divide(SizedBox(width: 60.rpx)),
|
||||
// ),
|
||||
|
||||
Stack(
|
||||
alignment: Alignment.bottomLeft,
|
||||
children: [
|
||||
@@ -520,7 +418,6 @@ class _BodyDevicePageState extends State<BodyDeviceWidget> {
|
||||
}),
|
||||
],
|
||||
),
|
||||
|
||||
Container(
|
||||
width:
|
||||
MediaQuery.sizeOf(context).width * 0.38,
|
||||
@@ -661,20 +558,6 @@ class _BodyDevicePageState extends State<BodyDeviceWidget> {
|
||||
.currentColor.sc2,
|
||||
),
|
||||
),
|
||||
// Text(
|
||||
// '体征检测设备.搜索'.tr,
|
||||
// style:
|
||||
// FlutterFlowTheme.of(context)
|
||||
// .bodyMedium
|
||||
// .override(
|
||||
// fontFamily: 'Inter',
|
||||
// fontSize: AppConstants()
|
||||
// .normal_text_fontSize,
|
||||
// letterSpacing: 0.0,
|
||||
// color: themeController
|
||||
// .currentColor.sc2,
|
||||
// ),
|
||||
// ),
|
||||
ClickableContainer(
|
||||
backgroundColor:
|
||||
Colors.transparent,
|
||||
@@ -722,27 +605,26 @@ class _BodyDevicePageState extends State<BodyDeviceWidget> {
|
||||
Obx(() {
|
||||
final isEmpty =
|
||||
bodyDeviceController.deviceList.value.isEmpty;
|
||||
|
||||
return isEmpty
|
||||
? Expanded(
|
||||
child: NullDataWidget(),
|
||||
)
|
||||
: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
30.rpx, 26.rpx, 30.rpx, 0),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: bodyDeviceController
|
||||
.deviceList.value
|
||||
.map((device) =>
|
||||
DeviceDataComponentWidget(
|
||||
device: device))
|
||||
.toList()
|
||||
.divide(SizedBox(height: 25.rpx)),
|
||||
return Expanded(
|
||||
child: isEmpty
|
||||
? NullDataWidget()
|
||||
: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
30.rpx, 26.rpx, 30.rpx, 0),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: bodyDeviceController
|
||||
.deviceList.value
|
||||
.map((device) =>
|
||||
DeviceDataComponentWidget(
|
||||
device: device))
|
||||
.toList()
|
||||
.divide(SizedBox(height: 25.rpx)),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user