重整多余的UI组件和未定功能的逻辑链路的修正
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
// import 'package:maibu_satabot_v2/components/app_logo.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/core/theme/AppTheme.dart';
|
||||
import '../../../../../core/di/injection.dart';
|
||||
@@ -40,6 +41,7 @@ import 'bind_device_page_v2.dart';
|
||||
import 'no_device_page_v2.dart';
|
||||
import 'package:maibu_satabot_v2/components/capsule_toast.dart';
|
||||
import '../widgets/device_card_v2.dart';
|
||||
import '../widgets/overview_device_telemetry.dart';
|
||||
import '../widgets/rename_device_dialog.dart';
|
||||
import 'package:maibu_satabot_v2/features/pv_control/presentation/widgets/pv_work_map.dart';
|
||||
import '../../data/models/robot_data_model.dart';
|
||||
@@ -57,7 +59,9 @@ import 'package:get_it/get_it.dart';
|
||||
/// 卡片点击跳转、蓝牙连接流程等逻辑与旧页逐行一致,仅替换视觉层;
|
||||
/// 旧页保留可随时回退(main_wrapper 切回 DeviceStatusPage 即可)。
|
||||
class DeviceStatusPageV2 extends StatelessWidget {
|
||||
const DeviceStatusPageV2({super.key});
|
||||
const DeviceStatusPageV2({super.key, this.isActive = true});
|
||||
|
||||
final bool isActive;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -74,14 +78,16 @@ class DeviceStatusPageV2 extends StatelessWidget {
|
||||
// 设备改名:UI 只调 Cubit,不直接依赖 UseCase/DataSource
|
||||
BlocProvider(create: (_) => sl<RenameDeviceCubit>()),
|
||||
],
|
||||
child: const DeviceStatusViewV2(),
|
||||
child: DeviceStatusViewV2(isActive: isActive),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 设备状态视图 V2
|
||||
class DeviceStatusViewV2 extends StatefulWidget {
|
||||
const DeviceStatusViewV2({super.key});
|
||||
const DeviceStatusViewV2({super.key, this.isActive = true});
|
||||
|
||||
final bool isActive;
|
||||
|
||||
@override
|
||||
State<DeviceStatusViewV2> createState() => _DeviceStatusViewV2State();
|
||||
@@ -89,6 +95,8 @@ class DeviceStatusViewV2 extends StatefulWidget {
|
||||
|
||||
class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
final _searchController = TextEditingController();
|
||||
final _v2SearchController = TextEditingController();
|
||||
final _v2SearchFocus = FocusNode();
|
||||
|
||||
/// 🔥 监听电站切换:只要电站发生变化,就根据当前选中的标签栏自动刷新对应接口
|
||||
StreamSubscription<SiteState>? _siteSub;
|
||||
@@ -138,6 +146,8 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
void dispose() {
|
||||
_siteSub?.cancel();
|
||||
_searchController.dispose();
|
||||
_v2SearchController.dispose();
|
||||
_v2SearchFocus.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -462,7 +472,7 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
final offlineCount = items
|
||||
.where((e) => e.status == DeviceV2Status.offline)
|
||||
.length;
|
||||
final visible = switch (_statusFilter) {
|
||||
final statusMatches = switch (_statusFilter) {
|
||||
'online' =>
|
||||
items.where((e) => e.status != DeviceV2Status.offline).toList(),
|
||||
'working' =>
|
||||
@@ -471,6 +481,10 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
items.where((e) => e.status == DeviceV2Status.offline).toList(),
|
||||
_ => items,
|
||||
};
|
||||
final query = _v2SearchController.text.trim().toLowerCase();
|
||||
final visible = query.isEmpty
|
||||
? statusMatches
|
||||
: statusMatches.where((item) => item.matchesSearch(query)).toList();
|
||||
|
||||
// 集中概览模式:统计卡 + 设备分布地图 + 复用状态药丸 + 设备表格
|
||||
if (_viewMode == 'overview') {
|
||||
@@ -506,7 +520,7 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
// 搜索框 + 状态药丸用 SliverPersistentHeader 吸顶
|
||||
child: RefreshIndicator(
|
||||
color: _v2Blue,
|
||||
edgeOffset: _v2PinnedExtentCard,
|
||||
edgeOffset: _v2PinnedFilterExtent,
|
||||
onRefresh: () async {
|
||||
// 与旧「全部」下拉刷新一致:统计 + 两个列表一起重拉
|
||||
context.read<DeviceListBloc.DeviceStatusBloc>().add(
|
||||
@@ -516,6 +530,8 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
},
|
||||
child: CustomScrollView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
keyboardDismissBehavior:
|
||||
ScrollViewKeyboardDismissBehavior.onDrag,
|
||||
slivers: [
|
||||
SliverToBoxAdapter(
|
||||
child: Column(
|
||||
@@ -527,22 +543,11 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
],
|
||||
),
|
||||
),
|
||||
SliverPersistentHeader(
|
||||
pinned: true,
|
||||
delegate: _V2PinnedHeaderDelegate(
|
||||
extent: _v2PinnedExtentCard,
|
||||
child: Column(
|
||||
children: [
|
||||
_buildV2SearchBox(),
|
||||
_buildStatusPills(
|
||||
items.length,
|
||||
onlineCount,
|
||||
workingCount,
|
||||
offlineCount,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
_buildV2Filters(
|
||||
items.length,
|
||||
onlineCount,
|
||||
workingCount,
|
||||
offlineCount,
|
||||
),
|
||||
if (stillLoading)
|
||||
const SliverToBoxAdapter(
|
||||
@@ -791,22 +796,19 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
}
|
||||
}
|
||||
|
||||
// ===== V2 顶栏:logo + 铃铛/蓝色⊕(与无设备页同款) =====
|
||||
// ===== V2 顶栏:添加设备按钮(与无设备页同款) =====
|
||||
Widget _buildV2TopBar(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Image.asset(
|
||||
'assets/images/me_left_logo.png',
|
||||
height: 44,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
// const AppLogo(size: 44), // 暂时隐藏设备页左上角 Logo。
|
||||
const Spacer(),
|
||||
Row(
|
||||
children: [
|
||||
_buildV2TopIconButton(Icons.notifications_none, onTap: _v2Todo),
|
||||
const SizedBox(width: 10),
|
||||
// 上架版隐藏消息入口,接入真实通知后恢复。
|
||||
// _buildV2TopIconButton(Icons.notifications_none, onTap: _v2Todo),
|
||||
// const SizedBox(width: 10),
|
||||
_buildV2TopIconButton(
|
||||
Icons.add,
|
||||
onTap: () => _showV2AddSheet(context),
|
||||
@@ -1102,33 +1104,88 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 搜索框:纯展示。后端设备列表缺对应字段,暂不接搜索 =====
|
||||
Widget _buildV2Filters(int all, int online, int working, int offline) {
|
||||
return SliverPersistentHeader(
|
||||
pinned: true,
|
||||
delegate: _V2PinnedHeaderDelegate(
|
||||
extent: _v2PinnedFilterExtent,
|
||||
child: Column(
|
||||
children: [
|
||||
_buildV2SearchBox(),
|
||||
_buildStatusPills(all, online, working, offline),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildV2SearchBox() {
|
||||
final hint = AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.search_hint_full');
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
|
||||
child: IgnorePointer(
|
||||
child: Container(
|
||||
height: 44,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: _v2Border),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const SizedBox(width: 14),
|
||||
const Icon(Icons.search, size: 20, color: Color(0xFFC9CDD4)),
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.search_hint_full'),
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
color: Color(0xFFB9C2CF),
|
||||
child: TextFieldTapRegion(
|
||||
child: GestureDetector(
|
||||
onTap: _v2SearchFocus.requestFocus,
|
||||
child: Container(
|
||||
height: 44,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: _v2Border),
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const SizedBox(width: 14),
|
||||
const Icon(Icons.search, size: 20, color: Color(0xFFC9CDD4)),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Stack(
|
||||
alignment: Alignment.centerLeft,
|
||||
children: [
|
||||
Semantics(
|
||||
label: hint,
|
||||
child: TextField(
|
||||
controller: _v2SearchController,
|
||||
focusNode: _v2SearchFocus,
|
||||
textInputAction: TextInputAction.search,
|
||||
style: const TextStyle(fontSize: 14, color: _v2Navy),
|
||||
cursorColor: _v2Blue,
|
||||
onChanged: (_) => setState(() {}),
|
||||
decoration: null,
|
||||
),
|
||||
),
|
||||
if (_v2SearchController.text.isEmpty)
|
||||
IgnorePointer(
|
||||
child: ExcludeSemantics(
|
||||
child: Text(
|
||||
hint,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
color: Color(0xFFB9C2CF),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
if (_v2SearchController.text.isNotEmpty)
|
||||
IconButton(
|
||||
tooltip: MaterialLocalizations.of(
|
||||
context,
|
||||
).clearButtonTooltip,
|
||||
icon: const Icon(Icons.close, size: 18, color: _v2Gray),
|
||||
onPressed: () => setState(_v2SearchController.clear),
|
||||
)
|
||||
else
|
||||
const SizedBox(width: 14),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1212,9 +1269,11 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
children: [
|
||||
_buildOverviewAppBar(),
|
||||
Expanded(
|
||||
// 与卡片视图同口径:标题/视图切换随内容滚走,状态药丸吸顶
|
||||
// 标题和视图切换随内容滚动,搜索和状态筛选吸顶。
|
||||
child: CustomScrollView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
keyboardDismissBehavior:
|
||||
ScrollViewKeyboardDismissBehavior.onDrag,
|
||||
slivers: [
|
||||
SliverToBoxAdapter(
|
||||
child: Column(
|
||||
@@ -1224,17 +1283,11 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
],
|
||||
),
|
||||
),
|
||||
SliverPersistentHeader(
|
||||
pinned: true,
|
||||
delegate: _V2PinnedHeaderDelegate(
|
||||
extent: _v2PinnedExtentPills,
|
||||
child: _buildStatusPills(
|
||||
all,
|
||||
onlineCount,
|
||||
workingCount,
|
||||
offlineCount,
|
||||
),
|
||||
),
|
||||
_buildV2Filters(
|
||||
all,
|
||||
onlineCount,
|
||||
workingCount,
|
||||
offlineCount,
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
@@ -1328,7 +1381,7 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
);
|
||||
}
|
||||
|
||||
/// 四张统计卡:设备总数 / 在线设备 / 作业中 / 告警离线
|
||||
/// 四张统计卡:设备总数 / 在线设备 / 作业中 / 离线
|
||||
Widget _buildStatCards(int all, int online, int working, int offline) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
final stats = [
|
||||
@@ -1346,10 +1399,10 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
l10n.translate('device_list_v2.stat_working'),
|
||||
),
|
||||
(
|
||||
Icons.warning_amber_rounded,
|
||||
const Color(0xFFE5484D),
|
||||
Icons.link_off,
|
||||
const Color(0xFF6B7280),
|
||||
offline,
|
||||
l10n.translate('device_list_v2.stat_alarm_offline'),
|
||||
l10n.translate('device_list_v2.offline'),
|
||||
),
|
||||
];
|
||||
return Row(
|
||||
@@ -1494,7 +1547,7 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
child: Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.th_location_task'),
|
||||
).translate('device_detail_v2.stat_control_mode'),
|
||||
style: const TextStyle(fontSize: 12, color: _v2Gray),
|
||||
),
|
||||
),
|
||||
@@ -1567,31 +1620,7 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
),
|
||||
),
|
||||
Expanded(flex: 3, child: _buildOverviewBadge(e.status)),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text(
|
||||
_buildOverviewBattery(e),
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: _v2Navy,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 4,
|
||||
child: Text(
|
||||
e.robot != null
|
||||
? '${DeviceV2Display.locationOf(e.snKey, AppLocalizations.of(context))} · ${e.robot!.task}'
|
||||
: DeviceV2Display.locationOf(
|
||||
e.snKey,
|
||||
AppLocalizations.of(context),
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontSize: 11, color: _v2Gray),
|
||||
),
|
||||
),
|
||||
Expanded(flex: 6, child: _buildOverviewTelemetry(e)),
|
||||
const Icon(Icons.chevron_right, size: 18, color: Color(0xFFC9CDD4)),
|
||||
],
|
||||
),
|
||||
@@ -1648,10 +1677,18 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
);
|
||||
}
|
||||
|
||||
String _buildOverviewBattery(_V2DeviceItem e) {
|
||||
final b = e.battery;
|
||||
if (e.status == DeviceV2Status.offline || b == null) return '—';
|
||||
return '$b%';
|
||||
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
|
||||
? sn
|
||||
: null,
|
||||
batteryFallback: e.robot != null
|
||||
? '--'
|
||||
: (battery == null ? '—' : '$battery%'),
|
||||
);
|
||||
}
|
||||
|
||||
/// 行内设备缩略图:蓝渐变底 + logo;离线置灰
|
||||
@@ -3160,12 +3197,8 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
}
|
||||
}
|
||||
|
||||
/// V2 卡片列表的统一展示项:机器人 / 无人机机场二选一
|
||||
/// 吸顶过滤栏高度:卡片视图 = 搜索框(56) + 状态药丸(42)
|
||||
const double _v2PinnedExtentCard = 98;
|
||||
|
||||
/// 吸顶过滤栏高度:集中概览视图 = 状态药丸(42)
|
||||
const double _v2PinnedExtentPills = 42;
|
||||
/// 吸顶过滤栏高度 = 搜索框(56) + 状态药丸(42)
|
||||
const double _v2PinnedFilterExtent = 98;
|
||||
|
||||
/// 吸顶过滤栏:滚动压过内容时平滑补上底色与阴影,避免卡片从下方穿帮
|
||||
class _V2PinnedHeaderDelegate extends SliverPersistentHeaderDelegate {
|
||||
@@ -3237,4 +3270,19 @@ class _V2DeviceItem {
|
||||
final int? battery;
|
||||
final RobotDataModel? robot;
|
||||
final DroneStationEntity? station;
|
||||
|
||||
bool matchesSearch(String query) {
|
||||
final fields = [
|
||||
name,
|
||||
modelText,
|
||||
snKey,
|
||||
robot?.name,
|
||||
robot?.productName,
|
||||
robot?.productModel,
|
||||
station?.deviceSn,
|
||||
];
|
||||
return fields.whereType<String>().any(
|
||||
(field) => field.toLowerCase().contains(query),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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/components/app_logo.dart';
|
||||
import 'package:maibu_satabot_v2/components/capsule_toast.dart';
|
||||
import 'package:maibu_satabot_v2/core/app/app_user_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
@@ -19,7 +20,7 @@ import 'qr_scanner_page_v2.dart';
|
||||
/// DeviceStatusLoaded 且 devices 为空时,由 DeviceStatusView 整页切换到本页。
|
||||
///
|
||||
/// 说明:
|
||||
/// - 顶栏按设计稿换新:SATA logo + 铃铛/⊕ 白底按钮;
|
||||
/// - 顶栏右侧提供添加设备按钮;
|
||||
/// - 右上角按钮下方小字「(场站名)」为切换场站入口,个人角色追加「个人账号」说明;
|
||||
/// - 「添加机器人」与卡片蓝色 ⊕ 均弹出底部添加弹窗,内部各项保持原跳转;
|
||||
/// - 「新手入门」三条二级内容未开发,统一 Toast 提示;
|
||||
@@ -141,24 +142,20 @@ class NoDevicePageV2 extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 顶栏:logo + 铃铛/⊕(设计稿新样式) =====
|
||||
// ===== 顶栏:添加设备按钮 =====
|
||||
Widget _buildTopBar(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Image.asset(
|
||||
'assets/images/me_left_logo.png',
|
||||
height: 44,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
// const AppLogo(size: 44), // 暂时隐藏设备页左上角 Logo。
|
||||
const Spacer(),
|
||||
Row(
|
||||
children: [
|
||||
_buildTopIconButton(
|
||||
Icons.notifications_none,
|
||||
onTap: () => _todoTap(context),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
// 设计稿:右上角 ⊕ 是蓝底白号主色按钮,与铃铛的白底按钮区分
|
||||
// 上架版隐藏消息入口,接入真实通知后恢复。
|
||||
// _buildTopIconButton(
|
||||
// Icons.notifications_none,
|
||||
// onTap: () => _todoTap(context),
|
||||
// ),
|
||||
// const SizedBox(width: 10),
|
||||
_buildTopIconButton(
|
||||
Icons.add,
|
||||
onTap: () => _showAddSheet(context),
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -24,7 +24,7 @@ class RobotFullInfoPageV2 extends StatelessWidget {
|
||||
static const Color _cardBorder = Color(0xFFE5EDF7);
|
||||
static const Color _green = Color(0xFF2FBF6B);
|
||||
static const Color _greenBg = Color(0xFFE5F8EC);
|
||||
static const Color _statBg = Color(0xFFEAF3FE);
|
||||
// static const Color _statBg = Color(0xFFEAF3FE); // 运行与控制信息。
|
||||
static const Color _divider = Color(0xFFF0F4FA);
|
||||
|
||||
static const String _robotImage = 'assets/images/robot_logo_login.png';
|
||||
@@ -53,12 +53,22 @@ class RobotFullInfoPageV2 extends StatelessWidget {
|
||||
.replaceFirst('%s', sn.substring(sn.length - 2));
|
||||
}
|
||||
|
||||
/*
|
||||
/// 电量:0 视为未上报
|
||||
String get _batteryText {
|
||||
final b = robot.battery;
|
||||
if (b <= 0) return '--';
|
||||
return '${b.round()}%';
|
||||
}
|
||||
*/
|
||||
|
||||
String get _deviceTypeText {
|
||||
final types = {
|
||||
robot.deviceTypeName?.trim() ?? '',
|
||||
robot.deviceType?.trim() ?? '',
|
||||
}..remove('');
|
||||
return types.isEmpty ? '--' : types.join(' · ');
|
||||
}
|
||||
|
||||
/// 运行模式:任务字段为“无/空”时按待机展示(返回空串表示待机)
|
||||
String get _modeText {
|
||||
@@ -108,12 +118,15 @@ class RobotFullInfoPageV2 extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildProfileCard(l10n),
|
||||
// 上架版暂时隐藏运行与控制信息。
|
||||
/*
|
||||
const SizedBox(height: 18),
|
||||
_buildSectionTitle(
|
||||
l10n.translate('robot_full_info_v2.sec_runtime'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildRuntimeCard(l10n),
|
||||
*/
|
||||
const SizedBox(height: 14),
|
||||
Center(
|
||||
child: Text(
|
||||
@@ -339,22 +352,27 @@ class RobotFullInfoPageV2 extends StatelessWidget {
|
||||
),
|
||||
_buildInfoRow(
|
||||
l10n.translate('robot_full_info_v2.row_type'),
|
||||
l10n.translate('robot_full_info_v2.val_type'),
|
||||
_deviceTypeText,
|
||||
),
|
||||
_buildInfoRow(
|
||||
l10n.translate('robot_full_info_v2.row_power'),
|
||||
l10n.translate('robot_full_info_v2.val_power'),
|
||||
isLast: true,
|
||||
),
|
||||
// 上架版暂时隐藏最近上报。
|
||||
/*
|
||||
_buildInfoRow(
|
||||
l10n.translate('robot_full_info_v2.row_report'),
|
||||
l10n.translate('robot_full_info_v2.val_report'),
|
||||
isLast: true,
|
||||
),
|
||||
*/
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
// ===== 运行与控制卡 =====
|
||||
Widget _buildRuntimeCard(AppLocalizations l10n) {
|
||||
return Container(
|
||||
@@ -448,6 +466,7 @@ class RobotFullInfoPageV2 extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
// ===== 通用信息行:左标签 / 右值 =====
|
||||
Widget _buildInfoRow(
|
||||
|
||||
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';
|
||||
|
||||
/// 自主作业二次确认弹窗(横屏)——对应设计稿 5 种确认框:
|
||||
/// 开始作业 / 暂停作业 / 停止作业 / 取消待执行 / 继续·断点续作。
|
||||
@@ -52,6 +53,7 @@ class _WorkConfirmDialog extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
final accent = danger ? _danger : _blue;
|
||||
return Dialog(
|
||||
backgroundColor: Colors.transparent,
|
||||
@@ -124,12 +126,12 @@ class _WorkConfirmDialog extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
for (final check in checks) ...[
|
||||
_checkRow(check),
|
||||
_checkRow(check, l10n),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
const SizedBox(height: 6),
|
||||
const Text(
|
||||
'这是视觉交互演示。实际确认结果必须等待机器人回执;超时不能直接显示成功。',
|
||||
Text(
|
||||
l10n.translate('autonomous_work.confirmation_demo_note'),
|
||||
style: TextStyle(
|
||||
fontSize: 11.5,
|
||||
height: 1.6,
|
||||
@@ -146,7 +148,7 @@ class _WorkConfirmDialog extends StatelessWidget {
|
||||
children: [
|
||||
Expanded(
|
||||
child: _button(
|
||||
label: '返回',
|
||||
label: l10n.translate('common.back'),
|
||||
onTap: () => Navigator.of(context).pop(false),
|
||||
),
|
||||
),
|
||||
@@ -168,7 +170,7 @@ class _WorkConfirmDialog extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _checkRow(String text) {
|
||||
Widget _checkRow(String text, AppLocalizations l10n) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 11),
|
||||
@@ -191,8 +193,8 @@ class _WorkConfirmDialog extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Text(
|
||||
'待设备校验',
|
||||
Text(
|
||||
l10n.translate('autonomous_work.pending_device_check'),
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w700,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/core/di/injection.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';
|
||||
@@ -25,6 +26,8 @@ class _WorkRecordPanel extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _WorkRecordPanelState extends State<_WorkRecordPanel> {
|
||||
AppLocalizations get _l10n => AppLocalizations.of(context);
|
||||
|
||||
late Future<WorkResult<List<WorkTaskSnapshot>>> _records = _load();
|
||||
Future<WorkResult<List<WorkTaskSnapshot>>> _load() async {
|
||||
final gateway = sl<AutonomousWorkGateway>();
|
||||
@@ -33,14 +36,16 @@ class _WorkRecordPanelState extends State<_WorkRecordPanel> {
|
||||
deviceId: widget.deviceId,
|
||||
);
|
||||
}
|
||||
return const WorkResult.fail('当前环境尚未提供真实作业记录');
|
||||
return WorkResult.fail(
|
||||
_l10n.translate('autonomous_work.records_unavailable'),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WorkPanelScaffold(
|
||||
title: '自主作业记录',
|
||||
desc: '显示任务池中的结束任务及本机收到的完成通知;未提供的面积、耗时不作估算。',
|
||||
title: _l10n.translate('autonomous_work.records_title'),
|
||||
desc: _l10n.translate('autonomous_work.records_description'),
|
||||
body: FutureBuilder<WorkResult<List<WorkTaskSnapshot>>>(
|
||||
future: _records,
|
||||
builder: (context, snapshot) {
|
||||
@@ -48,9 +53,14 @@ class _WorkRecordPanelState extends State<_WorkRecordPanel> {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
final result = snapshot.data!;
|
||||
if (!result.isOk) return Text(result.error ?? '记录加载失败');
|
||||
if (!result.isOk)
|
||||
return Text(
|
||||
result.error ??
|
||||
_l10n.translate('autonomous_work.records_load_failed'),
|
||||
);
|
||||
final records = result.data ?? const <WorkTaskSnapshot>[];
|
||||
if (records.isEmpty) return const Text('该设备暂无可查询的作业记录');
|
||||
if (records.isEmpty)
|
||||
return Text(_l10n.translate('autonomous_work.records_empty'));
|
||||
return Column(
|
||||
children: [
|
||||
for (final task in records)
|
||||
@@ -61,15 +71,36 @@ class _WorkRecordPanelState extends State<_WorkRecordPanel> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
task.routeName ?? '任务 #${task.taskId}',
|
||||
task.routeName ??
|
||||
_l10n.translate('autonomous_work.task_number', {
|
||||
'id': task.taskId,
|
||||
}),
|
||||
style: const TextStyle(fontWeight: FontWeight.w700),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(task.rawStatus == 'FINISH' ? '已完成' : '已终止'),
|
||||
Text('任务 ID:${task.taskId}'),
|
||||
Text(
|
||||
task.rawStatus == 'FINISH'
|
||||
? _l10n.translate('work_v2.plan.status_done')
|
||||
: _l10n.translate('autonomous_work.terminated'),
|
||||
),
|
||||
Text(
|
||||
_l10n.translate('autonomous_work.record_task_id', {
|
||||
'id': task.taskId,
|
||||
}),
|
||||
),
|
||||
if (task.createdAt != null)
|
||||
Text('下发时间:${task.createdAt}'),
|
||||
Text('已接收到达点:${task.completedPoints.length} 个'),
|
||||
Text(
|
||||
_l10n.translate(
|
||||
'autonomous_work.record_dispatched_at',
|
||||
{'time': task.createdAt},
|
||||
),
|
||||
),
|
||||
Text(
|
||||
_l10n.translate(
|
||||
'autonomous_work.record_completed_points',
|
||||
{'count': task.completedPoints.length},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -82,14 +113,14 @@ class _WorkRecordPanelState extends State<_WorkRecordPanel> {
|
||||
children: [
|
||||
Expanded(
|
||||
child: WorkButton(
|
||||
label: '刷新记录',
|
||||
label: _l10n.translate('autonomous_work.records_refresh'),
|
||||
onTap: () => setState(() => _records = _load()),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: WorkButton(
|
||||
label: '返回地图',
|
||||
label: _l10n.translate('autonomous_work.back_to_map'),
|
||||
primary: true,
|
||||
onTap: widget.onClose,
|
||||
),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/components/capsule_toast.dart';
|
||||
import 'package:maibu_satabot_v2/core/di/injection.dart';
|
||||
import 'package:maibu_satabot_v2/features/autonomous_work/domain/entities/work_session_models.dart';
|
||||
@@ -55,6 +56,8 @@ class _RouteLibraryPanel extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _RouteLibraryPanelState extends State<_RouteLibraryPanel> {
|
||||
AppLocalizations get _l10n => AppLocalizations.of(context);
|
||||
|
||||
late final AutonomousWorkGateway _gateway = sl<AutonomousWorkGateway>();
|
||||
|
||||
List<WorkRouteOption> _routes = const <WorkRouteOption>[];
|
||||
@@ -80,7 +83,7 @@ class _RouteLibraryPanelState extends State<_RouteLibraryPanel> {
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_loading = false;
|
||||
_error = '请先在首页选择场站';
|
||||
_error = _l10n.translate('work_v2.plan_create.no_site');
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -89,7 +92,7 @@ class _RouteLibraryPanelState extends State<_RouteLibraryPanel> {
|
||||
setState(() {
|
||||
_loading = false;
|
||||
_routes = result.data ?? const <WorkRouteOption>[];
|
||||
_error = _routes.isEmpty ? (result.error ?? '该场站下暂无作业路线') : null;
|
||||
_error = _routes.isEmpty ? (result.error ?? _l10n.translate('work_v2.route_lib.empty_site')) : null;
|
||||
if (_selectedId != null && !_routes.any((r) => r.id == _selectedId)) {
|
||||
_selectedId = null;
|
||||
}
|
||||
@@ -107,15 +110,15 @@ class _RouteLibraryPanelState extends State<_RouteLibraryPanel> {
|
||||
Widget build(BuildContext context) {
|
||||
final showEdit = _gateway.capabilities.routeEditing;
|
||||
return WorkPanelScaffold(
|
||||
title: '路线库 · 选择已有路线',
|
||||
desc: '一个区域可保存多条路线。执行期间可预览,但更换执行路线前必须先安全停止原任务并重新确认。',
|
||||
title: _l10n.translate('autonomous_work.route_library_title'),
|
||||
desc: _l10n.translate('autonomous_work.route_library_description'),
|
||||
body: _buildBody(),
|
||||
footer: Row(
|
||||
children: [
|
||||
if (showEdit) ...[
|
||||
Expanded(
|
||||
child: WorkButton(
|
||||
label: '+ 新建 / 编辑',
|
||||
label: _l10n.translate('autonomous_work.route_create_edit'),
|
||||
onTap: () => Navigator.of(
|
||||
context,
|
||||
).pop(const WorkRoutePanelResult.edit()),
|
||||
@@ -125,12 +128,12 @@ class _RouteLibraryPanelState extends State<_RouteLibraryPanel> {
|
||||
],
|
||||
Expanded(
|
||||
child: WorkButton(
|
||||
label: '确认路线',
|
||||
label: _l10n.translate('autonomous_work.route_confirm'),
|
||||
primary: true,
|
||||
onTap: () {
|
||||
final route = _selectedRoute();
|
||||
if (route == null) {
|
||||
CapsuleToast.show('请先选择一条路线', showCheck: false);
|
||||
CapsuleToast.show(_l10n.translate('autonomous_work.route_required'), showCheck: false);
|
||||
return;
|
||||
}
|
||||
Navigator.of(context).pop(WorkRoutePanelResult.select(route));
|
||||
@@ -156,7 +159,7 @@ class _RouteLibraryPanelState extends State<_RouteLibraryPanel> {
|
||||
children: [
|
||||
Text(error, style: const TextStyle(fontSize: 12.5, color: kWtGray)),
|
||||
const SizedBox(height: 12),
|
||||
WorkButton(label: '重新加载', onTap: _load),
|
||||
WorkButton(label: _l10n.translate('work_v2.all_work.retry'), onTap: _load),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -173,7 +176,7 @@ class _RouteLibraryPanelState extends State<_RouteLibraryPanel> {
|
||||
Widget _routeRow(int index, WorkRouteOption route) {
|
||||
final selected = _selectedId == route.id;
|
||||
// 列表接口往往只给元数据(几何在选中后补全),所以不在这里提示“无路径数据”
|
||||
final subtitle = route.metaText ?? route.planModeLabel ?? '';
|
||||
final subtitle = workRouteSummary(route, _l10n);
|
||||
return InkWell(
|
||||
onTap: () => setState(() => _selectedId = route.id),
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
@@ -242,7 +245,7 @@ class _RouteLibraryPanelState extends State<_RouteLibraryPanel> {
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
subtitle.isEmpty ? '路线 #${route.id}' : subtitle,
|
||||
subtitle.isEmpty ? _l10n.translate('autonomous_work.route_number', {'id': route.id}) : subtitle,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontSize: 11.5, color: kWtGray),
|
||||
@@ -291,6 +294,8 @@ class _TaskQueuePanel extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _TaskQueuePanelState extends State<_TaskQueuePanel> {
|
||||
AppLocalizations get _l10n => AppLocalizations.of(context);
|
||||
|
||||
late final AutonomousWorkGateway _gateway = sl<AutonomousWorkGateway>();
|
||||
|
||||
StreamSubscription<WorkTaskSnapshot?>? _sub;
|
||||
@@ -363,10 +368,10 @@ class _TaskQueuePanelState extends State<_TaskQueuePanel> {
|
||||
if (!mounted) return;
|
||||
setState(() => _busyTaskId = null);
|
||||
if (!result.isOk) {
|
||||
CapsuleToast.show(result.error ?? '取消失败', showCheck: false);
|
||||
CapsuleToast.show(result.error ?? _l10n.translate('autonomous_work.cancel_failed'), showCheck: false);
|
||||
return;
|
||||
}
|
||||
CapsuleToast.show('已取消任务 #${task.taskId}');
|
||||
CapsuleToast.show(_l10n.translate('autonomous_work.queue_task_canceled', {'id': task.taskId}));
|
||||
_load();
|
||||
}
|
||||
|
||||
@@ -385,28 +390,28 @@ class _TaskQueuePanelState extends State<_TaskQueuePanel> {
|
||||
if (!mounted) return;
|
||||
setState(() => _busyTaskId = null);
|
||||
if (!result.isOk) {
|
||||
CapsuleToast.show(result.error ?? '切换任务失败', showCheck: false);
|
||||
CapsuleToast.show(result.error ?? _l10n.translate('autonomous_work.queue_switch_failed'), showCheck: false);
|
||||
return;
|
||||
}
|
||||
widget.onClose();
|
||||
CapsuleToast.show('已切换到任务 #${task.taskId}');
|
||||
CapsuleToast.show(_l10n.translate('autonomous_work.queue_task_switched', {'id': task.taskId}));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WorkPanelScaffold(
|
||||
title: '多区域连续任务队列',
|
||||
desc: '尚未启动的任务可在此取消;正在执行的任务需要通过“停止作业”安全终止。',
|
||||
title: _l10n.translate('autonomous_work.queue_title'),
|
||||
desc: _l10n.translate('autonomous_work.queue_description'),
|
||||
body: _buildBody(),
|
||||
footer: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: WorkButton(label: '刷新队列', onTap: _load),
|
||||
child: WorkButton(label: _l10n.translate('autonomous_work.queue_refresh'), onTap: _load),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: WorkButton(
|
||||
label: '关闭',
|
||||
label: _l10n.translate('common.close'),
|
||||
primary: true,
|
||||
onTap: widget.onClose,
|
||||
),
|
||||
@@ -430,16 +435,16 @@ class _TaskQueuePanelState extends State<_TaskQueuePanel> {
|
||||
children: [
|
||||
Text(error, style: const TextStyle(fontSize: 12.5, color: kWtGray)),
|
||||
const SizedBox(height: 12),
|
||||
WorkButton(label: '重新加载', onTap: _load),
|
||||
WorkButton(label: _l10n.translate('work_v2.all_work.retry'), onTap: _load),
|
||||
],
|
||||
);
|
||||
}
|
||||
if (_tasks.isEmpty) {
|
||||
return const Padding(
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 24),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'该设备当前没有活跃任务',
|
||||
_l10n.translate('autonomous_work.queue_empty'),
|
||||
style: TextStyle(fontSize: 12.5, color: kWtGray),
|
||||
),
|
||||
),
|
||||
@@ -491,7 +496,7 @@ class _TaskQueuePanelState extends State<_TaskQueuePanel> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
task.routeName ?? '任务 #${task.taskId}',
|
||||
task.routeName ?? _l10n.translate('autonomous_work.task_number', {'id': task.taskId}),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
@@ -504,14 +509,14 @@ class _TaskQueuePanelState extends State<_TaskQueuePanel> {
|
||||
Row(
|
||||
children: [
|
||||
WorkChip(
|
||||
text: task.state.label,
|
||||
text: workRunStateLabel(task.state, _l10n),
|
||||
background: bg,
|
||||
foreground: fg,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Expanded(
|
||||
child: Text(
|
||||
task.createdAt ?? '任务 #${task.taskId}',
|
||||
task.createdAt ?? _l10n.translate('autonomous_work.task_number', {'id': task.taskId}),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontSize: 11, color: kWtGray),
|
||||
@@ -525,7 +530,7 @@ class _TaskQueuePanelState extends State<_TaskQueuePanel> {
|
||||
if (cancelable)
|
||||
TextButton(
|
||||
onPressed: busy ? null : () => _cancel(task),
|
||||
child: Text(busy ? '处理中…' : '取消'),
|
||||
child: Text(busy ? _l10n.translate('autonomous_work.processing') : _l10n.translate('common.cancel')),
|
||||
)
|
||||
else
|
||||
const Icon(
|
||||
@@ -573,45 +578,47 @@ class _SchedulePanel extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _SchedulePanelState extends State<_SchedulePanel> {
|
||||
AppLocalizations get _l10n => AppLocalizations.of(context);
|
||||
|
||||
bool _enabled = true;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WorkPanelScaffold(
|
||||
title: '定时任务计划',
|
||||
desc: '时间到达后需执行安全准入验证,不代表机器人可以无人监护地无条件启动。',
|
||||
title: _l10n.translate('autonomous_work.schedule_title'),
|
||||
desc: _l10n.translate('autonomous_work.schedule_description'),
|
||||
body: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_field(
|
||||
label: '作业路线',
|
||||
child: WorkSelectPill('A区 · 路线01', onTap: _demoSelect),
|
||||
label: _l10n.translate('work_v2.all_work.route'),
|
||||
child: WorkSelectPill(_l10n.translate('autonomous_work.demo_route'), onTap: _demoSelect),
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
_field(
|
||||
label: '执行日期',
|
||||
label: _l10n.translate('autonomous_work.schedule_date'),
|
||||
child: _textFieldLike('10/21/2026', Icons.calendar_today_outlined),
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
_field(
|
||||
label: '时间',
|
||||
label: _l10n.translate('autonomous_work.schedule_time'),
|
||||
child: _textFieldLike('08:30 AM', Icons.schedule_outlined),
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
_field(
|
||||
label: '重复规则',
|
||||
child: WorkSelectPill('仅一次', onTap: _demoSelect),
|
||||
label: _l10n.translate('autonomous_work.schedule_repeat'),
|
||||
child: WorkSelectPill(_l10n.translate('autonomous_work.schedule_once'), onTap: _demoSelect),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
WorkCard(
|
||||
child: Row(
|
||||
children: [
|
||||
const Expanded(
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'启用计划',
|
||||
_l10n.translate('autonomous_work.schedule_enabled'),
|
||||
style: TextStyle(
|
||||
fontSize: 13.5,
|
||||
fontWeight: FontWeight.w800,
|
||||
@@ -620,7 +627,7 @@ class _SchedulePanelState extends State<_SchedulePanel> {
|
||||
),
|
||||
SizedBox(height: 4),
|
||||
Text(
|
||||
'需满足安全策略与权限',
|
||||
_l10n.translate('autonomous_work.schedule_safety'),
|
||||
style: TextStyle(fontSize: 11.5, color: kWtGray),
|
||||
),
|
||||
],
|
||||
@@ -638,15 +645,15 @@ class _SchedulePanelState extends State<_SchedulePanel> {
|
||||
footer: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: WorkButton(label: '取消', onTap: widget.onClose),
|
||||
child: WorkButton(label: _l10n.translate('common.cancel'), onTap: widget.onClose),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: WorkButton(
|
||||
label: '保存计划',
|
||||
label: _l10n.translate('autonomous_work.schedule_save'),
|
||||
primary: true,
|
||||
onTap: () {
|
||||
CapsuleToast.show('计划下发通道未接入,仅作视觉演示', showCheck: false);
|
||||
CapsuleToast.show(_l10n.translate('autonomous_work.schedule_demo'), showCheck: false);
|
||||
widget.onClose();
|
||||
},
|
||||
),
|
||||
@@ -704,6 +711,6 @@ class _SchedulePanelState extends State<_SchedulePanel> {
|
||||
}
|
||||
|
||||
void _demoSelect() {
|
||||
CapsuleToast.show('表单选项为演示数据', showCheck: false);
|
||||
CapsuleToast.show(_l10n.translate('autonomous_work.schedule_demo_options'), showCheck: false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/components/capsule_toast.dart';
|
||||
|
||||
import 'work_ui.dart';
|
||||
@@ -25,13 +26,15 @@ class _WorkSettingPanel extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _WorkSettingPanelState extends State<_WorkSettingPanel> {
|
||||
AppLocalizations get _l10n => AppLocalizations.of(context);
|
||||
|
||||
static const List<String> _tabs = <String>[
|
||||
'路线覆盖',
|
||||
'执行割刀',
|
||||
'避障安全',
|
||||
'断点恢复',
|
||||
'返航策略',
|
||||
'弱网策略',
|
||||
'autonomous_work.settings_coverage',
|
||||
'autonomous_work.settings_blades',
|
||||
'autonomous_work.settings_obstacles',
|
||||
'autonomous_work.settings_resume',
|
||||
'autonomous_work.settings_return',
|
||||
'autonomous_work.settings_network',
|
||||
];
|
||||
|
||||
int _tab = 0;
|
||||
@@ -47,8 +50,8 @@ class _WorkSettingPanelState extends State<_WorkSettingPanel> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WorkPanelScaffold(
|
||||
title: '自主作业设置',
|
||||
desc: '本次任务可使用默认配置;任务执行中改变运动/割刀参数应先安全暂停并重新校验。',
|
||||
title: _l10n.translate('autonomous_work.settings_title'),
|
||||
desc: _l10n.translate('autonomous_work.settings_description'),
|
||||
body: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -64,15 +67,21 @@ class _WorkSettingPanelState extends State<_WorkSettingPanel> {
|
||||
footer: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: WorkButton(label: '取消', onTap: widget.onClose),
|
||||
child: WorkButton(
|
||||
label: _l10n.translate('common.cancel'),
|
||||
onTap: widget.onClose,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: WorkButton(
|
||||
label: '保存设置(演示)',
|
||||
label: _l10n.translate('autonomous_work.settings_save'),
|
||||
primary: true,
|
||||
onTap: () {
|
||||
CapsuleToast.show('设置已保存为本地演示偏好,未向设备下发参数', showCheck: false);
|
||||
CapsuleToast.show(
|
||||
_l10n.translate('autonomous_work.settings_saved'),
|
||||
showCheck: false,
|
||||
);
|
||||
widget.onClose();
|
||||
},
|
||||
),
|
||||
@@ -95,7 +104,7 @@ class _WorkSettingPanelState extends State<_WorkSettingPanel> {
|
||||
border: Border.all(color: selected ? Colors.transparent : kWtBorder),
|
||||
),
|
||||
child: Text(
|
||||
_tabs[index],
|
||||
_l10n.translate(_tabs[index]),
|
||||
style: TextStyle(
|
||||
fontSize: 12.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
@@ -128,14 +137,32 @@ class _WorkSettingPanelState extends State<_WorkSettingPanel> {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const WorkSectionTitle('路径与覆盖规划参数'),
|
||||
_paramRow(title: '作业割幅', subtitle: '依据机型割刀尺寸', value: '1.20 m'),
|
||||
WorkSectionTitle(_l10n.translate('autonomous_work.coverage_title')),
|
||||
_paramRow(
|
||||
title: _l10n.translate('autonomous_work.cut_width'),
|
||||
subtitle: _l10n.translate('autonomous_work.cut_width_detail'),
|
||||
value: '1.20 m',
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_paramRow(title: '路线重叠率', subtitle: '仅影响新规划任务', value: '10%'),
|
||||
_paramRow(
|
||||
title: _l10n.translate('autonomous_work.route_overlap'),
|
||||
subtitle: _l10n.translate('autonomous_work.route_overlap_detail'),
|
||||
value: '10%',
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_paramRow(title: '规划方向', subtitle: '沿光伏阵列方向优先', value: '沿阵列'),
|
||||
_paramRow(
|
||||
title: _l10n.translate('autonomous_work.planning_direction'),
|
||||
subtitle: _l10n.translate(
|
||||
'autonomous_work.planning_direction_detail',
|
||||
),
|
||||
value: _l10n.translate('autonomous_work.along_array'),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_paramRow(title: '边缘处理', subtitle: '地块边界贴边作业策略', value: '标准'),
|
||||
_paramRow(
|
||||
title: _l10n.translate('autonomous_work.edge_handling'),
|
||||
subtitle: _l10n.translate('autonomous_work.edge_handling_detail'),
|
||||
value: _l10n.translate('autonomous_work.standard'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -145,21 +172,29 @@ class _WorkSettingPanelState extends State<_WorkSettingPanel> {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const WorkSectionTitle('作业执行与割刀'),
|
||||
_paramRow(title: '自主作业速度', subtitle: '受最大安全速度限制', value: '0.6 m/s'),
|
||||
WorkSectionTitle(_l10n.translate('autonomous_work.blade_section')),
|
||||
_paramRow(
|
||||
title: _l10n.translate('autonomous_work.autonomous_speed'),
|
||||
subtitle: _l10n.translate('autonomous_work.autonomous_speed_detail'),
|
||||
value: '0.6 m/s',
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
WorkParamRow(
|
||||
title: '任务内割刀自动启停',
|
||||
subtitle: '依据任务状态和必要的安全条件',
|
||||
title: _l10n.translate('autonomous_work.automatic_blade'),
|
||||
subtitle: _l10n.translate('autonomous_work.automatic_blade_detail'),
|
||||
trailing: WorkSwitch(
|
||||
value: _mowerAuto,
|
||||
onChanged: (v) => setState(() => _mowerAuto = v),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_paramRow(title: '底盘高度策略', subtitle: '当前设备可用时开放', value: '按任务配置'),
|
||||
_paramRow(
|
||||
title: _l10n.translate('autonomous_work.chassis_height'),
|
||||
subtitle: _l10n.translate('autonomous_work.chassis_height_detail'),
|
||||
value: _l10n.translate('autonomous_work.configured_per_task'),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
const WorkNoteBar(text: '割刀动作前必须核验安全互锁;没有可靠高度反馈的机器不展示虚假的刀盘状态。'),
|
||||
WorkNoteBar(text: _l10n.translate('autonomous_work.blade_safety_note')),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -169,28 +204,36 @@ class _WorkSettingPanelState extends State<_WorkSettingPanel> {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const WorkSectionTitle('避障与安全策略'),
|
||||
WorkSectionTitle(_l10n.translate('autonomous_work.obstacle_section')),
|
||||
WorkParamRow(
|
||||
title: '避障状态监测',
|
||||
subtitle: '查看前向感知和超声波状态',
|
||||
title: _l10n.translate('autonomous_work.obstacle_monitoring'),
|
||||
subtitle: _l10n.translate(
|
||||
'autonomous_work.obstacle_monitoring_detail',
|
||||
),
|
||||
trailing: WorkSwitch(
|
||||
value: _avoidMonitor,
|
||||
onChanged: (v) => setState(() => _avoidMonitor = v),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_paramRow(title: '障碍触发的任务处理', subtitle: '安全停车为优先策略', value: '暂停并等待'),
|
||||
_paramRow(
|
||||
title: _l10n.translate('autonomous_work.obstacle_response'),
|
||||
subtitle: _l10n.translate('autonomous_work.obstacle_response_detail'),
|
||||
value: _l10n.translate('autonomous_work.pause_wait'),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
WorkParamRow(
|
||||
title: '人员接近预警',
|
||||
subtitle: '适用的警示机制保持启用',
|
||||
title: _l10n.translate('autonomous_work.person_alert'),
|
||||
subtitle: _l10n.translate('autonomous_work.person_alert_detail'),
|
||||
trailing: WorkSwitch(
|
||||
value: _personAlert,
|
||||
onChanged: (v) => setState(() => _personAlert = v),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
const WorkNoteBar(text: '不可通过此页面关闭不可绕过的碰撞保护、急停及必要的安全互锁。'),
|
||||
WorkNoteBar(
|
||||
text: _l10n.translate('autonomous_work.obstacle_safety_note'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -200,20 +243,24 @@ class _WorkSettingPanelState extends State<_WorkSettingPanel> {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const WorkSectionTitle('断点与恢复'),
|
||||
WorkSectionTitle(_l10n.translate('autonomous_work.resume_section')),
|
||||
WorkParamRow(
|
||||
title: '断点续作',
|
||||
subtitle: '任务中断或暂停后保留断点位置与已覆盖区域',
|
||||
title: _l10n.translate('autonomous_work.resume_checkpoint'),
|
||||
subtitle: _l10n.translate('autonomous_work.resume_checkpoint_detail'),
|
||||
trailing: WorkSwitch(
|
||||
value: _breakpointResume,
|
||||
onChanged: (v) => setState(() => _breakpointResume = v),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_paramRow(title: '恢复前校验', subtitle: '定位质量与路线版本必须匹配', value: '严格校验'),
|
||||
_paramRow(
|
||||
title: _l10n.translate('autonomous_work.resume_checks'),
|
||||
subtitle: _l10n.translate('autonomous_work.resume_checks_detail'),
|
||||
value: _l10n.translate('autonomous_work.strict_checks'),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
const WorkNoteBar(
|
||||
text: '断点恢复依赖可靠的定位与任务回执;校验不通过时应重新选择任务。',
|
||||
WorkNoteBar(
|
||||
text: _l10n.translate('autonomous_work.resume_note'),
|
||||
background: kWtSoftBlue,
|
||||
foreground: kWtBlue,
|
||||
),
|
||||
@@ -226,12 +273,26 @@ class _WorkSettingPanelState extends State<_WorkSettingPanel> {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const WorkSectionTitle('返航与收尾'),
|
||||
_paramRow(title: '任务结束后动作', subtitle: '任务完成后设备默认动作', value: '原地待命'),
|
||||
WorkSectionTitle(_l10n.translate('autonomous_work.return_section')),
|
||||
_paramRow(
|
||||
title: _l10n.translate('autonomous_work.completion_action'),
|
||||
subtitle: _l10n.translate('autonomous_work.completion_action_detail'),
|
||||
value: _l10n.translate('autonomous_work.standby_in_place'),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_paramRow(title: '低电量返航阈值', subtitle: '低于阈值触发返航提示', value: '20%'),
|
||||
_paramRow(
|
||||
title: _l10n.translate('autonomous_work.low_battery_threshold'),
|
||||
subtitle: _l10n.translate(
|
||||
'autonomous_work.low_battery_threshold_detail',
|
||||
),
|
||||
value: '20%',
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_paramRow(title: '返航通道', subtitle: '当前设备未开放自动返航指令位', value: '仅提示'),
|
||||
_paramRow(
|
||||
title: _l10n.translate('autonomous_work.return_channel'),
|
||||
subtitle: _l10n.translate('autonomous_work.return_channel_detail'),
|
||||
value: _l10n.translate('autonomous_work.notify_only'),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
);
|
||||
@@ -242,29 +303,33 @@ class _WorkSettingPanelState extends State<_WorkSettingPanel> {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const WorkSectionTitle('弱网与重连'),
|
||||
WorkSectionTitle(_l10n.translate('autonomous_work.network_section')),
|
||||
WorkParamRow(
|
||||
title: '弱网重连',
|
||||
subtitle: '信号波动时自动重建链路',
|
||||
title: _l10n.translate('autonomous_work.network_reconnect'),
|
||||
subtitle: _l10n.translate('autonomous_work.network_reconnect_detail'),
|
||||
trailing: WorkSwitch(
|
||||
value: _weakReconnect,
|
||||
onChanged: (v) => setState(() => _weakReconnect = v),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_paramRow(title: '指令超时处理', subtitle: '超时后不重发危险指令', value: '仅提示'),
|
||||
_paramRow(
|
||||
title: _l10n.translate('autonomous_work.command_timeout'),
|
||||
subtitle: _l10n.translate('autonomous_work.command_timeout_detail'),
|
||||
value: _l10n.translate('autonomous_work.notify_only'),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
WorkParamRow(
|
||||
title: '定时任务准入',
|
||||
subtitle: '启用计划任务执行前的安全准入验证',
|
||||
title: _l10n.translate('autonomous_work.scheduled_safety'),
|
||||
subtitle: _l10n.translate('autonomous_work.scheduled_safety_detail'),
|
||||
trailing: WorkSwitch(
|
||||
value: _scheduleEnabled,
|
||||
onChanged: (v) => setState(() => _scheduleEnabled = v),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
const WorkNoteBar(
|
||||
text: '弱网下不缓存危险指令;恢复后可先在界面重新确认再下发。',
|
||||
WorkNoteBar(
|
||||
text: _l10n.translate('autonomous_work.network_safety_note'),
|
||||
background: kWtSoftBlue,
|
||||
foreground: kWtBlue,
|
||||
),
|
||||
@@ -285,6 +350,9 @@ class _WorkSettingPanelState extends State<_WorkSettingPanel> {
|
||||
}
|
||||
|
||||
void _demoSelect() {
|
||||
CapsuleToast.show('参数下发通道未接入,本页仅作视觉演示', showCheck: false);
|
||||
CapsuleToast.show(
|
||||
_l10n.translate('autonomous_work.settings_demo'),
|
||||
showCheck: false,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/features/autonomous_work/domain/entities/work_session_models.dart';
|
||||
|
||||
// 自主作业中心(横屏)共享视觉与通用组件(色板 / 抽屉 / 卡片 / 按钮)。
|
||||
//
|
||||
@@ -25,6 +27,36 @@ const Color kWtLocked = Color(0xFFF4F6F9);
|
||||
const Color kWtMuted = Color(0xFFB0BAC9);
|
||||
const Color kWtBarrier = Color(0x8C0B1B2B);
|
||||
|
||||
String workRunStateLabel(WorkRunState state, AppLocalizations l10n) =>
|
||||
l10n.translate(switch (state) {
|
||||
WorkRunState.idle => 'autonomous_work.stage_setup',
|
||||
WorkRunState.queued => 'work_v2.stat_pending',
|
||||
WorkRunState.running => 'work_v2.stat_running',
|
||||
WorkRunState.paused => 'autonomous_work.stage_pause',
|
||||
WorkRunState.finished => 'autonomous_work.ended',
|
||||
WorkRunState.failed => 'autonomous_work.interrupted',
|
||||
});
|
||||
|
||||
String workRouteModeLabel(WorkRouteOption route, AppLocalizations l10n) =>
|
||||
l10n.translate(route.coverageMode
|
||||
? 'route_planning.bow_mode'
|
||||
: 'route_planning.custom_mode');
|
||||
|
||||
String workRouteSummary(WorkRouteOption route, AppLocalizations l10n) {
|
||||
final details = [
|
||||
if (route.pathPoints.isNotEmpty)
|
||||
l10n.translate('autonomous_work.path_point_count', {
|
||||
'count': route.pathPoints.length,
|
||||
}),
|
||||
if (route.outerPoints.isNotEmpty)
|
||||
l10n.translate('autonomous_work.boundary_point_count', {
|
||||
'count': route.outerPoints.length,
|
||||
}),
|
||||
if (route.planModeLabel != null) workRouteModeLabel(route, l10n),
|
||||
];
|
||||
return details.isEmpty ? route.metaText ?? '' : details.join(' · ');
|
||||
}
|
||||
|
||||
/// 右侧抽屉面板:从右侧滑入的浮层卡片(设计稿为右侧浮动大卡)。
|
||||
Future<T?> showWorkRightPanel<T>(
|
||||
BuildContext context, {
|
||||
|
||||
Reference in New Issue
Block a user