重整多余的UI组件和未定功能的逻辑链路的修正
This commit is contained in:
@@ -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