接入设备故障告警和场站实时任务进度
This commit is contained in:
@@ -9,6 +9,10 @@ import 'package:maibu_satabot_v2/features/pv_control/presentation/pages/pv_contr
|
||||
import 'package:maibu_satabot_v2/features/pv_control/presentation/widgets/pv_work_map.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../../../device_alarms/presentation/cubit/device_alarms_cubit.dart';
|
||||
import '../../../../device_alarms/presentation/widgets/device_alarm_dialog.dart';
|
||||
import '../../../../device_alarms/presentation/widgets/device_alarm_section.dart';
|
||||
import '../../../../device_alarms/presentation/widgets/device_alarm_summary_card.dart';
|
||||
import '../../../../device_control_mode/domain/entities/device_control_mode.dart';
|
||||
import '../../../../device_control_mode/presentation/widgets/control_mode_entry_gate.dart';
|
||||
import '../../../../devices/domain/entities/device_entity.dart';
|
||||
@@ -49,7 +53,7 @@ import 'route_editor_page_v2.dart';
|
||||
/// 仍跳 RobotControlPage,跳转前置(setTargetDevice + robotMap)与旧直进分支逐行一致,方便新旧对照。
|
||||
///
|
||||
/// 数据口径:在线态/电量/任务用接口真值(与列表卡同一口径,不造假);
|
||||
/// 后端暂未返回的字段(GNSS/割刀/故障等)显示 --,版本/位置用 DeviceV2Display 稳定占位。
|
||||
/// 后端暂未返回的字段(GNSS/割刀等)显示 --,版本/位置用 DeviceV2Display 稳定占位。
|
||||
class DeviceDetailPageV2 extends StatefulWidget {
|
||||
final RobotDataModel robot;
|
||||
|
||||
@@ -121,7 +125,7 @@ class _DeviceDetailPageV2State extends State<DeviceDetailPageV2> {
|
||||
static const _danger = Color(0xFFF0483E);
|
||||
static const _tabKeys = [
|
||||
'tab_overview',
|
||||
// 'tab_monitor', // 上架版暂时隐藏监测分栏。
|
||||
'tab_monitor',
|
||||
'tab_control',
|
||||
'tab_record',
|
||||
'tab_settings',
|
||||
@@ -129,6 +133,17 @@ class _DeviceDetailPageV2State extends State<DeviceDetailPageV2> {
|
||||
|
||||
String _tabKey = 'tab_overview';
|
||||
bool _modeDialogOpen = false;
|
||||
late final DeviceAlarmsCubit _alarmsCubit;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// 进入详情即订阅,不依赖切换设备或进入控制页。
|
||||
final sn = widget.robot.name.trim();
|
||||
GetIt.I<DeviceStatusBloc>().startMqttRealtimeListening(sn);
|
||||
_alarmsCubit = GetIt.I<DeviceAlarmsCubit>();
|
||||
_alarmsCubit.logSnapshot('进入设备详情', deviceSn: sn);
|
||||
}
|
||||
|
||||
/// 当前机型的版本(来自列表接口 productModel);null/空串时为 unknown
|
||||
DeviceEdition get _edition => widget.robot.modelInfo.edition;
|
||||
@@ -574,7 +589,7 @@ class _DeviceDetailPageV2State extends State<DeviceDetailPageV2> {
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 概览:运行概况六宫格(数据取自「设备数据监控」,点击弹原弹窗) =====
|
||||
// ===== 概览:运行概况(数据取自「设备数据监控」,点击弹原弹窗) =====
|
||||
Widget _buildOverviewSection() {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return BlocBuilder<DeviceStatusBloc, DeviceStatusState>(
|
||||
@@ -1147,10 +1162,7 @@ class _DeviceDetailPageV2State extends State<DeviceDetailPageV2> {
|
||||
),
|
||||
const Spacer(),
|
||||
GestureDetector(
|
||||
onTap: () => CapsuleToast.show(
|
||||
l10n.translate('device_list_v2.feature_todo'),
|
||||
showCheck: false,
|
||||
),
|
||||
onTap: _showFaultRecords,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
@@ -1970,109 +1982,14 @@ class _DeviceDetailPageV2State extends State<DeviceDetailPageV2> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFaultRecordCard() {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return GestureDetector(
|
||||
onTap: _showFaultRecords,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: const Color(0xFFE5EDF7)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 36,
|
||||
height: 36,
|
||||
decoration: BoxDecoration(
|
||||
color: _offlineBg,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
size: 20,
|
||||
color: _offlineGray,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(
|
||||
l10n.translate('robot_fault_v2.empty'),
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: _gray,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Icon(Icons.chevron_right, size: 18, color: Color(0xFFC9CDD4)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
Widget _buildFaultRecordCard() =>
|
||||
DeviceAlarmSummaryCard(cubit: _alarmsCubit, deviceSn: widget.robot.name);
|
||||
|
||||
void _showFaultRecords() {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
useSafeArea: true,
|
||||
backgroundColor: Colors.white,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(24)),
|
||||
),
|
||||
builder: (sheetContext) => SafeArea(
|
||||
top: false,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.fromLTRB(16, 6, 16, 32),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
l10n.translate('device_detail_v2.rec_fault_title'),
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
tooltip: l10n.translate('common.close'),
|
||||
onPressed: () => Navigator.of(sheetContext).pop(),
|
||||
icon: const Icon(Icons.close_rounded, color: _navy),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Container(
|
||||
width: 48,
|
||||
height: 48,
|
||||
decoration: BoxDecoration(
|
||||
color: _offlineBg,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.receipt_long_outlined,
|
||||
color: _offlineGray,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
l10n.translate('robot_fault_v2.empty'),
|
||||
style: const TextStyle(fontSize: 14, color: _gray),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
showDeviceAlarmDialog(
|
||||
context,
|
||||
cubit: _alarmsCubit,
|
||||
deviceSn: widget.robot.name,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2488,70 +2405,8 @@ class _DeviceDetailPageV2State extends State<DeviceDetailPageV2> {
|
||||
];
|
||||
}
|
||||
|
||||
// 故障详情接口接入前使用占位文案。
|
||||
Widget _buildFaultSection() {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Text(
|
||||
l10n.translate('device_detail_v2.fault_state'),
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: const Color(0xFFE5EDF7)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: _offlineBg,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.info_outline,
|
||||
size: 22,
|
||||
color: _offlineGray,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
l10n.translate('device_detail_v2.fault_none'),
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
l10n.translate('device_detail_v2.fault_none_sub'),
|
||||
style: const TextStyle(fontSize: 12, color: _gray),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
Widget _buildFaultSection() =>
|
||||
DeviceAlarmSection(cubit: _alarmsCubit, deviceSn: widget.robot.name);
|
||||
|
||||
Widget _buildFunctionSection() => DeviceQuickActions(
|
||||
preferences: GetIt.I<SharedPreferences>(),
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import 'dart:async';
|
||||
import '../../../../autonomous_work/data/site_device_realtime_subscriptions.dart';
|
||||
import 'package:flutter/foundation.dart' show debugPrintSynchronously;
|
||||
import '../../../../device_alarms/presentation/cubit/device_alarms_cubit.dart';
|
||||
import '../../../../device_alarms/presentation/widgets/site_alarm_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
@@ -93,7 +97,10 @@ class DeviceStatusViewV2 extends StatefulWidget {
|
||||
State<DeviceStatusViewV2> createState() => _DeviceStatusViewV2State();
|
||||
}
|
||||
|
||||
class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
class _DeviceStatusViewV2State extends State<DeviceStatusViewV2>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
final _searchController = TextEditingController();
|
||||
final _v2SearchController = TextEditingController();
|
||||
final _v2SearchFocus = FocusNode();
|
||||
@@ -103,6 +110,9 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
|
||||
/// 当前缓存的 siteId,用于判断是否真的发生了变化
|
||||
int? _currentSiteId;
|
||||
late final DeviceAlarmsCubit _alarmsCubit;
|
||||
late final SiteDeviceRealtimeSubscriptions _realtimeSubscriptions;
|
||||
bool _hasEntered = false;
|
||||
|
||||
/// 🔥 下拉刷新计数器:变更时联动重建"全部"标签下的机器人/无人机场内嵌列表,
|
||||
/// 使其与统计卡片(DeviceStatusBloc)同步刷新,避免统计数字与实际卡片对不上
|
||||
@@ -111,6 +121,9 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_alarmsCubit = sl<DeviceAlarmsCubit>();
|
||||
_realtimeSubscriptions = sl<SiteDeviceRealtimeSubscriptions>();
|
||||
_hasEntered = widget.isActive;
|
||||
final siteCubit = sl<SiteCubit>();
|
||||
final roleKey = sl<AppUserCubit>().state.user?.roleKey;
|
||||
|
||||
@@ -131,20 +144,63 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
siteCubit.selectSite(firstSite);
|
||||
}
|
||||
_currentSiteId = sl<SiteCubit>().state.selectedSite?.id;
|
||||
debugPrintSynchronously(
|
||||
'[场站告警][设备Tab] 初始化 active=${widget.isActive} site=$_currentSiteId',
|
||||
);
|
||||
if (_hasEntered) _ensureRealtimeSubscriptions('首次进入设备页');
|
||||
_siteSub = sl<SiteCubit>().stream.listen((siteState) {
|
||||
if (!mounted) return;
|
||||
final newSiteId = siteState.selectedSite?.id;
|
||||
// 只有 siteId 真正变化时才刷新(避免无意义的重复请求)
|
||||
if (newSiteId != _currentSiteId) {
|
||||
_currentSiteId = newSiteId;
|
||||
if (_hasEntered) {
|
||||
unawaited(_realtimeSubscriptions.ensureSubscriptions(newSiteId));
|
||||
}
|
||||
_refreshCurrentTabForSiteChange(newSiteId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant DeviceStatusViewV2 oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
debugPrintSynchronously(
|
||||
'[场站告警][设备Tab] 可见状态 old=${oldWidget.isActive} new=${widget.isActive} site=$_currentSiteId',
|
||||
);
|
||||
if (widget.isActive) {
|
||||
_ensureRealtimeSubscriptions(
|
||||
oldWidget.isActive ? '设备页重新显示' : '切回设备Tab',
|
||||
refresh: !oldWidget.isActive,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void _ensureRealtimeSubscriptions(String reason, {bool refresh = false}) {
|
||||
final siteId = sl<SiteCubit>().state.selectedSite?.id;
|
||||
debugPrintSynchronously(
|
||||
'[场站订阅][ENTRY] $reason active=${widget.isActive} site=$siteId',
|
||||
);
|
||||
if (!widget.isActive) return;
|
||||
_hasEntered = true;
|
||||
unawaited(_realtimeSubscriptions.ensureSubscriptions(siteId, refresh: refresh));
|
||||
}
|
||||
|
||||
@override
|
||||
void reassemble() {
|
||||
super.reassemble();
|
||||
// 热重载保留 State,不能只依赖 initState 启动和输出订阅。
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted && widget.isActive) {
|
||||
_ensureRealtimeSubscriptions('热重载后检查设备页订阅', refresh: true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_siteSub?.cancel();
|
||||
if (_hasEntered) unawaited(_realtimeSubscriptions.ensureSubscriptions(null));
|
||||
_searchController.dispose();
|
||||
_v2SearchController.dispose();
|
||||
_v2SearchFocus.dispose();
|
||||
@@ -224,6 +280,7 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 无设备页/卡片总览均为固定浅色设计,状态栏图标须恒为深色;
|
||||
super.build(context);
|
||||
// 若跟随深色主题给白色图标,会消失在浅蓝背景上。
|
||||
final blocState = context.watch<DeviceListBloc.DeviceStatusBloc>().state;
|
||||
final fixedLightUi =
|
||||
@@ -264,7 +321,7 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
// 无设备:该场站设备接口返回空时,整页(含顶栏)切换到
|
||||
// 「01_无设备首页」设计稿页面;逻辑链保持 场站→siteId→设备列表 不变。
|
||||
if (_isNoDeviceState(state)) {
|
||||
return const NoDevicePageV2();
|
||||
return NoDevicePageV2(alarmsCubit: _alarmsCubit);
|
||||
}
|
||||
// 有数据:整页切到「02_设备卡片总览」设计稿 UI。
|
||||
if (state is DeviceListState.DeviceStatusLoaded) {
|
||||
@@ -433,7 +490,8 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
name: (r.alias != null && r.alias!.isNotEmpty) ? r.alias! : r.name,
|
||||
// 型号 · 版本:由 getSiteList 的 productModel 解析(如 MC700 · PRO 旗舰版)
|
||||
modelText: r.modelLabelOf(AppLocalizations.of(context)),
|
||||
snKey: r.id,
|
||||
// SN 与设备详情一致,取 deviceName,不使用数字设备主键。
|
||||
snKey: r.name,
|
||||
status: _robotV2Status(r),
|
||||
battery: r.isOnline ? r.battery.round() : null,
|
||||
robot: r,
|
||||
@@ -527,6 +585,7 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
const DeviceListEvent.DeviceStatusRefresh(),
|
||||
);
|
||||
setState(() => _refreshTick++);
|
||||
unawaited(_realtimeSubscriptions.ensureSubscriptions(_currentSiteId, refresh: true));
|
||||
},
|
||||
child: CustomScrollView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
@@ -564,9 +623,9 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
padding: const EdgeInsets.all(40),
|
||||
child: Center(
|
||||
child: Text(
|
||||
AppLocalizations.of(context).translate(
|
||||
'device_list_v2.no_matching_device',
|
||||
),
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.no_matching_device'),
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: _v2Gray,
|
||||
@@ -707,7 +766,9 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
final message = state.errorMessage;
|
||||
if (message == null) return;
|
||||
CapsuleToast.show(
|
||||
message.isEmpty ? l10n.translate('device_list_v2.rename_failed') : message,
|
||||
message.isEmpty
|
||||
? l10n.translate('device_list_v2.rename_failed')
|
||||
: message,
|
||||
showCheck: false,
|
||||
);
|
||||
context.read<RenameDeviceCubit>().reset();
|
||||
@@ -806,9 +867,8 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
const Spacer(),
|
||||
Row(
|
||||
children: [
|
||||
// 上架版隐藏消息入口,接入真实通知后恢复。
|
||||
// _buildV2TopIconButton(Icons.notifications_none, onTap: _v2Todo),
|
||||
// const SizedBox(width: 10),
|
||||
SiteAlarmButton(cubit: _alarmsCubit),
|
||||
const SizedBox(width: 10),
|
||||
_buildV2TopIconButton(
|
||||
Icons.add,
|
||||
onTap: () => _showV2AddSheet(context),
|
||||
@@ -1385,7 +1445,12 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
Widget _buildStatCards(int all, int online, int working, int offline) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
final stats = [
|
||||
(Icons.smart_toy_rounded, _v2Blue, all, l10n.translate('device_list_v2.stat_total')),
|
||||
(
|
||||
Icons.smart_toy_rounded,
|
||||
_v2Blue,
|
||||
all,
|
||||
l10n.translate('device_list_v2.stat_total'),
|
||||
),
|
||||
(
|
||||
Icons.wifi_rounded,
|
||||
_v2Blue,
|
||||
@@ -1476,9 +1541,7 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
)
|
||||
AppLocalizations.of(context)
|
||||
.translate('device_list_v2.total_devices_count')
|
||||
.replaceAll('%s', '$all'),
|
||||
style: const TextStyle(fontSize: 12, color: _v2Blue),
|
||||
@@ -1679,10 +1742,9 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
|
||||
Widget _buildOverviewTelemetry(_V2DeviceItem e) {
|
||||
final sn = e.robot?.name.trim();
|
||||
final online = e.status != DeviceV2Status.offline;
|
||||
final battery = e.battery;
|
||||
return OverviewDeviceTelemetry(
|
||||
deviceSn: widget.isActive && online && sn != null && sn.isNotEmpty
|
||||
deviceSn: widget.isActive && sn != null && sn.isNotEmpty
|
||||
? sn
|
||||
: null,
|
||||
batteryFallback: e.robot != null
|
||||
@@ -2982,12 +3044,9 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.device_type_not_supported').replaceAll(
|
||||
'%s',
|
||||
deviceType,
|
||||
),
|
||||
AppLocalizations.of(context)
|
||||
.translate('device_list_v2.device_type_not_supported')
|
||||
.replaceAll('%s', deviceType),
|
||||
),
|
||||
duration: const Duration(seconds: 2),
|
||||
),
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../../device_alarms/presentation/cubit/device_alarms_cubit.dart';
|
||||
import '../../../../device_alarms/presentation/widgets/site_alarm_button.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
// import 'package:maibu_satabot_v2/components/app_logo.dart';
|
||||
@@ -27,7 +29,8 @@ import 'qr_scanner_page_v2.dart';
|
||||
/// - 背景用设计稿地图背景切图 shebei_bg.png,车图为透明底 shebei-logo.png,
|
||||
/// 车与背景分层不粘连。
|
||||
class NoDevicePageV2 extends StatelessWidget {
|
||||
const NoDevicePageV2({super.key});
|
||||
const NoDevicePageV2({super.key, this.alarmsCubit});
|
||||
final DeviceAlarmsCubit? alarmsCubit;
|
||||
|
||||
// ===== 固定视觉配色(与登录页/我的页 V2 同系) =====
|
||||
static const _bgTop = Color(0xFFFAFCFF);
|
||||
@@ -150,12 +153,10 @@ class NoDevicePageV2 extends StatelessWidget {
|
||||
const Spacer(),
|
||||
Row(
|
||||
children: [
|
||||
// 上架版隐藏消息入口,接入真实通知后恢复。
|
||||
// _buildTopIconButton(
|
||||
// Icons.notifications_none,
|
||||
// onTap: () => _todoTap(context),
|
||||
// ),
|
||||
// const SizedBox(width: 10),
|
||||
if (alarmsCubit case final cubit?) ...[
|
||||
SiteAlarmButton(cubit: cubit),
|
||||
const SizedBox(width: 10),
|
||||
],
|
||||
_buildTopIconButton(
|
||||
Icons.add,
|
||||
onTap: () => _showAddSheet(context),
|
||||
@@ -192,11 +193,7 @@ class NoDevicePageV2 extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Icon(
|
||||
icon,
|
||||
size: 22,
|
||||
color: primary ? Colors.white : _navy,
|
||||
),
|
||||
child: Icon(icon, size: 22, color: primary ? Colors.white : _navy),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -451,11 +448,7 @@ class NoDevicePageV2 extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(
|
||||
Icons.close,
|
||||
size: 20,
|
||||
color: _grayText,
|
||||
),
|
||||
icon: const Icon(Icons.close, size: 20, color: _grayText),
|
||||
onPressed: () => Navigator.pop(sheetCtx),
|
||||
),
|
||||
],
|
||||
@@ -545,10 +538,7 @@ class NoDevicePageV2 extends StatelessWidget {
|
||||
children: [
|
||||
Icon(icon, size: 20, color: _navy),
|
||||
const SizedBox(width: 12),
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(fontSize: 15, color: _navy),
|
||||
),
|
||||
Text(label, style: const TextStyle(fontSize: 15, color: _navy)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -599,11 +589,7 @@ class NoDevicePageV2 extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
const Icon(
|
||||
Icons.chevron_right,
|
||||
size: 20,
|
||||
color: Color(0xFFC9CDD4),
|
||||
),
|
||||
const Icon(Icons.chevron_right, size: 20, color: Color(0xFFC9CDD4)),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -10,6 +10,8 @@ import 'package:latlong2/latlong.dart';
|
||||
import 'package:maibu_satabot_v2/components/capsule_toast.dart';
|
||||
import 'package:maibu_satabot_v2/core/di/injection.dart';
|
||||
import 'package:maibu_satabot_v2/core/logging/work_trace_diagnostics.dart';
|
||||
import 'package:maibu_satabot_v2/features/autonomous_work/data/site_device_realtime_subscriptions.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/site/presentation/cubit/site_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/autonomous_work/domain/entities/work_session_models.dart';
|
||||
import 'package:maibu_satabot_v2/features/autonomous_work/domain/repositories/autonomous_work_gateway.dart';
|
||||
import 'package:maibu_satabot_v2/features/devices/domain/entities/running_status_entity.dart';
|
||||
@@ -24,6 +26,7 @@ import '../widgets/autonomous/work_record_panels.dart';
|
||||
import '../widgets/autonomous/work_route_panels.dart';
|
||||
import '../widgets/autonomous/work_setting_panel.dart';
|
||||
import '../widgets/autonomous/work_ui.dart';
|
||||
import '../widgets/autonomous/work_task_status_card.dart';
|
||||
import '../widgets/find_robot_sheet.dart';
|
||||
import '../widgets/voice_broadcast_sheet.dart';
|
||||
import 'robot_control_page.dart';
|
||||
@@ -106,6 +109,7 @@ class _RobotAutonomousWorkPageV2State extends State<RobotAutonomousWorkPageV2> {
|
||||
int _routeLoadGeneration = 0;
|
||||
|
||||
bool _infoExpanded = true;
|
||||
bool _taskInfoExpanded = false;
|
||||
|
||||
String get _deviceId => widget.robot.name;
|
||||
bool get _isOnline => widget.robot.isOnline;
|
||||
@@ -1165,6 +1169,8 @@ class _RobotAutonomousWorkPageV2State extends State<RobotAutonomousWorkPageV2> {
|
||||
],
|
||||
SizedBox(width: m.topGap),
|
||||
_statusDetailButton(m),
|
||||
SizedBox(width: m.topTight ? 6 : m.topGap),
|
||||
_statusDetailButton(m, taskStatus: true),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -1379,27 +1385,40 @@ class _RobotAutonomousWorkPageV2State extends State<RobotAutonomousWorkPageV2> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _statusDetailButton(_WorkLayout m) {
|
||||
Widget _statusDetailButton(_WorkLayout m, {bool taskStatus = false}) {
|
||||
final k = m.topK;
|
||||
final selected = taskStatus ? _taskInfoExpanded : _infoExpanded;
|
||||
return InkWell(
|
||||
onTap: () => setState(() => _infoExpanded = !_infoExpanded),
|
||||
onTap: () => setState(() {
|
||||
if (taskStatus) {
|
||||
_taskInfoExpanded = !_taskInfoExpanded;
|
||||
_infoExpanded = false;
|
||||
} else {
|
||||
_infoExpanded = !_infoExpanded;
|
||||
_taskInfoExpanded = false;
|
||||
}
|
||||
}),
|
||||
borderRadius: BorderRadius.circular((13 * k).clamp(10.0, 13.0)),
|
||||
child: Container(
|
||||
height: (38 * k).clamp(26.0, 38.0),
|
||||
padding: EdgeInsets.symmetric(horizontal: (16 * k).clamp(10.0, 16.0)),
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: selected ? kWtSoftBlue : Colors.white,
|
||||
borderRadius: BorderRadius.circular((13 * k).clamp(10.0, 13.0)),
|
||||
border: Border.all(color: kWtBorder),
|
||||
border: Border.all(color: selected ? kWtBlue : kWtBorder),
|
||||
),
|
||||
child: Text(
|
||||
_l10n.translate('autonomous_work.status_details'),
|
||||
_l10n.translate(
|
||||
taskStatus
|
||||
? 'autonomous_work.task_status.title'
|
||||
: 'autonomous_work.status_details',
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: (13.5 * k).clamp(10.0, 13.5),
|
||||
height: 1.1,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: kWtNavy,
|
||||
color: selected ? kWtBlue : kWtNavy,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1503,25 +1522,23 @@ class _RobotAutonomousWorkPageV2State extends State<RobotAutonomousWorkPageV2> {
|
||||
|
||||
// ===== 左列:机器人信息(头部/头像/底按钮固定,数据行区限高整行滚动)=====
|
||||
Widget _buildLeftColumn(_WorkLayout m) {
|
||||
final showTaskCard = _phase.hasTask && m.cardMaxH >= 430;
|
||||
return Positioned(
|
||||
left: m.margin,
|
||||
top: m.contentTop,
|
||||
width: m.cardW,
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(maxHeight: m.cardMaxH),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildRobotInfoCard(m),
|
||||
if (showTaskCard) ...[
|
||||
const SizedBox(height: 8),
|
||||
_buildCurrentTaskCard(m),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
child: _taskInfoExpanded
|
||||
? WorkTaskStatusCard(
|
||||
subscriptions: sl<SiteDeviceRealtimeSubscriptions>(),
|
||||
siteId: sl<SiteCubit>().state.selectedSite?.id,
|
||||
deviceSn: _deviceId,
|
||||
expectedTaskId: _session?.taskId,
|
||||
compact: m.compact,
|
||||
maxHeight: m.cardMaxH,
|
||||
onCollapse: () => setState(() => _taskInfoExpanded = false),
|
||||
)
|
||||
: SingleChildScrollView(child: _buildRobotInfoCard(m)),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -1844,88 +1861,6 @@ class _RobotAutonomousWorkPageV2State extends State<RobotAutonomousWorkPageV2> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCurrentTaskCard(_WorkLayout m) {
|
||||
final task = _session;
|
||||
final progress = task?.progress; // null = 该环境不提供进度
|
||||
final subTitle = switch (_phase) {
|
||||
WorkRunState.running => _l10n.translate('autonomous_work.task_running'),
|
||||
WorkRunState.paused => _l10n.translate('autonomous_work.task_paused'),
|
||||
WorkRunState.failed => _l10n.translate(
|
||||
'autonomous_work.task_interrupted',
|
||||
),
|
||||
WorkRunState.queued => _l10n.translate('autonomous_work.task_queued'),
|
||||
WorkRunState.idle => _l10n.translate('autonomous_work.task_not_started'),
|
||||
WorkRunState.finished => _l10n.translate('autonomous_work.task_ended'),
|
||||
};
|
||||
return Container(
|
||||
padding: EdgeInsets.all(m.compact ? 10 : 14),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x1A1A2B4A),
|
||||
blurRadius: 18,
|
||||
offset: Offset(0, 6),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
subTitle,
|
||||
style: TextStyle(fontSize: m.fsx(11.5, 8.5), color: kWtGray),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
progress == null ? '—' : '${(progress * 100).round()}%',
|
||||
style: TextStyle(
|
||||
fontSize: m.fsx(24, 16),
|
||||
fontWeight: FontWeight.w800,
|
||||
color: kWtNavy,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(999),
|
||||
child: LinearProgressIndicator(
|
||||
value: progress,
|
||||
minHeight: 6,
|
||||
backgroundColor: kWtSegBg,
|
||||
valueColor: const AlwaysStoppedAnimation<Color>(kWtGreen),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_kvRow(
|
||||
m,
|
||||
_l10n.translate('pv_control.task_field_no'),
|
||||
task == null ? '—' : '#${task.taskId}',
|
||||
),
|
||||
_kvRow(
|
||||
m,
|
||||
_l10n.translate('pv_control.task_field_status'),
|
||||
task == null || task.rawStatus.isEmpty
|
||||
? workRunStateLabel(_phase, _l10n)
|
||||
: '${workRunStateLabel(_phase, _l10n)} · ${task.rawStatus}',
|
||||
),
|
||||
_kvRow(m, _l10n.translate('work_v2.all_work.route'), _routeName),
|
||||
if (task?.routeId != null)
|
||||
_kvRow(
|
||||
m,
|
||||
_l10n.translate('pv_control.task_field_route'),
|
||||
task!.routeId!,
|
||||
),
|
||||
_kvRow(
|
||||
m,
|
||||
_l10n.translate('autonomous_work.dispatched_at'),
|
||||
task?.createdAt ?? '—',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 右侧功能栏(按可用高度均分,保证 6 项完整可见)=====
|
||||
Widget _buildRightRail(_WorkLayout m) {
|
||||
final compact = m.compact;
|
||||
@@ -2299,7 +2234,10 @@ class _RobotAutonomousWorkPageV2State extends State<RobotAutonomousWorkPageV2> {
|
||||
null,
|
||||
2,
|
||||
() {
|
||||
setState(() => _infoExpanded = true);
|
||||
setState(() {
|
||||
_infoExpanded = true;
|
||||
_taskInfoExpanded = false;
|
||||
});
|
||||
CapsuleToast.show(
|
||||
_l10n.translate('autonomous_work.robot_status_opened'),
|
||||
showCheck: false,
|
||||
|
||||
Reference in New Issue
Block a user