页面UI替换1远程遥控和各项弹窗和作业主页面和子页面+路径规划的主页面重构等
This commit is contained in:
337
lib/features/v2/work/presentation/pages/work_area_page_v2.dart
Normal file
337
lib/features/v2/work/presentation/pages/work_area_page_v2.dart
Normal file
@@ -0,0 +1,337 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:maibu_satabot_v2/components/capsule_toast.dart';
|
||||
import 'package:maibu_satabot_v2/core/di/injection.dart';
|
||||
import 'package:maibu_satabot_v2/features/home/presentation/widgets/map/geoserver_suzhou_layer.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';
|
||||
|
||||
/// 作业区域管理(W03)——作业首页「区域管理」入口进入。
|
||||
///
|
||||
/// 竖屏单页:区域卡片列表(缩略图 + 面积 + 边界点数),
|
||||
/// 右上「新建」、「编辑」都进入横屏「地图与区域编辑」去画边界。
|
||||
///
|
||||
/// 本页为演示页:区域数据是写死的示例,不读写真实地块;
|
||||
/// 只有「进入编辑器」是真实跳转,其余动作只做界面反馈。
|
||||
class WorkAreaPageV2 extends StatefulWidget {
|
||||
const WorkAreaPageV2({super.key});
|
||||
|
||||
static Route<void> route() =>
|
||||
MaterialPageRoute<void>(builder: (_) => const WorkAreaPageV2());
|
||||
|
||||
@override
|
||||
State<WorkAreaPageV2> createState() => _WorkAreaPageV2State();
|
||||
}
|
||||
|
||||
/// 一条演示区域
|
||||
class _DemoArea {
|
||||
const _DemoArea({
|
||||
required this.name,
|
||||
required this.kind,
|
||||
required this.area,
|
||||
required this.points,
|
||||
required this.robot,
|
||||
required this.enabled,
|
||||
});
|
||||
|
||||
final String name;
|
||||
|
||||
/// 作业区 / 禁行区 / 障碍区
|
||||
final String kind;
|
||||
final String area;
|
||||
final int points;
|
||||
final String robot;
|
||||
final bool enabled;
|
||||
}
|
||||
|
||||
class _WorkAreaPageV2State extends State<WorkAreaPageV2> {
|
||||
static const Color _navy = kWtNavy;
|
||||
static const Color _gray = kWtGray;
|
||||
static const Color _border = kWtBorder;
|
||||
static const Color _green = Color(0xFF00B42A);
|
||||
static const Color _red = Color(0xFFF0483E);
|
||||
static const Color _orange = Color(0xFFEE9A2E);
|
||||
|
||||
static const List<String> _filters = <String>['全部区域', '作业区', '禁行区', '障碍区'];
|
||||
int _filter = 0;
|
||||
|
||||
static const List<_DemoArea> _areas = <_DemoArea>[
|
||||
_DemoArea(
|
||||
name: 'A 区 · 主草坪',
|
||||
kind: '作业区',
|
||||
area: '3 240 m²',
|
||||
points: 12,
|
||||
robot: '山东01号机',
|
||||
enabled: true,
|
||||
),
|
||||
_DemoArea(
|
||||
name: 'B 区 · 东侧草坪',
|
||||
kind: '作业区',
|
||||
area: '2 860 m²',
|
||||
points: 9,
|
||||
robot: '山东02号机',
|
||||
enabled: true,
|
||||
),
|
||||
_DemoArea(
|
||||
name: 'C 区 · 苗圃',
|
||||
kind: '作业区',
|
||||
area: '640 m²',
|
||||
points: 14,
|
||||
robot: '山东01号机',
|
||||
enabled: false,
|
||||
),
|
||||
_DemoArea(
|
||||
name: '水池禁行区',
|
||||
kind: '禁行区',
|
||||
area: '186 m²',
|
||||
points: 6,
|
||||
robot: '全部设备',
|
||||
enabled: true,
|
||||
),
|
||||
_DemoArea(
|
||||
name: '工具房障碍',
|
||||
kind: '障碍区',
|
||||
area: '42 m²',
|
||||
points: 4,
|
||||
robot: '全部设备',
|
||||
enabled: true,
|
||||
),
|
||||
];
|
||||
|
||||
void _toast(String text) => CapsuleToast.show(text, showCheck: false);
|
||||
|
||||
LatLng get _center {
|
||||
final site = sl<SiteCubit>().state.selectedSite;
|
||||
return stationLayerCenter(site?.siteMapName) ??
|
||||
const LatLng(31.083296, 120.840355);
|
||||
}
|
||||
|
||||
List<_DemoArea> get _visible {
|
||||
if (_filter == 0) return _areas;
|
||||
final String kind = _filters[_filter];
|
||||
return _areas.where((a) => a.kind == kind).toList();
|
||||
}
|
||||
|
||||
/// 进入横屏「地图与区域编辑」画边界;返回后把方向还给竖屏
|
||||
Future<void> _openEditor() async {
|
||||
await Navigator.of(context).push(RouteEditorPageV2.route(deviceSn: ''));
|
||||
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||
}
|
||||
|
||||
Color _kindColor(String kind) {
|
||||
switch (kind) {
|
||||
case '禁行区':
|
||||
return _red;
|
||||
case '障碍区':
|
||||
return _orange;
|
||||
default:
|
||||
return _green;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final areas = _visible;
|
||||
return WorkPhoneScaffold(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
WorkPhoneTopBar(
|
||||
title: '区域管理',
|
||||
onBack: () => Navigator.of(context).maybePop(),
|
||||
trailing: WorkSquareButton(
|
||||
icon: Icons.add_rounded,
|
||||
label: '新建',
|
||||
primary: true,
|
||||
onTap: _openEditor,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
const WorkPageHeading(
|
||||
title: '作业区域管理',
|
||||
subtitle: '在地图和区域编辑里画出作业区、禁行区与障碍区',
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
WorkFilterRow(
|
||||
items: _filters,
|
||||
index: _filter,
|
||||
onChanged: (i) => setState(() => _filter = i),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Expanded(
|
||||
child: areas.isEmpty
|
||||
? _buildEmpty()
|
||||
: ListView.separated(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
itemCount: areas.length,
|
||||
separatorBuilder: (_, _) => const SizedBox(height: 10),
|
||||
itemBuilder: (context, i) => _buildAreaCard(areas[i]),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildEmpty() {
|
||||
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.layers_outlined, size: 26, color: kWtMuted),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const Text(
|
||||
'该类型下还没有区域',
|
||||
style: TextStyle(fontSize: 12.5, color: _gray),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 区域卡 =====
|
||||
Widget _buildAreaCard(_DemoArea a) {
|
||||
final Color kindColor = _kindColor(a.kind);
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: _border),
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 左侧缩略图:作业区叠区域块,禁行/障碍只留底图
|
||||
SizedBox(
|
||||
width: 92,
|
||||
child: WorkMapThumb(
|
||||
center: _center,
|
||||
width: 92,
|
||||
height: 70,
|
||||
radius: 10,
|
||||
zoom: 17.8,
|
||||
showAreas: a.kind == '作业区',
|
||||
showRoute: a.kind == '作业区',
|
||||
showRobot: false,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
a.name,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 7,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: kindColor.withValues(alpha: 0.12),
|
||||
borderRadius: BorderRadius.circular(999),
|
||||
),
|
||||
child: Text(
|
||||
a.kind,
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: kindColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Text(
|
||||
'${a.area} · ${a.points} 个边界点',
|
||||
style: const TextStyle(fontSize: 11.5, color: _gray),
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
'适用:${a.robot}',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontSize: 11, color: kWtHint),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
if (!a.enabled)
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 7,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: kWtLocked,
|
||||
borderRadius: BorderRadius.circular(999),
|
||||
),
|
||||
child: const Text(
|
||||
'已停用',
|
||||
style: TextStyle(fontSize: 9.5, color: kWtMuted),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
_smallAction('查看', () => _toast('区域详情接口未接入(演示)')),
|
||||
const SizedBox(width: 8),
|
||||
_smallAction('编辑', _openEditor, primary: true),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _smallAction(String text, VoidCallback onTap, {bool primary = false}) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
||||
decoration: BoxDecoration(
|
||||
color: primary ? kWtSoftBlue : kWtSegBg,
|
||||
borderRadius: BorderRadius.circular(9),
|
||||
border: Border.all(color: primary ? kWtBlue : _border),
|
||||
),
|
||||
child: Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontSize: 10.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: primary ? kWtBlue : kWtGray2,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
917
lib/features/v2/work/presentation/pages/work_home_page_v2.dart
Normal file
917
lib/features/v2/work/presentation/pages/work_home_page_v2.dart
Normal file
@@ -0,0 +1,917 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.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/devices/presentation/bloc/devices_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/devices/presentation/bloc/devices_state.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/device_list/presentation/bloc/robot_list_bloc.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/device_list/presentation/bloc/robot_list_event.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/device_list/presentation/bloc/robot_list_state.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/device_list/presentation/pages/robot_autonomous_work_page_v2.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/device_list/presentation/pages/route_editor_page_v2.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/site/presentation/cubit/site_cubit.dart';
|
||||
|
||||
import 'work_area_page_v2.dart';
|
||||
import 'work_map_page_v2.dart';
|
||||
import 'work_plan_page_v2.dart';
|
||||
import 'work_record_page_v2.dart';
|
||||
import 'work_route_library_page_v2.dart';
|
||||
|
||||
/// 作业 tab 首页(W01 设计稿)
|
||||
///
|
||||
/// 纯展示层:只负责视觉与入口收敛,所有未接通的入口统一走
|
||||
/// `CapsuleToast.show('功能暂未开发')`,与设备详情 V2 保持同一口径。
|
||||
class WorkHomePageV2 extends StatelessWidget {
|
||||
/// 顶部返回键:切回「设备」tab(作业是从设备派生出来的主线)
|
||||
final VoidCallback? onBack;
|
||||
|
||||
const WorkHomePageV2({super.key, this.onBack});
|
||||
|
||||
// ===== 设计稿色板 =====
|
||||
static const Color _navy = Color(0xFF1A2B4A);
|
||||
static const Color _gray = Color(0xFF86909C);
|
||||
static const Color _hint = Color(0xFFA8B3C5);
|
||||
static const Color _blue = Color(0xFF1C96F6);
|
||||
static const Color _border = Color(0xFFE5EDF7);
|
||||
static const Color _trackBg = Color(0xFFDCEBFA);
|
||||
|
||||
// ===== 示例数据(后续接 DeviceTaskCubit.taskPool 替换) =====
|
||||
static const int _runningCount = 1;
|
||||
static const int _pendingCount = 3;
|
||||
static const int _doneTodayCount = 2;
|
||||
static const String _demoAreaCount = '4';
|
||||
static const String _demoRouteLine = 'A区路线01';
|
||||
static const double _demoProgress = 0.68;
|
||||
static const String _demoDone = '1.7 / 2.5 亩';
|
||||
static const String _demoRemain = '预计剩余 40 分钟';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFF1F7FE),
|
||||
body: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
// 浅蓝渐变底:顶部接近白,向下逐渐加深
|
||||
const DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [Color(0xFFF8FCFF), Color(0xFFE6F1FD)],
|
||||
),
|
||||
),
|
||||
),
|
||||
SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.fromLTRB(16, 4, 16, 20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
_buildTopBar(context),
|
||||
const SizedBox(height: 14),
|
||||
_buildOverviewHeader(context),
|
||||
const SizedBox(height: 12),
|
||||
_buildSiteCard(context),
|
||||
const SizedBox(height: 12),
|
||||
_buildStatRow(),
|
||||
const SizedBox(height: 20),
|
||||
_buildSectionHeader(
|
||||
'当前作业',
|
||||
trailing: '全部任务',
|
||||
onTrailingTap: () => _openPlan(context),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildRunningTaskCard(context),
|
||||
const SizedBox(height: 12),
|
||||
_buildPendingTaskCard(context),
|
||||
const SizedBox(height: 20),
|
||||
_buildSectionTitleOnly('作业功能'),
|
||||
const SizedBox(height: 10),
|
||||
_buildFeatureGrid(context),
|
||||
const SizedBox(height: 20),
|
||||
_buildCreateTaskButton(context),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _todo() => CapsuleToast.show('功能暂未开发', showCheck: false);
|
||||
|
||||
/// 「新建作业任务」:进入横屏「地图与区域编辑」,先画区域再生成路线。
|
||||
///
|
||||
/// 本页是竖屏,进入时方向交给编辑器;**等 pop 转场结束**再恢复竖屏,
|
||||
/// 否则方向切换会和返回动画撞在一起(安卓上会闪一下桌面)。
|
||||
Future<void> _openRouteEditor(BuildContext context) async {
|
||||
final devices = sl<DevicesCubit>().state.devices;
|
||||
await Navigator.of(context).push(
|
||||
RouteEditorPageV2.route(
|
||||
deviceSn: devices.isEmpty ? '' : devices.first.deviceName,
|
||||
),
|
||||
);
|
||||
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||
}
|
||||
|
||||
/// 「作业地图」:竖屏单页,一张图上同时看区域 / 路线 / 机器人
|
||||
void _openWorkMap(BuildContext context) {
|
||||
Navigator.of(context).push(WorkMapPageV2.route());
|
||||
}
|
||||
|
||||
/// 「区域管理」:竖屏区域列表,新建/编辑再进横屏编辑器
|
||||
void _openArea(BuildContext context) {
|
||||
Navigator.of(context).push(WorkAreaPageV2.route());
|
||||
}
|
||||
|
||||
/// 「路线库」:按作业区归档的覆盖路线
|
||||
void _openRouteLibrary(BuildContext context) {
|
||||
Navigator.of(context).push(WorkRouteLibraryPageV2.route());
|
||||
}
|
||||
|
||||
/// 「作业计划」:竖屏计划时间线
|
||||
void _openPlan(BuildContext context) {
|
||||
Navigator.of(context).push(WorkPlanPageV2.route());
|
||||
}
|
||||
|
||||
/// 「作业记录」:竖屏归档列表,可继续看单次报告
|
||||
void _openRecord(BuildContext context) {
|
||||
Navigator.of(context).push(WorkRecordPageV2.route());
|
||||
}
|
||||
|
||||
/// 「自主作业」:进横屏自主作业中心。
|
||||
///
|
||||
/// 设备取 RobotListBloc 已加载的真实设备;尚未加载过就先拉一次列表,
|
||||
/// 本次提示稍后再进(不拿占位设备凑数)。返回后把方向还给竖屏。
|
||||
Future<void> _openAutonomousWork(BuildContext context) async {
|
||||
final bloc = sl<RobotListBloc>();
|
||||
final state = bloc.state;
|
||||
if (state is! RobotListLoaded || state.robots.isEmpty) {
|
||||
bloc.add(
|
||||
RobotListLoadData(siteId: sl<SiteCubit>().state.selectedSite?.id),
|
||||
);
|
||||
CapsuleToast.show('正在加载设备列表,请稍后再次进入自主作业', showCheck: false);
|
||||
return;
|
||||
}
|
||||
await Navigator.of(context).push(
|
||||
MaterialPageRoute<void>(
|
||||
builder: (_) => RobotAutonomousWorkPageV2(robot: state.robots.first),
|
||||
),
|
||||
);
|
||||
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||
}
|
||||
|
||||
// ===== 顶栏 =====
|
||||
Widget _buildTopBar(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
_buildSquareButton(
|
||||
icon: Icons.chevron_left_rounded,
|
||||
size: 22,
|
||||
onTap: onBack,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
const Text(
|
||||
'作业首页',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
// 右上角:作业记录 / 归档入口
|
||||
_buildSquareButton(
|
||||
icon: Icons.description_outlined,
|
||||
size: 18,
|
||||
onTap: () => _openRecord(context),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSquareButton({
|
||||
required IconData icon,
|
||||
required double size,
|
||||
VoidCallback? onTap,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Container(
|
||||
width: 36,
|
||||
height: 36,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: _border),
|
||||
),
|
||||
child: Icon(icon, size: size, color: _navy),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 作业总览标题区 =====
|
||||
Widget _buildOverviewHeader(BuildContext context) {
|
||||
return BlocBuilder<SiteCubit, SiteState>(
|
||||
bloc: sl<SiteCubit>(),
|
||||
builder: (context, siteState) {
|
||||
final siteName = siteState.selectedSite?.siteName ?? '未选择场站';
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'SATA · 智能运维',
|
||||
style: TextStyle(
|
||||
fontSize: 11.5,
|
||||
letterSpacing: 0.3,
|
||||
color: _gray,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
const Text(
|
||||
'作业总览',
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'$siteName · 全部作业机器人',
|
||||
style: const TextStyle(fontSize: 12, color: _gray),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: _todo,
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 场站卡 =====
|
||||
Widget _buildSiteCard(BuildContext context) {
|
||||
// 可执行机器人数与设备 tab 同源:DevicesCubit 是全局单例
|
||||
return BlocBuilder<DevicesCubit, DevicesState>(
|
||||
bloc: sl<DevicesCubit>(),
|
||||
builder: (context, deviceState) {
|
||||
final int deviceCount = deviceState.devices.length;
|
||||
return BlocBuilder<SiteCubit, SiteState>(
|
||||
bloc: sl<SiteCubit>(),
|
||||
builder: (context, siteState) {
|
||||
final siteName = siteState.selectedSite?.siteName ?? '未选择场站';
|
||||
return Container(
|
||||
padding: const EdgeInsets.fromLTRB(14, 13, 12, 13),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: _border),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'场站:$siteName',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'$_demoAreaCount个作业区域 · $deviceCount台可执行机器人',
|
||||
style: const TextStyle(fontSize: 11.5, color: _gray),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
GestureDetector(
|
||||
onTap: () => _showSitePicker(context, siteState),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 10,
|
||||
vertical: 5,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFE7F3FE),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'切换',
|
||||
style: TextStyle(
|
||||
fontSize: 11.5,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: _blue,
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
Icons.keyboard_arrow_down_rounded,
|
||||
size: 14,
|
||||
color: _blue,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// 切换场站:与设备页同一套 SiteCubit,选中后各页自动重拉数据
|
||||
void _showSitePicker(BuildContext context, SiteState siteState) {
|
||||
if (siteState.sites.isEmpty) {
|
||||
CapsuleToast.show('暂无场站数据', showCheck: false);
|
||||
return;
|
||||
}
|
||||
final siteCubit = sl<SiteCubit>();
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
backgroundColor: Colors.white,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
|
||||
),
|
||||
builder: (sheetCtx) {
|
||||
return SafeArea(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 14),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'选择场站',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const Divider(height: 1, color: Color(0xFFF0F4FA)),
|
||||
Flexible(
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: siteState.sites.length,
|
||||
itemBuilder: (_, i) {
|
||||
final site = siteState.sites[i];
|
||||
final selected =
|
||||
siteCubit.state.selectedSite?.id == site.id;
|
||||
return ListTile(
|
||||
title: Text(
|
||||
site.siteName,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: selected
|
||||
? FontWeight.w600
|
||||
: FontWeight.w400,
|
||||
color: selected ? _blue : _navy,
|
||||
),
|
||||
),
|
||||
trailing: selected
|
||||
? const Icon(Icons.check, size: 20, color: _blue)
|
||||
: null,
|
||||
onTap: () {
|
||||
siteCubit.selectSite(site);
|
||||
Navigator.pop(sheetCtx);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 三张统计卡 =====
|
||||
Widget _buildStatRow() {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildStatCard(
|
||||
label: '执行中',
|
||||
value: '$_runningCount',
|
||||
tag: '正常',
|
||||
tagColor: const Color(0xFF1D9E57),
|
||||
tagBg: const Color(0xFFE5F8EC),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: _buildStatCard(
|
||||
label: '待执行',
|
||||
value: '$_pendingCount',
|
||||
tag: '待安排',
|
||||
tagColor: const Color(0xFFD98A16),
|
||||
tagBg: const Color(0xFFFEF3E3),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: _buildStatCard(
|
||||
label: '今日已完成',
|
||||
value: '$_doneTodayCount',
|
||||
tag: '任务',
|
||||
tagColor: _blue,
|
||||
tagBg: const Color(0xFFE7F3FE),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatCard({
|
||||
required String label,
|
||||
required String value,
|
||||
required String tag,
|
||||
required Color tagColor,
|
||||
required Color tagBg,
|
||||
}) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 13, horizontal: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: _border),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontSize: 11.5, color: _gray),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
value,
|
||||
style: const TextStyle(
|
||||
fontSize: 26,
|
||||
height: 1.05,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 7),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 9, vertical: 2.5),
|
||||
decoration: BoxDecoration(
|
||||
color: tagBg,
|
||||
borderRadius: BorderRadius.circular(9),
|
||||
),
|
||||
child: Text(
|
||||
tag,
|
||||
style: TextStyle(
|
||||
fontSize: 10.5,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: tagColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 分组标题 =====
|
||||
Widget _buildSectionHeader(
|
||||
String title, {
|
||||
String? trailing,
|
||||
VoidCallback? onTrailingTap,
|
||||
}) {
|
||||
return Row(
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
if (trailing != null)
|
||||
GestureDetector(
|
||||
onTap: onTrailingTap,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
trailing,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: _blue,
|
||||
),
|
||||
),
|
||||
const Icon(Icons.arrow_forward_rounded, size: 13, color: _blue),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSectionTitleOnly(String title) {
|
||||
return Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _navy,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 执行中任务卡 =====
|
||||
Widget _buildRunningTaskCard(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.fromLTRB(14, 13, 14, 12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: _border),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Expanded(
|
||||
child: Text(
|
||||
'A区 · 自主割草任务',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 16.5,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
_buildStatusPill(
|
||||
'执行中',
|
||||
const Color(0xFF1D9E57),
|
||||
const Color(0xFFE5F8EC),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
const Text(
|
||||
'山东01号机 · MC700 PLUS · $_demoRouteLine',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(fontSize: 11.5, color: _gray),
|
||||
),
|
||||
const SizedBox(height: 11),
|
||||
// 进度条
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
child: Stack(
|
||||
children: [
|
||||
Container(height: 6, color: _trackBg),
|
||||
FractionallySizedBox(
|
||||
widthFactor: _demoProgress,
|
||||
child: Container(
|
||||
height: 6,
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [Color(0xFF3EB8FF), Color(0xFF1C96F6)],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 7),
|
||||
Row(
|
||||
children: [
|
||||
const Text(
|
||||
'已完成 $_demoDone',
|
||||
style: TextStyle(fontSize: 11.5, color: _gray),
|
||||
),
|
||||
const Spacer(),
|
||||
Text(
|
||||
'${(_demoProgress * 100).round()}%',
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _blue,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 11),
|
||||
const Divider(height: 1, color: Color(0xFFF0F4FA)),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
const Expanded(
|
||||
child: Text(
|
||||
_demoRemain,
|
||||
style: TextStyle(fontSize: 11.5, color: _gray),
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () => _openAutonomousWork(context),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 14,
|
||||
vertical: 8,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
gradient: const LinearGradient(
|
||||
colors: [Color(0xFF3EB8FF), Color(0xFF1C96F6)],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(18),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: _blue.withValues(alpha: 0.25),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'进入作业中心',
|
||||
style: TextStyle(
|
||||
fontSize: 11.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 3),
|
||||
Icon(
|
||||
Icons.arrow_forward_rounded,
|
||||
size: 13,
|
||||
color: Colors.white,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 待执行任务卡 =====
|
||||
Widget _buildPendingTaskCard(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.fromLTRB(14, 13, 14, 11),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: _border),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Expanded(
|
||||
child: Text(
|
||||
'B区 · 清晨割草',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 16.5,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
_buildStatusPill(
|
||||
'待执行',
|
||||
const Color(0xFFD98A16),
|
||||
const Color(0xFFFEF3E3),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
const Text(
|
||||
'山东02号机 · B区路线01 · 明日 08:00',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(fontSize: 11.5, color: _gray),
|
||||
),
|
||||
const SizedBox(height: 11),
|
||||
const Divider(height: 1, color: Color(0xFFF0F4FA)),
|
||||
const SizedBox(height: 9),
|
||||
GestureDetector(
|
||||
onTap: () => _openPlan(context),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'查看作业计划',
|
||||
style: TextStyle(
|
||||
fontSize: 11.5,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: _blue,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 2),
|
||||
Icon(Icons.arrow_forward_rounded, size: 13, color: _blue),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatusPill(String text, Color color, Color bg) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 3),
|
||||
decoration: BoxDecoration(
|
||||
color: bg,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontSize: 10.5,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 作业功能网格(2 列 3 行) =====
|
||||
Widget _buildFeatureGrid(BuildContext context) {
|
||||
final items = <(IconData, String, VoidCallback)>[
|
||||
(Icons.map_outlined, '作业地图', () => _openWorkMap(context)),
|
||||
(Icons.layers_outlined, '区域管理', () => _openArea(context)),
|
||||
(Icons.alt_route_outlined, '路线库', () => _openRouteLibrary(context)),
|
||||
(Icons.event_note_outlined, '作业计划', () => _openPlan(context)),
|
||||
(Icons.receipt_long_outlined, '作业记录', () => _openRecord(context)),
|
||||
(Icons.play_circle_outline, '自主作业', () => _openAutonomousWork(context)),
|
||||
];
|
||||
final rows = <Widget>[];
|
||||
for (var i = 0; i < items.length; i += 2) {
|
||||
rows.add(
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildFeatureTile(items[i].$1, items[i].$2, items[i].$3),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: i + 1 < items.length
|
||||
? _buildFeatureTile(
|
||||
items[i + 1].$1,
|
||||
items[i + 1].$2,
|
||||
items[i + 1].$3,
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
if (i + 2 < items.length) rows.add(const SizedBox(height: 10));
|
||||
}
|
||||
return Column(children: rows);
|
||||
}
|
||||
|
||||
Widget _buildFeatureTile(IconData icon, String title, VoidCallback onTap) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 13),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: _border),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 32,
|
||||
height: 32,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFEAF3FE),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Icon(icon, size: 17, color: _blue),
|
||||
),
|
||||
const SizedBox(width: 9),
|
||||
Expanded(
|
||||
child: Text(
|
||||
title,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Icon(Icons.chevron_right_rounded, size: 18, color: _hint),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 底部主操作 =====
|
||||
Widget _buildCreateTaskButton(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () => _openRouteEditor(context),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Container(
|
||||
height: 48,
|
||||
decoration: BoxDecoration(
|
||||
gradient: const LinearGradient(
|
||||
colors: [Color(0xFF3EB8FF), Color(0xFF1C96F6)],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: _blue.withValues(alpha: 0.28),
|
||||
blurRadius: 14,
|
||||
offset: const Offset(0, 5),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: const Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.add_rounded, size: 18, color: Colors.white),
|
||||
SizedBox(width: 5),
|
||||
Text(
|
||||
'新建作业任务',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
650
lib/features/v2/work/presentation/pages/work_map_page_v2.dart
Normal file
650
lib/features/v2/work/presentation/pages/work_map_page_v2.dart
Normal file
@@ -0,0 +1,650 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:maibu_satabot_v2/components/capsule_toast.dart';
|
||||
import 'package:maibu_satabot_v2/core/di/injection.dart';
|
||||
import 'package:maibu_satabot_v2/features/home/presentation/widgets/map/geoserver_suzhou_layer.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/device_list/presentation/pages/route_editor_page_v2.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/site/presentation/cubit/site_cubit.dart';
|
||||
|
||||
/// 作业地图(W02)——作业首页「作业地图」入口进入。
|
||||
///
|
||||
/// 竖屏单页:一张场站地图上同时叠「作业区 / 禁行区 / 覆盖路线 / 机器人」,
|
||||
/// 顶部图层筛选只切换显示,不改任何数据;底部信息卡指向当前执行中的任务。
|
||||
///
|
||||
/// 本页为演示页:
|
||||
/// - 区域、禁行区、覆盖路线均为按场站中心生成的**示意几何**,不读真实地块;
|
||||
/// - 不发起任务控制/查询接口,按钮只做界面反馈或进入已实现的页面。
|
||||
class WorkMapPageV2 extends StatefulWidget {
|
||||
const WorkMapPageV2({super.key});
|
||||
|
||||
static Route<void> route() =>
|
||||
MaterialPageRoute<void>(builder: (_) => const WorkMapPageV2());
|
||||
|
||||
@override
|
||||
State<WorkMapPageV2> createState() => _WorkMapPageV2State();
|
||||
}
|
||||
|
||||
class _WorkMapPageV2State extends State<WorkMapPageV2> {
|
||||
// ===== 设计稿色板(与作业首页 W01 同源) =====
|
||||
static const Color _navy = Color(0xFF1A2B4A);
|
||||
static const Color _gray = Color(0xFF86909C);
|
||||
static const Color _blue = Color(0xFF1C96F6);
|
||||
static const Color _border = Color(0xFFE5EDF7);
|
||||
static const Color _green = Color(0xFF00B42A);
|
||||
static const Color _greenBg = Color(0xFFE8F8EC);
|
||||
|
||||
// 图层配色(设计稿:A 区青绿 / B 区蓝 / 禁行红 / 路线亮青)
|
||||
static const Color _areaA = Color(0xFF00D5A0);
|
||||
static const Color _areaB = Color(0xFF2E86FF);
|
||||
static const Color _forbid = Color(0xFFFF5C5C);
|
||||
static const Color _routeLine = Color(0xFF00E5C0);
|
||||
|
||||
static const String _esriUrl =
|
||||
'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}';
|
||||
|
||||
/// 图层筛选:0 全部 / 1 作业区 / 2 机器人 / 3 禁行区 / 4 路线
|
||||
static const List<String> _layers = <String>[
|
||||
'全部图层',
|
||||
'作业区',
|
||||
'机器人',
|
||||
'禁行区',
|
||||
'路线',
|
||||
];
|
||||
int _layer = 0;
|
||||
|
||||
late final LatLng _center = _resolveCenter();
|
||||
late final _DemoGeometry _geo = _DemoGeometry(_center);
|
||||
|
||||
final MapController _map = MapController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// 场站高清图层:与路径规划/作业中心同一套数据源,失败自动回退内置兜底
|
||||
StationLayerRepo.instance.refresh();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_map.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/// 进场中心:优先当前选中场站高清图层中心,无有效场站兜底到苏州地块
|
||||
LatLng _resolveCenter() {
|
||||
final site = sl<SiteCubit>().state.selectedSite;
|
||||
return stationLayerCenter(site?.siteMapName) ??
|
||||
const LatLng(31.083296, 120.840355);
|
||||
}
|
||||
|
||||
void _toast(String text) => CapsuleToast.show(text, showCheck: false);
|
||||
|
||||
bool get _showAreas => _layer == 0 || _layer == 1;
|
||||
bool get _showRobot => _layer == 0 || _layer == 2;
|
||||
bool get _showForbid => _layer == 0 || _layer == 3;
|
||||
bool get _showRoute => _layer == 0 || _layer == 4;
|
||||
|
||||
/// 「管理区域」→ 横屏「地图与区域编辑」;返回后把方向还给竖屏
|
||||
Future<void> _openAreaEditor() async {
|
||||
await Navigator.of(context).push(RouteEditorPageV2.route(deviceSn: ''));
|
||||
if (!mounted) return;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFF1F7FE),
|
||||
body: DecoratedBox(
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [Color(0xFFF8FCFF), Color(0xFFE6F1FD)],
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 4, 16, 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
_buildTopBar(),
|
||||
const SizedBox(height: 14),
|
||||
_buildHeader(),
|
||||
const SizedBox(height: 12),
|
||||
_buildLayerChips(),
|
||||
const SizedBox(height: 12),
|
||||
Expanded(child: _buildMapCard()),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 顶栏 =====
|
||||
Widget _buildTopBar() {
|
||||
return Row(
|
||||
children: [
|
||||
_squareButton(
|
||||
Icons.chevron_left_rounded,
|
||||
size: 22,
|
||||
onTap: () => Navigator.of(context).maybePop(),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
const Text(
|
||||
'作业地图',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
_squareButton(
|
||||
Icons.description_outlined,
|
||||
size: 18,
|
||||
onTap: () => _toast('作业记录入口未接入(演示)'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _squareButton(
|
||||
IconData icon, {
|
||||
required double size,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Container(
|
||||
width: 36,
|
||||
height: 36,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: _border),
|
||||
),
|
||||
child: Icon(icon, size: size, color: _navy),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 标题区 =====
|
||||
Widget _buildHeader() {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'作业地图',
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 5),
|
||||
Text(
|
||||
'机器人、区域和任务在同一张场站地图上',
|
||||
style: TextStyle(fontSize: 12, color: _gray),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 6),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: _greenBg,
|
||||
borderRadius: BorderRadius.circular(999),
|
||||
),
|
||||
child: const Text(
|
||||
'3台在线',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: _green,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 图层筛选 =====
|
||||
Widget _buildLayerChips() {
|
||||
return SizedBox(
|
||||
height: 32,
|
||||
child: ListView.separated(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: _layers.length,
|
||||
separatorBuilder: (_, _) => const SizedBox(width: 8),
|
||||
itemBuilder: (context, index) {
|
||||
final selected = _layer == index;
|
||||
return GestureDetector(
|
||||
onTap: () => setState(() => _layer = index),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 160),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14),
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: selected ? const Color(0xFFEAF3FE) : Colors.white,
|
||||
borderRadius: BorderRadius.circular(999),
|
||||
border: Border.all(
|
||||
color: selected ? _blue : _border,
|
||||
width: selected ? 1.4 : 1,
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
_layers[index],
|
||||
style: TextStyle(
|
||||
fontSize: 12.5,
|
||||
fontWeight: selected ? FontWeight.w700 : FontWeight.w500,
|
||||
color: selected ? _blue : _gray,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 地图卡片 =====
|
||||
Widget _buildMapCard() {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFDDEAD8),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x1A1A2B4A),
|
||||
blurRadius: 18,
|
||||
offset: Offset(0, 6),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
_buildMap(),
|
||||
// 左上:底图来源
|
||||
Positioned(
|
||||
left: 10,
|
||||
top: 10,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 10,
|
||||
vertical: 5,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withValues(alpha: 0.92),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: const Text(
|
||||
'正射影像 · 山东场站',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// 右上:图层 / 定位
|
||||
Positioned(
|
||||
right: 10,
|
||||
top: 10,
|
||||
child: Column(
|
||||
children: [
|
||||
_mapFloatButton(
|
||||
Icons.layers_outlined,
|
||||
onTap: () => _toast('图层设置与顶部筛选联动(演示)'),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_mapFloatButton(Icons.place_outlined, onTap: _resetView),
|
||||
],
|
||||
),
|
||||
),
|
||||
// 底部:当前任务卡
|
||||
Positioned(
|
||||
left: 10,
|
||||
right: 10,
|
||||
bottom: 10,
|
||||
child: _buildTaskCard(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _mapFloatButton(IconData icon, {required VoidCallback onTap}) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
width: 34,
|
||||
height: 34,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withValues(alpha: 0.94),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x1A1A2B4A),
|
||||
blurRadius: 8,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Icon(icon, size: 17, color: _navy),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMap() {
|
||||
return FlutterMap(
|
||||
mapController: _map,
|
||||
options: MapOptions(
|
||||
initialCenter: _center,
|
||||
initialZoom: 18,
|
||||
minZoom: 3,
|
||||
maxZoom: 22,
|
||||
interactionOptions: const InteractionOptions(
|
||||
flags: InteractiveFlag.all & ~InteractiveFlag.rotate,
|
||||
),
|
||||
),
|
||||
children: [
|
||||
TileLayer(
|
||||
urlTemplate: _esriUrl,
|
||||
userAgentPackageName: 'com.maibu.maibu_satabot_v2',
|
||||
minZoom: 0,
|
||||
maxZoom: 19,
|
||||
),
|
||||
// 地块边界(白色细线,跟随作业区一起显隐)
|
||||
if (_showAreas)
|
||||
PolylineLayer(
|
||||
polylines: [
|
||||
Polyline(
|
||||
points: _geo.bounds,
|
||||
color: const Color(0xCCFFFFFF),
|
||||
strokeWidth: 1.6,
|
||||
),
|
||||
for (final line in _geo.parcelLines)
|
||||
Polyline(
|
||||
points: line,
|
||||
color: const Color(0x99FFFFFF),
|
||||
strokeWidth: 1.2,
|
||||
),
|
||||
],
|
||||
),
|
||||
// 作业区:A(青绿) / B(蓝)
|
||||
if (_showAreas)
|
||||
PolygonLayer(
|
||||
polygons: [
|
||||
Polygon(
|
||||
points: _geo.areaA,
|
||||
color: _areaA.withValues(alpha: 0.24),
|
||||
borderColor: _areaA,
|
||||
borderStrokeWidth: 2.4,
|
||||
),
|
||||
Polygon(
|
||||
points: _geo.areaB,
|
||||
color: _areaB.withValues(alpha: 0.20),
|
||||
borderColor: _areaB,
|
||||
borderStrokeWidth: 2.4,
|
||||
),
|
||||
],
|
||||
),
|
||||
// 禁行区
|
||||
if (_showForbid)
|
||||
PolygonLayer(
|
||||
polygons: [
|
||||
Polygon(
|
||||
points: _geo.forbidden,
|
||||
color: _forbid.withValues(alpha: 0.18),
|
||||
borderColor: _forbid,
|
||||
borderStrokeWidth: 2.2,
|
||||
),
|
||||
],
|
||||
),
|
||||
// 覆盖路线(蛇形往复)
|
||||
if (_showRoute)
|
||||
PolylineLayer(
|
||||
polylines: [
|
||||
Polyline(points: _geo.route, color: _routeLine, strokeWidth: 3.2),
|
||||
],
|
||||
),
|
||||
// 机器人当前位置
|
||||
if (_showRobot)
|
||||
MarkerLayer(
|
||||
markers: [
|
||||
Marker(
|
||||
point: _geo.robot,
|
||||
width: 22,
|
||||
height: 22,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: _blue,
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(color: Colors.white, width: 3),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x4D1C96F6),
|
||||
blurRadius: 8,
|
||||
offset: Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 定位按钮:把视图拉回场站中心(本页不接实时定位推送)
|
||||
void _resetView() {
|
||||
_map.move(_center, 18);
|
||||
_toast('已回到场站中心(演示)');
|
||||
}
|
||||
|
||||
Widget _buildTaskCard() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.fromLTRB(14, 12, 14, 12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x1F1A2B4A),
|
||||
blurRadius: 14,
|
||||
offset: Offset(0, 5),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Expanded(
|
||||
child: Text(
|
||||
'A区 · 自主割草',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
|
||||
decoration: BoxDecoration(
|
||||
color: _greenBg,
|
||||
borderRadius: BorderRadius.circular(999),
|
||||
),
|
||||
child: const Text(
|
||||
'68%',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: _green,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
const Text(
|
||||
'设备:山东01号机 · 任务执行中',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(fontSize: 12, color: _gray),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
_cardButton('管理区域', primary: false, onTap: _openAreaEditor),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: _cardButton(
|
||||
'进入作业中心',
|
||||
primary: true,
|
||||
onTap: () => _toast('作业中心需从设备详情进入(演示)'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cardButton(
|
||||
String label, {
|
||||
required bool primary,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Container(
|
||||
height: 36,
|
||||
padding: EdgeInsets.symmetric(horizontal: primary ? 12 : 14),
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: primary ? _blue : const Color(0xFFF2F7FE),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
boxShadow: primary
|
||||
? [
|
||||
BoxShadow(
|
||||
color: _blue.withValues(alpha: 0.28),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
]
|
||||
: null,
|
||||
),
|
||||
child: Text(
|
||||
label,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: primary ? Colors.white : _blue,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 设计稿示意几何:以场站中心为原点,用「米」偏移换算成经纬度。
|
||||
/// 这样拖动/缩放地图时,区域与路线会跟着底图一起移动,不会飘在屏幕上。
|
||||
class _DemoGeometry {
|
||||
_DemoGeometry(this.center);
|
||||
|
||||
final LatLng center;
|
||||
|
||||
static const double _latPerM = 1 / 111320;
|
||||
|
||||
LatLng at(double dxM, double dyM) {
|
||||
final double lngPerM =
|
||||
1 / (111320 * math.cos(center.latitude * math.pi / 180));
|
||||
return LatLng(
|
||||
center.latitude + dyM * _latPerM,
|
||||
center.longitude + dxM * lngPerM,
|
||||
);
|
||||
}
|
||||
|
||||
/// 地块外边界(白色细线框)
|
||||
List<LatLng> get bounds => [
|
||||
at(-125, -165),
|
||||
at(150, -175),
|
||||
at(162, 92),
|
||||
at(-112, 104),
|
||||
];
|
||||
|
||||
/// 地块内部分隔线
|
||||
List<List<LatLng>> get parcelLines => [
|
||||
[at(-125, -55), at(156, -66)],
|
||||
[at(62, -172), at(74, 100)],
|
||||
];
|
||||
|
||||
/// A 区(青绿,微倾斜四边形)
|
||||
List<LatLng> get areaA => [
|
||||
at(-95, -130),
|
||||
at(10, -150),
|
||||
at(48, 40),
|
||||
at(-62, 62),
|
||||
];
|
||||
|
||||
/// B 区(蓝,右侧窄长条)
|
||||
List<LatLng> get areaB => [
|
||||
at(62, -120),
|
||||
at(122, -108),
|
||||
at(106, 72),
|
||||
at(52, 54),
|
||||
];
|
||||
|
||||
/// 禁行区(红,A 区中部)
|
||||
List<LatLng> get forbidden => [
|
||||
at(-42, -46),
|
||||
at(16, -52),
|
||||
at(22, 14),
|
||||
at(-34, 20),
|
||||
];
|
||||
|
||||
/// 覆盖路线(A 区内横向往复)
|
||||
List<LatLng> get route => [
|
||||
at(-82, -112),
|
||||
at(2, -118),
|
||||
at(2, -88),
|
||||
at(-78, -82),
|
||||
at(-78, -52),
|
||||
at(6, -58),
|
||||
at(6, -28),
|
||||
at(-74, -22),
|
||||
at(-74, 8),
|
||||
at(10, 2),
|
||||
];
|
||||
|
||||
/// 机器人当前位置(A 区中心附近)
|
||||
LatLng get robot => at(-6, -10);
|
||||
}
|
||||
470
lib/features/v2/work/presentation/pages/work_plan_page_v2.dart
Normal file
470
lib/features/v2/work/presentation/pages/work_plan_page_v2.dart
Normal file
@@ -0,0 +1,470 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/components/capsule_toast.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/work/presentation/widgets/work_phone_ui.dart';
|
||||
|
||||
/// 任务列表与计划(W07)——作业首页「作业计划」入口进入。
|
||||
///
|
||||
/// 竖屏单页:按日期分组的时间线,每张卡是一段作业计划,
|
||||
/// 顶部筛选用状态过滤,右上日历与「+ 新建计划」为演示入口。
|
||||
///
|
||||
/// 本页为演示页:计划数据写死,不读写全局任务状态、不下发任务;
|
||||
/// 需要真实任务的场景请走「自主作业」。
|
||||
class WorkPlanPageV2 extends StatefulWidget {
|
||||
const WorkPlanPageV2({super.key});
|
||||
|
||||
static Route<void> route() =>
|
||||
MaterialPageRoute<void>(builder: (_) => const WorkPlanPageV2());
|
||||
|
||||
@override
|
||||
State<WorkPlanPageV2> createState() => _WorkPlanPageV2State();
|
||||
}
|
||||
|
||||
/// 计划状态
|
||||
enum _PlanStatus { running, pending, done, aborted }
|
||||
|
||||
/// 一条演示计划
|
||||
class _DemoPlan {
|
||||
const _DemoPlan({
|
||||
required this.time,
|
||||
required this.title,
|
||||
required this.zone,
|
||||
required this.robot,
|
||||
required this.routeName,
|
||||
required this.status,
|
||||
required this.progress,
|
||||
});
|
||||
|
||||
final String time;
|
||||
final String title;
|
||||
final String zone;
|
||||
final String robot;
|
||||
final String routeName;
|
||||
final _PlanStatus status;
|
||||
|
||||
/// 0~1,已完成任务为 1
|
||||
final double progress;
|
||||
}
|
||||
|
||||
/// 一天的分组
|
||||
class _DemoDay {
|
||||
const _DemoDay({
|
||||
required this.label,
|
||||
required this.date,
|
||||
required this.plans,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final String date;
|
||||
final List<_DemoPlan> plans;
|
||||
}
|
||||
|
||||
class _WorkPlanPageV2State extends State<WorkPlanPageV2> {
|
||||
static const Color _navy = kWtNavy;
|
||||
static const Color _gray = kWtGray;
|
||||
static const Color _border = kWtBorder;
|
||||
static const Color _green = Color(0xFF00B42A);
|
||||
static const Color _orange = Color(0xFFEE9A2E);
|
||||
static const Color _red = Color(0xFFF0483E);
|
||||
|
||||
static const List<String> _filters = <String>['全部', '执行中', '待执行', '已完成'];
|
||||
int _filter = 0;
|
||||
|
||||
static const List<_DemoDay> _days = <_DemoDay>[
|
||||
_DemoDay(
|
||||
label: '今天',
|
||||
date: '10-27 周二',
|
||||
plans: <_DemoPlan>[
|
||||
_DemoPlan(
|
||||
time: '08:00',
|
||||
title: 'A区 · 自主割草',
|
||||
zone: 'A 区 · 主草坪',
|
||||
robot: '山东01号机',
|
||||
routeName: 'A区路线01',
|
||||
status: _PlanStatus.running,
|
||||
progress: 0.68,
|
||||
),
|
||||
_DemoPlan(
|
||||
time: '14:30',
|
||||
title: 'C区 · 苗圃修剪',
|
||||
zone: 'C 区 · 苗圃',
|
||||
robot: '山东02号机',
|
||||
routeName: 'C区覆盖01',
|
||||
status: _PlanStatus.pending,
|
||||
progress: 0,
|
||||
),
|
||||
],
|
||||
),
|
||||
_DemoDay(
|
||||
label: '明天',
|
||||
date: '10-28 周三',
|
||||
plans: <_DemoPlan>[
|
||||
_DemoPlan(
|
||||
time: '08:00',
|
||||
title: 'B区 · 清晨割草',
|
||||
zone: 'B 区 · 东侧草坪',
|
||||
robot: '山东02号机',
|
||||
routeName: 'B区路线01',
|
||||
status: _PlanStatus.pending,
|
||||
progress: 0,
|
||||
),
|
||||
_DemoPlan(
|
||||
time: '16:00',
|
||||
title: '全场 · 沿边修整',
|
||||
zone: '全场',
|
||||
robot: '山东03号机',
|
||||
routeName: 'B区沿边01',
|
||||
status: _PlanStatus.pending,
|
||||
progress: 0,
|
||||
),
|
||||
],
|
||||
),
|
||||
_DemoDay(
|
||||
label: '昨天',
|
||||
date: '10-26 周一',
|
||||
plans: <_DemoPlan>[
|
||||
_DemoPlan(
|
||||
time: '08:00',
|
||||
title: 'B区 · 清晨割草',
|
||||
zone: 'B 区 · 东侧草坪',
|
||||
robot: '山东02号机',
|
||||
routeName: 'B区路线01',
|
||||
status: _PlanStatus.done,
|
||||
progress: 1,
|
||||
),
|
||||
_DemoPlan(
|
||||
time: '09:10',
|
||||
title: 'C区 · 雨后补割',
|
||||
zone: 'C 区 · 苗圃',
|
||||
robot: '山东01号机',
|
||||
routeName: 'C区覆盖01',
|
||||
status: _PlanStatus.aborted,
|
||||
progress: 0.42,
|
||||
),
|
||||
],
|
||||
),
|
||||
];
|
||||
|
||||
void _toast(String text) => CapsuleToast.show(text, showCheck: false);
|
||||
|
||||
/// 当前筛选下的分组(分组内无匹配则整组隐藏)
|
||||
List<_DemoDay> get _visible {
|
||||
if (_filter == 0) return _days;
|
||||
final _PlanStatus want = switch (_filter) {
|
||||
1 => _PlanStatus.running,
|
||||
2 => _PlanStatus.pending,
|
||||
_ => _PlanStatus.done,
|
||||
};
|
||||
final out = <_DemoDay>[];
|
||||
for (final day in _days) {
|
||||
final plans = day.plans.where((p) => p.status == want).toList();
|
||||
if (plans.isNotEmpty) {
|
||||
out.add(_DemoDay(label: day.label, date: day.date, plans: plans));
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final days = _visible;
|
||||
return WorkPhoneScaffold(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
WorkPhoneTopBar(
|
||||
title: '作业计划',
|
||||
onBack: () => Navigator.of(context).maybePop(),
|
||||
trailing: Row(
|
||||
children: [
|
||||
WorkSquareButton(
|
||||
icon: Icons.calendar_month_outlined,
|
||||
size: 17,
|
||||
onTap: () => _toast('日历视图接口未接入(演示)'),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
WorkSquareButton(
|
||||
icon: Icons.add_rounded,
|
||||
label: '新建',
|
||||
primary: true,
|
||||
onTap: () => _toast('任务编排接口未接入(演示)'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
const WorkPageHeading(
|
||||
title: '任务列表与计划',
|
||||
subtitle: '按日期排布作业任务,执行中的任务会实时推进进度',
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
WorkFilterRow(
|
||||
items: _filters,
|
||||
index: _filter,
|
||||
onChanged: (i) => setState(() => _filter = i),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Expanded(
|
||||
child: days.isEmpty
|
||||
? _buildEmpty()
|
||||
: ListView(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
children: [
|
||||
for (final day in days) ...[
|
||||
_buildDayHeader(day),
|
||||
const SizedBox(height: 8),
|
||||
for (var i = 0; i < day.plans.length; i++)
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: i == day.plans.length - 1 ? 0 : 10,
|
||||
),
|
||||
child: _buildPlanCard(day.plans[i]),
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildEmpty() {
|
||||
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.event_note_outlined,
|
||||
size: 26,
|
||||
color: kWtMuted,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const Text(
|
||||
'暂无该状态的作业计划',
|
||||
style: TextStyle(fontSize: 12.5, color: _gray),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 日期分组头 =====
|
||||
Widget _buildDayHeader(_DemoDay day) {
|
||||
final bool today = day.label == '今天';
|
||||
return Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 4,
|
||||
height: 14,
|
||||
decoration: BoxDecoration(
|
||||
color: today ? kWtBlue : kWtHint,
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 7),
|
||||
Text(
|
||||
day.label,
|
||||
style: TextStyle(
|
||||
fontSize: 13.5,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: today ? kWtBlue : _navy,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(day.date, style: const TextStyle(fontSize: 11, color: _gray)),
|
||||
const Spacer(),
|
||||
Text(
|
||||
'${day.plans.length} 个任务',
|
||||
style: const TextStyle(fontSize: 10.5, color: kWtHint),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 计划卡 =====
|
||||
Widget _buildPlanCard(_DemoPlan p) {
|
||||
final (Color color, Color bg, String label) = switch (p.status) {
|
||||
_PlanStatus.running => (kWtBlue, kWtSoftBlue, '执行中'),
|
||||
_PlanStatus.pending => (_orange, kWtWarnBg, '待执行'),
|
||||
_PlanStatus.done => (_green, kWtGreenBg, '已完成'),
|
||||
_PlanStatus.aborted => (_red, const Color(0xFFFDECEB), '已中止'),
|
||||
};
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.fromLTRB(12, 11, 12, 11),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(
|
||||
color: p.status == _PlanStatus.running
|
||||
? kWtBlue.withValues(alpha: 0.45)
|
||||
: _border,
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
// 左:时间块
|
||||
Container(
|
||||
width: 44,
|
||||
padding: const EdgeInsets.symmetric(vertical: 5),
|
||||
decoration: BoxDecoration(
|
||||
color: kWtSegBg,
|
||||
borderRadius: BorderRadius.circular(9),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
p.time,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 1),
|
||||
const Text(
|
||||
'开始',
|
||||
style: TextStyle(fontSize: 8.5, color: kWtHint),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
p.title,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 13.5,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 7,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: bg,
|
||||
borderRadius: BorderRadius.circular(999),
|
||||
),
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 9.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'${p.zone} · ${p.robot}',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontSize: 11, color: _gray),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 9),
|
||||
// 进度条(待执行不显示进度,避免误解为 0% 失败)
|
||||
if (p.status == _PlanStatus.running ||
|
||||
p.status == _PlanStatus.aborted ||
|
||||
p.status == _PlanStatus.done) ...[
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(999),
|
||||
child: LinearProgressIndicator(
|
||||
value: p.progress,
|
||||
minHeight: 4,
|
||||
backgroundColor: kWtDivider,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(color),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 7),
|
||||
],
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.alt_route_rounded, size: 12, color: kWtHint),
|
||||
const SizedBox(width: 3),
|
||||
Expanded(
|
||||
child: Text(
|
||||
p.routeName,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontSize: 10.5, color: kWtHint),
|
||||
),
|
||||
),
|
||||
if (p.status != _PlanStatus.pending)
|
||||
Text(
|
||||
'${(p.progress * 100).round()}%',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
if (p.status == _PlanStatus.done ||
|
||||
p.status == _PlanStatus.aborted) {
|
||||
// 已结束的计划:直接看这一票的单次作业报告
|
||||
Navigator.of(
|
||||
context,
|
||||
).push(WorkReportPageV2.route(taskName: p.title));
|
||||
} else {
|
||||
_toast('计划详情接口未接入(演示)');
|
||||
}
|
||||
},
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'详情',
|
||||
style: TextStyle(
|
||||
fontSize: 10.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: kWtBlue,
|
||||
),
|
||||
),
|
||||
Icon(Icons.chevron_right_rounded, size: 15, color: kWtBlue),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
417
lib/features/v2/work/presentation/pages/work_record_page_v2.dart
Normal file
417
lib/features/v2/work/presentation/pages/work_record_page_v2.dart
Normal file
@@ -0,0 +1,417 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/components/capsule_toast.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/work/presentation/widgets/work_phone_ui.dart';
|
||||
|
||||
/// 作业记录中心(W09)——作业首页「作业记录」入口进入。
|
||||
///
|
||||
/// 竖屏单页:本月汇总 + 筛选 + 记录列表,点单条进入「单次作业报告」(W10)。
|
||||
///
|
||||
/// 本页为演示页:记录列表是写死的示例,不查询真实作业历史;
|
||||
/// 筛选与搜索只在本地过滤,不请求接口。
|
||||
class WorkRecordPageV2 extends StatefulWidget {
|
||||
const WorkRecordPageV2({super.key});
|
||||
|
||||
static Route<void> route() =>
|
||||
MaterialPageRoute<void>(builder: (_) => const WorkRecordPageV2());
|
||||
|
||||
@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);
|
||||
|
||||
static const List<String> _filters = <String>['全部', '已完成', '已中止', '本周'];
|
||||
int _filter = 0;
|
||||
|
||||
static const List<_DemoRecord> _records = <_DemoRecord>[
|
||||
_DemoRecord(
|
||||
title: 'B区 · 清晨割草',
|
||||
robot: '山东02号机',
|
||||
date: '2026-10-26 08:00',
|
||||
area: '2 860 m²',
|
||||
duration: '2 h 42 min',
|
||||
done: true,
|
||||
coverage: '98.6%',
|
||||
),
|
||||
_DemoRecord(
|
||||
title: 'A区 · 定点巡检',
|
||||
robot: '山东01号机',
|
||||
date: '2026-10-25 16:20',
|
||||
area: '1 240 m²',
|
||||
duration: '1 h 05 min',
|
||||
done: true,
|
||||
coverage: '97.2%',
|
||||
),
|
||||
_DemoRecord(
|
||||
title: 'C区 · 雨后补割',
|
||||
robot: '山东01号机',
|
||||
date: '2026-10-25 09:10',
|
||||
area: '640 m²',
|
||||
duration: '0 h 38 min',
|
||||
done: false,
|
||||
coverage: '42.5%',
|
||||
),
|
||||
_DemoRecord(
|
||||
title: 'A区 · 自主割草',
|
||||
robot: '山东02号机',
|
||||
date: '2026-10-24 14:00',
|
||||
area: '3 120 m²',
|
||||
duration: '3 h 12 min',
|
||||
done: true,
|
||||
coverage: '99.1%',
|
||||
),
|
||||
_DemoRecord(
|
||||
title: 'D区 · 边界修整',
|
||||
robot: '山东03号机',
|
||||
date: '2026-10-23 10:30',
|
||||
area: '980 m²',
|
||||
duration: '1 h 12 min',
|
||||
done: true,
|
||||
coverage: '96.4%',
|
||||
),
|
||||
];
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
void _openReport(_DemoRecord r) {
|
||||
Navigator.of(context).push(WorkReportPageV2.route(taskName: r.title));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final records = _visible;
|
||||
return WorkPhoneScaffold(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
WorkPhoneTopBar(
|
||||
title: '作业记录',
|
||||
onBack: () => Navigator.of(context).maybePop(),
|
||||
trailing: WorkSquareButton(
|
||||
icon: Icons.file_download_outlined,
|
||||
size: 17,
|
||||
onTap: () => _toast('批量导出接口未接入(演示)'),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
const WorkPageHeading(
|
||||
title: '作业记录',
|
||||
subtitle: '按月归档每一次作业,点开可查看单次作业报告',
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildSummary(),
|
||||
const SizedBox(height: 12),
|
||||
WorkFilterRow(
|
||||
items: _filters,
|
||||
index: _filter,
|
||||
onChanged: (i) => setState(() => _filter = i),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Expanded(
|
||||
child: records.isEmpty
|
||||
? _buildEmpty()
|
||||
: ListView.separated(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
itemCount: records.length,
|
||||
separatorBuilder: (_, _) => const SizedBox(height: 10),
|
||||
itemBuilder: (context, i) => _buildRecordCard(records[i]),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 本月汇总 =====
|
||||
Widget _buildSummary() {
|
||||
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),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Text(
|
||||
'本月作业',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
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: const [
|
||||
_SummaryCell(value: '18', label: '作业次数'),
|
||||
_SummaryCell(value: '4.6', label: '累计面积(亩)'),
|
||||
_SummaryCell(value: '21.3', label: '作业时长(h)'),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildEmpty() {
|
||||
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),
|
||||
const Text(
|
||||
'该筛选下暂无作业记录',
|
||||
style: TextStyle(fontSize: 12.5, color: _gray),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 记录卡 =====
|
||||
Widget _buildRecordCard(_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(
|
||||
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 ? '已完成' : '已中止',
|
||||
style: TextStyle(
|
||||
fontSize: 10.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: statusColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Text(
|
||||
'${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,
|
||||
children: [
|
||||
_metaItem(Icons.crop_free_rounded, r.area),
|
||||
_metaItem(Icons.schedule_rounded, r.duration),
|
||||
_metaItem(Icons.donut_large_rounded, r.coverage),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
const Text(
|
||||
'报告',
|
||||
style: TextStyle(
|
||||
fontSize: 11.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: kWtBlue,
|
||||
),
|
||||
),
|
||||
const Icon(
|
||||
Icons.chevron_right_rounded,
|
||||
size: 16,
|
||||
color: kWtBlue,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
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,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 汇总卡里的一格(深蓝底上的白字)
|
||||
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),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
479
lib/features/v2/work/presentation/pages/work_report_page_v2.dart
Normal file
479
lib/features/v2/work/presentation/pages/work_report_page_v2.dart
Normal file
@@ -0,0 +1,479 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:maibu_satabot_v2/components/capsule_toast.dart';
|
||||
import 'package:maibu_satabot_v2/core/di/injection.dart';
|
||||
import 'package:maibu_satabot_v2/features/home/presentation/widgets/map/geoserver_suzhou_layer.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';
|
||||
|
||||
/// 单次作业报告(W10)——作业记录中心里点开单条记录进入。
|
||||
///
|
||||
/// 竖屏单页:任务概要 + 轨迹缩略图 + 4 个关键指标 + 作业信息 + 过程节点。
|
||||
///
|
||||
/// 本页为演示页:所有数字都是写死的示例值,不查询真实作业记录,
|
||||
/// 也不做 PDF 导出(点了只提示「导出接口未接入」)。
|
||||
class WorkReportPageV2 extends StatelessWidget {
|
||||
const WorkReportPageV2({super.key, this.taskName = 'B区 · 清晨割草'});
|
||||
|
||||
/// 从记录列表带进来的任务名,仅用于标题展示
|
||||
final String taskName;
|
||||
|
||||
static Route<void> route({String taskName = 'B区 · 清晨割草'}) {
|
||||
return MaterialPageRoute<void>(
|
||||
builder: (_) => WorkReportPageV2(taskName: taskName),
|
||||
);
|
||||
}
|
||||
|
||||
static const Color _navy = kWtNavy;
|
||||
static const Color _gray = kWtGray;
|
||||
static const Color _border = kWtBorder;
|
||||
static const Color _green = Color(0xFF00B42A);
|
||||
static const Color _greenBg = Color(0xFFE8F8EC);
|
||||
|
||||
void _toast(String text) => CapsuleToast.show(text, showCheck: false);
|
||||
|
||||
LatLng get _center {
|
||||
final site = sl<SiteCubit>().state.selectedSite;
|
||||
return stationLayerCenter(site?.siteMapName) ??
|
||||
const LatLng(31.083296, 120.840355);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WorkPhoneScaffold(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
WorkPhoneTopBar(
|
||||
title: '作业报告',
|
||||
onBack: () => Navigator.of(context).maybePop(),
|
||||
trailing: WorkSquareButton(
|
||||
icon: Icons.ios_share_rounded,
|
||||
size: 17,
|
||||
onTap: () => _toast('分享接口未接入(演示)'),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Expanded(
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
children: [
|
||||
_buildHeader(),
|
||||
const SizedBox(height: 12),
|
||||
_buildMapCard(),
|
||||
const SizedBox(height: 12),
|
||||
_buildMetrics(),
|
||||
const SizedBox(height: 12),
|
||||
_buildInfoCard(),
|
||||
const SizedBox(height: 12),
|
||||
_buildEventCard(),
|
||||
const SizedBox(height: 14),
|
||||
_buildActions(context),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 标题区:任务名 + 完成状态 =====
|
||||
Widget _buildHeader() {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
taskName,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 21,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: _greenBg,
|
||||
borderRadius: BorderRadius.circular(999),
|
||||
),
|
||||
child: const Text(
|
||||
'已完成',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: _green,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
const Text(
|
||||
'2026-10-26 08:00 — 10:42 · 山东02号机',
|
||||
style: TextStyle(fontSize: 12, color: _gray),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 轨迹缩略图 =====
|
||||
Widget _buildMapCard() {
|
||||
return Stack(
|
||||
children: [
|
||||
WorkMapThumb(
|
||||
center: _center,
|
||||
height: 158,
|
||||
radius: 16,
|
||||
badgeText: '实际作业轨迹',
|
||||
showAreas: true,
|
||||
showRoute: true,
|
||||
showRobot: false,
|
||||
),
|
||||
Positioned(
|
||||
right: 10,
|
||||
bottom: 10,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 9, vertical: 5),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withValues(alpha: 0.94),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.timeline_rounded, size: 13, color: kWtBlue),
|
||||
SizedBox(width: 4),
|
||||
Text(
|
||||
'轨迹回放',
|
||||
style: TextStyle(
|
||||
fontSize: 10.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: kWtNavy,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 4 个关键指标(2×2:竖屏宽度放不下四列) =====
|
||||
Widget _buildMetrics() {
|
||||
const metrics = <(String, String, String)>[
|
||||
('作业面积', '2 860', 'm²'),
|
||||
('作业时长', '2 h 42', 'min'),
|
||||
('覆盖率', '98.6', '%'),
|
||||
('耗电', '34', '%'),
|
||||
];
|
||||
return Column(
|
||||
children: [
|
||||
for (var row = 0; row < 2; row++) ...[
|
||||
if (row > 0) const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
for (var col = 0; col < 2; col++) ...[
|
||||
if (col > 0) const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: _metricTile(
|
||||
metrics[row * 2 + col].$1,
|
||||
metrics[row * 2 + col].$2,
|
||||
metrics[row * 2 + col].$3,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _metricTile(String label, String value, String unit) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 11),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: _border),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontSize: 10.5, color: _gray),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.baseline,
|
||||
textBaseline: TextBaseline.alphabetic,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
value,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 2),
|
||||
Text(unit, style: const TextStyle(fontSize: 9.5, color: _gray)),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 作业信息 =====
|
||||
Widget _buildInfoCard() {
|
||||
const rows = <(String, String)>[
|
||||
('作业区域', 'B区 · 东侧草坪'),
|
||||
('作业路线', 'B区路线01 · 往复式'),
|
||||
('执行设备', '山东02号机'),
|
||||
('开始时间', '2026-10-26 08:00'),
|
||||
('结束时间', '2026-10-26 10:42'),
|
||||
];
|
||||
return Container(
|
||||
padding: const EdgeInsets.fromLTRB(14, 12, 14, 6),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: _border),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'作业信息',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
for (final r in rows)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 6),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 66,
|
||||
child: Text(
|
||||
r.$1,
|
||||
style: const TextStyle(fontSize: 12, color: _gray),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
r.$2,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 12.5,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 过程节点 =====
|
||||
Widget _buildEventCard() {
|
||||
const events = <(String, String, String)>[
|
||||
('08:00', '任务下发成功', '设备已接受任务并原地自检'),
|
||||
('08:06', '进入 B 区开始作业', '沿 B区路线01 往复推进'),
|
||||
('09:58', '中途补充割草高度', '人工干预:割草高度 45 → 50 mm'),
|
||||
('10:42', '作业完成并返航', '回到充电桩,剩余电量 66%'),
|
||||
];
|
||||
return Container(
|
||||
padding: const EdgeInsets.fromLTRB(14, 12, 14, 12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: _border),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'过程记录',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
for (var i = 0; i < events.length; i++)
|
||||
_eventRow(
|
||||
events[i].$1,
|
||||
events[i].$2,
|
||||
events[i].$3,
|
||||
first: i == 0,
|
||||
last: i == events.length - 1,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _eventRow(
|
||||
String time,
|
||||
String title,
|
||||
String desc, {
|
||||
required bool first,
|
||||
required bool last,
|
||||
}) {
|
||||
return IntrinsicHeight(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 38,
|
||||
child: Text(
|
||||
time,
|
||||
style: const TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 3),
|
||||
width: 8,
|
||||
height: 8,
|
||||
decoration: BoxDecoration(
|
||||
color: first ? Colors.transparent : kWtBlue,
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: first ? kWtBlue : Colors.white,
|
||||
width: first ? 2 : 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (!last)
|
||||
Expanded(
|
||||
child: Container(
|
||||
width: 1.4,
|
||||
margin: const EdgeInsets.symmetric(vertical: 2),
|
||||
color: kWtDivider,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(bottom: last ? 0 : 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 12.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
desc,
|
||||
style: const TextStyle(
|
||||
fontSize: 11,
|
||||
height: 1.35,
|
||||
color: _gray,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 底部动作 =====
|
||||
Widget _buildActions(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () => Navigator.of(context).maybePop(),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Container(
|
||||
height: 46,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: _border),
|
||||
),
|
||||
child: const Text(
|
||||
'返回记录',
|
||||
style: TextStyle(
|
||||
fontSize: 13.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () => _toast('报告导出接口未接入(演示)'),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Container(
|
||||
height: 46,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
gradient: const LinearGradient(
|
||||
colors: [Color(0xFF3EB8FF), Color(0xFF1C96F6)],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
child: const Text(
|
||||
'导出报告',
|
||||
style: TextStyle(
|
||||
fontSize: 13.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,364 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:maibu_satabot_v2/components/capsule_toast.dart';
|
||||
import 'package:maibu_satabot_v2/core/di/injection.dart';
|
||||
import 'package:maibu_satabot_v2/features/home/presentation/widgets/map/geoserver_suzhou_layer.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';
|
||||
|
||||
/// 路线库(W05)——作业首页「路线库」入口进入。
|
||||
///
|
||||
/// 竖屏单页:按作业区归档的覆盖路线,卡片上直给长度 / 预估时长 / 间距,
|
||||
/// 「新建路线」「编辑」都进入横屏「地图与区域编辑」绘制。
|
||||
///
|
||||
/// 本页为演示页:路线是写死的示例,不读真实路线数据;
|
||||
/// 「应用到任务」只做界面反馈,不写全局任务状态。
|
||||
class WorkRouteLibraryPageV2 extends StatefulWidget {
|
||||
const WorkRouteLibraryPageV2({super.key});
|
||||
|
||||
static Route<void> route() =>
|
||||
MaterialPageRoute<void>(builder: (_) => const WorkRouteLibraryPageV2());
|
||||
|
||||
@override
|
||||
State<WorkRouteLibraryPageV2> createState() => _WorkRouteLibraryPageV2State();
|
||||
}
|
||||
|
||||
/// 一条演示路线
|
||||
class _DemoRoute {
|
||||
const _DemoRoute({
|
||||
required this.name,
|
||||
required this.kind,
|
||||
required this.zone,
|
||||
required this.length,
|
||||
required this.duration,
|
||||
required this.spacing,
|
||||
required this.used,
|
||||
});
|
||||
|
||||
final String name;
|
||||
|
||||
/// 覆盖 / 返航 / 沿边
|
||||
final String kind;
|
||||
final String zone;
|
||||
final String length;
|
||||
final String duration;
|
||||
final String spacing;
|
||||
|
||||
/// 最近使用时间,空表示未使用
|
||||
final String used;
|
||||
}
|
||||
|
||||
class _WorkRouteLibraryPageV2State extends State<WorkRouteLibraryPageV2> {
|
||||
static const Color _navy = kWtNavy;
|
||||
static const Color _gray = kWtGray;
|
||||
static const Color _border = kWtBorder;
|
||||
static const Color _cyan = Color(0xFF00B8A8);
|
||||
static const Color _orange = Color(0xFFEE9A2E);
|
||||
|
||||
static const List<String> _filters = <String>['全部路线', '覆盖路线', '返航路线', '沿边路线'];
|
||||
int _filter = 0;
|
||||
|
||||
static const List<_DemoRoute> _routes = <_DemoRoute>[
|
||||
_DemoRoute(
|
||||
name: 'A区路线01',
|
||||
kind: '覆盖路线',
|
||||
zone: 'A 区 · 主草坪',
|
||||
length: '486 m',
|
||||
duration: '42 min',
|
||||
spacing: '0.9 m',
|
||||
used: '今天 08:12',
|
||||
),
|
||||
_DemoRoute(
|
||||
name: 'B区路线01',
|
||||
kind: '覆盖路线',
|
||||
zone: 'B 区 · 东侧草坪',
|
||||
length: '392 m',
|
||||
duration: '35 min',
|
||||
spacing: '0.9 m',
|
||||
used: '今天 08:00',
|
||||
),
|
||||
_DemoRoute(
|
||||
name: 'B区沿边01',
|
||||
kind: '沿边路线',
|
||||
zone: 'B 区 · 东侧草坪',
|
||||
length: '164 m',
|
||||
duration: '14 min',
|
||||
spacing: '0.6 m',
|
||||
used: '昨天 16:40',
|
||||
),
|
||||
_DemoRoute(
|
||||
name: 'C区覆盖01',
|
||||
kind: '覆盖路线',
|
||||
zone: 'C 区 · 苗圃',
|
||||
length: '128 m',
|
||||
duration: '11 min',
|
||||
spacing: '0.7 m',
|
||||
used: '',
|
||||
),
|
||||
_DemoRoute(
|
||||
name: '全场返航路线',
|
||||
kind: '返航路线',
|
||||
zone: '全场',
|
||||
length: '96 m',
|
||||
duration: '9 min',
|
||||
spacing: '—',
|
||||
used: '今天 10:42',
|
||||
),
|
||||
];
|
||||
|
||||
/// 路线颜色(覆盖青绿 / 返航橙 / 沿边蓝)
|
||||
static const Map<String, Color> _kindColors = <String, Color>{
|
||||
'覆盖路线': _cyan,
|
||||
'返航路线': _orange,
|
||||
'沿边路线': kWtBlue,
|
||||
};
|
||||
|
||||
void _toast(String text) => CapsuleToast.show(text, showCheck: false);
|
||||
|
||||
LatLng get _center {
|
||||
final site = sl<SiteCubit>().state.selectedSite;
|
||||
return stationLayerCenter(site?.siteMapName) ??
|
||||
const LatLng(31.083296, 120.840355);
|
||||
}
|
||||
|
||||
List<_DemoRoute> get _visible {
|
||||
if (_filter == 0) return _routes;
|
||||
final String kind = _filters[_filter];
|
||||
return _routes.where((r) => r.kind == kind).toList();
|
||||
}
|
||||
|
||||
/// 进入横屏「地图与区域编辑」画路线;返回后把方向还给竖屏
|
||||
Future<void> _openEditor() async {
|
||||
await Navigator.of(context).push(RouteEditorPageV2.route(deviceSn: ''));
|
||||
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final routes = _visible;
|
||||
return WorkPhoneScaffold(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
WorkPhoneTopBar(
|
||||
title: '路线库',
|
||||
onBack: () => Navigator.of(context).maybePop(),
|
||||
trailing: WorkSquareButton(
|
||||
icon: Icons.add_rounded,
|
||||
label: '新建',
|
||||
primary: true,
|
||||
onTap: _openEditor,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
const WorkPageHeading(
|
||||
title: '路线库',
|
||||
subtitle: '按作业区归档覆盖路线,可直接应用到新的作业任务',
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
WorkFilterRow(
|
||||
items: _filters,
|
||||
index: _filter,
|
||||
onChanged: (i) => setState(() => _filter = i),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Expanded(
|
||||
child: routes.isEmpty
|
||||
? _buildEmpty()
|
||||
: ListView.separated(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
itemCount: routes.length,
|
||||
separatorBuilder: (_, _) => const SizedBox(height: 10),
|
||||
itemBuilder: (context, i) => _buildRouteCard(routes[i]),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildEmpty() {
|
||||
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.alt_route_outlined,
|
||||
size: 26,
|
||||
color: kWtMuted,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const Text(
|
||||
'该类型下还没有路线',
|
||||
style: TextStyle(fontSize: 12.5, color: _gray),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 路线卡 =====
|
||||
Widget _buildRouteCard(_DemoRoute r) {
|
||||
final Color kindColor = _kindColors[r.kind] ?? kWtBlue;
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: _border),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// 顶部缩略图:叠一层路线示意
|
||||
Stack(
|
||||
children: [
|
||||
WorkMapThumb(
|
||||
center: _center,
|
||||
height: 96,
|
||||
radius: 16,
|
||||
zoom: 17.6,
|
||||
showAreas: r.kind != '返航路线',
|
||||
showRoute: true,
|
||||
showRobot: false,
|
||||
),
|
||||
Positioned(
|
||||
left: 10,
|
||||
top: 10,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 3,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: kindColor,
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: Text(
|
||||
r.kind,
|
||||
style: const TextStyle(
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(13, 10, 13, 11),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
r.name,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 14.5,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (r.used.isNotEmpty)
|
||||
Text(
|
||||
'最近 ${r.used}',
|
||||
style: const TextStyle(fontSize: 10, color: kWtHint),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
r.zone,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontSize: 11.5, color: _gray),
|
||||
),
|
||||
const SizedBox(height: 9),
|
||||
Row(
|
||||
children: [
|
||||
_metaItem(Icons.straighten_rounded, r.length),
|
||||
const SizedBox(width: 14),
|
||||
_metaItem(Icons.schedule_rounded, r.duration),
|
||||
const SizedBox(width: 14),
|
||||
_metaItem(Icons.space_bar_rounded, r.spacing),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
const Spacer(),
|
||||
_smallAction('编辑', _openEditor),
|
||||
const SizedBox(width: 8),
|
||||
_smallAction(
|
||||
'应用到任务',
|
||||
() => _toast('任务编排接口未接入(演示)'),
|
||||
primary: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
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 _smallAction(String text, VoidCallback onTap, {bool primary = false}) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 11, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: primary ? kWtSoftBlue : kWtSegBg,
|
||||
borderRadius: BorderRadius.circular(9),
|
||||
border: Border.all(color: primary ? kWtBlue : _border),
|
||||
),
|
||||
child: Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontSize: 10.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: primary ? kWtBlue : kWtGray2,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
519
lib/features/v2/work/presentation/widgets/work_phone_ui.dart
Normal file
519
lib/features/v2/work/presentation/widgets/work_phone_ui.dart
Normal file
@@ -0,0 +1,519 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
|
||||
import 'package:maibu_satabot_v2/features/v2/device_list/presentation/widgets/autonomous/work_ui.dart';
|
||||
|
||||
/// 竖屏作业页通用外壳与小组件(W02/W03/W05/W07/W09/W10 共用)。
|
||||
/// 色板直接复用横屏作业中心的 [work_ui.dart],保证两套页面观感一致。
|
||||
const Color kWpTopBg = Color(0xFFF8FCFF);
|
||||
const Color kWpBottomBg = Color(0xFFE6F1FD);
|
||||
const Color kWpPageBg = Color(0xFFF1F7FE);
|
||||
|
||||
/// 页面外壳:浅蓝渐变底 + 安全区 + 统一内边距。
|
||||
/// child 由页面自行决定是否滚动(地图类页面需要 Column + Expanded,不滚动)。
|
||||
class WorkPhoneScaffold extends StatelessWidget {
|
||||
const WorkPhoneScaffold({
|
||||
super.key,
|
||||
required this.child,
|
||||
this.padding = const EdgeInsets.fromLTRB(16, 4, 16, 16),
|
||||
});
|
||||
|
||||
final Widget child;
|
||||
final EdgeInsets padding;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: kWpPageBg,
|
||||
body: DecoratedBox(
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [kWpTopBg, kWpBottomBg],
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
child: Padding(padding: padding, child: child),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 竖屏页顶栏:返回 + 标题(可带右侧动作)。
|
||||
class WorkPhoneTopBar extends StatelessWidget {
|
||||
const WorkPhoneTopBar({
|
||||
super.key,
|
||||
required this.title,
|
||||
this.trailing,
|
||||
this.onBack,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final Widget? trailing;
|
||||
final VoidCallback? onBack;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
WorkSquareButton(
|
||||
icon: Icons.chevron_left_rounded,
|
||||
size: 22,
|
||||
onTap: onBack ?? () => Navigator.of(context).maybePop(),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(
|
||||
title,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: kWtNavy,
|
||||
),
|
||||
),
|
||||
),
|
||||
?trailing,
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 白底圆角方块图标按钮(顶栏右侧常用)。
|
||||
class WorkSquareButton extends StatelessWidget {
|
||||
const WorkSquareButton({
|
||||
super.key,
|
||||
required this.icon,
|
||||
required this.onTap,
|
||||
this.size = 18,
|
||||
this.label,
|
||||
this.primary = false,
|
||||
});
|
||||
|
||||
final IconData icon;
|
||||
final VoidCallback onTap;
|
||||
final double size;
|
||||
|
||||
/// 有文字时变成胶囊按钮(如「+ 新建」)
|
||||
final String? label;
|
||||
|
||||
/// 主色实心(新建类动作)
|
||||
final bool primary;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final bool pill = label != null;
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Container(
|
||||
width: pill ? null : 36,
|
||||
height: 36,
|
||||
padding: pill
|
||||
? const EdgeInsets.symmetric(horizontal: 12)
|
||||
: EdgeInsets.zero,
|
||||
decoration: BoxDecoration(
|
||||
color: primary ? kWtBlue : Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: primary ? Colors.transparent : kWtBorder),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(icon, size: size, color: primary ? Colors.white : kWtNavy),
|
||||
if (pill) ...[
|
||||
const SizedBox(width: 3),
|
||||
Text(
|
||||
label!,
|
||||
style: TextStyle(
|
||||
fontSize: 12.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: primary ? Colors.white : kWtNavy,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 页面大标题 + 灰色说明。
|
||||
class WorkPageHeading extends StatelessWidget {
|
||||
const WorkPageHeading({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.subtitle,
|
||||
this.trailing,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final String subtitle;
|
||||
final Widget? trailing;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: kWtNavy,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Text(
|
||||
subtitle,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
height: 1.4,
|
||||
color: kWtGray,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (trailing != null) ...[const SizedBox(width: 10), trailing!],
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 横向筛选胶囊行(单选,蓝底蓝字表示选中)。
|
||||
class WorkFilterRow extends StatelessWidget {
|
||||
const WorkFilterRow({
|
||||
super.key,
|
||||
required this.items,
|
||||
required this.index,
|
||||
required this.onChanged,
|
||||
this.height = 32,
|
||||
});
|
||||
|
||||
final List<String> items;
|
||||
final int index;
|
||||
final ValueChanged<int> onChanged;
|
||||
final double height;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
height: height,
|
||||
child: ListView.separated(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: items.length,
|
||||
separatorBuilder: (_, _) => const SizedBox(width: 8),
|
||||
itemBuilder: (context, i) {
|
||||
final bool selected = index == i;
|
||||
return GestureDetector(
|
||||
onTap: () => onChanged(i),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 160),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14),
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: selected ? kWtSoftBlue : Colors.white,
|
||||
borderRadius: BorderRadius.circular(999),
|
||||
border: Border.all(
|
||||
color: selected ? kWtBlue : kWtBorder,
|
||||
width: selected ? 1.4 : 1,
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
items[i],
|
||||
style: TextStyle(
|
||||
fontSize: 12.5,
|
||||
fontWeight: selected ? FontWeight.w700 : FontWeight.w500,
|
||||
color: selected ? kWtBlue : kWtGray,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 搜索框(本页列表为演示数据,输入只做本地过滤)。
|
||||
class WorkSearchField extends StatelessWidget {
|
||||
const WorkSearchField({
|
||||
super.key,
|
||||
required this.controller,
|
||||
required this.hint,
|
||||
this.onChanged,
|
||||
});
|
||||
|
||||
final TextEditingController controller;
|
||||
final String hint;
|
||||
final ValueChanged<String>? onChanged;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: 44,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: kWtBorder),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.search_rounded, size: 19, color: kWtHint),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: controller,
|
||||
onChanged: onChanged,
|
||||
style: const TextStyle(fontSize: 13.5, color: kWtNavy),
|
||||
decoration: InputDecoration(
|
||||
isDense: true,
|
||||
border: InputBorder.none,
|
||||
hintText: hint,
|
||||
hintStyle: const TextStyle(fontSize: 13.5, color: kWtHint),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 地图缩略图:非交互的场站底图 + 演示几何(区域 / 禁行区 / 路线 / 机器点)。
|
||||
/// 用于「作业区域管理」「路线库」「单次作业报告」里的示意图。
|
||||
class WorkMapThumb extends StatelessWidget {
|
||||
const WorkMapThumb({
|
||||
super.key,
|
||||
required this.center,
|
||||
this.width,
|
||||
this.height = 118,
|
||||
this.radius = 14,
|
||||
this.zoom = 17.6,
|
||||
this.badgeText,
|
||||
this.showRoute = true,
|
||||
this.showAreas = true,
|
||||
this.showRobot = true,
|
||||
});
|
||||
|
||||
final LatLng center;
|
||||
final double? width;
|
||||
final double height;
|
||||
final double radius;
|
||||
final double zoom;
|
||||
final String? badgeText;
|
||||
final bool showRoute;
|
||||
final bool showAreas;
|
||||
final bool showRobot;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final WorkGeo geo = WorkGeo(center);
|
||||
return ClipRRect(
|
||||
borderRadius: BorderRadius.circular(radius),
|
||||
child: SizedBox(
|
||||
width: width,
|
||||
height: height,
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
const ColoredBox(color: Color(0xFFDDEAD8)),
|
||||
FlutterMap(
|
||||
options: MapOptions(
|
||||
initialCenter: center,
|
||||
initialZoom: zoom,
|
||||
minZoom: 3,
|
||||
maxZoom: 22,
|
||||
interactionOptions: const InteractionOptions(
|
||||
flags: InteractiveFlag.none,
|
||||
),
|
||||
),
|
||||
children: [
|
||||
TileLayer(
|
||||
urlTemplate:
|
||||
'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
|
||||
userAgentPackageName: 'com.maibu.maibu_satabot_v2',
|
||||
minZoom: 0,
|
||||
maxZoom: 19,
|
||||
),
|
||||
if (showAreas) ...[
|
||||
PolygonLayer(
|
||||
polygons: [
|
||||
Polygon(
|
||||
points: geo.areaA,
|
||||
color: const Color(0xFF00D5A0).withValues(alpha: 0.22),
|
||||
borderColor: const Color(0xFF00D5A0),
|
||||
borderStrokeWidth: 2,
|
||||
),
|
||||
Polygon(
|
||||
points: geo.areaB,
|
||||
color: const Color(0xFF2E86FF).withValues(alpha: 0.18),
|
||||
borderColor: const Color(0xFF2E86FF),
|
||||
borderStrokeWidth: 2,
|
||||
),
|
||||
],
|
||||
),
|
||||
PolylineLayer(
|
||||
polylines: [
|
||||
Polyline(
|
||||
points: geo.bounds,
|
||||
color: const Color(0xCCFFFFFF),
|
||||
strokeWidth: 1.4,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
if (showRoute)
|
||||
PolylineLayer(
|
||||
polylines: [
|
||||
Polyline(
|
||||
points: geo.route,
|
||||
color: const Color(0xFF00E5C0),
|
||||
strokeWidth: 2.6,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
if (showRobot)
|
||||
Align(
|
||||
alignment: const Alignment(0.05, 0.15),
|
||||
child: Container(
|
||||
width: 26,
|
||||
height: 26,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
shape: BoxShape.circle,
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x33000000),
|
||||
blurRadius: 6,
|
||||
offset: Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.videocam_rounded,
|
||||
size: 15,
|
||||
color: kWtBlue,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (badgeText != null)
|
||||
Positioned(
|
||||
left: 8,
|
||||
top: 8,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withValues(alpha: 0.94),
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: Text(
|
||||
badgeText!,
|
||||
style: const TextStyle(
|
||||
fontSize: 10.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: kWtNavy,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 设计稿示意几何:以场站中心为原点,用「米」偏移换算成经纬度,
|
||||
/// 这样底图缩放/平移时区域与路线会跟着一起动。
|
||||
class WorkGeo {
|
||||
WorkGeo(this.center);
|
||||
|
||||
final LatLng center;
|
||||
|
||||
static const double _latPerM = 1 / 111320;
|
||||
|
||||
LatLng at(double dxM, double dyM) {
|
||||
final double lngPerM =
|
||||
1 / (111320 * math.cos(center.latitude * math.pi / 180));
|
||||
return LatLng(
|
||||
center.latitude + dyM * _latPerM,
|
||||
center.longitude + dxM * lngPerM,
|
||||
);
|
||||
}
|
||||
|
||||
/// 地块外边界(白细线)
|
||||
List<LatLng> get bounds => [
|
||||
at(-125, -165),
|
||||
at(150, -175),
|
||||
at(162, 92),
|
||||
at(-112, 104),
|
||||
];
|
||||
|
||||
/// 地块内部分隔线
|
||||
List<List<LatLng>> get parcelLines => [
|
||||
[at(-125, -55), at(156, -66)],
|
||||
[at(62, -172), at(74, 100)],
|
||||
];
|
||||
|
||||
/// A 区(青绿)
|
||||
List<LatLng> get areaA => [
|
||||
at(-95, -130),
|
||||
at(10, -150),
|
||||
at(48, 40),
|
||||
at(-62, 62),
|
||||
];
|
||||
|
||||
/// B 区(蓝)
|
||||
List<LatLng> get areaB => [
|
||||
at(62, -120),
|
||||
at(122, -108),
|
||||
at(106, 72),
|
||||
at(52, 54),
|
||||
];
|
||||
|
||||
/// 禁行区(红)
|
||||
List<LatLng> get forbidden => [
|
||||
at(-42, -46),
|
||||
at(16, -52),
|
||||
at(22, 14),
|
||||
at(-34, 20),
|
||||
];
|
||||
|
||||
/// 覆盖路线(A 区内横向往复)
|
||||
List<LatLng> get route => [
|
||||
at(-82, -112),
|
||||
at(2, -118),
|
||||
at(2, -88),
|
||||
at(-78, -82),
|
||||
at(-78, -52),
|
||||
at(6, -58),
|
||||
at(6, -28),
|
||||
at(-74, -22),
|
||||
at(-74, 8),
|
||||
at(10, 2),
|
||||
];
|
||||
|
||||
/// 机器人当前位置
|
||||
LatLng get robot => at(-6, -10);
|
||||
}
|
||||
Reference in New Issue
Block a user