页面UI替换1远程遥控和各项弹窗和作业主页面和子页面+路径规划的主页面重构等

This commit is contained in:
2026-10-28 14:38:24 +08:00
parent 8a41113c92
commit eb8dec2868
64 changed files with 25316 additions and 1174 deletions

View 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);
}