2024-08-30 17:57:33 +08:00
|
|
|
|
//实时数据卡片
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:get/get.dart';
|
2024-11-18 14:48:54 +08:00
|
|
|
|
import 'package:intl/intl.dart';
|
2024-08-30 17:57:33 +08:00
|
|
|
|
|
2024-11-06 17:23:29 +08:00
|
|
|
|
import 'real_controller.dart';
|
2024-08-30 17:57:33 +08:00
|
|
|
|
|
|
|
|
|
class RealDataShow extends StatelessWidget {
|
|
|
|
|
const RealDataShow({super.key});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final Size size = MediaQuery.of(context).size;
|
|
|
|
|
final Orientation orientation =
|
|
|
|
|
MediaQuery.of(context).orientation; // 获取屏幕方向
|
|
|
|
|
// var isDataVisible = true.obs;
|
|
|
|
|
final RealController controller1 = Get.find();
|
|
|
|
|
bool isDarkMode = Theme.of(context).brightness == Brightness.dark;
|
|
|
|
|
double width;
|
|
|
|
|
double height;
|
|
|
|
|
|
|
|
|
|
// 根据屏幕方向设置宽度和高度
|
|
|
|
|
if (orientation == Orientation.portrait) {
|
|
|
|
|
width = size.width / 5 * 2.4; // 纵向时的宽度
|
|
|
|
|
height = size.height / 5 * 2; // 纵向时的高度
|
|
|
|
|
} else {
|
|
|
|
|
width = size.width / 3.7; // 横向时的宽度
|
|
|
|
|
height = size.height / 1.5; // 横向时的高度
|
|
|
|
|
}
|
|
|
|
|
return Obx(() => Positioned(
|
|
|
|
|
left: controller1.sightOffset1.value.dx,
|
|
|
|
|
top: controller1.sightOffset1.value.dy,
|
|
|
|
|
width: width,
|
|
|
|
|
height: height,
|
|
|
|
|
child: GestureDetector(
|
|
|
|
|
onPanStart: (details) {
|
|
|
|
|
// 记录初始偏移量
|
|
|
|
|
controller1.sightInit1.value =
|
|
|
|
|
details.localPosition - controller1.sightOffset1.value;
|
|
|
|
|
},
|
|
|
|
|
onPanUpdate: (details) {
|
|
|
|
|
// 更新卡片的位置
|
|
|
|
|
controller1.sightOffset1.value =
|
|
|
|
|
details.localPosition - controller1.sightInit1.value;
|
|
|
|
|
},
|
|
|
|
|
child: Visibility(
|
|
|
|
|
visible: controller1.isDataVisible.value,
|
|
|
|
|
child: Container(
|
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
|
color: Color.fromARGB(0, 214, 133, 133)),
|
|
|
|
|
child: Card(
|
|
|
|
|
elevation: 5.0,
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
"实时数据",
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 19,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
color: isDarkMode
|
|
|
|
|
? Colors.white
|
|
|
|
|
: Colors.black),
|
|
|
|
|
),
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: const Icon(Icons.close),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
controller1.isDataVisible.value = false;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
2024-11-18 14:48:54 +08:00
|
|
|
|
Obx(() {
|
|
|
|
|
controller1.dataCount;
|
|
|
|
|
return Column(children: [
|
|
|
|
|
..._buildRealTimeDataList(context, controller1)
|
|
|
|
|
]);
|
|
|
|
|
})
|
2024-08-30 17:57:33 +08:00
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)))));
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-06 17:23:29 +08:00
|
|
|
|
// Widget _buildCard(BuildContext context, double width, double height) {
|
|
|
|
|
// final RealController controller1 = Get.find();
|
2024-08-30 17:57:33 +08:00
|
|
|
|
|
2024-11-06 17:23:29 +08:00
|
|
|
|
// return Container(
|
|
|
|
|
// decoration: const BoxDecoration(color: Color.fromARGB(0, 214, 133, 133)),
|
|
|
|
|
// child: Card(
|
|
|
|
|
// elevation: 5.0,
|
|
|
|
|
// child: Padding(
|
|
|
|
|
// padding: const EdgeInsets.all(8.0),
|
|
|
|
|
// child: Column(
|
|
|
|
|
// mainAxisSize: MainAxisSize.min,
|
|
|
|
|
// children: [
|
|
|
|
|
// Row(
|
|
|
|
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
// children: [
|
|
|
|
|
// const Text("实时数据"),
|
|
|
|
|
// IconButton(
|
|
|
|
|
// icon: const Icon(Icons.close),
|
|
|
|
|
// onPressed: () {
|
|
|
|
|
// controller1.isDataVisible.value = false;
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// ],
|
|
|
|
|
// ),
|
|
|
|
|
// ..._buildRealTimeDataList(context),
|
|
|
|
|
// ],
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
// );
|
|
|
|
|
// }
|
2024-08-30 17:57:33 +08:00
|
|
|
|
|
2024-11-18 14:48:54 +08:00
|
|
|
|
List<Widget> _buildRealTimeDataList(
|
|
|
|
|
BuildContext context, RealController controller) {
|
2024-08-30 17:57:33 +08:00
|
|
|
|
bool isDarkMode = Theme.of(context).brightness == Brightness.dark;
|
|
|
|
|
|
|
|
|
|
// final orientation = MediaQuery.of(context).orientation;
|
|
|
|
|
// bool isPortrait = Orientation.portrait == orientation ? true : false;
|
|
|
|
|
// 创建数据项列表
|
2024-11-15 17:42:52 +08:00
|
|
|
|
// pile_cm
|
|
|
|
|
// List<DataItem> dataItems = [
|
|
|
|
|
// DataItem(
|
|
|
|
|
// "速度(m/min):",
|
|
|
|
|
// () => realController.speed.abs() >= 100
|
|
|
|
|
// ? realController.speed.toStringAsFixed(1)
|
|
|
|
|
// : realController.speed.toStringAsFixed(2)),
|
|
|
|
|
// DataItem("时间(min:s):", () => realController.time.value),
|
|
|
|
|
// DataItem("深度(m):", () => realController.depth.toStringAsFixed(2)),
|
|
|
|
|
// DataItem("1#瞬时流量(L/min):",
|
|
|
|
|
// () => realController.subtotalFlow1.toStringAsFixed(2)),
|
|
|
|
|
// DataItem("2#瞬时流量(L/min):",
|
|
|
|
|
// () => realController.subtotalFlow2.toStringAsFixed(2)),
|
|
|
|
|
// DataItem(
|
|
|
|
|
// "1#累计流量(L):", () => realController.totalFlow1.toStringAsFixed(2)),
|
|
|
|
|
// DataItem(
|
|
|
|
|
// "2#累计流量(L):", () => realController.totalFlow2.toStringAsFixed(2)),
|
|
|
|
|
// ];
|
|
|
|
|
// hydraulic_tamping
|
2024-08-30 17:57:33 +08:00
|
|
|
|
List<DataItem> dataItems = [
|
2024-11-18 14:48:54 +08:00
|
|
|
|
DataItem(
|
|
|
|
|
"时间(min:s):",
|
|
|
|
|
() => DateFormat('HH:mm:ss').format(
|
|
|
|
|
DateTime.fromMillisecondsSinceEpoch(
|
|
|
|
|
controller.processdata.value.utc * 1000))),
|
2024-11-15 17:42:52 +08:00
|
|
|
|
// DataItem("夯击次数:", () => realController.times.value)
|
2024-08-30 17:57:33 +08:00
|
|
|
|
];
|
|
|
|
|
// 返回数据项的列表
|
|
|
|
|
return dataItems.map((item) {
|
|
|
|
|
return Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(item.title,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 13,
|
|
|
|
|
color: isDarkMode ? Colors.white : Colors.black,
|
|
|
|
|
)),
|
2024-11-18 14:48:54 +08:00
|
|
|
|
Text(item.value(),
|
2024-08-30 17:57:33 +08:00
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 18,
|
|
|
|
|
color: isDarkMode ? Colors.white : Colors.black,
|
2024-11-18 14:48:54 +08:00
|
|
|
|
)),
|
2024-08-30 17:57:33 +08:00
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}).toList();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class DataItem {
|
|
|
|
|
final String title;
|
|
|
|
|
final String Function() value;
|
|
|
|
|
|
|
|
|
|
DataItem(this.title, this.value);
|
|
|
|
|
}
|