1.优化补足了首页下拉刷新中对获取场站接口的加入,确保能够实时获取数据并渲染。
2.优化修改了tcp重连机制,具体操作:断开重连时候不再建立新链接 而是将旧链接重置,并重新发送数据。 3.大面积的给项目中的各个页面 手动接入了多语言的支持。同时也调整了相应带来的问题英文长度较大影响原有的样式的问题,已解决了对应的样式不和谐问题。保证了外观的统一性。 4.给项目中的主要操作加了几个核心的操作比如远程遥控和路径规划添加了双层的保护,设置里安全模式,即在此期间对服务器推送的重复登录操作后的自动退出登录做一个拦截 保证操作的安全性。
This commit is contained in:
@@ -49,7 +49,7 @@ class DeviceStatusBloc extends Bloc<DeviceStatusEvent, DeviceStatusState> {
|
||||
try {
|
||||
final response = await getDeviceStatusDataUseCase.execute(
|
||||
siteId: currentState.siteId,
|
||||
typeFilter: currentState.selectedType == '全部'
|
||||
typeFilter: currentState.selectedType == 'all'
|
||||
? null
|
||||
: currentState.selectedType,
|
||||
);
|
||||
|
||||
@@ -27,7 +27,7 @@ class DeviceStatusLoaded extends DeviceStatusState {
|
||||
const DeviceStatusLoaded({
|
||||
required this.deviceStatus,
|
||||
required this.devices,
|
||||
this.selectedType = '全部',
|
||||
this.selectedType = 'all',
|
||||
this.searchKeyword = '',
|
||||
this.siteId,
|
||||
});
|
||||
|
||||
@@ -34,10 +34,12 @@ class DroneStationBloc extends Bloc<DroneStationEvent, DroneStationState> {
|
||||
final result = await getDroneStationListUseCase(event.siteId);
|
||||
|
||||
result.fold(
|
||||
(failure) => emit(DroneStationError(
|
||||
message: ErrorHandler.getErrorMessage(failure.message),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
)),
|
||||
(failure) => emit(
|
||||
DroneStationError(
|
||||
message: ErrorHandler.getErrorMessage(failure.message),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
),
|
||||
),
|
||||
(stations) => emit(DroneStationLoaded(stations)),
|
||||
);
|
||||
}
|
||||
@@ -50,10 +52,12 @@ class DroneStationBloc extends Bloc<DroneStationEvent, DroneStationState> {
|
||||
final result = await getDroneStationListUseCase(event.siteId);
|
||||
|
||||
result.fold(
|
||||
(failure) => emit(DroneStationError(
|
||||
message: ErrorHandler.getErrorMessage(failure.message),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
)),
|
||||
(failure) => emit(
|
||||
DroneStationError(
|
||||
message: ErrorHandler.getErrorMessage(failure.message),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
),
|
||||
),
|
||||
(stations) => emit(DroneStationLoaded(stations)),
|
||||
);
|
||||
}
|
||||
@@ -68,10 +72,12 @@ class DroneStationBloc extends Bloc<DroneStationEvent, DroneStationState> {
|
||||
final result = await getUAVDetailUseCase(event.gatewaySn, event.deviceSn);
|
||||
|
||||
result.fold(
|
||||
(failure) => emit(UAVDetailError(
|
||||
message: ErrorHandler.getErrorMessage(failure.message),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
)),
|
||||
(failure) => emit(
|
||||
UAVDetailError(
|
||||
message: ErrorHandler.getErrorMessage(failure.message),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
),
|
||||
),
|
||||
(detail) => emit(UAVDetailLoaded(detail)),
|
||||
);
|
||||
}
|
||||
@@ -89,11 +95,14 @@ class DroneStationBloc extends Bloc<DroneStationEvent, DroneStationState> {
|
||||
);
|
||||
|
||||
result.fold(
|
||||
(failure) => emit(VideoStreamError(
|
||||
message: ErrorHandler.getErrorMessage(failure.message),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
)),
|
||||
(videoStream) => emit(VideoStreamLoaded(videoStream, event.cameraPosition)),
|
||||
(failure) => emit(
|
||||
VideoStreamError(
|
||||
message: ErrorHandler.getErrorMessage(failure.message),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
),
|
||||
),
|
||||
(videoStream) =>
|
||||
emit(VideoStreamLoaded(videoStream, event.cameraPosition)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -113,15 +122,19 @@ class DroneStationBloc extends Bloc<DroneStationEvent, DroneStationState> {
|
||||
);
|
||||
|
||||
result.fold(
|
||||
(failure) => emit(UavVideoStreamError(
|
||||
message: ErrorHandler.getErrorMessage(failure.message),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
)),
|
||||
(videoStream) => emit(UavVideoStreamLoaded(
|
||||
videoStream: videoStream,
|
||||
cameraIndex: event.cameraIndex,
|
||||
lensType: event.lensType,
|
||||
)),
|
||||
(failure) => emit(
|
||||
UavVideoStreamError(
|
||||
message: ErrorHandler.getErrorMessage(failure.message),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
),
|
||||
),
|
||||
(videoStream) => emit(
|
||||
UavVideoStreamLoaded(
|
||||
videoStream: videoStream,
|
||||
cameraIndex: event.cameraIndex,
|
||||
lensType: event.lensType,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,44 +18,30 @@ class FloatBarSettingService {
|
||||
|
||||
FloatBarSettingService(this._prefs) {
|
||||
_instance = this;
|
||||
// 从持久化读取初始状态
|
||||
_isEnabled = _prefs.getBool(_key) ?? true;
|
||||
_settingNotifier.value = _isEnabled;
|
||||
print('✅ [FloatBarSettingService] 初始化完成,初始状态: $_isEnabled');
|
||||
debugPrint('✅ [FloatBarSettingService] 初始化完成,初始状态: $_isEnabled');
|
||||
}
|
||||
|
||||
/// 获取静态实例
|
||||
static FloatBarSettingService? get instance => _instance;
|
||||
|
||||
/// 获取 ValueNotifier
|
||||
static ValueNotifier<bool> get settingNotifier => _settingNotifier;
|
||||
|
||||
/// 获取当前是否启用(直接从静态变量读取)
|
||||
static bool get isEnabled => _isEnabled;
|
||||
|
||||
/// 设置是否启用
|
||||
static Future<void> setEnabled(bool enabled) async {
|
||||
print('🔍 [FloatBarSettingService] setEnabled 被调用,新值: $enabled');
|
||||
|
||||
// 1. 更新静态变量
|
||||
debugPrint('🔍 [FloatBarSettingService] setEnabled 被调用,新值: $enabled');
|
||||
_isEnabled = enabled;
|
||||
print('🔍 [FloatBarSettingService] 静态变量已更新: $_isEnabled');
|
||||
|
||||
// 2. 更新 ValueNotifier(通知所有监听者)
|
||||
_settingNotifier.value = enabled;
|
||||
print(
|
||||
'🔍 [FloatBarSettingService] ValueNotifier 已更新: ${_settingNotifier.value}',
|
||||
);
|
||||
|
||||
// 3. 持久化到 SharedPreferences
|
||||
final instance = _instance;
|
||||
if (instance != null) {
|
||||
await instance._prefs.setBool(_key, enabled);
|
||||
print('🔍 [FloatBarSettingService] 已保存到 SharedPreferences');
|
||||
debugPrint('🔍 [FloatBarSettingService] 已保存到 SharedPreferences');
|
||||
}
|
||||
}
|
||||
|
||||
/// 切换开关
|
||||
static Future<void> toggle() async {
|
||||
await setEnabled(!_isEnabled);
|
||||
}
|
||||
|
||||
@@ -37,9 +37,7 @@ class FloatBarManager {
|
||||
hide();
|
||||
}
|
||||
|
||||
_overlayEntry = OverlayEntry(
|
||||
builder: (context) => const FloatBarWidget(),
|
||||
);
|
||||
_overlayEntry = OverlayEntry(builder: (context) => const FloatBarWidget());
|
||||
|
||||
Overlay.of(_globalContext!)?.insert(_overlayEntry!);
|
||||
}
|
||||
@@ -66,4 +64,4 @@ class FloatBarManager {
|
||||
_globalContext = null;
|
||||
_isInitialized = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
|
||||
/// 清洗/除草机器人任务详情页
|
||||
class CleaningWeedingRobotTaskPage extends StatelessWidget {
|
||||
@@ -8,8 +9,10 @@ class CleaningWeedingRobotTaskPage extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isCleaning = robot['type'] == '清洗机器人';
|
||||
final title = isCleaning ? '清洗机器人任务' : '除草机器人任务';
|
||||
final isCleaning = robot['type'] == 'cleaning';
|
||||
final title = isCleaning
|
||||
? AppLocalizations.of(context).translate('device_list_v2.cleaning_robot') + ' ' + AppLocalizations.of(context).translate('device_list_v2.task')
|
||||
: AppLocalizations.of(context).translate('device_list_v2.weeding_robot') + ' ' + AppLocalizations.of(context).translate('device_list_v2.task');
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFF5F6F8),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import '../../../../../core/di/injection.dart';
|
||||
import '../../../../../core/app/app_user_cubit.dart';
|
||||
import '../../../../../components/tcp_status_indicator.dart';
|
||||
@@ -47,6 +48,16 @@ class DeviceStatusPage extends StatelessWidget {
|
||||
class DeviceStatusView extends StatelessWidget {
|
||||
const DeviceStatusView({super.key});
|
||||
|
||||
/// 🔥 机器人设备名称前缀,用于从通用设备列表中过滤掉机器人
|
||||
static const _robotPrefixes = [
|
||||
'RCHETD-CN',
|
||||
'MC700PLUS-CN',
|
||||
'MC700-CN',
|
||||
'MC700PRO-CN',
|
||||
'RCETD-CN',
|
||||
'MC700AIR-CN',
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnnotatedRegion<SystemUiOverlayStyle>(
|
||||
@@ -98,9 +109,9 @@ class DeviceStatusView extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: Row(
|
||||
children: [
|
||||
const Text(
|
||||
'设备状态',
|
||||
style: TextStyle(
|
||||
Text(
|
||||
AppLocalizations.of(context).translate('device_list_v2.title'),
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
@@ -137,7 +148,9 @@ class DeviceStatusView extends StatelessWidget {
|
||||
padding: const EdgeInsets.fromLTRB(16.0, 8, 16.0, 8),
|
||||
child: TextField(
|
||||
decoration: InputDecoration(
|
||||
hintText: '搜索设备名称/编号',
|
||||
hintText: AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.search_hint'),
|
||||
hintStyle: const TextStyle(color: Color(0xFF86909C), fontSize: 14),
|
||||
prefixIcon: const Icon(
|
||||
Icons.search,
|
||||
@@ -148,9 +161,9 @@ class DeviceStatusView extends StatelessWidget {
|
||||
onPressed: () {
|
||||
// TODO: 触发搜索
|
||||
},
|
||||
child: const Text(
|
||||
'搜索',
|
||||
style: TextStyle(
|
||||
child: Text(
|
||||
AppLocalizations.of(context).translate('device_list_v2.search'),
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF165DFF),
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
@@ -188,14 +201,31 @@ class DeviceStatusView extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _buildTypeFilterBar(BuildContext context) {
|
||||
final types = ['全部', '机器人', '无人机机场', '逆变器', '汇流箱', '组件', '监控'];
|
||||
final typeCodes = [
|
||||
'all',
|
||||
'robot',
|
||||
'drone_station',
|
||||
'inverter',
|
||||
'combiner_box',
|
||||
'module',
|
||||
'monitor',
|
||||
];
|
||||
final typeLabels = [
|
||||
AppLocalizations.of(context).translate('device_list_v2.all'),
|
||||
AppLocalizations.of(context).translate('device_list_v2.robot'),
|
||||
AppLocalizations.of(context).translate('device_list_v2.drone_station'),
|
||||
AppLocalizations.of(context).translate('device_list_v2.inverter'),
|
||||
AppLocalizations.of(context).translate('device_list_v2.combiner_box'),
|
||||
AppLocalizations.of(context).translate('device_list_v2.module'),
|
||||
AppLocalizations.of(context).translate('device_list_v2.monitor'),
|
||||
];
|
||||
|
||||
return BlocBuilder<
|
||||
DeviceListBloc.DeviceStatusBloc,
|
||||
DeviceListState.DeviceStatusState
|
||||
>(
|
||||
builder: (context, state) {
|
||||
String selectedType = '全部';
|
||||
String selectedType = 'all';
|
||||
if (state is DeviceListState.DeviceStatusLoaded) {
|
||||
selectedType = state.selectedType;
|
||||
}
|
||||
@@ -206,16 +236,17 @@ class DeviceStatusView extends StatelessWidget {
|
||||
scrollDirection: Axis.horizontal,
|
||||
physics: const ClampingScrollPhysics(),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
itemCount: types.length,
|
||||
itemCount: typeCodes.length,
|
||||
separatorBuilder: (context, index) => const SizedBox(width: 24.0),
|
||||
itemBuilder: (context, index) {
|
||||
final type = types[index];
|
||||
final isSelected = selectedType == type;
|
||||
final typeCode = typeCodes[index];
|
||||
final typeLabel = typeLabels[index];
|
||||
final isSelected = selectedType == typeCode;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
context.read<DeviceListBloc.DeviceStatusBloc>().add(
|
||||
DeviceListEvent.DeviceStatusChangeType(type),
|
||||
DeviceListEvent.DeviceStatusChangeType(typeCode),
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
@@ -223,7 +254,7 @@ class DeviceStatusView extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
type,
|
||||
typeLabel,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: isSelected
|
||||
@@ -259,19 +290,16 @@ class DeviceStatusView extends StatelessWidget {
|
||||
BuildContext context,
|
||||
DeviceListState.DeviceStatusState state,
|
||||
) {
|
||||
// 如果选择的是"机器人",显示机器人专属页面
|
||||
if (state is DeviceListState.DeviceStatusLoaded &&
|
||||
state.selectedType == '机器人') {
|
||||
state.selectedType == 'robot') {
|
||||
return const RobotListPage();
|
||||
}
|
||||
|
||||
// 如果选择的是"无人机机场",显示机场列表
|
||||
if (state is DeviceListState.DeviceStatusLoaded &&
|
||||
state.selectedType == '无人机机场') {
|
||||
state.selectedType == 'drone_station') {
|
||||
return _buildDroneStationList(context);
|
||||
}
|
||||
|
||||
// 其他类型显示原有设备列表
|
||||
return _buildDeviceList(context, state);
|
||||
}
|
||||
|
||||
@@ -293,12 +321,24 @@ class DeviceStatusView extends StatelessWidget {
|
||||
}
|
||||
|
||||
if (state is DeviceListState.DeviceStatusLoaded) {
|
||||
// 🔥 先根据类型过滤
|
||||
List filteredByType = state.devices;
|
||||
if (state.selectedType != '全部') {
|
||||
if (state.selectedType != 'all') {
|
||||
filteredByType = state.devices.where((device) {
|
||||
return device.type == state.selectedType;
|
||||
}).toList();
|
||||
} else {
|
||||
// 🔥 "全部"模式下,排除已由专用组件渲染的类型,避免重复展示
|
||||
// drone_station 已通过 _buildDroneStationList 渲染
|
||||
// 机器人(通过名称前缀识别)已通过 _buildEmbeddedRobotList 渲染
|
||||
filteredByType = state.devices.where((device) {
|
||||
if (device.type == 'drone_station') return false;
|
||||
final isRobot = _robotPrefixes.any(
|
||||
(prefix) =>
|
||||
device.name.startsWith(prefix) ||
|
||||
device.deviceId.startsWith(prefix),
|
||||
);
|
||||
return !isRobot;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
// 🔥 再根据搜索关键词过滤
|
||||
@@ -322,19 +362,32 @@ class DeviceStatusView extends StatelessWidget {
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
children: [
|
||||
_buildStatusCard(state),
|
||||
_buildStatusCard(context, state),
|
||||
const SizedBox(height: 20.0),
|
||||
// 🔥 机器人列表(直接复用 RobotListPage 的布局)
|
||||
if (state.selectedType == '全部') _buildEmbeddedRobotList(context),
|
||||
if (state.selectedType == 'all') _buildEmbeddedRobotList(context),
|
||||
// 🔥 无人机机场列表(直接复用 _buildDroneStationList 的布局)
|
||||
if (state.selectedType == '全部')
|
||||
if (state.selectedType == 'all')
|
||||
_buildDroneStationList(context, embedded: true),
|
||||
// 🔥 普通设备列表
|
||||
...filteredDevices
|
||||
.map(
|
||||
(device) => DeviceItemWidget(
|
||||
device: device,
|
||||
onTap: () => _navigateToDeviceDetail(context, device),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return const Center(child: Text('暂无数据'));
|
||||
return Center(
|
||||
child: Text(
|
||||
AppLocalizations.of(context).translate('device_list_v2.no_data'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 🔥 嵌入式机器人列表(直接复用 RobotListPage 的布局)
|
||||
@@ -428,9 +481,11 @@ class DeviceStatusView extends StatelessWidget {
|
||||
children: [
|
||||
const Icon(Icons.location_off, size: 48, color: Color(0xFF86909C)),
|
||||
const SizedBox(height: 16),
|
||||
const Text(
|
||||
'请先选择场站',
|
||||
style: TextStyle(fontSize: 14, color: Color(0xFF4E5969)),
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.select_site_first'),
|
||||
style: const TextStyle(fontSize: 14, color: Color(0xFF4E5969)),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -471,10 +526,15 @@ class DeviceStatusView extends StatelessWidget {
|
||||
final stations = state.stations;
|
||||
|
||||
if (stations.isEmpty) {
|
||||
return const Center(
|
||||
return Center(
|
||||
child: Text(
|
||||
'该场站暂无无人机机场',
|
||||
style: TextStyle(fontSize: 14, color: Color(0xFF4E5969)),
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.no_drone_stations'),
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
color: Color(0xFF4E5969),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -512,13 +572,20 @@ class DeviceStatusView extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
return const Center(child: Text('暂无数据'));
|
||||
return Center(
|
||||
child: Text(
|
||||
AppLocalizations.of(context).translate('device_list_v2.no_data'),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatusCard(DeviceListState.DeviceStatusLoaded state) {
|
||||
Widget _buildStatusCard(
|
||||
BuildContext context,
|
||||
DeviceListState.DeviceStatusLoaded state,
|
||||
) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
@@ -537,28 +604,36 @@ class DeviceStatusView extends StatelessWidget {
|
||||
children: [
|
||||
_buildStatItem(
|
||||
value: state.deviceStatus.total.toString(),
|
||||
label: '全部设备',
|
||||
label: AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.total_devices'),
|
||||
dotColor: const Color(0xFF86909C),
|
||||
textColor: const Color(0xFF86909C), // 新增字体颜色
|
||||
textColor: const Color(0xFF86909C),
|
||||
),
|
||||
Container(width: 1, height: 40, color: const Color(0xFFE5E6EB)),
|
||||
_buildStatItem(
|
||||
value: state.deviceStatus.online.toString(),
|
||||
label: '在线',
|
||||
label: AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.online'),
|
||||
dotColor: const Color(0xFF00B42A),
|
||||
textColor: const Color(0xFF00B42A),
|
||||
),
|
||||
Container(width: 1, height: 40, color: const Color(0xFFE5E6EB)),
|
||||
_buildStatItem(
|
||||
value: state.deviceStatus.exception.toString(),
|
||||
label: '告警',
|
||||
label: AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.alarm'),
|
||||
dotColor: const Color(0xFFFF7D00),
|
||||
textColor: const Color(0xFFFF7D00),
|
||||
),
|
||||
Container(width: 1, height: 40, color: const Color(0xFFE5E6EB)),
|
||||
_buildStatItem(
|
||||
value: state.deviceStatus.offline.toString(),
|
||||
label: '离线',
|
||||
label: AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.offline'),
|
||||
dotColor: const Color(0xFFF53F3F),
|
||||
textColor: const Color(0xFFF53F3F),
|
||||
),
|
||||
@@ -597,11 +672,16 @@ class DeviceStatusView extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: textColor ?? const Color(0xFF4E5969),
|
||||
Flexible(
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: textColor ?? const Color(0xFF4E5969),
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -646,14 +726,7 @@ class DeviceStatusView extends StatelessWidget {
|
||||
debugPrint('🔍 [DeviceStatusPage] 设备类型: $deviceType');
|
||||
|
||||
// 🔥 判断是否为机器人(根据设备类型前缀)
|
||||
final robotPrefixes = [
|
||||
'RCHETD-CN',
|
||||
'MC700PLUS-CN',
|
||||
'MC700-CN',
|
||||
'MC700PRO-CN',
|
||||
'RCETD-CN',
|
||||
'MC700AIR-CN',
|
||||
];
|
||||
final robotPrefixes = _robotPrefixes;
|
||||
bool isRobot = robotPrefixes.any((prefix) => deviceType.startsWith(prefix));
|
||||
|
||||
// 🔥 判断是否为无人机机场(根据设备类型包含关键字)
|
||||
|
||||
@@ -4,9 +4,13 @@ import 'package:dio/dio.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import '../../../../../core/consts/http_api_consts.dart';
|
||||
import '../../../../../core/di/injection.dart';
|
||||
import '../../../../../core/managers/drone_task_state_manager.dart';
|
||||
import '../../domain/entities/flight_task_entity.dart';
|
||||
import '../../domain/entities/flight_task_detail_entity.dart';
|
||||
import '../../domain/entities/drone_station_entity.dart';
|
||||
import '../../domain/usecases/update_flight_task_status_usecase.dart';
|
||||
import '../bloc/drone_station_bloc.dart';
|
||||
import '../float_bar/view/float_bar_widget.dart';
|
||||
|
||||
/// 无人机任务与航线控制页面
|
||||
class DroneMissionControlPage extends StatefulWidget {
|
||||
@@ -120,11 +124,14 @@ class _DroneMissionControlPageState extends State<DroneMissionControlPage> {
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(failure.message)));
|
||||
},
|
||||
(data) {
|
||||
(data) async {
|
||||
print('✅ [DroneMissionControl] 任务执行成功: $data');
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(const SnackBar(content: Text('任务执行成功')));
|
||||
|
||||
// 🔥 获取无人机详情并设置给 FloatBarWidget
|
||||
await _loadDroneDetailAndSetToFloatBar();
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
@@ -135,6 +142,65 @@ class _DroneMissionControlPageState extends State<DroneMissionControlPage> {
|
||||
}
|
||||
}
|
||||
|
||||
/// 加载无人机详情并设置给 FloatBarWidget
|
||||
Future<void> _loadDroneDetailAndSetToFloatBar() async {
|
||||
if (_detailTask == null || _detailTask!.sn.isEmpty) {
|
||||
print('⚠️ [DroneMissionControl] 任务 SN 为空,无法获取无人机详情');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
print('🔍 [DroneMissionControl] 开始获取无人机详情, sn: ${_detailTask!.sn}');
|
||||
|
||||
final response = await Dio().get(
|
||||
HttpApiConsts.getUAVDetail,
|
||||
queryParameters: {
|
||||
'gatewaySn': _detailTask!.sn, // 机场 SN
|
||||
'deviceSn': '', // 无人机 SN(可选)
|
||||
},
|
||||
);
|
||||
|
||||
print('📡 [DroneMissionControl] 响应状态码: ${response.statusCode}');
|
||||
print('📦 [DroneMissionControl] 响应数据: ${response.data}');
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final Map<String, dynamic> jsonData = (response.data is String)
|
||||
? json.decode(response.data)
|
||||
: Map<String, dynamic>.from(response.data);
|
||||
|
||||
if (jsonData['code'] == 0 || jsonData['code'] == 200) {
|
||||
final detailData = jsonData['data'];
|
||||
final Map<String, dynamic> detailMap = (detailData is Map)
|
||||
? Map<String, dynamic>.from(detailData)
|
||||
: <String, dynamic>{};
|
||||
|
||||
final droneDetail = UAVDetailEntity.fromJson(detailMap);
|
||||
|
||||
print('✅ [DroneMissionControl] 获取无人机详情成功');
|
||||
print(' droneSn: ${droneDetail.deviceSn}');
|
||||
print(' gatewaySn: ${droneDetail.gatewaySn}');
|
||||
print(' cameraList: ${droneDetail.droneCameraList?.length ?? 0}');
|
||||
|
||||
// 创建无人机任务信息
|
||||
final droneTaskInfo = DroneTaskInfo(
|
||||
droneSn: droneDetail.deviceSn,
|
||||
gatewaySn: droneDetail.gatewaySn,
|
||||
cameraList: droneDetail.droneCameraList,
|
||||
);
|
||||
|
||||
// 设置给 FloatBarWidget
|
||||
droneTaskStateManager.setDroneTaskInfo(droneTaskInfo);
|
||||
|
||||
print('✅ [DroneMissionControl] 已设置无人机任务信息到 FloatBarWidget');
|
||||
} else {
|
||||
print('❌ [DroneMissionControl] 获取无人机详情失败: ${jsonData['message']}');
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
print('❌ [DroneMissionControl] 获取无人机详情异常: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../../../../core/di/injection.dart';
|
||||
import '../../../../../core/managers/drone_task_state_manager.dart';
|
||||
import '../../domain/entities/drone_station_entity.dart';
|
||||
import '../bloc/drone_station_bloc.dart';
|
||||
import '../bloc/drone_station_event.dart';
|
||||
@@ -402,18 +403,36 @@ class _DroneStationDetailPageState extends State<DroneStationDetailPage> {
|
||||
}
|
||||
|
||||
Widget _buildDroneStatusCard(UAVDetailEntity detail) {
|
||||
// 检查无人机是否在线
|
||||
final bool isOnline = detail.droneOnlineStatus == 1;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
// 扩展功能:无论在线还是离线,都同步到悬浮弹窗
|
||||
debugPrint('👆 [DroneStationDetailPage] 点击无人机状态卡片,同步到悬浮弹窗');
|
||||
debugPrint(' droneSn: ${detail.deviceSn}');
|
||||
debugPrint(' gatewaySn: ${detail.gatewaySn}');
|
||||
debugPrint(' 是否在线: ${isOnline ? '在线' : '离线'}');
|
||||
|
||||
final droneTaskInfo = DroneTaskInfo(
|
||||
droneSn: detail.deviceSn,
|
||||
gatewaySn: detail.gatewaySn,
|
||||
cameraList: detail.droneCameraList,
|
||||
isOnline: isOnline,
|
||||
stationName: detail.callsign,
|
||||
droneName: detail.droneCallsign,
|
||||
);
|
||||
droneTaskStateManager.setDroneTaskInfo(droneTaskInfo);
|
||||
|
||||
// 原有逻辑:跳转到无人机视频控制页面
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => DroneVideoControlPage(
|
||||
droneSn: detail.deviceSn,
|
||||
gatewaySn: detail.gatewaySn,
|
||||
// 使用无人机摄像头列表,如果为null则传空列表
|
||||
cameraList: detail.droneCameraList ?? [],
|
||||
// 传入网关摄像头列表作为备选视频源
|
||||
gatewayCameraList: detail.gatewayCameraList ?? [],
|
||||
cameraList: detail.droneCameraList,
|
||||
gatewayCameraList: detail.gatewayCameraList,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,65 +1,193 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../../../../core/di/injection.dart';
|
||||
import '../../../../../core/managers/drone_task_state_manager.dart';
|
||||
import '../bloc/drone_station_bloc.dart';
|
||||
import '../bloc/drone_station_event.dart';
|
||||
import '../bloc/drone_station_state.dart';
|
||||
import '../../domain/entities/drone_station_entity.dart';
|
||||
import 'drone_video_control_page.dart';
|
||||
|
||||
/// 无人机机场与设备状态页面
|
||||
class DroneStationStatusPage extends StatelessWidget {
|
||||
const DroneStationStatusPage({super.key});
|
||||
/// 支持从机场详情页进入,点击无人机卡片同步视频和轨迹到悬浮弹窗
|
||||
class DroneStationStatusPage extends StatefulWidget {
|
||||
final String? gatewaySn;
|
||||
final String? deviceSn;
|
||||
|
||||
const DroneStationStatusPage({super.key, this.gatewaySn, this.deviceSn});
|
||||
|
||||
@override
|
||||
State<DroneStationStatusPage> createState() => _DroneStationStatusPageState();
|
||||
}
|
||||
|
||||
class _DroneStationStatusPageState extends State<DroneStationStatusPage> {
|
||||
late final DroneStationBloc _bloc;
|
||||
UAVDetailEntity? _uavDetail;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_bloc = sl<DroneStationBloc>();
|
||||
_loadUAVDetail();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_bloc.close();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/// 加载无人机详情
|
||||
void _loadUAVDetail() {
|
||||
if (widget.gatewaySn != null && widget.gatewaySn!.isNotEmpty) {
|
||||
_bloc.add(
|
||||
UAVDetailLoad(
|
||||
gatewaySn: widget.gatewaySn!,
|
||||
deviceSn: widget.deviceSn ?? '',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 检查无人机是否在线
|
||||
bool _isDroneOnline() {
|
||||
return _uavDetail != null && _uavDetail!.droneOnlineStatus == 1;
|
||||
}
|
||||
|
||||
/// 点击无人机卡片处理
|
||||
/// 无论在线还是离线,都同步到悬浮弹窗,同时跳转到视频控制页面
|
||||
void _onDroneCardTap() {
|
||||
debugPrint('👆 [DroneStationStatusPage] 点击无人机卡片');
|
||||
|
||||
if (_uavDetail == null) {
|
||||
debugPrint('⚠️ [DroneStationStatusPage] 无人机详情为空');
|
||||
return;
|
||||
}
|
||||
|
||||
// 扩展功能:无论在线还是离线,都同步到悬浮弹窗
|
||||
debugPrint('🛸 [DroneStationStatusPage] 同步无人机信息到悬浮弹窗');
|
||||
debugPrint(' droneSn: ${_uavDetail!.deviceSn}');
|
||||
debugPrint(' gatewaySn: ${_uavDetail!.gatewaySn}');
|
||||
debugPrint(' 是否在线: ${_isDroneOnline() ? '在线' : '离线'}');
|
||||
|
||||
final droneTaskInfo = DroneTaskInfo(
|
||||
droneSn: _uavDetail!.deviceSn,
|
||||
gatewaySn: _uavDetail!.gatewaySn,
|
||||
cameraList: _uavDetail!.droneCameraList,
|
||||
isOnline: _isDroneOnline(),
|
||||
stationName: _uavDetail!.callsign,
|
||||
droneName: _uavDetail!.droneCallsign,
|
||||
);
|
||||
|
||||
debugPrint(' cameraList: ${droneTaskInfo.cameraList?.length ?? 0}');
|
||||
droneTaskStateManager.setDroneTaskInfo(droneTaskInfo);
|
||||
|
||||
// 原有逻辑:跳转到无人机视频控制页面
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => DroneVideoControlPage(
|
||||
droneSn: _uavDetail!.deviceSn,
|
||||
gatewaySn: _uavDetail!.gatewaySn,
|
||||
cameraList: _uavDetail!.droneCameraList,
|
||||
gatewayCameraList: _uavDetail!.gatewayCameraList,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 显示无人机不在线提示
|
||||
void _showOfflineToast() {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('无人机不在线,无法查看实时视频和轨迹'),
|
||||
duration: Duration(seconds: 2),
|
||||
backgroundColor: Color(0xFFFF7D00),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFF5F6F8),
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
// 顶部导航栏
|
||||
SliverAppBar(
|
||||
backgroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
pinned: true,
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back, color: Color(0xFF1D2129)),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
title: const Text(
|
||||
'无人机机场与设备状态',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
return BlocProvider.value(
|
||||
value: _bloc,
|
||||
child: BlocListener<DroneStationBloc, DroneStationState>(
|
||||
listener: (context, state) {
|
||||
if (state is UAVDetailLoaded) {
|
||||
setState(() {
|
||||
_uavDetail = state.detail;
|
||||
});
|
||||
debugPrint('✅ [DroneStationStatusPage] 无人机详情加载成功');
|
||||
debugPrint(
|
||||
' droneOnlineStatus: ${state.detail.droneOnlineStatus}',
|
||||
);
|
||||
debugPrint(' deviceSn: ${state.detail.deviceSn}');
|
||||
debugPrint(' gatewaySn: ${state.detail.gatewaySn}');
|
||||
} else if (state is UAVDetailError) {
|
||||
debugPrint(
|
||||
'❌ [DroneStationStatusPage] 无人机详情加载失败: ${state.message}',
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
backgroundColor: const Color(0xFFF5F6F8),
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
// 顶部导航栏
|
||||
SliverAppBar(
|
||||
backgroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
pinned: true,
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back, color: Color(0xFF1D2129)),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
title: const Text(
|
||||
'无人机机场与设备状态',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
centerTitle: true,
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(
|
||||
Icons.notifications_none,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
onPressed: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
centerTitle: true,
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.notifications_none, color: Color(0xFF1D2129)),
|
||||
onPressed: () {},
|
||||
// 内容区域
|
||||
SliverToBoxAdapter(
|
||||
child: Column(
|
||||
children: [
|
||||
ListView(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
// 机场状态卡片
|
||||
_buildAirportStatusCard(),
|
||||
const SizedBox(height: 12),
|
||||
// 无人机状态卡片
|
||||
_buildDroneStatusCard(),
|
||||
const SizedBox(height: 12),
|
||||
// 快捷操作
|
||||
_buildQuickActions(),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 80), // 为底部 Tab 栏留出空间
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// 内容区域
|
||||
SliverToBoxAdapter(
|
||||
child: Column(
|
||||
children: [
|
||||
ListView(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
// 机场状态卡片
|
||||
_buildAirportStatusCard(),
|
||||
const SizedBox(height: 12),
|
||||
// 无人机状态卡片
|
||||
_buildDroneStatusCard(),
|
||||
const SizedBox(height: 12),
|
||||
// 快捷操作
|
||||
_buildQuickActions(),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 80), // 为底部 Tab 栏留出空间
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -91,7 +219,11 @@ class DroneStationStatusPage extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildStatusRow('机场编号', 'AIRPORT-01', status: '正常'),
|
||||
_buildStatusRow(
|
||||
'机场编号',
|
||||
_uavDetail?.gatewaySn ?? 'AIRPORT-01',
|
||||
status: '正常',
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildStatusRow('位置', '升压站旁 - 无人机机场'),
|
||||
const SizedBox(height: 12),
|
||||
@@ -108,87 +240,116 @@ class DroneStationStatusPage extends StatelessWidget {
|
||||
}
|
||||
|
||||
/// 无人机状态卡片
|
||||
/// 点击卡片时只有无人机在线才会同步到悬浮弹窗
|
||||
Widget _buildDroneStatusCard() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x0D000000),
|
||||
blurRadius: 8,
|
||||
offset: Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Text(
|
||||
'无人机状态',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF00B42A).withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: const Text(
|
||||
'在线',
|
||||
final isOnline = _isDroneOnline();
|
||||
|
||||
return GestureDetector(
|
||||
onTap: _onDroneCardTap,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x0D000000),
|
||||
blurRadius: 8,
|
||||
offset: Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Text(
|
||||
'无人机状态',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Color(0xFF00B42A),
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
children: [
|
||||
Image.asset(
|
||||
'assets/images/xunjian.png',
|
||||
width: 60,
|
||||
height: 60,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'无人机 - 01',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
const Spacer(),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: isOnline
|
||||
? const Color(0xFF00B42A).withOpacity(0.1)
|
||||
: const Color(0xFFFF7D00).withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
isOnline ? '在线' : '离线',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: isOnline
|
||||
? const Color(0xFF00B42A)
|
||||
: const Color(0xFFFF7D00),
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_buildDroneBatteryRow(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// const SizedBox(height: 12),
|
||||
// _buildStatusRow('飞行模式', '待命'),
|
||||
// const SizedBox(height: 12),
|
||||
// _buildStatusRow('机身状态', '正常'),
|
||||
// const SizedBox(height: 12),
|
||||
// _buildStatusRow('上次任务', '逆变器区巡检(05-20 10:30)'),
|
||||
],
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
children: [
|
||||
Image.asset(
|
||||
'assets/images/xunjian.png',
|
||||
width: 60,
|
||||
height: 60,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
_uavDetail?.droneCallsign ?? '无人机 - 01',
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_buildDroneBatteryRow(),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.keyboard_arrow_right,
|
||||
size: 16,
|
||||
color: isOnline
|
||||
? const Color(0xFF165DFF)
|
||||
: const Color(0xFFC9CDD4),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
isOnline ? '点击查看实时视频和轨迹' : '无人机离线,无法查看视频和轨迹',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: isOnline
|
||||
? const Color(0xFF165DFF)
|
||||
: const Color(0xFF86909C),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -282,19 +443,12 @@ class DroneStationStatusPage extends StatelessWidget {
|
||||
color: color.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Icon(
|
||||
icon,
|
||||
color: color,
|
||||
size: 24,
|
||||
),
|
||||
child: Icon(icon, color: color, size: 24),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Color(0xFF4E5969),
|
||||
),
|
||||
style: const TextStyle(fontSize: 12, color: Color(0xFF4E5969)),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -307,10 +461,7 @@ class DroneStationStatusPage extends StatelessWidget {
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF86909C),
|
||||
),
|
||||
style: const TextStyle(fontSize: 13, color: Color(0xFF86909C)),
|
||||
),
|
||||
const Spacer(),
|
||||
Text(
|
||||
@@ -344,15 +495,16 @@ class DroneStationStatusPage extends StatelessWidget {
|
||||
}
|
||||
|
||||
/// 带进度条的状态行
|
||||
Widget _buildStatusRowWithProgress(String label, String value, String progress) {
|
||||
Widget _buildStatusRowWithProgress(
|
||||
String label,
|
||||
String value,
|
||||
String progress,
|
||||
) {
|
||||
return Row(
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF86909C),
|
||||
),
|
||||
style: const TextStyle(fontSize: 13, color: Color(0xFF86909C)),
|
||||
),
|
||||
const Spacer(),
|
||||
Text(
|
||||
@@ -373,11 +525,7 @@ class DroneStationStatusPage extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
const Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
size: 12,
|
||||
color: Color(0xFF86909C),
|
||||
),
|
||||
const Icon(Icons.arrow_forward_ios, size: 12, color: Color(0xFF86909C)),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -388,17 +536,14 @@ class DroneStationStatusPage extends StatelessWidget {
|
||||
children: [
|
||||
const Text(
|
||||
'气象条件',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF86909C),
|
||||
),
|
||||
style: TextStyle(fontSize: 13, color: Color(0xFF86909C)),
|
||||
),
|
||||
const Spacer(),
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.wb_sunny, size: 16, color: Color(0xFFFF7D00)),
|
||||
const SizedBox(width: 4),
|
||||
const Text(
|
||||
children: const [
|
||||
Icon(Icons.wb_sunny, size: 16, color: Color(0xFFFF7D00)),
|
||||
SizedBox(width: 4),
|
||||
Text(
|
||||
'晴',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
@@ -406,21 +551,15 @@ class DroneStationStatusPage extends StatelessWidget {
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Text(
|
||||
SizedBox(width: 8),
|
||||
Text(
|
||||
'25°C',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
style: TextStyle(fontSize: 13, color: Color(0xFF1D2129)),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Text(
|
||||
SizedBox(width: 8),
|
||||
Text(
|
||||
'东南风 2级',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
style: TextStyle(fontSize: 13, color: Color(0xFF1D2129)),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -430,33 +569,38 @@ class DroneStationStatusPage extends StatelessWidget {
|
||||
|
||||
/// 无人机电量行
|
||||
Widget _buildDroneBatteryRow() {
|
||||
final capacity = _uavDetail?.liveCapacity ?? 78;
|
||||
|
||||
return Row(
|
||||
children: [
|
||||
const Text(
|
||||
'电量',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF86909C),
|
||||
),
|
||||
style: TextStyle(fontSize: 13, color: Color(0xFF86909C)),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
child: LinearProgressIndicator(
|
||||
value: 0.78,
|
||||
value: capacity / 100,
|
||||
backgroundColor: const Color(0xFFF2F3F5),
|
||||
valueColor: const AlwaysStoppedAnimation<Color>(Color(0xFF00B42A)),
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
capacity > 20
|
||||
? const Color(0xFF00B42A)
|
||||
: const Color(0xFFFF7D00),
|
||||
),
|
||||
minHeight: 6,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Text(
|
||||
'78%',
|
||||
Text(
|
||||
'${capacity.toInt()}%',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF00B42A),
|
||||
color: capacity > 20
|
||||
? const Color(0xFF00B42A)
|
||||
: const Color(0xFFFF7D00),
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -158,8 +158,10 @@ class _DroneVideoControlPageState extends State<DroneVideoControlPage> {
|
||||
|
||||
// 根据是否使用备选视频源决定使用哪个 SN
|
||||
final effectiveSn = _useBackupSource ? widget.gatewaySn : widget.droneSn;
|
||||
|
||||
debugPrint('📤 请求视频流 - SN: $effectiveSn, 摄像头: ${_currentCamera!.cameraIndex}');
|
||||
|
||||
debugPrint(
|
||||
'📤 请求视频流 - SN: $effectiveSn, 摄像头: ${_currentCamera!.cameraIndex}',
|
||||
);
|
||||
|
||||
_bloc.add(
|
||||
UavVideoStreamLoad(
|
||||
@@ -190,20 +192,22 @@ class _DroneVideoControlPageState extends State<DroneVideoControlPage> {
|
||||
void _toggleBackupSource(bool useBackup) {
|
||||
debugPrint('=== 🔄 切换视频源 ===');
|
||||
debugPrint('切换到: ${useBackup ? "备选(网关)" : "主视频源(无人机)"}');
|
||||
|
||||
|
||||
setState(() {
|
||||
_useBackupSource = useBackup;
|
||||
// 更新实际使用的摄像头列表
|
||||
_effectiveCameraList = useBackup
|
||||
_effectiveCameraList = useBackup
|
||||
? (_backupCameraList ?? [])
|
||||
: (widget.cameraList ?? []);
|
||||
// 选择新列表的第一个摄像头
|
||||
_currentCamera = _effectiveCameraList.isNotEmpty ? _effectiveCameraList.first : null;
|
||||
_currentCamera = _effectiveCameraList.isNotEmpty
|
||||
? _effectiveCameraList.first
|
||||
: null;
|
||||
});
|
||||
|
||||
|
||||
debugPrint('新摄像头列表长度: ${_effectiveCameraList.length}');
|
||||
debugPrint('选中的摄像头: ${_currentCamera?.cameraIndex}');
|
||||
|
||||
|
||||
// 重新加载视频流
|
||||
if (_currentCamera != null) {
|
||||
_loadVideoStream(_currentLensType ?? UavLensType.wide);
|
||||
@@ -372,7 +376,8 @@ class _DroneVideoControlPageState extends State<DroneVideoControlPage> {
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
if (_effectiveCameraList.isNotEmpty || _backupCameraList?.isNotEmpty == true)
|
||||
if (_effectiveCameraList.isNotEmpty ||
|
||||
_backupCameraList?.isNotEmpty == true)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: Row(
|
||||
@@ -391,9 +396,16 @@ class _DroneVideoControlPageState extends State<DroneVideoControlPage> {
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: const [
|
||||
Icon(Icons.flight, size: 16, color: Color(0xFF165DFF)),
|
||||
Icon(
|
||||
Icons.flight,
|
||||
size: 16,
|
||||
color: Color(0xFF165DFF),
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
Text('无人机', style: TextStyle(fontSize: 12)),
|
||||
Text(
|
||||
'无人机',
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -402,15 +414,23 @@ class _DroneVideoControlPageState extends State<DroneVideoControlPage> {
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: const [
|
||||
Icon(Icons.home_work, size: 16, color: Color(0xFFFF7D00)),
|
||||
Icon(
|
||||
Icons.home_work,
|
||||
size: 16,
|
||||
color: Color(0xFFFF7D00),
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
Text('备选', style: TextStyle(fontSize: 12)),
|
||||
Text(
|
||||
'备选',
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
onChanged: (bool? useBackup) {
|
||||
if (useBackup != null && useBackup != _useBackupSource) {
|
||||
if (useBackup != null &&
|
||||
useBackup != _useBackupSource) {
|
||||
_toggleBackupSource(useBackup);
|
||||
}
|
||||
},
|
||||
@@ -440,9 +460,13 @@ class _DroneVideoControlPageState extends State<DroneVideoControlPage> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
_useBackupSource ? Icons.home_work : Icons.videocam,
|
||||
_useBackupSource
|
||||
? Icons.home_work
|
||||
: Icons.videocam,
|
||||
size: 16,
|
||||
color: _useBackupSource ? const Color(0xFFFF7D00) : const Color(0xFF165DFF),
|
||||
color: _useBackupSource
|
||||
? const Color(0xFFFF7D00)
|
||||
: const Color(0xFF165DFF),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import '../../../../../core/di/injection.dart';
|
||||
import '../../../../../core/logging/i_logger_service.dart';
|
||||
import '../../../../devices/presentation/bloc/devices_cubit.dart';
|
||||
@@ -25,7 +26,8 @@ class RobotListPage extends StatelessWidget {
|
||||
final siteId = selectedSite?.id;
|
||||
|
||||
return BlocProvider(
|
||||
create: (_) => sl<RobotListBloc>()..add(RobotListLoadData(siteId: siteId)),
|
||||
create: (_) =>
|
||||
sl<RobotListBloc>()..add(RobotListLoadData(siteId: siteId)),
|
||||
child: RobotListView(siteId: siteId),
|
||||
);
|
||||
}
|
||||
@@ -63,9 +65,7 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
builder: (context, state) {
|
||||
if (state is RobotListLoading) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Color(0xFF165DFF),
|
||||
),
|
||||
child: CircularProgressIndicator(color: Color(0xFF165DFF)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -99,13 +99,18 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
}
|
||||
|
||||
Widget _buildStatsCard(RobotListLoaded state) {
|
||||
// 计算各类型机器人数量
|
||||
final allRobots = state.robots;
|
||||
final inspectionRobots = allRobots.where((r) => r.type.contains('巡检')).toList();
|
||||
final cleaningRobots = allRobots.where((r) => r.type.contains('清洗')).toList();
|
||||
final weedingRobots = allRobots.where((r) => r.type.contains('除草')).toList();
|
||||
|
||||
final onlineInspection = inspectionRobots.where((r) => r.status == '在线').length;
|
||||
final inspectionRobots = allRobots
|
||||
.where((r) => r.type == 'inspection')
|
||||
.toList();
|
||||
final cleaningRobots = allRobots
|
||||
.where((r) => r.type == 'cleaning')
|
||||
.toList();
|
||||
final weedingRobots = allRobots.where((r) => r.type == 'weeding').toList();
|
||||
|
||||
final onlineInspection = inspectionRobots
|
||||
.where((r) => r.status == '在线')
|
||||
.length;
|
||||
final onlineCleaning = cleaningRobots.where((r) => r.status == '在线').length;
|
||||
final onlineWeeding = weedingRobots.where((r) => r.status == '在线').length;
|
||||
return Container(
|
||||
@@ -129,37 +134,43 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
onTap: () {
|
||||
context.read<RobotListBloc>().add(
|
||||
RobotListChangeType(
|
||||
_selectedType == '巡检机器人' ? null : '巡检机器人',
|
||||
_selectedType == 'inspection' ? null : 'inspection',
|
||||
),
|
||||
);
|
||||
setState(() {
|
||||
_selectedType = _selectedType == '巡检机器人' ? null : '巡检机器人';
|
||||
_selectedType = _selectedType == 'inspection'
|
||||
? null
|
||||
: 'inspection';
|
||||
});
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
gradient: _selectedType == '巡检机器人'
|
||||
gradient: _selectedType == 'inspection'
|
||||
? const LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
Color(0xFFE8F4FF),
|
||||
Color(0xFFFFFFFF),
|
||||
],
|
||||
colors: [Color(0xFFE8F4FF), Color(0xFFFFFFFF)],
|
||||
)
|
||||
: null,
|
||||
color: _selectedType != '巡检机器人' ? Colors.transparent : null,
|
||||
color: _selectedType != 'inspection'
|
||||
? Colors.transparent
|
||||
: null,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
'巡检机器人',
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.inspection_robot'),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: _selectedType == '巡检机器人'
|
||||
color: _selectedType == 'inspection'
|
||||
? const Color(0xFF165DFF)
|
||||
: const Color(0xFF1D2129),
|
||||
),
|
||||
@@ -169,21 +180,29 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Image.asset('assets/images/xunjian.png', width: 48, height: 48),
|
||||
Image.asset(
|
||||
'assets/images/xunjian.png',
|
||||
width: 48,
|
||||
height: 48,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'${inspectionRobots.length}',
|
||||
style: const TextStyle(fontSize: 28, fontWeight: FontWeight.bold, color: Color(0xFF165DFF)),
|
||||
style: const TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF165DFF),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'在线$onlineInspection台',
|
||||
'${AppLocalizations.of(context).translate('device_list_v2.online')}$onlineInspection台',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: _selectedType == '巡检机器人'
|
||||
color: _selectedType == 'inspection'
|
||||
? const Color(0xFF165DFF)
|
||||
: const Color(0xFF00B42A),
|
||||
),
|
||||
@@ -198,37 +217,43 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
onTap: () {
|
||||
context.read<RobotListBloc>().add(
|
||||
RobotListChangeType(
|
||||
_selectedType == '清洗机器人' ? null : '清洗机器人',
|
||||
_selectedType == 'cleaning' ? null : 'cleaning',
|
||||
),
|
||||
);
|
||||
setState(() {
|
||||
_selectedType = _selectedType == '清洗机器人' ? null : '清洗机器人';
|
||||
_selectedType = _selectedType == 'cleaning'
|
||||
? null
|
||||
: 'cleaning';
|
||||
});
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
gradient: _selectedType == '清洗机器人'
|
||||
gradient: _selectedType == 'cleaning'
|
||||
? const LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
Color(0xFFE8F4FF),
|
||||
Color(0xFFFFFFFF),
|
||||
],
|
||||
colors: [Color(0xFFE8F4FF), Color(0xFFFFFFFF)],
|
||||
)
|
||||
: null,
|
||||
color: _selectedType != '清洗机器人' ? Colors.transparent : null,
|
||||
color: _selectedType != 'cleaning'
|
||||
? Colors.transparent
|
||||
: null,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
'清洗机器人',
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.cleaning_robot'),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: _selectedType == '清洗机器人'
|
||||
color: _selectedType == 'cleaning'
|
||||
? const Color(0xFF165DFF)
|
||||
: const Color(0xFF1D2129),
|
||||
),
|
||||
@@ -238,21 +263,29 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Image.asset('assets/images/qinxi.png', width: 48, height: 48),
|
||||
Image.asset(
|
||||
'assets/images/qinxi.png',
|
||||
width: 48,
|
||||
height: 48,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'${cleaningRobots.length}',
|
||||
style: const TextStyle(fontSize: 28, fontWeight: FontWeight.bold, color: Color(0xFF165DFF)),
|
||||
style: const TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF165DFF),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'在线$onlineCleaning台',
|
||||
'${AppLocalizations.of(context).translate('device_list_v2.online')}$onlineCleaning台',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: _selectedType == '清洗机器人'
|
||||
color: _selectedType == 'cleaning'
|
||||
? const Color(0xFF165DFF)
|
||||
: const Color(0xFF00B42A),
|
||||
),
|
||||
@@ -267,37 +300,41 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
onTap: () {
|
||||
context.read<RobotListBloc>().add(
|
||||
RobotListChangeType(
|
||||
_selectedType == '除草机器人' ? null : '除草机器人',
|
||||
_selectedType == 'weeding' ? null : 'weeding',
|
||||
),
|
||||
);
|
||||
setState(() {
|
||||
_selectedType = _selectedType == '除草机器人' ? null : '除草机器人';
|
||||
_selectedType = _selectedType == 'weeding' ? null : 'weeding';
|
||||
});
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
gradient: _selectedType == '除草机器人'
|
||||
gradient: _selectedType == 'weeding'
|
||||
? const LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
Color(0xFFE8F4FF),
|
||||
Color(0xFFFFFFFF),
|
||||
],
|
||||
colors: [Color(0xFFE8F4FF), Color(0xFFFFFFFF)],
|
||||
)
|
||||
: null,
|
||||
color: _selectedType != '除草机器人' ? Colors.transparent : null,
|
||||
color: _selectedType != 'weeding'
|
||||
? Colors.transparent
|
||||
: null,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
'除草机器人',
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.weeding_robot'),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: _selectedType == '除草机器人'
|
||||
color: _selectedType == 'weeding'
|
||||
? const Color(0xFF165DFF)
|
||||
: const Color(0xFF1D2129),
|
||||
),
|
||||
@@ -307,14 +344,18 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Image.asset('assets/images/chucao.png', width: 48, height: 48),
|
||||
Image.asset(
|
||||
'assets/images/chucao.png',
|
||||
width: 48,
|
||||
height: 48,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'${weedingRobots.length}',
|
||||
style: TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _selectedType == '除草机器人'
|
||||
color: _selectedType == 'weeding'
|
||||
? const Color(0xFF165DFF)
|
||||
: const Color(0xFF00B42A),
|
||||
),
|
||||
@@ -323,11 +364,11 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'在线$onlineWeeding台',
|
||||
'${AppLocalizations.of(context).translate('device_list_v2.online')}$onlineWeeding台',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: _selectedType == '除草机器人'
|
||||
color: _selectedType == 'weeding'
|
||||
? const Color(0xFF165DFF)
|
||||
: const Color(0xFF00B42A),
|
||||
),
|
||||
@@ -344,38 +385,78 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
Widget _buildQuickActions(RobotListLoaded state) {
|
||||
// 计算统计数据
|
||||
final onlineCount = state.robots.where((r) => r.status == '在线').length;
|
||||
final workingCount = state.robots.where((r) => r.task != '待机中' && r.task != '充电中').length;
|
||||
final workingCount = state.robots
|
||||
.where((r) => r.task != '待机中' && r.task != '充电中')
|
||||
.length;
|
||||
final standbyCount = state.robots.where((r) => r.task == '待机中').length;
|
||||
final faultCount = state.robots.where((r) => r.status == '异常' || r.status == '离线').length;
|
||||
final faultCount = state.robots
|
||||
.where((r) => r.status == '异常' || r.status == '离线')
|
||||
.length;
|
||||
return Container(
|
||||
margin: const EdgeInsets.fromLTRB(16, 0, 16, 12),
|
||||
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: const [BoxShadow(color: Color(0x0D000000), blurRadius: 8, offset: Offset(0, 2))],
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x0D000000),
|
||||
blurRadius: 8,
|
||||
offset: Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
_buildStatusItem(value: '$onlineCount', label: '在线设备', valueColor: const Color(0xFF165DFF)),
|
||||
_buildStatusItem(
|
||||
value: '$onlineCount',
|
||||
label: '在线设备',
|
||||
valueColor: const Color(0xFF165DFF),
|
||||
),
|
||||
Container(width: 1, height: 40, color: const Color(0xFFE5E6EB)),
|
||||
_buildStatusItem(value: '$workingCount', label: '作业中', valueColor: const Color(0xFF00B42A)),
|
||||
_buildStatusItem(
|
||||
value: '$workingCount',
|
||||
label: '作业中',
|
||||
valueColor: const Color(0xFF00B42A),
|
||||
),
|
||||
Container(width: 1, height: 40, color: const Color(0xFFE5E6EB)),
|
||||
_buildStatusItem(value: '$standbyCount', label: '待命', valueColor: const Color(0xFFFF7D00)),
|
||||
_buildStatusItem(
|
||||
value: '$standbyCount',
|
||||
label: '待命',
|
||||
valueColor: const Color(0xFFFF7D00),
|
||||
),
|
||||
Container(width: 1, height: 40, color: const Color(0xFFE5E6EB)),
|
||||
_buildStatusItem(value: '$faultCount', label: '故障数', valueColor: const Color(0xFFF53F3F)),
|
||||
_buildStatusItem(
|
||||
value: '$faultCount',
|
||||
label: '故障数',
|
||||
valueColor: const Color(0xFFF53F3F),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatusItem({required String value, required String label, required Color valueColor}) {
|
||||
Widget _buildStatusItem({
|
||||
required String value,
|
||||
required String label,
|
||||
required Color valueColor,
|
||||
}) {
|
||||
return Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
Text(value, style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold, color: valueColor)),
|
||||
Text(
|
||||
value,
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: valueColor,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(label, style: const TextStyle(fontSize: 13, color: Color(0xFF4E5969))),
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(fontSize: 13, color: Color(0xFF4E5969)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -385,14 +466,16 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
// 获取第一个正在执行任务的机器人
|
||||
final workingRobot = state.robots.firstWhere(
|
||||
(r) => r.task != '待机中' && r.task != '充电中',
|
||||
orElse: () => state.robots.isNotEmpty ? state.robots.first : RobotDataModel(
|
||||
name: '',
|
||||
id: '',
|
||||
type: '',
|
||||
status: '',
|
||||
battery: 0,
|
||||
task: '无任务',
|
||||
),
|
||||
orElse: () => state.robots.isNotEmpty
|
||||
? state.robots.first
|
||||
: RobotDataModel(
|
||||
name: '',
|
||||
id: '',
|
||||
type: '',
|
||||
status: '',
|
||||
battery: 0,
|
||||
task: '无任务',
|
||||
),
|
||||
);
|
||||
return Container(
|
||||
margin: const EdgeInsets.fromLTRB(16, 0, 16, 12),
|
||||
@@ -400,18 +483,36 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: const [BoxShadow(color: Color(0x0D000000), blurRadius: 8, offset: Offset(0, 2))],
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x0D000000),
|
||||
blurRadius: 8,
|
||||
offset: Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text('当前任务', style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: Color(0xFF1D2129))),
|
||||
const Text(
|
||||
'当前任务',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Image.asset('assets/images/xunjian.png', width: 80, height: 80, fit: BoxFit.cover),
|
||||
child: Image.asset(
|
||||
'assets/images/xunjian.png',
|
||||
width: 80,
|
||||
height: 80,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
@@ -420,16 +521,41 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Expanded(child: Text('巡检任务-逆变器区巡检', style: TextStyle(fontSize: 15, fontWeight: FontWeight.w500, color: Color(0xFF1D2129)))),
|
||||
const Expanded(
|
||||
child: Text(
|
||||
'巡检任务-逆变器区巡检',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
decoration: BoxDecoration(color: const Color(0xFF165DFF).withOpacity(0.1), borderRadius: BorderRadius.circular(4)),
|
||||
child: const Text('进行中', style: TextStyle(fontSize: 11, color: Color(0xFF165DFF), fontWeight: FontWeight.w500)),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF165DFF).withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: const Text(
|
||||
'进行中',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: Color(0xFF165DFF),
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_buildTaskInfo('机器人:', workingRobot.name.isNotEmpty ? workingRobot.name : '无'),
|
||||
_buildTaskInfo(
|
||||
'机器人:',
|
||||
workingRobot.name.isNotEmpty ? workingRobot.name : '无',
|
||||
),
|
||||
_buildTaskInfo('区域:', '逆变器区A区'),
|
||||
_buildTaskInfo('进度:', '62%'),
|
||||
_buildTaskInfo('预计完成:', '12:30'),
|
||||
@@ -449,8 +575,14 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
TextSpan(text: label, style: const TextStyle(fontSize: 13, color: Color(0xFF86909C))),
|
||||
TextSpan(text: value, style: const TextStyle(fontSize: 13, color: Color(0xFF1D2129))),
|
||||
TextSpan(
|
||||
text: label,
|
||||
style: const TextStyle(fontSize: 13, color: Color(0xFF86909C)),
|
||||
),
|
||||
TextSpan(
|
||||
text: value,
|
||||
style: const TextStyle(fontSize: 13, color: Color(0xFF1D2129)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -461,64 +593,84 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
final allRobots = state.robots;
|
||||
|
||||
// 根据选中的类型过滤
|
||||
final filteredRobots = state.selectedType == null
|
||||
? allRobots
|
||||
: allRobots.where((robot) => robot.type.contains(state.selectedType!)).toList();
|
||||
final filteredRobots = state.selectedType == null
|
||||
? allRobots
|
||||
: allRobots
|
||||
.where((robot) => robot.type.contains(state.selectedType!))
|
||||
.toList();
|
||||
|
||||
if (filteredRobots.isEmpty) {
|
||||
return [const Center(child: Padding(padding: EdgeInsets.all(32), child: Text('暂无机器人数据', style: TextStyle(fontSize: 14, color: Color(0xFF86909C)))))];
|
||||
return [
|
||||
const Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(32),
|
||||
child: Text(
|
||||
'暂无机器人数据',
|
||||
style: TextStyle(fontSize: 14, color: Color(0xFF86909C)),
|
||||
),
|
||||
),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
return filteredRobots.map((robot) => RobotItemCard(
|
||||
name: robot.name,
|
||||
id: robot.id,
|
||||
alias: robot.alias, // 传递别名
|
||||
type: robot.type,
|
||||
status: robot.status,
|
||||
battery: robot.battery,
|
||||
task: robot.task,
|
||||
onTap: () async {
|
||||
// final logger = sl<ILoggerService>();
|
||||
debugPrint('🔴🔴🔴 [选中机器人] ========== 点击事件触发 ==========');
|
||||
debugPrint('🔴🔴🔴 [选中机器人] name: ${robot.name}, id: ${robot.id}, type: ${robot.type}');
|
||||
debugPrint('🔴🔴🔴 [选中机器人] status: ${robot.status}, battery: ${robot.battery}, task: ${robot.task}');
|
||||
|
||||
// 1. 将当前机器人设置为全局待控制设备(用 robot.name 作为 deviceName)
|
||||
final device = DeviceEntity(
|
||||
deviceName: robot.name, // ✅ 修正: 用 name 而不是 id
|
||||
productId: -1,
|
||||
productName: robot.type,
|
||||
tenantId: 0,
|
||||
tenantName: '',
|
||||
status: robot.status == '在线' ? 1 : 0,
|
||||
onlineStatus: robot.status == '在线' ? 1 : 0,
|
||||
);
|
||||
|
||||
debugPrint('🎯 [RobotListPage] 准备调用 setTargetDevice...');
|
||||
// 🔥 使用 GetIt 直接获取 RemoteControlCubit 单例
|
||||
final remoteCubit = GetIt.I<RemoteControlCubit>();
|
||||
remoteCubit.setTargetDevice(device); // 🔥 TCP连接在后台异步执行
|
||||
debugPrint('✅ [RobotListPage] setTargetDevice 已调用(TCP连接中)');
|
||||
|
||||
// 2. 跳转到机器人控制页面
|
||||
final robotMap = {
|
||||
'name': robot.name,
|
||||
'id': robot.id,
|
||||
'alias': robot.alias, // 传递别名
|
||||
'type': robot.type,
|
||||
'status': robot.status,
|
||||
'battery': robot.battery,
|
||||
'task': robot.task,
|
||||
};
|
||||
|
||||
debugPrint('🚀 [RobotListPage] 准备跳转页面...');
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => RobotControlPage(robot: robotMap),
|
||||
return filteredRobots
|
||||
.map(
|
||||
(robot) => RobotItemCard(
|
||||
name: robot.name,
|
||||
id: robot.id,
|
||||
alias: robot.alias, // 传递别名
|
||||
type: robot.type,
|
||||
status: robot.status,
|
||||
battery: robot.battery,
|
||||
task: robot.task,
|
||||
onTap: () async {
|
||||
// final logger = sl<ILoggerService>();
|
||||
debugPrint('🔴🔴🔴 [选中机器人] ========== 点击事件触发 ==========');
|
||||
debugPrint(
|
||||
'🔴🔴🔴 [选中机器人] name: ${robot.name}, id: ${robot.id}, type: ${robot.type}',
|
||||
);
|
||||
debugPrint(
|
||||
'🔴🔴🔴 [选中机器人] status: ${robot.status}, battery: ${robot.battery}, task: ${robot.task}',
|
||||
);
|
||||
|
||||
// 1. 将当前机器人设置为全局待控制设备(用 robot.name 作为 deviceName)
|
||||
final device = DeviceEntity(
|
||||
deviceName: robot.name, // ✅ 修正: 用 name 而不是 id
|
||||
productId: -1,
|
||||
productName: robot.type,
|
||||
tenantId: 0,
|
||||
tenantName: '',
|
||||
status: robot.status == '在线' ? 1 : 0,
|
||||
onlineStatus: robot.status == '在线' ? 1 : 0,
|
||||
);
|
||||
|
||||
debugPrint('🎯 [RobotListPage] 准备调用 setTargetDevice...');
|
||||
// 🔥 使用 GetIt 直接获取 RemoteControlCubit 单例
|
||||
final remoteCubit = GetIt.I<RemoteControlCubit>();
|
||||
remoteCubit.setTargetDevice(device); // 🔥 TCP连接在后台异步执行
|
||||
debugPrint('✅ [RobotListPage] setTargetDevice 已调用(TCP连接中)');
|
||||
|
||||
// 2. 跳转到机器人控制页面
|
||||
final robotMap = {
|
||||
'name': robot.name,
|
||||
'id': robot.id,
|
||||
'alias': robot.alias, // 传递别名
|
||||
'type': robot.type,
|
||||
'status': robot.status,
|
||||
'battery': robot.battery,
|
||||
'task': robot.task,
|
||||
};
|
||||
|
||||
debugPrint('🚀 [RobotListPage] 准备跳转页面...');
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => RobotControlPage(robot: robotMap),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
)).toList();
|
||||
)
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,7 @@ class DeviceBottomNavBar extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border(
|
||||
top: BorderSide(
|
||||
color: const Color(0xFFF2F3F5),
|
||||
width: 0.5,
|
||||
),
|
||||
top: BorderSide(color: const Color(0xFFF2F3F5), width: 0.5),
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
@@ -79,7 +76,9 @@ class DeviceBottomNavBar extends StatelessWidget {
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
color: isSelected ? const Color(0xFF004CFD) : const Color(0xFF86909C),
|
||||
color: isSelected
|
||||
? const Color(0xFF004CFD)
|
||||
: const Color(0xFF86909C),
|
||||
size: 24,
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
@@ -87,7 +86,9 @@ class DeviceBottomNavBar extends StatelessWidget {
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: isSelected ? const Color(0xFF004FFF) : const Color(0xFF86909C),
|
||||
color: isSelected
|
||||
? const Color(0xFF004FFF)
|
||||
: const Color(0xFF86909C),
|
||||
fontWeight: isSelected ? FontWeight.w500 : FontWeight.normal,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../domain/entities/device_entity.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
|
||||
/// 设备列表项 Widget
|
||||
class DeviceItemWidget extends StatelessWidget {
|
||||
@@ -68,7 +69,7 @@ class DeviceItemWidget extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
// 第二行:设备数据
|
||||
_buildDeviceData(device),
|
||||
_buildDeviceData(context, device),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -112,11 +113,7 @@ class DeviceItemWidget extends StatelessWidget {
|
||||
color: color.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Icon(
|
||||
icon,
|
||||
color: color,
|
||||
size: 28,
|
||||
),
|
||||
child: Icon(icon, color: color, size: 28),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -148,46 +145,71 @@ class DeviceItemWidget extends StatelessWidget {
|
||||
color: bgColor,
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
),
|
||||
child: Text(
|
||||
status,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: textColor,
|
||||
),
|
||||
),
|
||||
child: Text(status, style: TextStyle(fontSize: 12, color: textColor)),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDeviceData(DeviceEntity device) {
|
||||
Widget _buildDeviceData(BuildContext context, DeviceEntity device) {
|
||||
final dataItems = <Widget>[];
|
||||
|
||||
// 根据设备类型显示不同的数据
|
||||
if (device.type == '逆变器') {
|
||||
dataItems.add(_buildDataItem('${device.power}', 'kW | 功率'));
|
||||
if (device.type == 'inverter') {
|
||||
dataItems.add(
|
||||
_buildDataItem(
|
||||
'${device.power}',
|
||||
'${AppLocalizations.of(context).translate('device_list_v2.inverter')} | ${AppLocalizations.of(context).translate('device_list_v2.power')}',
|
||||
),
|
||||
);
|
||||
dataItems.add(const SizedBox(width: 16));
|
||||
dataItems.add(_buildDataItem('${device.todayEnergy}', 'kWh | 今日发电'));
|
||||
} else if (device.type == '汇流箱') {
|
||||
dataItems.add(
|
||||
_buildDataItem(
|
||||
'${device.todayEnergy}',
|
||||
'${AppLocalizations.of(context).translate('device_list_v2.today_energy')}',
|
||||
),
|
||||
);
|
||||
} else if (device.type == 'combiner_box') {
|
||||
if (device.current != null) {
|
||||
dataItems.add(_buildDataItem('${device.current}', 'A | 电流'));
|
||||
dataItems.add(
|
||||
_buildDataItem(
|
||||
'${device.current}',
|
||||
'${AppLocalizations.of(context).translate('device_list_v2.current')}',
|
||||
),
|
||||
);
|
||||
dataItems.add(const SizedBox(width: 16));
|
||||
}
|
||||
if (device.temperature != null) {
|
||||
dataItems.add(_buildDataItem('${device.temperature}', '℃ | 温度'));
|
||||
dataItems.add(
|
||||
_buildDataItem(
|
||||
'${device.temperature}',
|
||||
'${AppLocalizations.of(context).translate('device_list_v2.temperature')}',
|
||||
),
|
||||
);
|
||||
}
|
||||
} else if (device.type == '组件') {
|
||||
dataItems.add(_buildDataItem('${device.power}', 'kW | 功率'));
|
||||
} else if (device.type == 'module') {
|
||||
dataItems.add(
|
||||
_buildDataItem(
|
||||
'${device.power}',
|
||||
'${AppLocalizations.of(context).translate('device_list_v2.power')}',
|
||||
),
|
||||
);
|
||||
dataItems.add(const SizedBox(width: 16));
|
||||
if (device.radiation != null) {
|
||||
dataItems.add(_buildDataItem('${device.radiation}', 'W/m² | 辐照度'));
|
||||
dataItems.add(
|
||||
_buildDataItem(
|
||||
'${device.radiation}',
|
||||
'${AppLocalizations.of(context).translate('device_list_v2.radiation')}',
|
||||
),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// 监控等其他类型
|
||||
dataItems.add(_buildDataItem('--', '数据'));
|
||||
dataItems.add(
|
||||
_buildDataItem(
|
||||
'--',
|
||||
'${AppLocalizations.of(context).translate('device_list_v2.data')}',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Row(
|
||||
children: dataItems,
|
||||
);
|
||||
return Row(children: dataItems);
|
||||
}
|
||||
|
||||
Widget _buildDataItem(String value, String unit) {
|
||||
@@ -205,10 +227,7 @@ class DeviceItemWidget extends StatelessWidget {
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
unit,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Color(0xFF4E5969),
|
||||
),
|
||||
style: const TextStyle(fontSize: 12, color: Color(0xFF4E5969)),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
|
||||
/// 机器人卡片组件
|
||||
class RobotItemCard extends StatelessWidget {
|
||||
@@ -83,7 +84,9 @@ class RobotItemCard extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
alias != null && alias!.isNotEmpty ? '别名: $alias' : 'ID: $id',
|
||||
alias != null && alias!.isNotEmpty
|
||||
? '别名: $alias'
|
||||
: 'ID: $id',
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Color(0xFF86909C),
|
||||
@@ -111,14 +114,14 @@ class RobotItemCard extends StatelessWidget {
|
||||
battery > 50
|
||||
? Icons.battery_full
|
||||
: battery > 20
|
||||
? Icons.battery_std
|
||||
: Icons.battery_alert,
|
||||
? Icons.battery_std
|
||||
: Icons.battery_alert,
|
||||
size: 16,
|
||||
color: battery > 50
|
||||
? const Color(0xFF00B42A)
|
||||
: battery > 20
|
||||
? const Color(0xFFFF7D00)
|
||||
: const Color(0xFFF53F3F),
|
||||
? const Color(0xFFFF7D00)
|
||||
: const Color(0xFFF53F3F),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
@@ -129,15 +132,17 @@ class RobotItemCard extends StatelessWidget {
|
||||
color: battery > 50
|
||||
? const Color(0xFF00B42A)
|
||||
: battery > 20
|
||||
? const Color(0xFFFF7D00)
|
||||
: const Color(0xFFF53F3F),
|
||||
? const Color(0xFFFF7D00)
|
||||
: const Color(0xFFF53F3F),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
const Text(
|
||||
'电量',
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.battery_level'),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Color(0xFF4E5969),
|
||||
@@ -162,8 +167,10 @@ class RobotItemCard extends StatelessWidget {
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
const Text(
|
||||
'当前任务',
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.current_task'),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Color(0xFF4E5969),
|
||||
@@ -208,23 +215,17 @@ class RobotItemCard extends StatelessWidget {
|
||||
color: bgColor,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
status,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: textColor,
|
||||
),
|
||||
),
|
||||
child: Text(status, style: TextStyle(fontSize: 12, color: textColor)),
|
||||
);
|
||||
}
|
||||
|
||||
String _getRobotImage() {
|
||||
switch (type) {
|
||||
case '巡检机器人':
|
||||
case 'inspection':
|
||||
return 'assets/images/xunjian.png';
|
||||
case '清洗机器人':
|
||||
case 'cleaning':
|
||||
return 'assets/images/qinxi.png';
|
||||
case '除草机器人':
|
||||
case 'weeding':
|
||||
return 'assets/images/chucao.png';
|
||||
default:
|
||||
return 'assets/images/xunjian.png';
|
||||
|
||||
Reference in New Issue
Block a user