1优化改动设备栏中全部标签栏的设备列表中数据的整合,又数据合并解耦成使用已有组件各自维护,使其样式和逻辑一致。
2接入了无人机机场的实时信息和无人机的实时信息,并创建了对应的组件,并测试。 3.实现了机器人的详情页的视频显示的逻辑为当机器人在线,就在下方同步出来机器人的各个方位视频,并且支持切换。 4.实现了全部设备中对类型的区分和实现了点击进入对应的详情页。 5.修复了部分bug,优化了代码结构,提高了代码的可读性和可维护性。 6更改了机器人列表项中的信息展示为机器序列号和别名和id(优先展示别名) 7.更改了无人机场的信息展示上位 无人机及序列号下位机场序列号。 8优化了无人机机场信息只能是的为明文展示。便于观看理解。
This commit is contained in:
@@ -13,9 +13,15 @@ import 'package:maibu_satabot_v2/features/devices/presentation/bloc/device_statu
|
||||
import '../bloc/drone_station_bloc.dart';
|
||||
import '../bloc/drone_station_event.dart';
|
||||
import '../bloc/drone_station_state.dart';
|
||||
import '../bloc/robot_list_bloc.dart'; // 🔥 添加 RobotListBloc 导入
|
||||
import '../bloc/robot_list_event.dart'; // 🔥 添加 RobotListEvent 导入
|
||||
import '../bloc/robot_list_state.dart'; // 🔥 添加 RobotListState 导入
|
||||
import '../widgets/device_item_widget.dart';
|
||||
import '../widgets/drone_station_item_card.dart';
|
||||
import '../widgets/robot_item_card.dart'; // 🔥 添加 RobotItemCard 导入
|
||||
import '../../domain/entities/drone_station_entity.dart'; // 🔥 添加 DroneStationEntity 导入
|
||||
import 'robot_list_page.dart';
|
||||
import 'robot_control_page.dart';
|
||||
import 'drone_station_detail_page.dart';
|
||||
import '../../../../remote_control/presentation/bloc/remote_control_cubit.dart';
|
||||
|
||||
@@ -51,35 +57,36 @@ class DeviceStatusView extends StatelessWidget {
|
||||
child: Scaffold(
|
||||
backgroundColor: const Color(0xFFF7F7F7),
|
||||
body: SafeArea(
|
||||
child: BlocConsumer<
|
||||
DeviceListBloc.DeviceStatusBloc,
|
||||
DeviceListState.DeviceStatusState
|
||||
>(
|
||||
listener: (context, state) {
|
||||
// 🔥 监听错误状态,显示友好提示
|
||||
if (state is DeviceListState.DeviceStatusError &&
|
||||
state.shouldShowError) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(state.message),
|
||||
duration: const Duration(seconds: 2),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
backgroundColor: Colors.orange,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
return Column(
|
||||
children: [
|
||||
_buildAppBar(context),
|
||||
_buildSearchBar(context),
|
||||
_buildTypeFilterBar(context),
|
||||
Expanded(child: _buildContent(context, state)),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
child:
|
||||
BlocConsumer<
|
||||
DeviceListBloc.DeviceStatusBloc,
|
||||
DeviceListState.DeviceStatusState
|
||||
>(
|
||||
listener: (context, state) {
|
||||
// 🔥 监听错误状态,显示友好提示
|
||||
if (state is DeviceListState.DeviceStatusError &&
|
||||
state.shouldShowError) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(state.message),
|
||||
duration: const Duration(seconds: 2),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
backgroundColor: Colors.orange,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
return Column(
|
||||
children: [
|
||||
_buildAppBar(context),
|
||||
_buildSearchBar(context),
|
||||
_buildTypeFilterBar(context),
|
||||
Expanded(child: _buildContent(context, state)),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -317,25 +324,11 @@ class DeviceStatusView extends StatelessWidget {
|
||||
children: [
|
||||
_buildStatusCard(state),
|
||||
const SizedBox(height: 20.0),
|
||||
ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
itemCount: filteredDevices.length,
|
||||
itemBuilder: (context, index) {
|
||||
final device = filteredDevices[index];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
child: DeviceItemWidget(
|
||||
device: device,
|
||||
onTap: () {
|
||||
debugPrint('点击设备: ${device.name}');
|
||||
// TODO: 导航到设备详情页
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
// 🔥 机器人列表(直接复用 RobotListPage 的布局)
|
||||
if (state.selectedType == '全部') _buildEmbeddedRobotList(context),
|
||||
// 🔥 无人机机场列表(直接复用 _buildDroneStationList 的布局)
|
||||
if (state.selectedType == '全部')
|
||||
_buildDroneStationList(context, embedded: true),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -344,7 +337,87 @@ class DeviceStatusView extends StatelessWidget {
|
||||
return const Center(child: Text('暂无数据'));
|
||||
}
|
||||
|
||||
Widget _buildDroneStationList(BuildContext context) {
|
||||
/// 🔥 嵌入式机器人列表(直接复用 RobotListPage 的布局)
|
||||
Widget _buildEmbeddedRobotList(BuildContext context) {
|
||||
final selectedSite = sl<SiteCubit>().state.selectedSite;
|
||||
final siteId = selectedSite?.id;
|
||||
|
||||
debugPrint('🔍 [EmbeddedRobotList] 开始加载机器人数据, siteId: $siteId');
|
||||
|
||||
return BlocProvider(
|
||||
create: (_) =>
|
||||
sl<RobotListBloc>()..add(RobotListLoadData(siteId: siteId)),
|
||||
child: BlocConsumer<RobotListBloc, RobotListState>(
|
||||
listener: (context, state) {
|
||||
if (state is RobotListError && state.shouldShowError) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(state.message),
|
||||
duration: const Duration(seconds: 2),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
backgroundColor: Colors.orange,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
debugPrint('🔍 [EmbeddedRobotList] 当前状态: ${state.runtimeType}');
|
||||
|
||||
if (state is RobotListLoading) {
|
||||
return const Padding(
|
||||
padding: EdgeInsets.all(32),
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(color: Color(0xFF165DFF)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (state is RobotListLoaded) {
|
||||
debugPrint(
|
||||
'✅ [EmbeddedRobotList] 加载成功,机器人数量: ${state.robots.length}',
|
||||
);
|
||||
|
||||
// 🔥 直接复用 RobotListPage 的布局结构(不显示标题)
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
...state.robots.map((robot) {
|
||||
debugPrint(
|
||||
'📍 [EmbeddedRobotList] 机器人 - name: ${robot.name}, id: ${robot.id}',
|
||||
);
|
||||
return RobotItemCard(
|
||||
name: robot.name,
|
||||
id: robot.id,
|
||||
type: robot.type,
|
||||
status: robot.status,
|
||||
battery: robot.battery,
|
||||
task: robot.task,
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
RobotControlPage(robot: robot.toJson()),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
if (state is RobotListError) {
|
||||
debugPrint('❌ [EmbeddedRobotList] 加载失败: ${state.message}');
|
||||
}
|
||||
|
||||
return const SizedBox.shrink();
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDroneStationList(BuildContext context, {bool embedded = false}) {
|
||||
// 从全局 SiteCubit 获取选中的场站 ID
|
||||
final selectedSite = sl<SiteCubit>().state.selectedSite;
|
||||
|
||||
@@ -414,6 +487,10 @@ class DeviceStatusView extends StatelessWidget {
|
||||
},
|
||||
color: const Color(0xFF165DFF),
|
||||
child: ListView.builder(
|
||||
shrinkWrap: embedded,
|
||||
physics: embedded
|
||||
? const NeverScrollableScrollPhysics()
|
||||
: const AlwaysScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.only(top: 16, bottom: 16),
|
||||
itemCount: stations.length,
|
||||
itemBuilder: (context, index) {
|
||||
@@ -557,4 +634,153 @@ class DeviceStatusView extends StatelessWidget {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// 🔥 根据设备类型导航到不同的详情页
|
||||
void _navigateToDeviceDetail(BuildContext context, dynamic device) {
|
||||
final deviceName = device.name ?? '';
|
||||
final deviceId = device.deviceId ?? '';
|
||||
final deviceType = device.type ?? ''; // 🔥 使用接口返回的设备类型字段
|
||||
|
||||
debugPrint('🔍 [DeviceStatusPage] 设备名称: $deviceName');
|
||||
debugPrint('🔍 [DeviceStatusPage] 设备ID: $deviceId');
|
||||
debugPrint('🔍 [DeviceStatusPage] 设备类型: $deviceType');
|
||||
|
||||
// 🔥 判断是否为机器人(根据设备类型前缀)
|
||||
final robotPrefixes = [
|
||||
'RCHETD-CN',
|
||||
'MC700PLUS-CN',
|
||||
'MC700-CN',
|
||||
'MC700PRO-CN',
|
||||
'RCETD-CN',
|
||||
'MC700AIR-CN',
|
||||
];
|
||||
bool isRobot = robotPrefixes.any((prefix) => deviceType.startsWith(prefix));
|
||||
|
||||
// 🔥 判断是否为无人机机场(根据设备类型包含关键字)
|
||||
final droneStationKeywords = [
|
||||
'DJI Dock3',
|
||||
'DOCK3',
|
||||
'DOCK-2',
|
||||
'采集车',
|
||||
'机场',
|
||||
'无人机机场',
|
||||
];
|
||||
bool isDroneStation = droneStationKeywords.any(
|
||||
(keyword) => deviceType.contains(keyword),
|
||||
);
|
||||
|
||||
// 🔥 兜底逻辑:如果 type 字段是"未知设备"或空,则使用设备名称进行二次判断
|
||||
if (!isRobot &&
|
||||
!isDroneStation &&
|
||||
(deviceType.isEmpty || deviceType == '未知设备' || deviceType == '未知类型')) {
|
||||
debugPrint('⚠️ [DeviceStatusPage] type 字段无效,使用设备名称进行二次判断');
|
||||
|
||||
// 检查每个机器人前缀是否匹配
|
||||
for (final prefix in robotPrefixes) {
|
||||
final nameMatch = deviceName.startsWith(prefix);
|
||||
final idMatch = deviceId.startsWith(prefix);
|
||||
if (nameMatch || idMatch) {
|
||||
debugPrint(
|
||||
'🔍 [DeviceStatusPage] 机器人前缀匹配: "$prefix" -> 名称匹配=$nameMatch, ID匹配=$idMatch',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 根据设备名称前缀判断机器人
|
||||
isRobot = robotPrefixes.any(
|
||||
(prefix) =>
|
||||
deviceName.startsWith(prefix) || deviceId.startsWith(prefix),
|
||||
);
|
||||
|
||||
// 检查每个无人机关键字是否匹配
|
||||
for (final keyword in droneStationKeywords) {
|
||||
if (deviceName.contains(keyword)) {
|
||||
debugPrint('🔍 [DeviceStatusPage] 无人机关键字匹配: "$keyword"');
|
||||
}
|
||||
}
|
||||
|
||||
// 根据设备名称包含关键字判断无人机机场
|
||||
isDroneStation = droneStationKeywords.any(
|
||||
(keyword) => deviceName.contains(keyword),
|
||||
);
|
||||
|
||||
// 🔥 重要:如果同时匹配机器人和无人机机场,优先判断为无人机机场
|
||||
if (isRobot && isDroneStation) {
|
||||
debugPrint('⚠️ [DeviceStatusPage] 同时匹配机器人和无人机机场,优先判断为无人机机场');
|
||||
isRobot = false;
|
||||
isDroneStation = true;
|
||||
}
|
||||
|
||||
debugPrint('🔍 [DeviceStatusPage] 二次判断 - 是否机器人: $isRobot');
|
||||
debugPrint('🔍 [DeviceStatusPage] 二次判断 - 是否无人机机场: $isDroneStation');
|
||||
}
|
||||
|
||||
debugPrint('🔍 [DeviceStatusPage] 最终判断 - 是否机器人: $isRobot');
|
||||
debugPrint('🔍 [DeviceStatusPage] 最终判断 - 是否无人机机场: $isDroneStation');
|
||||
|
||||
if (isRobot) {
|
||||
// 跳转到机器人控制页面
|
||||
debugPrint('🚀 [DeviceStatusPage] 跳转到机器人控制页面');
|
||||
final robotMap = {
|
||||
'name': deviceName,
|
||||
'id': deviceId,
|
||||
'type': deviceType,
|
||||
'status': device.status ?? '在线',
|
||||
'battery': 100.0, // DeviceEntity 没有 battery 字段,使用默认值
|
||||
'task': '待机中', // DeviceEntity 没有 task 字段,使用默认值
|
||||
};
|
||||
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => RobotControlPage(robot: robotMap),
|
||||
),
|
||||
);
|
||||
} else if (isDroneStation) {
|
||||
// 跳转到无人机机场详情页面
|
||||
debugPrint('🚀 [DeviceStatusPage] 跳转到无人机机场详情页面');
|
||||
|
||||
// 🔥 从 DroneStationBloc 中获取已加载的机场列表
|
||||
final droneStationBloc = sl<DroneStationBloc>();
|
||||
DroneStationEntity? matchedStation;
|
||||
|
||||
if (droneStationBloc.state is DroneStationLoaded) {
|
||||
final loadedState = droneStationBloc.state as DroneStationLoaded;
|
||||
// 根据 deviceId 或 deviceName 匹配
|
||||
for (final station in loadedState.stations) {
|
||||
if (station.gatewaySn == deviceId || station.callsign == deviceName) {
|
||||
matchedStation = station;
|
||||
debugPrint(
|
||||
'✅ 匹配到机场 - gatewaySn: ${station.gatewaySn}, deviceSn: ${station.deviceSn}',
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (matchedStation != null) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
DroneStationDetailPage(station: matchedStation!),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
debugPrint('⚠️ 未找到匹配的机场,请从无人机机场标签页进入');
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text('请从"无人机机场"标签页查看详情')));
|
||||
}
|
||||
} else {
|
||||
// 其他设备类型,显示提示
|
||||
debugPrint('⚠️ [DeviceStatusPage] 未知设备类型: $deviceType');
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('该设备类型暂不支持查看详情: $deviceType'),
|
||||
duration: const Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import '../../domain/entities/drone_station_entity.dart';
|
||||
import '../bloc/drone_station_bloc.dart';
|
||||
import '../bloc/drone_station_event.dart';
|
||||
import '../bloc/drone_station_state.dart';
|
||||
import '../widgets/drone_station_osd_card.dart'; // 🔥 添加机场 OSD 卡片
|
||||
import '../widgets/drone_osd_card.dart'; // 🔥 添加无人机 OSD 卡片
|
||||
import 'drone_video_control_page.dart';
|
||||
import 'drone_mission_control_page.dart';
|
||||
import 'drone_monitor_page.dart';
|
||||
@@ -27,8 +29,6 @@ class _DroneStationDetailPageState extends State<DroneStationDetailPage> {
|
||||
UAVDetailEntity? _detail;
|
||||
String? _droneSn;
|
||||
|
||||
|
||||
|
||||
// 无人机状态轮询计时器
|
||||
Timer? _droneStatusPollingTimer;
|
||||
|
||||
@@ -44,59 +44,59 @@ class _DroneStationDetailPageState extends State<DroneStationDetailPage> {
|
||||
);
|
||||
|
||||
// 启动无人机状态轮询(每5秒刷新一次)
|
||||
_startDroneStatusPolling();
|
||||
// 🔥 已禁用自动轮询,改为手动下拉刷新
|
||||
// _startDroneStatusPolling();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_bloc.close();
|
||||
_droneStatusPollingTimer?.cancel(); // 停止轮询
|
||||
// 🔥 已禁用自动轮询,无需停止
|
||||
// _droneStatusPollingTimer?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/// 启动无人机状态轮询
|
||||
/// 🔥 已禁用自动轮询功能
|
||||
void _startDroneStatusPolling() {
|
||||
_scheduleDroneStatusPoll();
|
||||
// _scheduleDroneStatusPoll();
|
||||
}
|
||||
|
||||
/// 根据无人机状态动态调整轮询周期
|
||||
/// 🔥 已禁用自动轮询功能
|
||||
void _scheduleDroneStatusPoll() {
|
||||
if (!mounted) return;
|
||||
|
||||
// 检查当前无人机状态
|
||||
Duration interval = const Duration(seconds: 60); // 默认60秒
|
||||
final currentState = _bloc.state;
|
||||
if (currentState is UAVDetailLoaded) {
|
||||
if (currentState.detail.droneOnlineStatus == 1) {
|
||||
// 无人机在线时,每30秒轮询一次
|
||||
interval = const Duration(seconds: 30);
|
||||
} else {
|
||||
// 无人机离线时,每60秒轮询一次(降低频率)
|
||||
interval = const Duration(seconds: 60);
|
||||
}
|
||||
}
|
||||
|
||||
_droneStatusPollingTimer?.cancel();
|
||||
_droneStatusPollingTimer = Timer(interval, () {
|
||||
if (!mounted) return;
|
||||
|
||||
debugPrint('🔄 定时刷新无人机状态...');
|
||||
_bloc.add(
|
||||
UAVDetailLoad(
|
||||
gatewaySn: widget.station.gatewaySn,
|
||||
deviceSn: widget.station.deviceSn,
|
||||
),
|
||||
);
|
||||
|
||||
// 重新调度下一次轮询(动态周期)
|
||||
_scheduleDroneStatusPoll();
|
||||
});
|
||||
// if (!mounted) return;
|
||||
//
|
||||
// // 检查当前无人机状态
|
||||
// Duration interval = const Duration(seconds: 60); // 默认60秒
|
||||
// final currentState = _bloc.state;
|
||||
// if (currentState is UAVDetailLoaded) {
|
||||
// if (currentState.detail.droneOnlineStatus == 1) {
|
||||
// // 无人机在线时,每30秒轮询一次
|
||||
// interval = const Duration(seconds: 30);
|
||||
// } else {
|
||||
// // 无人机离线时,每60秒轮询一次(降低频率)
|
||||
// interval = const Duration(seconds: 60);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// _droneStatusPollingTimer?.cancel();
|
||||
// _droneStatusPollingTimer = Timer(interval, () {
|
||||
// if (!mounted) return;
|
||||
//
|
||||
// debugPrint('🔄 定时刷新无人机状态...');
|
||||
// _bloc.add(
|
||||
// UAVDetailLoad(
|
||||
// gatewaySn: widget.station.gatewaySn,
|
||||
// deviceSn: widget.station.deviceSn,
|
||||
// ),
|
||||
// );
|
||||
//
|
||||
// // 重新调度下一次轮询(动态周期)
|
||||
// _scheduleDroneStatusPoll();
|
||||
// });
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider.value(
|
||||
@@ -182,22 +182,35 @@ class _DroneStationDetailPageState extends State<DroneStationDetailPage> {
|
||||
_detail = detail; // 保存详情数据供其他方法使用
|
||||
_droneSn = detail.deviceSn; // 保存无人机序列号
|
||||
return RefreshIndicator(
|
||||
onRefresh: _handleRefresh,
|
||||
color: const Color(0xFF165DFF),
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
_buildAirportStatusCard(detail),
|
||||
const SizedBox(height: 12),
|
||||
_buildMonitorCard(),
|
||||
const SizedBox(height: 12),
|
||||
_buildDroneStatusCard(detail),
|
||||
const SizedBox(height: 12),
|
||||
_buildQuickActions(),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
onRefresh: _handleRefresh,
|
||||
color: const Color(0xFF165DFF),
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
_buildAirportStatusCard(detail),
|
||||
const SizedBox(height: 12),
|
||||
// 🔥 添加机场 OSD 实时数据卡片
|
||||
DroneStationOsdCard(
|
||||
gatewaySn: widget.station.gatewaySn,
|
||||
isOnline: detail.isOnline,
|
||||
),
|
||||
);
|
||||
const SizedBox(height: 12),
|
||||
// 🔥 添加无人机 OSD 实时数据卡片(无人机在线时显示)
|
||||
DroneOsdCard(
|
||||
deviceSn: widget.station.deviceSn,
|
||||
gatewaySn: widget.station.gatewaySn,
|
||||
isDroneOnline: detail.isDroneOnline,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildMonitorCard(),
|
||||
const SizedBox(height: 12),
|
||||
_buildDroneStatusCard(detail),
|
||||
const SizedBox(height: 12),
|
||||
_buildQuickActions(),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 处理下拉刷新
|
||||
@@ -210,7 +223,8 @@ class _DroneStationDetailPageState extends State<DroneStationDetailPage> {
|
||||
),
|
||||
);
|
||||
// 重置轮询计时器,使用新的状态
|
||||
_scheduleDroneStatusPoll();
|
||||
// 🔥 已禁用自动轮询,无需重置
|
||||
// _scheduleDroneStatusPoll();
|
||||
}
|
||||
|
||||
Widget _buildMonitorCard() {
|
||||
@@ -348,7 +362,7 @@ class _DroneStationDetailPageState extends State<DroneStationDetailPage> {
|
||||
'风速',
|
||||
detail.windSpeed != null ? '${detail.windSpeed} m/s' : '未知',
|
||||
),
|
||||
_buildInfoRow('降雨量', detail.rainfall ?? '未知'),
|
||||
_buildInfoRow('降雨量', _formatRainfall(detail.rainfall)),
|
||||
_buildInfoRow('网络状态', detail.networkState?.toString() ?? '未知'),
|
||||
_buildPositionStateRow('位置状态', detail.positionState),
|
||||
],
|
||||
@@ -356,6 +370,37 @@ class _DroneStationDetailPageState extends State<DroneStationDetailPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPositionStateRow(String label, PositionState? positionState) {
|
||||
String value = '未知';
|
||||
if (positionState != null) {
|
||||
final fixedStatus = positionState.isFixed == 'fixing_successful'
|
||||
? '已固定'
|
||||
: '未固定';
|
||||
value =
|
||||
'GPS:${positionState.gpsNumber} RTX:${positionState.rtkNumber} 固定:$fixedStatus';
|
||||
}
|
||||
return Row(
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(fontSize: 13, color: Color(0xFF86909C)),
|
||||
),
|
||||
const Spacer(),
|
||||
Flexible(
|
||||
child: Text(
|
||||
value,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF1D2129),
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
textAlign: TextAlign.right,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDroneStatusCard(UAVDetailEntity detail) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
@@ -644,8 +689,6 @@ class _DroneStationDetailPageState extends State<DroneStationDetailPage> {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Widget _buildQuickActionButton({
|
||||
required IconData icon,
|
||||
required String label,
|
||||
@@ -710,36 +753,6 @@ class _DroneStationDetailPageState extends State<DroneStationDetailPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPositionStateRow(String label, PositionState? positionState) {
|
||||
String value = '未知';
|
||||
if (positionState != null) {
|
||||
value =
|
||||
'GPS:${positionState.gpsNumber} RTX:${positionState.rtkNumber} 固定:${positionState.isFixed}';
|
||||
}
|
||||
return Row(
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(fontSize: 13, color: Color(0xFF86909C)),
|
||||
),
|
||||
const Spacer(),
|
||||
Flexible(
|
||||
child: Text(
|
||||
value,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF1D2129),
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
textAlign: TextAlign.right,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Widget _buildCameraListRow(String label, List<CameraInfo> cameras) {
|
||||
String value = cameras
|
||||
.map((c) => '${c.cameraIndex}:${c.cameraPosition}')
|
||||
@@ -766,4 +779,31 @@ class _DroneStationDetailPageState extends State<DroneStationDetailPage> {
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 格式化降雨量显示
|
||||
String _formatRainfall(String? rainfall) {
|
||||
if (rainfall == null || rainfall.isEmpty) {
|
||||
return '未知';
|
||||
}
|
||||
|
||||
// 特殊值映射
|
||||
switch (rainfall.toLowerCase()) {
|
||||
case 'no_rain':
|
||||
return '无降雨';
|
||||
case 'light_rain':
|
||||
return '小雨';
|
||||
case 'moderate_rain':
|
||||
return '中雨';
|
||||
case 'heavy_rain':
|
||||
return '大雨';
|
||||
default:
|
||||
// 如果是数字,直接显示
|
||||
try {
|
||||
final value = double.parse(rainfall);
|
||||
return '$value mm';
|
||||
} catch (e) {
|
||||
return rainfall;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -472,6 +472,7 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
return filteredRobots.map((robot) => RobotItemCard(
|
||||
name: robot.name,
|
||||
id: robot.id,
|
||||
alias: robot.alias, // 传递别名
|
||||
type: robot.type,
|
||||
status: robot.status,
|
||||
battery: robot.battery,
|
||||
@@ -503,6 +504,7 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
final robotMap = {
|
||||
'name': robot.name,
|
||||
'id': robot.id,
|
||||
'alias': robot.alias, // 传递别名
|
||||
'type': robot.type,
|
||||
'status': robot.status,
|
||||
'battery': robot.battery,
|
||||
|
||||
Reference in New Issue
Block a user