重整多余的UI组件和未定功能的逻辑链路的修正
This commit is contained in:
@@ -26,6 +26,9 @@ class RobotDataModel {
|
||||
/// 展示位置在版本号(PRO / PLUS / STD)之前:`MC700 · PRO 旗舰版`。
|
||||
final String? deviceType;
|
||||
|
||||
/// 设备类型名称,保留接口 deviceTypeName 的原文。
|
||||
final String? deviceTypeName;
|
||||
|
||||
/// 归属信息:当前挂在哪个组织 / 场站 / 负责人下。
|
||||
///
|
||||
/// 后端 getSiteList 不一定回传这些字段,因此全部可空:
|
||||
@@ -51,6 +54,7 @@ class RobotDataModel {
|
||||
this.productName,
|
||||
this.productModel,
|
||||
this.deviceType,
|
||||
this.deviceTypeName,
|
||||
this.orgId,
|
||||
this.orgName,
|
||||
this.siteId,
|
||||
@@ -72,12 +76,13 @@ class RobotDataModel {
|
||||
|
||||
// 设备状态码(原始 status 字段)
|
||||
final statusCode = json['status'] ?? 0;
|
||||
final deviceTypeName = _pickStr(json['deviceTypeName']);
|
||||
|
||||
return RobotDataModel(
|
||||
name: json['deviceName'] ?? json['name'] ?? '',
|
||||
id: json['deviceId']?.toString() ?? json['id']?.toString() ?? '',
|
||||
alias: json['deviceAlias'] as String?, // 获取别名字段
|
||||
type: _convertType(json['deviceTypeName'] ?? json['type'] ?? '未知类型'),
|
||||
type: _convertType(deviceTypeName ?? _pickStr(json['type']) ?? '未知类型'),
|
||||
status: isOnline ? '在线' : '离线',
|
||||
isOnline: isOnline,
|
||||
statusCode: statusCode is int ? statusCode : 0,
|
||||
@@ -86,7 +91,8 @@ class RobotDataModel {
|
||||
hasHost: json['hasHost'] as bool? ?? false,
|
||||
productName: _pickStr(json['productName']),
|
||||
productModel: _pickStr(json['productModel']),
|
||||
deviceType: _pickStr(json['deviceType'] ?? json['device_type']),
|
||||
deviceType: _pickStr(json['deviceType']) ?? _pickStr(json['device_type']),
|
||||
deviceTypeName: deviceTypeName,
|
||||
orgId: _pickInt(json, const ['orgId', 'org_id', 'organizationId']),
|
||||
orgName: _pickStr(
|
||||
json['orgName'] ?? json['org_name'] ?? json['organizationName'],
|
||||
@@ -153,6 +159,7 @@ class RobotDataModel {
|
||||
'productName': productName,
|
||||
'productModel': productModel,
|
||||
'deviceType': deviceType,
|
||||
'deviceTypeName': deviceTypeName,
|
||||
'orgId': orgId,
|
||||
'orgName': orgName,
|
||||
'siteId': siteId,
|
||||
|
||||
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, {
|
||||
|
||||
@@ -6,7 +6,9 @@ import 'package:maibu_satabot_v2/core/theme/AppTheme.dart';
|
||||
|
||||
/// 帮助与反馈页面
|
||||
class HelpFeedbackPage extends StatefulWidget {
|
||||
const HelpFeedbackPage({super.key});
|
||||
const HelpFeedbackPage({super.key, this.faqOnly = false});
|
||||
|
||||
final bool faqOnly;
|
||||
|
||||
@override
|
||||
State<HelpFeedbackPage> createState() => _HelpFeedbackPageState();
|
||||
@@ -81,6 +83,7 @@ class _HelpFeedbackPageState extends State<HelpFeedbackPage>
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return AnnotatedRegion<SystemUiOverlayStyle>(
|
||||
value: const SystemUiOverlayStyle(
|
||||
statusBarColor: Colors.transparent,
|
||||
@@ -95,7 +98,9 @@ class _HelpFeedbackPageState extends State<HelpFeedbackPage>
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context).translate('my_v2.help_feedback'),
|
||||
l10n.translate(
|
||||
widget.faqOnly ? 'help_feedback.tab_faq' : 'my_v2.help_feedback',
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -103,25 +108,26 @@ class _HelpFeedbackPageState extends State<HelpFeedbackPage>
|
||||
),
|
||||
),
|
||||
centerTitle: true,
|
||||
bottom: TabBar(
|
||||
controller: _tabController,
|
||||
labelColor: const Color(0xFF165DFF),
|
||||
unselectedLabelColor: context.appColors.textTertiary,
|
||||
indicatorColor: const Color(0xFF165DFF),
|
||||
indicatorSize: TabBarIndicatorSize.label,
|
||||
tabs: [
|
||||
Tab(text: AppLocalizations.of(context).translate('help_feedback.tab_faq')),
|
||||
Tab(text: AppLocalizations.of(context).translate('help_feedback.tab_feedback')),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: TabBarView(
|
||||
controller: _tabController,
|
||||
children: [
|
||||
_buildFAQTab(),
|
||||
_buildFeedbackTab(),
|
||||
],
|
||||
bottom: widget.faqOnly
|
||||
? null
|
||||
: TabBar(
|
||||
controller: _tabController,
|
||||
labelColor: const Color(0xFF165DFF),
|
||||
unselectedLabelColor: context.appColors.textTertiary,
|
||||
indicatorColor: const Color(0xFF165DFF),
|
||||
indicatorSize: TabBarIndicatorSize.label,
|
||||
tabs: [
|
||||
Tab(text: l10n.translate('help_feedback.tab_faq')),
|
||||
Tab(text: l10n.translate('help_feedback.tab_feedback')),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: widget.faqOnly
|
||||
? _buildFAQTab()
|
||||
: TabBarView(
|
||||
controller: _tabController,
|
||||
children: [_buildFAQTab(), _buildFeedbackTab()],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -129,12 +135,17 @@ class _HelpFeedbackPageState extends State<HelpFeedbackPage>
|
||||
// ==================== 常见问题 ====================
|
||||
|
||||
Widget _buildFAQTab() {
|
||||
const guideCategories = {'cat_bind', 'cat_path', 'cat_remote'};
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
..._faqList.map((category) => _buildFAQCategory(category)),
|
||||
const SizedBox(height: 20),
|
||||
_buildContactSection(),
|
||||
for (final category in _faqList)
|
||||
if (!widget.faqOnly || guideCategories.contains(category['category']))
|
||||
_buildFAQCategory(category),
|
||||
if (!widget.faqOnly) ...[
|
||||
const SizedBox(height: 20),
|
||||
_buildContactSection(),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,26 +2,18 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
// import 'package:maibu_satabot_v2/components/app_logo.dart';
|
||||
import 'package:maibu_satabot_v2/core/app/app_user_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/core/router/route_paths.dart';
|
||||
import 'package:maibu_satabot_v2/core/storage/user_storage.dart';
|
||||
import 'package:maibu_satabot_v2/core/utils/image_url_util.dart';
|
||||
import 'package:maibu_satabot_v2/components/capsule_toast.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/features/auth/presentation/bloc/auth_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/device_list/presentation/widgets/device_confirm_dialog.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/presentation/pages/help_feedback_page.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/presentation/pages/profile_detail_page.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/presentation/pages/system_settings_page.dart';
|
||||
|
||||
/// 我的页面 V2 —— 按 M01「我的首页」设计稿实现。
|
||||
///
|
||||
/// 说明:
|
||||
/// - 视觉:背景渐变复用登录页 V2(纵向浅蓝 + 左上/右上径向光晕);
|
||||
/// 顶部 me_left_logo.png + 铃铛/设置按钮;用户卡片底图用 logo_me_bg.png 切图。
|
||||
/// - 保留旧版 my_page.dart(本文件为新版,路由/Tab 已切到本页)。
|
||||
/// - 「编辑个人资料」→ 现有 ProfileDetailPage;「通用设置」→ 现有 SystemSettingsPage。
|
||||
/// - 数字(工单/保养/未读)暂无接口,按约定显示「未知」;未实现入口统一 Toast。
|
||||
/// - 退出登录按需求放在页脚下方。
|
||||
/// 我的首页提供个人信息、设置和常见问题入口。
|
||||
class MyPageV2 extends StatelessWidget {
|
||||
const MyPageV2({super.key});
|
||||
|
||||
@@ -33,30 +25,29 @@ class MyPageV2 extends StatelessWidget {
|
||||
static const _grayText = Color(0xFF86909C);
|
||||
static const _subText = Color(0xFF4E5969);
|
||||
static const _primaryBlue = Color(0xFF1C96F6);
|
||||
static const _orange = Color(0xFFF5A623);
|
||||
static const _iconBgBlue = Color(0xFFE9F3FE);
|
||||
static const _iconBgOrange = Color(0xFFFEF3E3);
|
||||
static const _divider = Color(0xFFF0F4FA);
|
||||
static const _noteBg = Color(0xFFEAF3FD);
|
||||
// 设计稿卡片描边:白卡周围那圈淡蓝边(实测约 RGB 241,247,254)
|
||||
static const _cardBorder = Color(0xFFE9F1FA);
|
||||
|
||||
/// 未实现入口的统一提示
|
||||
static void _todoTap(BuildContext context) {
|
||||
CapsuleToast.show(
|
||||
AppLocalizations.of(context).translate('my_v2.todo_developing'),
|
||||
showCheck: false,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final user = context.watch<AppUserCubit>().state.user;
|
||||
final userName =
|
||||
user?.nickname ??
|
||||
user?.username ??
|
||||
AppLocalizations.of(context).translate('my_v2.default_user_name');
|
||||
final userContact = user?.email ?? user?.phone;
|
||||
final l10n = AppLocalizations.of(context);
|
||||
final userName = [user?.nickname, user?.username]
|
||||
.whereType<String>()
|
||||
.map((name) => name.trim())
|
||||
.firstWhere(
|
||||
(name) => name.isNotEmpty,
|
||||
orElse: () => l10n.translate('my_v2.default_user_name'),
|
||||
);
|
||||
final userContact = [user?.email, user?.phone]
|
||||
.whereType<String>()
|
||||
.map((contact) => contact.trim())
|
||||
.firstWhere(
|
||||
(contact) => contact.isNotEmpty,
|
||||
orElse: () => l10n.translate('my_v2.contact_not_set'),
|
||||
);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: _bgTop,
|
||||
@@ -101,35 +92,12 @@ class MyPageV2 extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 12),
|
||||
_buildTopBar(context),
|
||||
const SizedBox(height: 16),
|
||||
// const AppLogo(size: 44), // 暂时隐藏「我的」页左上角 Logo。
|
||||
// const SizedBox(height: 16),
|
||||
_buildUserCard(context, userName, userContact, user?.avatar),
|
||||
const SizedBox(height: 14),
|
||||
_buildStatsRow(context),
|
||||
const SizedBox(height: 22),
|
||||
_buildSectionTitle(
|
||||
AppLocalizations.of(context).translate('my_v2.service_support'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildServiceGroup(context),
|
||||
const SizedBox(height: 22),
|
||||
_buildSectionTitle(
|
||||
AppLocalizations.of(context).translate('my_v2.account_settings'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildAccountGroup(context),
|
||||
const SizedBox(height: 16),
|
||||
_buildNoteCard(context),
|
||||
const SizedBox(height: 14),
|
||||
// 页脚灰字(设计稿)
|
||||
Center(
|
||||
child: Text(
|
||||
AppLocalizations.of(context).translate('my_v2.footer_note'),
|
||||
style: const TextStyle(fontSize: 11, color: _grayText),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
// 退出登录:按需求放在设计稿内容下方
|
||||
_buildLinks(context, isAdmin: user?.isAdmin == true),
|
||||
const SizedBox(height: 16),
|
||||
_buildLogoutButton(context),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
@@ -141,61 +109,11 @@ class MyPageV2 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,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
_buildTopIconButton(
|
||||
Icons.notifications_none,
|
||||
onTap: () => _todoTap(context),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
_buildTopIconButton(
|
||||
Icons.settings_outlined,
|
||||
onTap: () => _push(context, const SystemSettingsPage()),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTopIconButton(IconData icon, {required VoidCallback onTap}) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
width: 44,
|
||||
height: 44,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: _cardBorder),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: _primaryBlue.withValues(alpha: 0.05),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Icon(icon, size: 22, color: _navy),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 用户卡片:底图用 logo_me_bg.png 切图 =====
|
||||
Widget _buildUserCard(
|
||||
BuildContext context,
|
||||
String userName,
|
||||
String? userContact,
|
||||
String userContact,
|
||||
String? avatarUrl,
|
||||
) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
@@ -204,77 +122,64 @@ class MyPageV2 extends StatelessWidget {
|
||||
// 切图自身已烘进圆角、细描边与透明留白:不能再套 ClipRRect+cover,
|
||||
// 否则裁切会把描边线残留在卡片内部形成痕迹;fill 原样呈现即可。
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: Image.asset(
|
||||
'assets/images/logo_me_bg.png',
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: Image.asset(
|
||||
'assets/images/logo_me_bg.png',
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
children: [
|
||||
_buildAvatar(avatarUrl),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
userName,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 19,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Icon(
|
||||
Icons.chevron_right,
|
||||
size: 18,
|
||||
color: _navy,
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
children: [
|
||||
_buildAvatar(avatarUrl),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
userName,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 19,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _navy,
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
'${l10n.translate('my_v2.personal_account')} · ${userContact ?? l10n.translate('my_v2.contact_not_set')}',
|
||||
style: const TextStyle(
|
||||
fontSize: 12.5,
|
||||
color: _subText,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
l10n.translate('my_v2.edit_profile'),
|
||||
style: const TextStyle(
|
||||
fontSize: 13.5,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: _primaryBlue,
|
||||
),
|
||||
),
|
||||
const Icon(
|
||||
Icons.chevron_right,
|
||||
size: 16,
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
userContact,
|
||||
style: const TextStyle(fontSize: 12.5, color: _subText),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
l10n.translate('my_v2.personal_info'),
|
||||
style: const TextStyle(
|
||||
fontSize: 13.5,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: _primaryBlue,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Icon(
|
||||
Icons.chevron_right,
|
||||
size: 16,
|
||||
color: _primaryBlue,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -285,7 +190,10 @@ class MyPageV2 extends StatelessWidget {
|
||||
width: 60,
|
||||
height: 60,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
decoration: const BoxDecoration(color: Colors.white, shape: BoxShape.circle),
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: url != null && url.isNotEmpty
|
||||
? Image.network(
|
||||
url,
|
||||
@@ -301,102 +209,8 @@ class MyPageV2 extends StatelessWidget {
|
||||
return const Icon(Icons.person, size: 36, color: _primaryBlue);
|
||||
}
|
||||
|
||||
// ===== 三个数据卡 =====
|
||||
Widget _buildStatsRow(BuildContext context) {
|
||||
Widget _buildLinks(BuildContext context, {required bool isAdmin}) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildStatCard(
|
||||
icon: Icons.assignment_outlined,
|
||||
iconColor: _primaryBlue,
|
||||
value: l10n.translate('my_v2.unknown'),
|
||||
label: l10n.translate('my_v2.stat_processing_order'),
|
||||
onTap: () => _todoTap(context),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: _buildStatCard(
|
||||
icon: Icons.build_outlined,
|
||||
iconColor: _orange,
|
||||
value: l10n.translate('my_v2.unknown'),
|
||||
label: l10n.translate('my_v2.stat_maintenance_reminder'),
|
||||
onTap: () => _todoTap(context),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: _buildStatCard(
|
||||
icon: Icons.article_outlined,
|
||||
iconColor: _primaryBlue,
|
||||
value: l10n.translate('my_v2.stat_tutorial'),
|
||||
label: l10n.translate('my_v2.stat_usage_help'),
|
||||
onTap: () => _push(context, const HelpFeedbackPage()),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatCard({
|
||||
required IconData icon,
|
||||
required Color iconColor,
|
||||
required String value,
|
||||
required String label,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: _cardBorder),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: _primaryBlue.withValues(alpha: 0.05),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Icon(icon, size: 20, color: iconColor),
|
||||
const SizedBox(height: 4),
|
||||
// 字号与登录页统一:数值 16 ≈ 登录按钮字号
|
||||
Text(
|
||||
value,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 1),
|
||||
// 标签 11.5 ≈ 登录页辅助文字,略小于输入提示 14
|
||||
Text(label, style: const TextStyle(fontSize: 11.5, color: _grayText)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 分组卡片 =====
|
||||
Widget _buildSectionTitle(String title) {
|
||||
return Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _navy,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildGroupCard(List<Widget> rows) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
@@ -410,93 +224,41 @@ class MyPageV2 extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(children: rows),
|
||||
child: Column(
|
||||
children: [
|
||||
_buildMenuRow(
|
||||
icon: Icons.settings_outlined,
|
||||
title: l10n.translate('my_v2.general_settings'),
|
||||
subtitle: l10n.translate(
|
||||
isAdmin
|
||||
? 'my_v2.general_settings_desc'
|
||||
: 'my_v2.general_settings_basic_desc',
|
||||
),
|
||||
onTap: () => _push(context, const SystemSettingsPage()),
|
||||
),
|
||||
const Divider(height: 1, thickness: 1, color: _divider, indent: 66),
|
||||
_buildMenuRow(
|
||||
icon: Icons.menu_book_outlined,
|
||||
title: l10n.translate('help_feedback.tab_faq'),
|
||||
subtitle: l10n.translate('my_v2.help_guide_desc'),
|
||||
onTap: () => _push(context, const HelpFeedbackPage(faqOnly: true)),
|
||||
),
|
||||
const Divider(height: 1, thickness: 1, color: _divider, indent: 66),
|
||||
_buildMenuRow(
|
||||
icon: Icons.policy_outlined,
|
||||
title: l10n.translate('my_v2.privacy_and_terms'),
|
||||
onTap: () => _showLegalDocuments(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildServiceGroup(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return _buildGroupCard([
|
||||
_buildMenuRow(
|
||||
icon: Icons.headset_mic_outlined,
|
||||
iconBg: _iconBgBlue,
|
||||
iconColor: _primaryBlue,
|
||||
title: l10n.translate('my_v2.after_sales_center'),
|
||||
subtitle: l10n.translate('my_v2.after_sales_center_desc'),
|
||||
onTap: () => _todoTap(context),
|
||||
),
|
||||
_buildRowDivider(),
|
||||
_buildMenuRow(
|
||||
icon: Icons.build_outlined,
|
||||
iconBg: _iconBgOrange,
|
||||
iconColor: _orange,
|
||||
title: l10n.translate('my_v2.maintenance'),
|
||||
subtitle: l10n.translate('my_v2.maintenance_desc'),
|
||||
onTap: () => _todoTap(context),
|
||||
),
|
||||
_buildRowDivider(),
|
||||
_buildMenuRow(
|
||||
icon: Icons.menu_book_outlined,
|
||||
iconBg: _iconBgBlue,
|
||||
iconColor: _primaryBlue,
|
||||
title: l10n.translate('my_v2.help_guide'),
|
||||
subtitle: l10n.translate('my_v2.help_guide_desc'),
|
||||
onTap: () => _push(context, const HelpFeedbackPage()),
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
Widget _buildAccountGroup(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return _buildGroupCard([
|
||||
_buildMenuRow(
|
||||
icon: Icons.verified_user_outlined,
|
||||
iconBg: _iconBgBlue,
|
||||
iconColor: _primaryBlue,
|
||||
title: l10n.translate('my_v2.account_security'),
|
||||
subtitle: l10n.translate('my_v2.account_security_desc'),
|
||||
onTap: () => _todoTap(context),
|
||||
),
|
||||
_buildRowDivider(),
|
||||
_buildMenuRow(
|
||||
icon: Icons.notifications_none,
|
||||
iconBg: _iconBgBlue,
|
||||
iconColor: _primaryBlue,
|
||||
title: l10n.translate('my_v2.message_notice'),
|
||||
subtitle: l10n.translate('my_v2.message_notice_desc'),
|
||||
// 未读接口暂无,按约定显示「未知」
|
||||
trailingText: l10n.translate('my_v2.unread_unknown'),
|
||||
onTap: () => _todoTap(context),
|
||||
),
|
||||
_buildRowDivider(),
|
||||
_buildMenuRow(
|
||||
icon: Icons.settings_outlined,
|
||||
iconBg: _iconBgBlue,
|
||||
iconColor: _primaryBlue,
|
||||
title: l10n.translate('my_v2.general_settings'),
|
||||
subtitle: l10n.translate('my_v2.general_settings_desc'),
|
||||
onTap: () => _push(context, const SystemSettingsPage()),
|
||||
),
|
||||
_buildRowDivider(),
|
||||
_buildMenuRow(
|
||||
icon: Icons.info_outline,
|
||||
iconBg: _iconBgBlue,
|
||||
iconColor: _primaryBlue,
|
||||
title: l10n.translate('my_v2.about_legal'),
|
||||
subtitle: l10n.translate('my_v2.about_legal_desc'),
|
||||
onTap: () => _todoTap(context),
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
Widget _buildMenuRow({
|
||||
required IconData icon,
|
||||
required Color iconBg,
|
||||
required Color iconColor,
|
||||
required String title,
|
||||
required String subtitle,
|
||||
String? subtitle,
|
||||
required VoidCallback onTap,
|
||||
String? trailingText,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
@@ -509,10 +271,10 @@ class MyPageV2 extends StatelessWidget {
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: iconBg,
|
||||
color: _iconBgBlue,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Icon(icon, size: 21, color: iconColor),
|
||||
child: Icon(icon, size: 21, color: _primaryBlue),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
@@ -527,19 +289,16 @@ class MyPageV2 extends StatelessWidget {
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
subtitle,
|
||||
style: const TextStyle(fontSize: 12, color: _grayText),
|
||||
),
|
||||
if (subtitle != null) ...[
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
subtitle,
|
||||
style: const TextStyle(fontSize: 12, color: _grayText),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
if (trailingText != null)
|
||||
Text(
|
||||
trailingText,
|
||||
style: const TextStyle(fontSize: 12.5, color: _grayText),
|
||||
),
|
||||
const SizedBox(width: 2),
|
||||
const Icon(Icons.chevron_right, size: 18, color: Color(0xFFC9CDD4)),
|
||||
],
|
||||
@@ -548,27 +307,29 @@ class MyPageV2 extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRowDivider() {
|
||||
return const Divider(height: 1, thickness: 1, color: _divider, indent: 66);
|
||||
}
|
||||
|
||||
// ===== 底部说明卡(设计稿原文) =====
|
||||
Widget _buildNoteCard(BuildContext context) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
color: _noteBg,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
AppLocalizations.of(context).translate('my_v2.note_card'),
|
||||
style: const TextStyle(fontSize: 12.5, color: _subText, height: 1.6),
|
||||
void _showLegalDocuments(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
showDragHandle: true,
|
||||
builder: (context) => SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
for (final titleKey in ['my.privacy_policy', 'my.user_agreement'])
|
||||
ListTile(
|
||||
title: Text(l10n.translate(titleKey)),
|
||||
subtitle: Text(l10n.translate('my_v2.legal_unavailable')),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 退出登录(放在页脚下方) =====
|
||||
// ===== 退出登录 =====
|
||||
Widget _buildLogoutButton(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () => _showLogoutDialog(context),
|
||||
@@ -590,41 +351,27 @@ class MyPageV2 extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
void _showLogoutDialog(BuildContext context) {
|
||||
Future<void> _showLogoutDialog(BuildContext context) async {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (dialogContext) => AlertDialog(
|
||||
title: Text(l10n.translate('my_v2.logout')),
|
||||
content: Text(l10n.translate('my_v2.logout_confirm')),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext),
|
||||
child: Text(l10n.translate('my_v2.cancel')),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.pop(dialogContext);
|
||||
await GetIt.I<UserStorage>().deleteUser();
|
||||
GetIt.I<AuthCubit>().logout();
|
||||
if (dialogContext.mounted) {
|
||||
GoRouter.of(dialogContext).go(RoutePaths.login);
|
||||
}
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: const Color(0xFFF53F3F),
|
||||
),
|
||||
child: Text(l10n.translate('my_v2.confirm')),
|
||||
),
|
||||
],
|
||||
),
|
||||
final logoutLabel = l10n.translate('my_v2.logout');
|
||||
final confirmed = await showDeviceConfirmDialog(
|
||||
context,
|
||||
icon: Icons.logout_rounded,
|
||||
title: logoutLabel,
|
||||
message: l10n.translate('my_v2.logout_confirm'),
|
||||
confirmText: logoutLabel,
|
||||
cancelText: l10n.translate('my_v2.cancel'),
|
||||
danger: true,
|
||||
);
|
||||
if (!confirmed || !context.mounted) return;
|
||||
|
||||
await GetIt.I<AuthCubit>().logout();
|
||||
if (context.mounted) {
|
||||
context.go(RoutePaths.login);
|
||||
}
|
||||
}
|
||||
|
||||
void _push(BuildContext context, Widget page) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => page),
|
||||
);
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => page));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,10 +51,6 @@ class ProfileDetailPage extends StatelessWidget {
|
||||
|
||||
// 信息列表
|
||||
_buildInfoCard(context, user),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 操作按钮
|
||||
_buildActionButtons(context),
|
||||
],
|
||||
);
|
||||
},
|
||||
@@ -254,41 +250,4 @@ class ProfileDetailPage extends StatelessWidget {
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 操作按钮
|
||||
Widget _buildActionButtons(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return Column(
|
||||
children: [
|
||||
// 编辑资料按钮(预留)
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 48,
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: () {
|
||||
// TODO: 跳转到编辑资料页面
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(l10n.translate('my_v2.edit_in_progress')),
|
||||
),
|
||||
);
|
||||
},
|
||||
icon: const Icon(Icons.edit, size: 20),
|
||||
label: Text(
|
||||
l10n.translate('my_v2.edit_profile_action'),
|
||||
style: const TextStyle(fontSize: 16),
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF165DFF),
|
||||
foregroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import 'package:maibu_satabot_v2/core/theme/AppTheme.dart';
|
||||
import 'package:maibu_satabot_v2/core/storage/user_storage.dart';
|
||||
import 'package:maibu_satabot_v2/features/auth/presentation/bloc/auth_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/main_container/presentation/cubit/tab_config_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/main_container/domain/tab_config.dart';
|
||||
import 'package:maibu_satabot_v2/core/app/app_user_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/device_list/presentation/float_bar/cubit/float_bar_setting_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/core/update/update_cubit.dart';
|
||||
@@ -38,6 +37,7 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
Future<void> _loadVersion() async {
|
||||
try {
|
||||
final String versionString = await rootBundle.loadString('pubspec.yaml');
|
||||
if (!mounted) return;
|
||||
final versionMatch = RegExp(r'version:\s*(\d+\.\d+\.\d+)\+(\d+)').firstMatch(versionString);
|
||||
setState(() {
|
||||
_currentVersion = versionMatch?.group(1) ?? '1.0.0';
|
||||
@@ -47,6 +47,8 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
}
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final user = context.watch<AppUserCubit>().state.user;
|
||||
final isAdmin = user?.isAdmin == true;
|
||||
return Scaffold(
|
||||
backgroundColor: context.appColors.pageBackground,
|
||||
appBar: AppBar(
|
||||
@@ -69,16 +71,17 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
// Tab 设置
|
||||
_buildTabSettingsSection(),
|
||||
_buildTabSettingsSection(user?.roleKey, isAdmin: isAdmin),
|
||||
const SizedBox(height: 12),
|
||||
// 悬浮条设置
|
||||
_buildFloatBarSection(),
|
||||
const SizedBox(height: 12),
|
||||
// 语言设置
|
||||
if (isAdmin) ...[
|
||||
_buildFloatBarSection(),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
_buildLanguageSection(),
|
||||
const SizedBox(height: 12),
|
||||
// 版本更新
|
||||
_buildUpdateSection(),
|
||||
if (isAdmin) ...[
|
||||
const SizedBox(height: 12),
|
||||
_buildUpdateSection(),
|
||||
],
|
||||
const SizedBox(height: 12),
|
||||
// 退出登录(已挪至“我的”页面最下边,此处注释掉)
|
||||
// _buildLogoutButton(context),
|
||||
@@ -148,10 +151,7 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
}
|
||||
|
||||
/// Tab 设置
|
||||
Widget _buildTabSettingsSection() {
|
||||
// 🔥 个人角色(roleKey == 'personal'):Tab 设置只列出「设备 + 我的」,且开关常开锁定
|
||||
final roleKey = context.watch<AppUserCubit>().state.user?.roleKey;
|
||||
final isPersonal = roleKey == TabConfig.personalRoleKey;
|
||||
Widget _buildTabSettingsSection(String? roleKey, {required bool isAdmin}) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
@@ -177,9 +177,9 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
BlocBuilder<TabConfigCubit, dynamic>(
|
||||
BlocBuilder<TabConfigCubit, TabConfigState>(
|
||||
builder: (context, state) {
|
||||
if (state.runtimeType.toString() != 'TabConfigLoaded') {
|
||||
if (state is! TabConfigLoaded) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
@@ -208,13 +208,10 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
),
|
||||
),
|
||||
Switch(
|
||||
// 个人角色:设备/我的 强制常开且不可关闭
|
||||
value: isPersonal ? true : tab.isEnabled,
|
||||
onChanged: isPersonal
|
||||
? null
|
||||
: (value) {
|
||||
context.read<TabConfigCubit>().toggleTab(tab.id);
|
||||
},
|
||||
value: tab.isEnabled,
|
||||
onChanged: isAdmin
|
||||
? (_) => context.read<TabConfigCubit>().toggleTab(tab.id)
|
||||
: null,
|
||||
activeColor: const Color(0xFF165DFF),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:maibu_satabot_v2/features/regions/domain/entities/region_draft.d
|
||||
import 'package:maibu_satabot_v2/features/regions/presentation/cubit/region_list_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/regions/presentation/widgets/region_list_panel.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/device_list/presentation/pages/route_editor_page_v2.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/device_list/presentation/widgets/autonomous/work_ui.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/site/presentation/cubit/site_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/work/presentation/widgets/work_phone_ui.dart';
|
||||
|
||||
@@ -84,27 +85,75 @@ class _WorkAreaPageV2State extends State<WorkAreaPageV2> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => WorkPhoneScaffold(
|
||||
child: Column(
|
||||
children: [
|
||||
WorkPhoneTopBar(
|
||||
title: AppLocalizations.of(context).translate('work_v2.area.title'),
|
||||
onBack: () => Navigator.of(context).maybePop(),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Expanded(
|
||||
child: AbsorbPointer(
|
||||
absorbing: _opening,
|
||||
child: RegionListPanel(
|
||||
cubit: _regions,
|
||||
currentScope: () => _scope,
|
||||
onCreate: () => _openEditor(),
|
||||
onEdit: _openEditor,
|
||||
onSelect: _openEditor,
|
||||
onRefresh: _reload,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
child: AbsorbPointer(
|
||||
absorbing: _opening,
|
||||
child: RegionListPanel(
|
||||
cubit: _regions,
|
||||
currentScope: () => _scope,
|
||||
onCreate: () => _openEditor(),
|
||||
onEdit: _openEditor,
|
||||
onSelect: _openEditor,
|
||||
onRefresh: _reload,
|
||||
pageHeaderBuilder: _buildPageHeader,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Widget _buildPageHeader(
|
||||
BuildContext context,
|
||||
RegionListState state,
|
||||
VoidCallback? onCreate,
|
||||
VoidCallback? onRefresh,
|
||||
) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
WorkPhoneTopBar(
|
||||
title: l10n.translate('work_v2.area.title'),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Tooltip(
|
||||
message: l10n.translate('work_v2.area.refresh'),
|
||||
child: WorkSquareButton(
|
||||
icon: Icons.refresh_rounded,
|
||||
onTap: onRefresh,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
WorkSquareButton(
|
||||
key: const ValueKey('region_list_create'),
|
||||
icon: Icons.add_rounded,
|
||||
label: l10n.translate('work_v2.area.new'),
|
||||
primary: true,
|
||||
onTap: onCreate,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
WorkPageHeading(
|
||||
title: l10n.translate('work_v2.area.page_title'),
|
||||
subtitle: l10n.translate('work_v2.area.page_subtitle'),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: WorkSectionTitle(
|
||||
l10n.translate('work_v2.area.filter_all'),
|
||||
),
|
||||
),
|
||||
if (state.status == RegionListStatus.ready)
|
||||
WorkChip(
|
||||
text: '${state.regions.length}',
|
||||
background: kWtSoftBlue,
|
||||
foreground: kWtBlue,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,9 @@ import 'package:maibu_satabot_v2/features/v2/device_list/presentation/pages/rout
|
||||
import 'package:maibu_satabot_v2/features/v2/site/presentation/cubit/site_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/work/presentation/cubit/work_home_task_cubit.dart';
|
||||
|
||||
import '../widgets/all_work_sheet.dart';
|
||||
import 'work_area_page_v2.dart';
|
||||
import 'work_map_page_v2.dart';
|
||||
// import 'work_map_page_v2.dart';
|
||||
// 旧计划列表页保留,恢复原入口时再启用。
|
||||
// import 'work_plan_page_v2.dart';
|
||||
import 'work_plan_create_page_v2.dart';
|
||||
@@ -166,8 +167,8 @@ class _WorkHomePageV2State extends State<WorkHomePageV2>
|
||||
).translate('work_v2.section_current'),
|
||||
trailing: AppLocalizations.of(
|
||||
context,
|
||||
).translate('work_v2.all_tasks'),
|
||||
onTrailingTap: () => _showTaskPool(context),
|
||||
).translate('work_v2.all_work.title'),
|
||||
onTrailingTap: () => _showAllWork(context),
|
||||
refreshError:
|
||||
taskState.status == WorkHomeTaskStatus.ready
|
||||
? taskState.error
|
||||
@@ -196,11 +197,6 @@ class _WorkHomePageV2State extends State<WorkHomePageV2>
|
||||
);
|
||||
}
|
||||
|
||||
void _todo(BuildContext context) => CapsuleToast.show(
|
||||
AppLocalizations.of(context).translate('work_v2.toast_todo'),
|
||||
showCheck: false,
|
||||
);
|
||||
|
||||
/// 「新建路线」:进入横屏「地图与区域编辑」,先画区域再生成路线。
|
||||
///
|
||||
/// 本页是竖屏,进入时方向交给编辑器;**等 pop 转场结束**再恢复竖屏,
|
||||
@@ -218,9 +214,9 @@ class _WorkHomePageV2State extends State<WorkHomePageV2>
|
||||
}
|
||||
|
||||
/// 「作业地图」:竖屏单页,一张图上同时看区域 / 路线 / 机器人
|
||||
void _openWorkMap(BuildContext context) {
|
||||
Navigator.of(context).push(WorkMapPageV2.route());
|
||||
}
|
||||
// void _openWorkMap(BuildContext context) {
|
||||
// Navigator.of(context).push(WorkMapPageV2.route());
|
||||
// }
|
||||
|
||||
/// 「区域管理」:竖屏区域列表,新建/编辑再进横屏编辑器
|
||||
void _openArea(BuildContext context) {
|
||||
@@ -389,56 +385,31 @@ class _WorkHomePageV2State extends State<WorkHomePageV2>
|
||||
final siteName =
|
||||
siteState.selectedSite?.siteName ??
|
||||
l10n.translate('work_v2.no_site_selected');
|
||||
return Row(
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context).translate('work_v2.tag'),
|
||||
style: const TextStyle(
|
||||
fontSize: 11.5,
|
||||
letterSpacing: 0.3,
|
||||
color: _gray,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
l10n.translate('work_v2.overview'),
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'$siteName · ${l10n.translate('work_v2.all_work_robots')}',
|
||||
style: const TextStyle(fontSize: 12, color: _gray),
|
||||
),
|
||||
],
|
||||
Text(
|
||||
l10n.translate('work_v2.tag'),
|
||||
style: const TextStyle(
|
||||
fontSize: 11.5,
|
||||
letterSpacing: 0.3,
|
||||
color: _gray,
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () => _todo(context),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Container(
|
||||
width: 36,
|
||||
height: 36,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: _border),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.wb_sunny_outlined,
|
||||
size: 18,
|
||||
color: _blue,
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
l10n.translate('work_v2.overview'),
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'$siteName · ${l10n.translate('work_v2.all_work_robots')}',
|
||||
style: const TextStyle(fontSize: 12, color: _gray),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
@@ -883,6 +854,31 @@ class _WorkHomePageV2State extends State<WorkHomePageV2>
|
||||
);
|
||||
}
|
||||
|
||||
void _showAllWork(BuildContext context) {
|
||||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
useSafeArea: true,
|
||||
backgroundColor: Colors.white,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
||||
),
|
||||
builder: (_) => AllWorkSheet(
|
||||
refreshTaskPool: _refreshTasks,
|
||||
taskPoolBuilder: (_, controller) =>
|
||||
BlocBuilder<WorkHomeTaskCubit, WorkHomeTaskState>(
|
||||
bloc: _tasks,
|
||||
builder: (context, state) => ListView(
|
||||
key: const ValueKey('all_work_task_pool'),
|
||||
controller: controller,
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [_buildCurrentTasks(context, state)],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showTaskPool(BuildContext context, {String? status}) {
|
||||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
@@ -1085,11 +1081,12 @@ class _WorkHomePageV2State extends State<WorkHomePageV2>
|
||||
Widget _buildFeatureGrid(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
final items = <(IconData, String, VoidCallback)>[
|
||||
(
|
||||
Icons.map_outlined,
|
||||
l10n.translate('work_v2.feature_map'),
|
||||
() => _openWorkMap(context),
|
||||
),
|
||||
// 作业地图入口暂时隐藏,保留配置以便后续恢复。
|
||||
// (
|
||||
// Icons.map_outlined,
|
||||
// l10n.translate('work_v2.feature_map'),
|
||||
// () => _openWorkMap(context),
|
||||
// ),
|
||||
(
|
||||
Icons.layers_outlined,
|
||||
l10n.translate('work_v2.feature_area'),
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/features/consecutive_tasks/presentation/cubit/area_task_create_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/consecutive_tasks/presentation/widgets/area_dispatch_section.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:maibu_satabot_v2/components/capsule_toast.dart';
|
||||
@@ -23,6 +25,7 @@ enum _ExecutionTiming { immediate, scheduled }
|
||||
|
||||
/// 新建作业任务——作业首页「下发作业计划」进入。
|
||||
/// 路线立即下发先进入自主作业中心确认,定时任务仍走已有计划接口。
|
||||
/// 区域下发:选择当前场站分区及绑定路线,按用户排序创建连续任务。
|
||||
///
|
||||
/// 提交链路(清洁架构):页面 → [SchedulePlanCreateCubit] →
|
||||
/// SaveDeviceSchedulePlanUseCase → DeviceTaskRepository → DeviceTaskDatasource
|
||||
@@ -74,6 +77,7 @@ class _WorkPlanCreatePageV2State extends State<WorkPlanCreatePageV2> {
|
||||
|
||||
/// 设备列表:RobotListBloc 是 registerFactory,页面自持实例并负责 close
|
||||
late final RobotListBloc _robotBloc = sl<RobotListBloc>();
|
||||
late final AreaTaskCreateCubit _areaCubit = sl<AreaTaskCreateCubit>();
|
||||
|
||||
// ===== 表单状态(纯 UI 输入由页面持有,接口状态归 Cubit)=====
|
||||
RobotDataModel? _device;
|
||||
@@ -88,8 +92,12 @@ class _WorkPlanCreatePageV2State extends State<WorkPlanCreatePageV2> {
|
||||
DateTime _end = DateTime.now().add(const Duration(days: 30));
|
||||
|
||||
bool get _isRoute => _target == _DispatchTarget.route;
|
||||
bool get _isScheduled => _timing == _ExecutionTiming.scheduled;
|
||||
bool get _canSubmit => _isRoute;
|
||||
bool get _isScheduled => _isRoute && _timing == _ExecutionTiming.scheduled;
|
||||
String get _submitLabelKey => !_isRoute
|
||||
? 'work_v2.plan_create.submit_consecutive'
|
||||
: _isScheduled
|
||||
? 'work_v2.plan_create.submit'
|
||||
: 'work_v2.plan_create.submit_now';
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -102,11 +110,14 @@ class _WorkPlanCreatePageV2State extends State<WorkPlanCreatePageV2> {
|
||||
void dispose() {
|
||||
_formScrollController.dispose();
|
||||
_robotBloc.close();
|
||||
_areaCubit.close();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _toast(String text) => CapsuleToast.show(text, showCheck: false);
|
||||
|
||||
void _loadAreas() => _areaCubit.load(_entrySiteId ?? 0);
|
||||
|
||||
// ===== 选择器 =====
|
||||
|
||||
/// 选执行设备:底部弹窗,列表来自 RobotListBloc(当前场站设备)
|
||||
@@ -136,6 +147,23 @@ class _WorkPlanCreatePageV2State extends State<WorkPlanCreatePageV2> {
|
||||
Flexible(
|
||||
child: BlocBuilder<RobotListBloc, RobotListState>(
|
||||
builder: (context, state) {
|
||||
if (state is RobotListError) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(state.message),
|
||||
TextButton.icon(
|
||||
onPressed: () => _robotBloc.add(
|
||||
RobotListLoadData(siteId: _entrySiteId),
|
||||
),
|
||||
icon: const Icon(Icons.refresh_rounded),
|
||||
label: Text(
|
||||
l10n.translate('work_v2.plan_create.area_reload'),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
if (state is! RobotListLoaded) {
|
||||
return const SizedBox(
|
||||
height: 120,
|
||||
@@ -269,20 +297,16 @@ class _WorkPlanCreatePageV2State extends State<WorkPlanCreatePageV2> {
|
||||
|
||||
/// 组装业务实体 → Cubit → UseCase(后端字段/格式在数据层映射)
|
||||
Future<void> _submit(BuildContext context) async {
|
||||
debugPrint('[新建作业] 点击${_isScheduled ? '创建计划' : '立即下发'}');
|
||||
final l10n = AppLocalizations.of(context);
|
||||
debugPrint('[新建作业] 点击${l10n.translate(_submitLabelKey)}');
|
||||
final cubit = context.read<SchedulePlanCreateCubit>();
|
||||
if (cubit.state.isSubmitting || _openingWorkCenter) return;
|
||||
// 区域模式保留页面入口,后续独立接入,不复用路线接口。
|
||||
if (!_canSubmit) return;
|
||||
if (cubit.state.isSubmitting ||
|
||||
_areaCubit.state.isSubmitting ||
|
||||
_openingWorkCenter)
|
||||
return;
|
||||
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
|
||||
final route = _route;
|
||||
if (route == null) {
|
||||
debugPrint('[新建计划] 校验未通过:未选择作业路线');
|
||||
_toast(l10n.translate('work_v2.plan_create.route_pick'));
|
||||
return;
|
||||
}
|
||||
final device = _device;
|
||||
if (device == null || device.name.trim().isEmpty) {
|
||||
_toast(l10n.translate('work_v2.plan_create.device_pick'));
|
||||
@@ -298,6 +322,26 @@ class _WorkPlanCreatePageV2State extends State<WorkPlanCreatePageV2> {
|
||||
_toast(l10n.translate('work_v2.plan_create.selection_changed'));
|
||||
return;
|
||||
}
|
||||
if (!_isRoute) {
|
||||
final robots = _robotBloc.state;
|
||||
if (robots is! RobotListLoaded ||
|
||||
robots.siteId != site.id ||
|
||||
!robots.robots.any((robot) => robot.name == device.name)) {
|
||||
_toast(l10n.translate('work_v2.plan_create.selection_changed'));
|
||||
return;
|
||||
}
|
||||
await _areaCubit.submit(
|
||||
deviceId: device.name,
|
||||
orgId: site.orgId,
|
||||
siteId: site.id,
|
||||
);
|
||||
return;
|
||||
}
|
||||
final route = _route;
|
||||
if (route == null) {
|
||||
_toast(l10n.translate('work_v2.plan_create.route_pick'));
|
||||
return;
|
||||
}
|
||||
if (!_isScheduled) {
|
||||
await _openWorkCenter(context, device, route);
|
||||
return;
|
||||
@@ -367,6 +411,42 @@ class _WorkPlanCreatePageV2State extends State<WorkPlanCreatePageV2> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider<AreaTaskCreateCubit>.value(
|
||||
value: _areaCubit,
|
||||
child: BlocConsumer<AreaTaskCreateCubit, AreaTaskCreateState>(
|
||||
listenWhen: (previous, current) =>
|
||||
previous.submitStatus != current.submitStatus,
|
||||
listener: (context, state) {
|
||||
if (state.submitStatus == AreaTaskSubmitStatus.success) {
|
||||
CapsuleToast.show(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('work_v2.plan_create.area_success'),
|
||||
showCheck: true,
|
||||
);
|
||||
// 等待提交锁随成功状态解除,再返回上一页。
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (context.mounted) Navigator.of(context).maybePop();
|
||||
});
|
||||
} else if (state.submitStatus == AreaTaskSubmitStatus.failure) {
|
||||
_toast(
|
||||
state.submitError ??
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('work_v2.plan_create.failed'),
|
||||
);
|
||||
_areaCubit.clearFailure();
|
||||
}
|
||||
},
|
||||
builder: (context, state) => PopScope(
|
||||
canPop: !state.isSubmitting,
|
||||
child: _buildSchedulePage(context),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSchedulePage(BuildContext context) {
|
||||
return BlocProvider<SchedulePlanCreateCubit>(
|
||||
create: (_) => sl<SchedulePlanCreateCubit>(),
|
||||
child: BlocListener<SchedulePlanCreateCubit, SchedulePlanCreateState>(
|
||||
@@ -391,8 +471,12 @@ class _WorkPlanCreatePageV2State extends State<WorkPlanCreatePageV2> {
|
||||
}
|
||||
},
|
||||
child: BlocBuilder<SchedulePlanCreateCubit, SchedulePlanCreateState>(
|
||||
builder: (context, state) =>
|
||||
_buildForm(context, state.isSubmitting || _openingWorkCenter),
|
||||
builder: (context, state) => _buildForm(
|
||||
context,
|
||||
state.isSubmitting ||
|
||||
_areaCubit.state.isSubmitting ||
|
||||
_openingWorkCenter,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -408,7 +492,9 @@ class _WorkPlanCreatePageV2State extends State<WorkPlanCreatePageV2> {
|
||||
children: [
|
||||
WorkPhoneTopBar(
|
||||
title: l10n.translate('work_v2.plan_create.title'),
|
||||
onBack: () => Navigator.of(context).maybePop(),
|
||||
onBack: () {
|
||||
if (!submitting) Navigator.of(context).maybePop();
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
AbsorbPointer(absorbing: submitting, child: _buildDispatchTabs(l10n)),
|
||||
@@ -422,10 +508,8 @@ class _WorkPlanCreatePageV2State extends State<WorkPlanCreatePageV2> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
_buildExecutionSelector(l10n),
|
||||
const SizedBox(height: 12),
|
||||
if (!_canSubmit) ...[
|
||||
_buildAvailabilityNote(l10n),
|
||||
if (_isRoute) ...[
|
||||
_buildExecutionSelector(l10n),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
// ===== 基本信息 =====
|
||||
@@ -436,6 +520,16 @@ class _WorkPlanCreatePageV2State extends State<WorkPlanCreatePageV2> {
|
||||
Icons.assignment_outlined,
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
if (!_isRoute) ...[
|
||||
_hint(
|
||||
l10n.translate(
|
||||
'work_v2.plan_create.area_immediate_hint',
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
AreaDispatchSection(onReload: _loadAreas),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
_selectField(
|
||||
label: l10n.translate(
|
||||
'work_v2.plan_create.device_label',
|
||||
@@ -459,16 +553,6 @@ class _WorkPlanCreatePageV2State extends State<WorkPlanCreatePageV2> {
|
||||
'work_v2.plan_create.route_pick',
|
||||
),
|
||||
onTap: _pickRoute,
|
||||
)
|
||||
else
|
||||
_selectField(
|
||||
label: l10n.translate(
|
||||
'work_v2.plan_create.area_label',
|
||||
),
|
||||
placeholder: l10n.translate(
|
||||
'work_v2.plan_create.area_pick',
|
||||
),
|
||||
onTap: null,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -628,7 +712,13 @@ class _WorkPlanCreatePageV2State extends State<WorkPlanCreatePageV2> {
|
||||
key: ValueKey('work_plan_dispatch_${target.name}'),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
onTap: () {
|
||||
if (_target == target) return;
|
||||
setState(() => _target = target);
|
||||
if (target == _DispatchTarget.area &&
|
||||
!_areaCubit.state.loaded &&
|
||||
!_areaCubit.state.loading) {
|
||||
_loadAreas();
|
||||
}
|
||||
if (_formScrollController.hasClients) {
|
||||
_formScrollController.jumpTo(0);
|
||||
}
|
||||
@@ -747,11 +837,9 @@ class _WorkPlanCreatePageV2State extends State<WorkPlanCreatePageV2> {
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
l10n.translate(
|
||||
'work_v2.plan_create.${_isScheduled
|
||||
? 'scheduled_hint'
|
||||
: _isRoute
|
||||
? 'immediate_hint'
|
||||
: 'area_immediate_hint'}',
|
||||
_isScheduled
|
||||
? 'work_v2.plan_create.scheduled_hint'
|
||||
: 'work_v2.plan_create.immediate_hint',
|
||||
),
|
||||
style: const TextStyle(fontSize: 11.5, color: _gray, height: 1.5),
|
||||
),
|
||||
@@ -759,43 +847,17 @@ class _WorkPlanCreatePageV2State extends State<WorkPlanCreatePageV2> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAvailabilityNote(AppLocalizations l10n) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFFFF6E5),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: const Color(0xFFFFE1A8)),
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.info_outline_rounded,
|
||||
size: 18,
|
||||
color: Color(0xFF9B6500),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
l10n.translate('work_v2.plan_create.area_pending'),
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Color(0xFF9B6500),
|
||||
height: 1.5,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSubmitBar(
|
||||
BuildContext context,
|
||||
AppLocalizations l10n,
|
||||
bool submitting,
|
||||
) {
|
||||
final dispatch = l10n.translate(
|
||||
'work_v2.plan_create.dispatch_${_target.name}',
|
||||
);
|
||||
final description = _isRoute
|
||||
? '$dispatch · ${l10n.translate('work_v2.plan_create.timing_${_timing.name}')}'
|
||||
: dispatch;
|
||||
return Container(
|
||||
padding: const EdgeInsets.only(top: 12, bottom: 4),
|
||||
decoration: const BoxDecoration(
|
||||
@@ -814,21 +876,12 @@ class _WorkPlanCreatePageV2State extends State<WorkPlanCreatePageV2> {
|
||||
const SizedBox(width: 5),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'${l10n.translate('work_v2.plan_create.dispatch_${_target.name}')} · '
|
||||
'${l10n.translate('work_v2.plan_create.timing_${_timing.name}')}',
|
||||
description,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontSize: 11.5, color: _gray),
|
||||
),
|
||||
),
|
||||
if (!_canSubmit)
|
||||
Text(
|
||||
l10n.translate('work_v2.plan_create.coming_soon'),
|
||||
style: const TextStyle(
|
||||
fontSize: 11,
|
||||
color: Color(0xFF9B6500),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
@@ -836,10 +889,8 @@ class _WorkPlanCreatePageV2State extends State<WorkPlanCreatePageV2> {
|
||||
height: 48,
|
||||
child: FilledButton(
|
||||
key: const ValueKey('work_plan_submit'),
|
||||
// 定时任务从当前 Cubit 保存;立即下发仅导航至作业中心。
|
||||
onPressed: submitting || !_canSubmit
|
||||
? null
|
||||
: () => _submit(context),
|
||||
// 路线定时保存计划、路线立即进入作业中心;区域立即提交连续任务。
|
||||
onPressed: submitting ? null : () => _submit(context),
|
||||
style: FilledButton.styleFrom(
|
||||
backgroundColor: _navy,
|
||||
foregroundColor: Colors.white,
|
||||
@@ -870,9 +921,7 @@ class _WorkPlanCreatePageV2State extends State<WorkPlanCreatePageV2> {
|
||||
const SizedBox(width: 8),
|
||||
Flexible(
|
||||
child: Text(
|
||||
l10n.translate(
|
||||
'work_v2.plan_create.${_isScheduled ? 'submit' : 'submit_now'}',
|
||||
),
|
||||
l10n.translate(_submitLabelKey),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
|
||||
@@ -1,443 +1,451 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/components/capsule_toast.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:maibu_satabot_v2/core/di/injection.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/device_list/data/models/robot_data_model.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/device_list/presentation/widgets/autonomous/work_ui.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/work/presentation/pages/work_report_page_v2.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/site/presentation/cubit/site_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/work/presentation/widgets/work_phone_ui.dart';
|
||||
import 'package:maibu_satabot_v2/features/work_history/domain/entities/work_history_record.dart';
|
||||
import 'package:maibu_satabot_v2/features/work_history/presentation/cubit/work_history_cubit.dart';
|
||||
|
||||
/// 作业记录中心(W09)——作业首页「作业记录」入口进入。
|
||||
///
|
||||
/// 竖屏单页:本月汇总 + 筛选 + 记录列表,点单条进入「单次作业报告」(W10)。
|
||||
///
|
||||
/// 本页为演示页:记录列表是写死的示例,不查询真实作业历史;
|
||||
/// 筛选与搜索只在本地过滤,不请求接口。
|
||||
/// 作业执行历史。设备详情入口传入设备,作业页入口查看当前场站。
|
||||
class WorkRecordPageV2 extends StatefulWidget {
|
||||
const WorkRecordPageV2({super.key});
|
||||
const WorkRecordPageV2({super.key, this.robot});
|
||||
|
||||
static Route<void> route() =>
|
||||
MaterialPageRoute<void>(builder: (_) => const WorkRecordPageV2());
|
||||
final RobotDataModel? robot;
|
||||
|
||||
static Route<void> route({RobotDataModel? robot}) =>
|
||||
MaterialPageRoute<void>(builder: (_) => WorkRecordPageV2(robot: robot));
|
||||
|
||||
@override
|
||||
State<WorkRecordPageV2> createState() => _WorkRecordPageV2State();
|
||||
}
|
||||
|
||||
/// 一条演示作业记录
|
||||
class _DemoRecord {
|
||||
const _DemoRecord({
|
||||
required this.title,
|
||||
required this.robot,
|
||||
required this.date,
|
||||
required this.area,
|
||||
required this.duration,
|
||||
required this.done,
|
||||
required this.coverage,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final String robot;
|
||||
final String date;
|
||||
final String area;
|
||||
final String duration;
|
||||
final bool done;
|
||||
final String coverage;
|
||||
}
|
||||
|
||||
class _WorkRecordPageV2State extends State<WorkRecordPageV2> {
|
||||
static const Color _navy = kWtNavy;
|
||||
static const Color _gray = kWtGray;
|
||||
static const Color _border = kWtBorder;
|
||||
static const Color _green = Color(0xFF00B42A);
|
||||
static const Color _abort = Color(0xFFF0483E);
|
||||
|
||||
/// 筛选顺序:全部 / 已完成 / 已中止 / 本周
|
||||
late final WorkHistoryCubit _history = sl<WorkHistoryCubit>();
|
||||
StreamSubscription<(int?, int?)>? _scopeSubscription;
|
||||
int _filter = 0;
|
||||
|
||||
static const List<_DemoRecord> _records = <_DemoRecord>[
|
||||
_DemoRecord(
|
||||
title: 'work_v2.demo_zone_b_task',
|
||||
robot: 'work_v2.demo_robot_2',
|
||||
date: '2026-10-26 08:00',
|
||||
area: '2 860 m²',
|
||||
duration: '2 h 42 min',
|
||||
done: true,
|
||||
coverage: '98.6%',
|
||||
),
|
||||
_DemoRecord(
|
||||
title: 'work_v2.demo_task_a_inspect',
|
||||
robot: 'work_v2.demo_robot_1',
|
||||
date: '2026-10-25 16:20',
|
||||
area: '1 240 m²',
|
||||
duration: '1 h 05 min',
|
||||
done: true,
|
||||
coverage: '97.2%',
|
||||
),
|
||||
_DemoRecord(
|
||||
title: 'work_v2.demo_task_c_retry',
|
||||
robot: 'work_v2.demo_robot_1',
|
||||
date: '2026-10-25 09:10',
|
||||
area: '640 m²',
|
||||
duration: '0 h 38 min',
|
||||
done: false,
|
||||
coverage: '42.5%',
|
||||
),
|
||||
_DemoRecord(
|
||||
title: 'work_v2.demo_task_zone_a',
|
||||
robot: 'work_v2.demo_robot_2',
|
||||
date: '2026-10-24 14:00',
|
||||
area: '3 120 m²',
|
||||
duration: '3 h 12 min',
|
||||
done: true,
|
||||
coverage: '99.1%',
|
||||
),
|
||||
_DemoRecord(
|
||||
title: 'work_v2.demo_task_d_edge',
|
||||
robot: 'work_v2.demo_robot_3',
|
||||
date: '2026-10-23 10:30',
|
||||
area: '980 m²',
|
||||
duration: '1 h 12 min',
|
||||
done: true,
|
||||
coverage: '96.4%',
|
||||
),
|
||||
];
|
||||
|
||||
/// 顶部筛选文案(顺序:全部 / 已完成 / 已中止 / 本周)
|
||||
List<String> _filterLabels(AppLocalizations l10n) => <String>[
|
||||
l10n.translate('work_v2.record.filter_all'),
|
||||
l10n.translate('work_v2.record.filter_done'),
|
||||
l10n.translate('work_v2.record.filter_aborted'),
|
||||
l10n.translate('work_v2.record.filter_week'),
|
||||
];
|
||||
|
||||
void _toast(String text) => CapsuleToast.show(text, showCheck: false);
|
||||
|
||||
/// 当前筛选下要显示的记录
|
||||
List<_DemoRecord> get _visible {
|
||||
switch (_filter) {
|
||||
case 1:
|
||||
return _records.where((r) => r.done).toList();
|
||||
case 2:
|
||||
return _records.where((r) => !r.done).toList();
|
||||
case 3:
|
||||
// 演示:取最近 4 条当作「本周」
|
||||
return _records.take(4).toList();
|
||||
default:
|
||||
return _records;
|
||||
}
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final sites = sl<SiteCubit>();
|
||||
var currentScope = _scopeOf(sites.state);
|
||||
_scopeSubscription = sites.stream.map(_scopeOf).listen((scope) {
|
||||
if (!mounted || scope == currentScope) return;
|
||||
currentScope = scope;
|
||||
setState(() => _filter = 0);
|
||||
unawaited(_refresh());
|
||||
});
|
||||
unawaited(_refresh());
|
||||
}
|
||||
|
||||
void _openReport(_DemoRecord r) {
|
||||
Navigator.of(context).push(
|
||||
WorkReportPageV2.route(
|
||||
taskName: AppLocalizations.of(context).translate(r.title),
|
||||
),
|
||||
(int?, int?) _scopeOf(SiteState state) {
|
||||
final robot = widget.robot;
|
||||
final selected = state.selectedSite;
|
||||
final deviceSiteId = robot?.siteId;
|
||||
if (deviceSiteId == null || deviceSiteId <= 0) {
|
||||
return (selected?.id, selected?.orgId);
|
||||
}
|
||||
|
||||
final site = selected?.id == deviceSiteId
|
||||
? selected
|
||||
: state.sites.where((site) => site.id == deviceSiteId).firstOrNull;
|
||||
final siteOrgId = site?.orgId;
|
||||
return (
|
||||
deviceSiteId,
|
||||
siteOrgId != null && siteOrgId > 0 ? siteOrgId : robot?.orgId,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _refresh() {
|
||||
final (siteId, orgId) = _scopeOf(sl<SiteCubit>().state);
|
||||
return _history.load(siteId: siteId, orgId: orgId);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
final records = _visible;
|
||||
return WorkPhoneScaffold(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
WorkPhoneTopBar(
|
||||
title: l10n.translate('work_v2.record.title'),
|
||||
onBack: () => Navigator.of(context).maybePop(),
|
||||
trailing: WorkSquareButton(
|
||||
icon: Icons.file_download_outlined,
|
||||
size: 17,
|
||||
onTap: () =>
|
||||
_toast(l10n.translate('work_v2.record.toast_export_todo')),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
WorkPageHeading(
|
||||
title: l10n.translate('work_v2.record.title'),
|
||||
subtitle: l10n.translate('work_v2.record.page_subtitle'),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildSummary(l10n),
|
||||
const SizedBox(height: 12),
|
||||
WorkFilterRow(
|
||||
items: _filterLabels(l10n),
|
||||
index: _filter,
|
||||
onChanged: (i) => setState(() => _filter = i),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Expanded(
|
||||
child: records.isEmpty
|
||||
? _buildEmpty(l10n)
|
||||
: ListView.separated(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
itemCount: records.length,
|
||||
separatorBuilder: (_, _) => const SizedBox(height: 10),
|
||||
itemBuilder: (context, i) =>
|
||||
_buildRecordCard(l10n, records[i]),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
void dispose() {
|
||||
final subscription = _scopeSubscription;
|
||||
if (subscription != null) unawaited(subscription.cancel());
|
||||
unawaited(_history.close());
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
// ===== 本月汇总 =====
|
||||
Widget _buildSummary(AppLocalizations l10n) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.fromLTRB(14, 12, 14, 12),
|
||||
decoration: BoxDecoration(
|
||||
gradient: const LinearGradient(
|
||||
colors: [Color(0xFF2E8DF7), Color(0xFF1C96F6)],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x331C96F6),
|
||||
blurRadius: 12,
|
||||
offset: Offset(0, 4),
|
||||
),
|
||||
],
|
||||
String _t(String key) =>
|
||||
AppLocalizations.of(context).translate('work_v2.record.$key');
|
||||
|
||||
String _title(WorkHistoryRecord record) => record.workName.isEmpty
|
||||
? '${_t('task_id')} #${record.id}'
|
||||
: record.workName;
|
||||
|
||||
String _status(WorkHistoryRecord record) => record.statusLabel.isNotEmpty
|
||||
? record.statusLabel
|
||||
: record.status.isNotEmpty
|
||||
? record.status
|
||||
: _t('unknown_status');
|
||||
|
||||
String _device(WorkHistoryRecord record) {
|
||||
final serial = record.deviceId.isEmpty ? '—' : record.deviceId;
|
||||
return record.deviceAlias == null
|
||||
? serial
|
||||
: '${record.deviceAlias}($serial)';
|
||||
}
|
||||
|
||||
List<WorkHistoryRecord> _recordsForEntry(List<WorkHistoryRecord> records) {
|
||||
final robot = widget.robot;
|
||||
if (robot == null) return records;
|
||||
|
||||
final deviceIds = {robot.name.trim(), robot.id.trim()}..remove('');
|
||||
return records
|
||||
.where((record) => deviceIds.contains(record.deviceId))
|
||||
.toList();
|
||||
}
|
||||
|
||||
List<WorkHistoryRecord> _visible(List<WorkHistoryRecord> records) {
|
||||
if (_filter == 1) {
|
||||
return records.where((record) => record.isCompleted).toList();
|
||||
}
|
||||
if (_filter == 2) {
|
||||
return records.where((record) => record.isCanceled).toList();
|
||||
}
|
||||
if (_filter == 3) {
|
||||
final now = DateTime.now();
|
||||
final today = DateTime(now.year, now.month, now.day);
|
||||
final monday = today.subtract(Duration(days: now.weekday - 1));
|
||||
final nextMonday = monday.add(const Duration(days: 7));
|
||||
return records.where((record) {
|
||||
final date = record.recordDate;
|
||||
return date != null &&
|
||||
!date.isBefore(monday) &&
|
||||
date.isBefore(nextMonday);
|
||||
}).toList();
|
||||
}
|
||||
return records;
|
||||
}
|
||||
|
||||
Color _statusColor(WorkHistoryRecord record) {
|
||||
if (record.isCompleted) return const Color(0xFF22A06B);
|
||||
if (record.isCanceled || record.normalizedStatus == 'FAILED') {
|
||||
return const Color(0xFFF0483E);
|
||||
}
|
||||
return kWtBlue;
|
||||
}
|
||||
|
||||
void _openDetails(WorkHistoryRecord record) {
|
||||
final fields = <(String, String)>[
|
||||
(_t('task_id'), '${record.id}'),
|
||||
(_t('device'), _device(record)),
|
||||
(_t('status'), _status(record)),
|
||||
(_t('created_at'), record.createdAt ?? '—'),
|
||||
(_t('started_at'), record.startedAt ?? '—'),
|
||||
(_t('finished_at'), record.finishedAt ?? '—'),
|
||||
(_t('updated_at'), record.updatedAt ?? '—'),
|
||||
(_t('route_id'), record.routeId?.toString() ?? '—'),
|
||||
(_t('plan_id'), record.planId?.toString() ?? '—'),
|
||||
(_t('task_type'), record.taskType ?? '—'),
|
||||
(_t('route_type'), record.routeType ?? '—'),
|
||||
(
|
||||
_t('accepted'),
|
||||
record.accepted == null
|
||||
? '—'
|
||||
: record.accepted!
|
||||
? _t('yes')
|
||||
: _t('no'),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
if (record.remark != null) (_t('remark'), record.remark!),
|
||||
];
|
||||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
showDragHandle: true,
|
||||
backgroundColor: Colors.white,
|
||||
builder: (sheetContext) => SafeArea(
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: MediaQuery.sizeOf(sheetContext).height * 0.8,
|
||||
),
|
||||
child: ListView(
|
||||
shrinkWrap: true,
|
||||
padding: const EdgeInsets.fromLTRB(20, 0, 20, 20),
|
||||
children: [
|
||||
Text(
|
||||
l10n.translate('work_v2.record.summary_title'),
|
||||
_title(record),
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: kWtNavy,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withValues(alpha: 0.22),
|
||||
borderRadius: BorderRadius.circular(999),
|
||||
),
|
||||
child: const Text(
|
||||
'2026-10',
|
||||
style: TextStyle(
|
||||
fontSize: 10.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: [
|
||||
_SummaryCell(
|
||||
value: '18',
|
||||
label: l10n.translate('work_v2.record.summary_count'),
|
||||
),
|
||||
_SummaryCell(
|
||||
value: '4.6',
|
||||
label: l10n.translate('work_v2.record.summary_area'),
|
||||
),
|
||||
_SummaryCell(
|
||||
value: '21.3',
|
||||
label: l10n.translate('work_v2.record.summary_hours'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildEmpty(AppLocalizations l10n) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: 56,
|
||||
height: 56,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.receipt_long_outlined,
|
||||
size: 26,
|
||||
color: kWtMuted,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
l10n.translate('work_v2.record.empty'),
|
||||
style: const TextStyle(fontSize: 12.5, color: _gray),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 记录卡 =====
|
||||
Widget _buildRecordCard(AppLocalizations l10n, _DemoRecord r) {
|
||||
final Color statusColor = r.done ? _green : _abort;
|
||||
final Color statusBg = r.done
|
||||
? const Color(0xFFE8F8EC)
|
||||
: const Color(0xFFFDECEB);
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () => _openReport(r),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.fromLTRB(14, 12, 12, 12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: _border),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
l10n.translate(r.title),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 9,
|
||||
vertical: 3,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: statusBg,
|
||||
borderRadius: BorderRadius.circular(999),
|
||||
),
|
||||
child: Text(
|
||||
r.done
|
||||
? l10n.translate('work_v2.plan.status_done')
|
||||
: l10n.translate('work_v2.plan.status_aborted'),
|
||||
style: TextStyle(
|
||||
fontSize: 10.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: statusColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Text(
|
||||
'${l10n.translate(r.robot)} · ${r.date}',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontSize: 11.5, color: _gray),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const Divider(height: 1, color: kWtDivider),
|
||||
const SizedBox(height: 9),
|
||||
Row(
|
||||
children: [
|
||||
// 三项指标用 Wrap:窄屏自动换行,不把「报告」顶出去
|
||||
Expanded(
|
||||
child: Wrap(
|
||||
spacing: 12,
|
||||
runSpacing: 5,
|
||||
const SizedBox(height: 12),
|
||||
for (final field in fields)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 7),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_metaItem(Icons.crop_free_rounded, r.area),
|
||||
_metaItem(Icons.schedule_rounded, r.duration),
|
||||
_metaItem(Icons.donut_large_rounded, r.coverage),
|
||||
SizedBox(
|
||||
width: 90,
|
||||
child: Text(
|
||||
field.$1,
|
||||
style: const TextStyle(color: kWtGray, fontSize: 12),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: SelectableText(
|
||||
field.$2,
|
||||
style: const TextStyle(
|
||||
color: kWtNavy,
|
||||
fontSize: 12.5,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
l10n.translate('work_v2.record.report'),
|
||||
style: const TextStyle(
|
||||
fontSize: 11.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: kWtBlue,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(
|
||||
BuildContext context,
|
||||
) => BlocBuilder<WorkHistoryCubit, WorkHistoryState>(
|
||||
bloc: _history,
|
||||
builder: (context, state) {
|
||||
final deviceEntry = widget.robot != null;
|
||||
final entryRecords = _recordsForEntry(state.records);
|
||||
final records = _visible(entryRecords);
|
||||
final scopeLabel = _t(
|
||||
deviceEntry ? 'device_history_scope' : 'history_scope',
|
||||
);
|
||||
final loadedLabel = deviceEntry
|
||||
? _t(
|
||||
'device_loaded_count',
|
||||
).replaceFirst('%s', '${entryRecords.length}')
|
||||
: _t('loaded_count')
|
||||
.replaceFirst('%s', '${state.records.length}')
|
||||
.replaceFirst('%s', '${state.total}');
|
||||
return WorkPhoneScaffold(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
WorkPhoneTopBar(
|
||||
title: _t('title'),
|
||||
trailing: WorkSquareButton(
|
||||
icon: Icons.refresh_rounded,
|
||||
onTap: () {
|
||||
if (!state.loading) unawaited(_refresh());
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
WorkPageHeading(
|
||||
title: _t('title'),
|
||||
subtitle: _t(
|
||||
deviceEntry ? 'device_page_subtitle' : 'page_subtitle',
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
color: kWtSoftBlue,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.receipt_long_outlined, color: kWtBlue),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(
|
||||
state.loaded ? loadedLabel : scopeLabel,
|
||||
style: const TextStyle(
|
||||
fontSize: 12.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: kWtNavy,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const Icon(
|
||||
Icons.chevron_right_rounded,
|
||||
size: 16,
|
||||
color: kWtBlue,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
WorkFilterRow(
|
||||
items: [
|
||||
_t('filter_all'),
|
||||
_t('filter_done'),
|
||||
_t('filter_canceled'),
|
||||
_t('filter_week'),
|
||||
],
|
||||
index: _filter,
|
||||
onChanged: (value) => setState(() => _filter = value),
|
||||
),
|
||||
if (state.loading && state.loaded) ...[
|
||||
const SizedBox(height: 8),
|
||||
const LinearProgressIndicator(minHeight: 2),
|
||||
],
|
||||
if (state.error != null) ...[
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
state.error!,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Color(0xFFF0483E),
|
||||
),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => unawaited(_refresh()),
|
||||
child: Text(_t('retry')),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 10),
|
||||
Expanded(
|
||||
child: RefreshIndicator(
|
||||
onRefresh: _refresh,
|
||||
child: ListView.separated(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
itemCount: records.isEmpty ? 1 : records.length,
|
||||
separatorBuilder: (_, _) => const SizedBox(height: 10),
|
||||
itemBuilder: (context, index) {
|
||||
if (records.isEmpty) {
|
||||
return SizedBox(
|
||||
height: 160,
|
||||
child: Center(
|
||||
child: state.loading && !state.loaded
|
||||
? const CircularProgressIndicator(strokeWidth: 2)
|
||||
: Text(
|
||||
state.loaded ? _t('empty') : _t('load_hint'),
|
||||
style: const TextStyle(
|
||||
fontSize: 12.5,
|
||||
color: kWtGray,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return _recordCard(records[index]);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
Widget _metaItem(IconData icon, String text) {
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(icon, size: 12.5, color: kWtHint),
|
||||
const SizedBox(width: 3),
|
||||
Text(
|
||||
text,
|
||||
style: const TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: kWtGray2,
|
||||
Widget _recordCard(WorkHistoryRecord record) {
|
||||
final color = _statusColor(record);
|
||||
return Material(
|
||||
color: Colors.white,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
side: const BorderSide(color: kWtBorder),
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: () => _openDetails(record),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(14),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
_title(record),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: kWtNavy,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Flexible(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 9,
|
||||
vertical: 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Text(
|
||||
_status(record),
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
_device(record),
|
||||
style: const TextStyle(fontSize: 12, color: kWtGray),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'${_t('created_at')}:${record.createdAt ?? '—'}',
|
||||
style: const TextStyle(fontSize: 11.5, color: kWtGray),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'${_t('started_at')}:${record.startedAt ?? '—'}',
|
||||
style: const TextStyle(fontSize: 11.5, color: kWtGray),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'${_t('finished_at')}:${record.finishedAt ?? '—'}',
|
||||
style: const TextStyle(fontSize: 11.5, color: kWtGray),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
'${_t('task_id')} #${record.id}',
|
||||
style: const TextStyle(fontSize: 11, color: kWtHint),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
_t('details'),
|
||||
style: const TextStyle(
|
||||
fontSize: 11.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: kWtBlue,
|
||||
),
|
||||
),
|
||||
const Icon(
|
||||
Icons.chevron_right_rounded,
|
||||
size: 17,
|
||||
color: kWtBlue,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 汇总卡里的一格(深蓝底上的白字)
|
||||
class _SummaryCell extends StatelessWidget {
|
||||
const _SummaryCell({required this.value, required this.label});
|
||||
|
||||
final String value;
|
||||
final String label;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
value,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 21,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: Colors.white,
|
||||
height: 1.1,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
label,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 10.5,
|
||||
color: Colors.white.withValues(alpha: 0.82),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/app/app_user_cubit.dart';
|
||||
import '../cubit/return_plan_library_cubit.dart';
|
||||
import '../widgets/return_plan_library_section.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:maibu_satabot_v2/components/capsule_toast.dart';
|
||||
@@ -48,6 +52,13 @@ class _WorkRouteLibraryPageV2State extends State<WorkRouteLibraryPageV2> {
|
||||
// 'custom',
|
||||
];
|
||||
int _filter = 0;
|
||||
bool get _isReturn => _filterKeys[_filter] == 'return';
|
||||
late final ReturnPlanLibraryCubit _returnPlans = sl<ReturnPlanLibraryCubit>();
|
||||
StreamSubscription<dynamic>? _siteSubscription;
|
||||
StreamSubscription<dynamic>? _ownerSubscription;
|
||||
(int?, int?)? _siteScope;
|
||||
String? _ownerId;
|
||||
int _routesGeneration = 0;
|
||||
|
||||
late final AutonomousWorkGateway _gateway = sl<AutonomousWorkGateway>();
|
||||
|
||||
@@ -58,41 +69,94 @@ class _WorkRouteLibraryPageV2State extends State<WorkRouteLibraryPageV2> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_load();
|
||||
final site = sl<SiteCubit>().state.selectedSite;
|
||||
_siteScope = (site?.id, site?.orgId);
|
||||
_ownerId = sl<AppUserCubit>().state.user?.userId;
|
||||
_siteSubscription = sl<SiteCubit>().stream
|
||||
.map((state) => (state.selectedSite?.id, state.selectedSite?.orgId))
|
||||
.distinct()
|
||||
.listen((scope) {
|
||||
if (_siteScope == scope) return;
|
||||
_siteScope = scope;
|
||||
_scopeChanged();
|
||||
});
|
||||
_ownerSubscription = sl<AppUserCubit>().stream
|
||||
.map((state) => state.user?.userId)
|
||||
.distinct()
|
||||
.listen((owner) {
|
||||
if (_ownerId == owner) return;
|
||||
_ownerId = owner;
|
||||
_scopeChanged();
|
||||
});
|
||||
unawaited(_load());
|
||||
}
|
||||
|
||||
/// 拉取当前场站下的所有路线:与自主作业抽屉面板同一链路
|
||||
/// (resolveScope → siteId → loadRoutes),页面不直接依赖任何接口。
|
||||
@override
|
||||
void dispose() {
|
||||
++_routesGeneration;
|
||||
_siteSubscription?.cancel();
|
||||
_ownerSubscription?.cancel();
|
||||
_returnPlans.close();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _scopeChanged() {
|
||||
if (!mounted) return;
|
||||
++_routesGeneration;
|
||||
_returnPlans.clear();
|
||||
setState(() {
|
||||
_routes = const [];
|
||||
_error = null;
|
||||
});
|
||||
unawaited(_load());
|
||||
}
|
||||
|
||||
/// 两个分栏使用各自领域查询,不把场站返航方案当普通作业路线。
|
||||
Future<void> _load() async {
|
||||
final site = sl<SiteCubit>().state.selectedSite;
|
||||
if (_isReturn) {
|
||||
await _returnPlans.load(siteId: site?.id, orgId: site?.orgId);
|
||||
return;
|
||||
}
|
||||
final generation = ++_routesGeneration;
|
||||
setState(() {
|
||||
_loading = true;
|
||||
_error = null;
|
||||
});
|
||||
final scope = await _gateway.resolveScope(deviceId: '');
|
||||
final siteId = scope.siteId;
|
||||
if (!mounted) return;
|
||||
if (siteId == null) {
|
||||
try {
|
||||
final scope = await _gateway.resolveScope(deviceId: '');
|
||||
if (!mounted || generation != _routesGeneration) return;
|
||||
final siteId = scope.siteId;
|
||||
if (siteId == null) {
|
||||
setState(() {
|
||||
_loading = false;
|
||||
_error = AppLocalizations.of(
|
||||
context,
|
||||
).translate('work_v2.route_lib.no_site');
|
||||
});
|
||||
return;
|
||||
}
|
||||
final result = await _gateway.loadRoutes(siteId: siteId);
|
||||
if (!mounted || generation != _routesGeneration) return;
|
||||
final routes = result.data ?? const <WorkRouteOption>[];
|
||||
setState(() {
|
||||
_loading = false;
|
||||
_error = AppLocalizations.of(
|
||||
context,
|
||||
).translate('work_v2.route_lib.no_site');
|
||||
_routes = routes;
|
||||
_error = !result.isOk
|
||||
? result.error
|
||||
: routes.isEmpty
|
||||
? AppLocalizations.of(
|
||||
context,
|
||||
).translate('work_v2.route_lib.empty_site')
|
||||
: null;
|
||||
});
|
||||
} catch (error) {
|
||||
if (!mounted || generation != _routesGeneration) return;
|
||||
setState(() {
|
||||
_loading = false;
|
||||
_error = '$error';
|
||||
});
|
||||
return;
|
||||
}
|
||||
final result = await _gateway.loadRoutes(siteId: siteId);
|
||||
if (!mounted) return;
|
||||
final routes = result.data ?? const <WorkRouteOption>[];
|
||||
setState(() {
|
||||
_loading = false;
|
||||
_routes = routes;
|
||||
_error = routes.isEmpty
|
||||
? (result.error ??
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('work_v2.route_lib.empty_site'))
|
||||
: null;
|
||||
});
|
||||
}
|
||||
|
||||
/// 路线类型代码 -> 当前语言文案
|
||||
@@ -118,19 +182,20 @@ class _WorkRouteLibraryPageV2State extends State<WorkRouteLibraryPageV2> {
|
||||
const LatLng(31.083296, 120.840355);
|
||||
}
|
||||
|
||||
/// 按分栏过滤:返航为预留项(作业记录接口暂无返航类型数据,选中显示空态);
|
||||
/// 覆盖/自定义模式过滤逻辑保留,恢复 _filterKeys 对应分栏即可重新生效
|
||||
/// 普通路线仍按覆盖/自定义模式筛选;返航分栏由独立方案组件展示。
|
||||
List<WorkRouteOption> get _visible {
|
||||
if (_filter == 0) return _routes;
|
||||
final String kind = _filterKeys[_filter];
|
||||
if (kind == 'return') return const <WorkRouteOption>[];
|
||||
if (kind == 'return') return _routes;
|
||||
final bool wantCoverage = kind == 'coverage';
|
||||
return _routes.where((r) => r.coverageMode == wantCoverage).toList();
|
||||
}
|
||||
|
||||
/// 进入横屏「地图与区域编辑」画路线;返回后把方向还给竖屏并刷新列表
|
||||
Future<void> _openEditor() async {
|
||||
await Navigator.of(context).push(RouteEditorPageV2.route(deviceSn: ''));
|
||||
await Navigator.of(
|
||||
context,
|
||||
).push(RouteEditorPageV2.route(deviceSn: '', startReturnEditor: _isReturn));
|
||||
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||
if (mounted) _load();
|
||||
@@ -178,7 +243,11 @@ class _WorkRouteLibraryPageV2State extends State<WorkRouteLibraryPageV2> {
|
||||
onBack: () => Navigator.of(context).maybePop(),
|
||||
trailing: WorkSquareButton(
|
||||
icon: Icons.add_rounded,
|
||||
label: l10n.translate('work_v2.route_lib.new'),
|
||||
label: l10n.translate(
|
||||
_isReturn
|
||||
? 'work_v2.route_lib.return_manage'
|
||||
: 'work_v2.route_lib.new',
|
||||
),
|
||||
primary: true,
|
||||
onTap: _openEditor,
|
||||
),
|
||||
@@ -186,13 +255,21 @@ class _WorkRouteLibraryPageV2State extends State<WorkRouteLibraryPageV2> {
|
||||
const SizedBox(height: 12),
|
||||
WorkPageHeading(
|
||||
title: l10n.translate('work_v2.route_lib.title'),
|
||||
subtitle: l10n.translate('work_v2.route_lib.page_subtitle'),
|
||||
subtitle: l10n.translate(
|
||||
_isReturn
|
||||
? 'work_v2.route_lib.return_subtitle'
|
||||
: 'work_v2.route_lib.page_subtitle',
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
WorkFilterRow(
|
||||
items: _filterKeys.map((k) => _kindLabel(l10n, k)).toList(),
|
||||
index: _filter,
|
||||
onChanged: (i) => setState(() => _filter = i),
|
||||
onChanged: (i) {
|
||||
if (_filter == i) return;
|
||||
setState(() => _filter = i);
|
||||
unawaited(_load());
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Expanded(child: _buildBody(l10n, routes)),
|
||||
@@ -202,6 +279,13 @@ class _WorkRouteLibraryPageV2State extends State<WorkRouteLibraryPageV2> {
|
||||
}
|
||||
|
||||
Widget _buildBody(AppLocalizations l10n, List<WorkRouteOption> routes) {
|
||||
if (_isReturn) {
|
||||
return ReturnPlanLibrarySection(
|
||||
cubit: _returnPlans,
|
||||
onReload: _load,
|
||||
onEdit: _openEditor,
|
||||
);
|
||||
}
|
||||
if (_loading) {
|
||||
return const Center(child: CircularProgressIndicator(strokeWidth: 2));
|
||||
}
|
||||
@@ -270,10 +354,7 @@ class _WorkRouteLibraryPageV2State extends State<WorkRouteLibraryPageV2> {
|
||||
Widget _buildRouteCard(AppLocalizations l10n, WorkRouteOption r) {
|
||||
final bool coverage = r.coverageMode;
|
||||
final Color kindColor = coverage ? _cyan : kWtBlue;
|
||||
final String kindLabel = _kindLabel(
|
||||
l10n,
|
||||
coverage ? 'coverage' : 'custom',
|
||||
);
|
||||
final String kindLabel = _kindLabel(l10n, coverage ? 'coverage' : 'custom');
|
||||
final subtitle = r.metaText ?? r.planModeLabel ?? '路线 #${r.id}';
|
||||
final imageUrl = r.imageUrl;
|
||||
final String enterLabel = l10n.translate('work_v2.enter_work_center');
|
||||
@@ -303,8 +384,8 @@ class _WorkRouteLibraryPageV2State extends State<WorkRouteLibraryPageV2> {
|
||||
height: 96,
|
||||
fit: BoxFit.cover,
|
||||
width: double.infinity,
|
||||
errorBuilder:
|
||||
(context, error, stackTrace) => _mapThumb(),
|
||||
errorBuilder: (context, error, stackTrace) =>
|
||||
_mapThumb(),
|
||||
),
|
||||
)
|
||||
else
|
||||
@@ -401,11 +482,7 @@ class _WorkRouteLibraryPageV2State extends State<WorkRouteLibraryPageV2> {
|
||||
showRobot: false,
|
||||
);
|
||||
|
||||
Widget _smallAction(
|
||||
String text,
|
||||
VoidCallback onTap, {
|
||||
bool primary = false,
|
||||
}) {
|
||||
Widget _smallAction(String text, VoidCallback onTap, {bool primary = false}) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
|
||||
@@ -98,7 +98,7 @@ class WorkSquareButton extends StatelessWidget {
|
||||
});
|
||||
|
||||
final IconData icon;
|
||||
final VoidCallback onTap;
|
||||
final VoidCallback? onTap;
|
||||
final double size;
|
||||
|
||||
/// 有文字时变成胶囊按钮(如「+ 新建」)
|
||||
@@ -110,6 +110,10 @@ class WorkSquareButton extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final bool pill = label != null;
|
||||
final bool filled = primary && onTap != null;
|
||||
final foreground = onTap == null
|
||||
? kWtHint
|
||||
: (filled ? Colors.white : kWtNavy);
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
@@ -120,15 +124,15 @@ class WorkSquareButton extends StatelessWidget {
|
||||
? const EdgeInsets.symmetric(horizontal: 12)
|
||||
: EdgeInsets.zero,
|
||||
decoration: BoxDecoration(
|
||||
color: primary ? kWtBlue : Colors.white,
|
||||
color: filled ? kWtBlue : Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: primary ? Colors.transparent : kWtBorder),
|
||||
border: Border.all(color: filled ? Colors.transparent : kWtBorder),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(icon, size: size, color: primary ? Colors.white : kWtNavy),
|
||||
Icon(icon, size: size, color: foreground),
|
||||
if (pill) ...[
|
||||
const SizedBox(width: 3),
|
||||
Text(
|
||||
@@ -136,7 +140,7 @@ class WorkSquareButton extends StatelessWidget {
|
||||
style: TextStyle(
|
||||
fontSize: 12.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: primary ? Colors.white : kWtNavy,
|
||||
color: foreground,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user