页面UI替换1远程遥控和各项弹窗和作业主页面和子页面+路径规划的主页面重构等
This commit is contained in:
@@ -43,11 +43,20 @@ enum PvViewMode { normal, manualControl }
|
||||
/// 第二行控制栏固定高度。右侧列可在「信息」与「地图」间切换;
|
||||
/// 「手动控制」进入视频铺满全屏 + 摇杆的形态,底部折叠图标返回。
|
||||
class PvControlPage extends StatefulWidget {
|
||||
const PvControlPage({super.key, required this.deviceId, this.deviceName});
|
||||
const PvControlPage({
|
||||
super.key,
|
||||
required this.deviceId,
|
||||
this.deviceName,
|
||||
this.initialMode = PvViewMode.normal,
|
||||
});
|
||||
|
||||
final String deviceId;
|
||||
final String? deviceName;
|
||||
|
||||
/// 初始视图模式:默认先进普通态大屏;设备详情「远程遥控」入口传
|
||||
/// [PvViewMode.manualControl],进页直接是手动控制 HUD(不再经过大屏)。
|
||||
final PvViewMode initialMode;
|
||||
|
||||
@override
|
||||
State<PvControlPage> createState() => _PvControlPageState();
|
||||
}
|
||||
@@ -81,7 +90,7 @@ class _PvControlPageState extends State<PvControlPage> {
|
||||
/// 记录上次弹窗显示态,用于检测 false→true 的上升沿。
|
||||
bool? _lastPermissionDialogState;
|
||||
|
||||
PvViewMode _mode = PvViewMode.normal;
|
||||
late PvViewMode _mode = widget.initialMode;
|
||||
|
||||
/// 右侧列是否显示地图(点击「查看地图」切换)
|
||||
bool _showMap = false;
|
||||
@@ -455,6 +464,8 @@ class _PvControlPageState extends State<PvControlPage> {
|
||||
}
|
||||
|
||||
return PvSettingsSheet(
|
||||
// 手动控制 HUD 用浅色玻璃皮肤,普通态大屏仍用原深色面板
|
||||
light: _mode == PvViewMode.manualControl,
|
||||
videoSource: _videoSource,
|
||||
videoFit: _videoFit,
|
||||
simObstacle: _simObstacle,
|
||||
|
||||
143
lib/features/pv_control/presentation/theme/pv_hud_theme.dart
Normal file
143
lib/features/pv_control/presentation/theme/pv_hud_theme.dart
Normal file
@@ -0,0 +1,143 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// 遥控模式 HUD(手动控制全屏视图)专用「浅色玻璃」配色。
|
||||
///
|
||||
/// 与 pv_control 普通态大屏的深蓝科技风 [PvColors] 完全不同:HUD 以视频铺底,
|
||||
/// 上层控件全部是「近白半透明卡片 + 柔和投影 + 深墨蓝文字」,让画面不被压暗。
|
||||
/// 这里独立维护一套常量,避免改动 PvColors 影响普通态页面。
|
||||
class PvHudColors {
|
||||
PvHudColors._();
|
||||
|
||||
// ===== 面板 =====
|
||||
/// 卡片 / 面板底色(近白微透明,让视频透出一点层次)
|
||||
static const Color panel = Color(0xF7FFFFFF);
|
||||
|
||||
/// 实白(顶栏 / 悬浮按钮)
|
||||
static const Color panelSolid = Color(0xFFFFFFFF);
|
||||
|
||||
/// 面板描边(极淡冷灰)
|
||||
static const Color border = Color(0x14203244);
|
||||
|
||||
/// 面板投影
|
||||
static const Color shadow = Color(0x1F0E2233);
|
||||
|
||||
// ===== 文字 =====
|
||||
/// 主文字(深墨蓝)
|
||||
static const Color textPrimary = Color(0xFF10202E);
|
||||
|
||||
/// 次要文字
|
||||
static const Color textSecondary = Color(0xFF6C7F8F);
|
||||
|
||||
/// 更弱的辅助文字
|
||||
static const Color textTertiary = Color(0xFF9AAAB6);
|
||||
|
||||
// ===== 语义色 =====
|
||||
/// 在线 / 正常 / 运行中 / RTK 固定解
|
||||
static const Color success = Color(0xFF16B364);
|
||||
|
||||
/// 绿色浅底(状态胶囊)
|
||||
static const Color successBg = Color(0xFFE8F8EF);
|
||||
|
||||
/// 蓝色:方向箭头、播放键
|
||||
static const Color blue = Color(0xFF2F6BFF);
|
||||
|
||||
/// 蓝色浅底
|
||||
static const Color blueBg = Color(0xFFEAF0FF);
|
||||
|
||||
/// 危险 / 障碍告警
|
||||
static const Color danger = Color(0xFFFF3B4E);
|
||||
|
||||
/// 危险浅底(未在控制 / 异常状态胶囊)
|
||||
static const Color dangerBg = Color(0xFFFDECEE);
|
||||
|
||||
/// 深色玻璃(摇杆底盘 / 视频浮窗底)
|
||||
static const Color glassDark = Color(0xCC2A343D);
|
||||
|
||||
/// 药丸形控件背景(顶栏按钮、底部条按钮)
|
||||
static const Color pill = Color(0xFFF1F4F7);
|
||||
|
||||
/// 标准卡片装饰:近白底 + 极淡描边 + 柔和投影
|
||||
static BoxDecoration panelDeco({
|
||||
double radius = 16,
|
||||
Color? fill,
|
||||
double blur = 18,
|
||||
double alpha = 0.13,
|
||||
}) {
|
||||
return BoxDecoration(
|
||||
color: fill ?? panel,
|
||||
borderRadius: BorderRadius.circular(radius),
|
||||
border: Border.all(color: border, width: 1),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: shadow.withValues(alpha: alpha),
|
||||
blurRadius: blur,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 胶囊控件装饰(无投影 / 轻投影)
|
||||
static BoxDecoration pillDeco({
|
||||
double radius = 14,
|
||||
Color? fill,
|
||||
bool shadowed = false,
|
||||
}) {
|
||||
return BoxDecoration(
|
||||
color: fill ?? pill,
|
||||
borderRadius: BorderRadius.circular(radius),
|
||||
boxShadow: shadowed
|
||||
? [
|
||||
BoxShadow(
|
||||
color: shadow.withValues(alpha: 0.1),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
]
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
/// 绿色状态胶囊(「正常」「运行中」等)
|
||||
static BoxDecoration successPill({double radius = 10}) {
|
||||
return BoxDecoration(
|
||||
color: successBg,
|
||||
borderRadius: BorderRadius.circular(radius),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// HUD 文本样式:深色墨蓝一套,交给各组件 copyWith(color:) 调色与缩字号。
|
||||
class PvHudType {
|
||||
PvHudType._();
|
||||
|
||||
/// 顶栏标题
|
||||
static const TextStyle title = TextStyle(
|
||||
color: PvHudColors.textPrimary,
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.w800,
|
||||
height: 1.2,
|
||||
);
|
||||
|
||||
/// 卡片内的主数值
|
||||
static const TextStyle value = TextStyle(
|
||||
color: PvHudColors.textPrimary,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w700,
|
||||
height: 1.2,
|
||||
);
|
||||
|
||||
/// 次要标签
|
||||
static const TextStyle label = TextStyle(
|
||||
color: PvHudColors.textSecondary,
|
||||
fontSize: 12,
|
||||
height: 1.2,
|
||||
);
|
||||
|
||||
/// 更小的辅助文字(单位 / 角标)
|
||||
static const TextStyle caption = TextStyle(
|
||||
color: PvHudColors.textTertiary,
|
||||
fontSize: 10,
|
||||
height: 1.2,
|
||||
);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,24 +3,26 @@ import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/features/remote_control/presentation/widgets/webrtc/webrtc_local_player.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
|
||||
import '../theme/pv_colors.dart';
|
||||
import '../theme/pv_hud_theme.dart';
|
||||
|
||||
/// 可复用的「倒车影像 / 后视图」卡片组件。
|
||||
/// 可复用的「倒车影像 / 后视图」卡片组件(遥控 HUD 左下浮窗样式)。
|
||||
///
|
||||
/// 从遥控 HUD 左栏抽出,纯展示 + 插槽设计,方便多处复用:
|
||||
/// 纯展示 + 插槽设计:
|
||||
/// - [streamUrl] 非空时用 [WebRTCLocalPlayer] 播放视频流,空时显示占位图标
|
||||
/// (当前阶段为模块还原,接嵌入式后视流后直接传 url 即可,无需改组件);
|
||||
/// - [overlay] 可叠加任意覆盖层(例如将来把 remote_control 的
|
||||
/// ReverseGuideOverlay 倒车引导线传进来叠在画面上),组件不感知其实现;
|
||||
/// - [overlay] 可叠加任意覆盖层(倒车引导线 ReverseGuideOverlay 从这里传入),
|
||||
/// 组件不感知其实现;
|
||||
/// - [scale] 沿用遥控 HUD 的 _sc 缩放体系,手机横屏 / 平板等比自适应;
|
||||
/// - [onExpand] 右上角全屏按钮回调,null 时默认打印占位日志。
|
||||
///
|
||||
/// 视觉:白色圆角外框包住画面,标题与全屏按钮以半透明深色浮标压在画面之上,
|
||||
/// 尺寸完全由父级给定的约束决定(HUD 里用 Positioned + width/height 定位)。
|
||||
class PvRearViewCard extends StatelessWidget {
|
||||
const PvRearViewCard({
|
||||
super.key,
|
||||
this.title,
|
||||
this.streamUrl = '',
|
||||
this.scale = 1,
|
||||
this.videoHeight,
|
||||
this.overlay,
|
||||
this.onExpand,
|
||||
});
|
||||
@@ -34,9 +36,6 @@ class PvRearViewCard extends StatelessWidget {
|
||||
/// 缩放系数(HUD 传入 _sc;独立使用时保持默认 1 即为设计像素)。
|
||||
final double scale;
|
||||
|
||||
/// 画面区高度,默认 70 设计像素 × [scale]。
|
||||
final double? videoHeight;
|
||||
|
||||
/// 叠在画面之上的覆盖层(如倒车引导线动画),不拦截手势。
|
||||
final Widget? overlay;
|
||||
|
||||
@@ -49,65 +48,89 @@ class PvRearViewCard extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final label =
|
||||
title ?? AppLocalizations.of(context).translate('pv_control.rear_view');
|
||||
return Container(
|
||||
padding: EdgeInsets.all(_d(6)),
|
||||
decoration: PvColors.panel(radius: _d(12)),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title ??
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('pv_control.rear_view'),
|
||||
style: _s(PvType.label, 12),
|
||||
),
|
||||
SizedBox(height: _d(4)),
|
||||
SizedBox(
|
||||
height: videoHeight ?? _d(70),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(_d(8)),
|
||||
child: Container(
|
||||
color: Colors.black54,
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
// 画面:有流播流,无流占位
|
||||
if (streamUrl.isNotEmpty)
|
||||
WebRTCLocalPlayer(
|
||||
streamUrl: streamUrl,
|
||||
showLeftPip: false,
|
||||
showRightPip: false,
|
||||
mainViewAlignment: Alignment.center,
|
||||
)
|
||||
else
|
||||
const Center(
|
||||
child: Icon(Icons.no_photography,
|
||||
color: Colors.white24, size: 26),
|
||||
),
|
||||
// 覆盖层插槽(倒车引导线等),不吃手势
|
||||
if (overlay != null)
|
||||
Positioned.fill(child: IgnorePointer(child: overlay!)),
|
||||
// 全屏按钮
|
||||
Positioned(
|
||||
right: _d(4),
|
||||
top: _d(4),
|
||||
child: GestureDetector(
|
||||
onTap: onExpand ?? () => debugPrint('[PV遥控] 后视图放大'),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(_d(2)),
|
||||
child: Icon(Icons.fullscreen,
|
||||
color: PvColors.textSecondary, size: _d(16)),
|
||||
),
|
||||
),
|
||||
// 外框收细到 1.2dp:原来 3dp 的白边太粗,抢画面
|
||||
padding: EdgeInsets.all(_d(1.2)),
|
||||
decoration: PvHudColors.panelDeco(
|
||||
radius: _d(14),
|
||||
fill: PvHudColors.panelSolid,
|
||||
blur: _d(16),
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(_d(12.5)),
|
||||
child: Container(
|
||||
color: PvHudColors.glassDark,
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
// 画面:有流播流,无流占位
|
||||
if (streamUrl.isNotEmpty)
|
||||
WebRTCLocalPlayer(
|
||||
streamUrl: streamUrl,
|
||||
showLeftPip: false,
|
||||
showRightPip: false,
|
||||
mainViewAlignment: Alignment.center,
|
||||
)
|
||||
else
|
||||
const Center(
|
||||
child: Icon(
|
||||
Icons.no_photography,
|
||||
color: Colors.white24,
|
||||
size: 26,
|
||||
),
|
||||
),
|
||||
// 覆盖层插槽(倒车引导线等),不吃手势
|
||||
if (overlay != null)
|
||||
Positioned.fill(child: IgnorePointer(child: overlay!)),
|
||||
// 左上标题浮标
|
||||
Positioned(
|
||||
left: _d(6),
|
||||
top: _d(6),
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: _d(7),
|
||||
vertical: _d(2),
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withValues(alpha: 0.45),
|
||||
borderRadius: BorderRadius.circular(_d(6)),
|
||||
),
|
||||
child: Text(
|
||||
label,
|
||||
style: _s(PvHudType.label, 11).copyWith(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// 右上全屏按钮
|
||||
Positioned(
|
||||
right: _d(6),
|
||||
top: _d(6),
|
||||
child: GestureDetector(
|
||||
onTap: onExpand ?? () => debugPrint('[PV遥控] 后视图放大'),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Container(
|
||||
width: _d(24),
|
||||
height: _d(24),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withValues(alpha: 0.45),
|
||||
borderRadius: BorderRadius.circular(_d(6)),
|
||||
),
|
||||
child: Icon(
|
||||
Icons.open_in_full,
|
||||
color: Colors.white,
|
||||
size: _d(14),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import '../models/pv_video_fit.dart';
|
||||
import '../models/pv_video_source.dart';
|
||||
import '../theme/pv_colors.dart';
|
||||
import '../theme/pv_hud_theme.dart';
|
||||
|
||||
/// 页面设置面板(底部弹出,遮罩半透明可透视下方视频,边调边看效果)。
|
||||
///
|
||||
@@ -14,6 +15,9 @@ import '../theme/pv_colors.dart';
|
||||
/// - 模拟障碍物信息:真实推送未接入前手动触发,开启 = 相当于收到机器告警推送,
|
||||
/// 预警横幅 + AR 障碍框 + 屏幕四周泛红**同时**显示;
|
||||
/// - 倒车影像:开启后左栏后视卡叠加倒车引导线效果(模拟倒车挡)。
|
||||
///
|
||||
/// 皮肤两套(由 [light] 选择):普通态大屏沿用原深蓝面板;手动控制全屏视图
|
||||
/// (HUD)用近白玻璃卡,与其上的顶栏 / 侧栏 / 底部条保持同一视觉体系。
|
||||
class PvSettingsSheet extends StatelessWidget {
|
||||
const PvSettingsSheet({
|
||||
super.key,
|
||||
@@ -25,6 +29,7 @@ class PvSettingsSheet extends StatelessWidget {
|
||||
required this.onVideoFitChanged,
|
||||
required this.onSimObstacleChanged,
|
||||
required this.onSimReverseChanged,
|
||||
this.light = false,
|
||||
});
|
||||
|
||||
final PvVideoSource videoSource;
|
||||
@@ -36,6 +41,9 @@ class PvSettingsSheet extends StatelessWidget {
|
||||
final ValueChanged<bool> onSimObstacleChanged;
|
||||
final ValueChanged<bool> onSimReverseChanged;
|
||||
|
||||
/// 是否套用 HUD 浅色玻璃皮肤(默认 false = 普通态大屏的深色皮肤,与改造前一致)。
|
||||
final bool light;
|
||||
|
||||
/// 视频源选项:顺序与文案按需求固定(以太网 RTSP 源、HDMI、WebRTC)。
|
||||
static const List<(PvVideoSource, String)> _sources = [
|
||||
(PvVideoSource.localRtsp, 'pv_control.set_source_rtsp'),
|
||||
@@ -49,9 +57,12 @@ class PvSettingsSheet extends StatelessWidget {
|
||||
(PvVideoFit.cover, 'pv_control.set_fit_cover'),
|
||||
];
|
||||
|
||||
_SheetSkin get _skin => light ? _SheetSkin.light : _SheetSkin.dark;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final tr = AppLocalizations.of(context);
|
||||
final skin = _skin;
|
||||
// 横屏可用高度有限:最大高度限幅 + 可滚动防底部裁切;
|
||||
// 视频源行用 Wrap,窄屏 / 大字体下药丸自动换行不溢出。
|
||||
final maxH = MediaQuery.sizeOf(context).height * 0.72;
|
||||
@@ -63,9 +74,10 @@ class PvSettingsSheet extends StatelessWidget {
|
||||
child: Container(
|
||||
padding: const EdgeInsets.fromLTRB(14, 4, 10, 8),
|
||||
decoration: BoxDecoration(
|
||||
color: PvColors.card,
|
||||
color: skin.panel,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: PvColors.cardBorder),
|
||||
border: Border.all(color: skin.border),
|
||||
boxShadow: skin.panelShadow,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -74,21 +86,19 @@ class PvSettingsSheet extends StatelessWidget {
|
||||
// 标题行 + 关闭
|
||||
Row(
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.settings_outlined,
|
||||
color: PvColors.accentBright,
|
||||
size: 18,
|
||||
),
|
||||
Icon(Icons.settings_outlined, color: skin.accent, size: 18),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
tr.translate('pv_control.nav_settings'),
|
||||
style: PvType.cardTitle,
|
||||
style: PvType.cardTitle.copyWith(
|
||||
color: skin.textPrimary,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
IconButton(
|
||||
icon: const Icon(
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: PvColors.textSecondary,
|
||||
color: skin.textSecondary,
|
||||
size: 20,
|
||||
),
|
||||
visualDensity: VisualDensity.compact,
|
||||
@@ -107,7 +117,7 @@ class PvSettingsSheet extends StatelessWidget {
|
||||
children: [
|
||||
Text(
|
||||
tr.translate('pv_control.set_video_source'),
|
||||
style: PvType.label,
|
||||
style: PvType.label.copyWith(color: skin.textSecondary),
|
||||
),
|
||||
for (final (src, label) in _sources)
|
||||
_pill(
|
||||
@@ -126,7 +136,7 @@ class PvSettingsSheet extends StatelessWidget {
|
||||
children: [
|
||||
Text(
|
||||
tr.translate('pv_control.set_video_fit'),
|
||||
style: PvType.label,
|
||||
style: PvType.label.copyWith(color: skin.textSecondary),
|
||||
),
|
||||
for (final (fitMode, label) in _fits)
|
||||
_pill(
|
||||
@@ -138,17 +148,14 @@ class PvSettingsSheet extends StatelessWidget {
|
||||
videoFit == PvVideoFit.contain
|
||||
? tr.translate('pv_control.set_fit_contain_hint')
|
||||
: tr.translate('pv_control.set_fit_cover_hint'),
|
||||
style: PvType.caption.copyWith(
|
||||
color: PvColors.textTertiary,
|
||||
),
|
||||
style: PvType.caption.copyWith(color: skin.textTertiary),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
_switchTile(
|
||||
icon: Icons.warning_amber_rounded,
|
||||
iconColor:
|
||||
simObstacle ? PvColors.danger : PvColors.textTertiary,
|
||||
iconColor: simObstacle ? skin.danger : skin.textTertiary,
|
||||
title: tr.translate('pv_control.set_sim_obstacle'),
|
||||
subtitle: tr.translate('pv_control.set_sim_obstacle_sub'),
|
||||
value: simObstacle,
|
||||
@@ -156,8 +163,7 @@ class PvSettingsSheet extends StatelessWidget {
|
||||
),
|
||||
_switchTile(
|
||||
icon: Icons.directions_car,
|
||||
iconColor:
|
||||
simReverse ? PvColors.accentBright : PvColors.textTertiary,
|
||||
iconColor: simReverse ? skin.accent : skin.textTertiary,
|
||||
title: tr.translate('pv_control.set_sim_reverse'),
|
||||
subtitle: tr.translate('pv_control.set_sim_reverse_sub'),
|
||||
value: simReverse,
|
||||
@@ -171,13 +177,14 @@ class PvSettingsSheet extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// 药丸选项:选中态青色描边 + 填充,与 HUD 预设档位风格一致(视频源 / 视频展示共用)。
|
||||
/// 药丸选项:选中态强调色描边 + 浅底,与当前皮肤同体系(视频源 / 视频展示共用)。
|
||||
/// 左右间距由外层 Wrap 的 spacing 提供,此处只留纵向呼吸。
|
||||
Widget _pill({
|
||||
required String label,
|
||||
required bool selected,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
final skin = _skin;
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
@@ -185,20 +192,16 @@ class PvSettingsSheet extends StatelessWidget {
|
||||
duration: const Duration(milliseconds: 180),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: selected
|
||||
? PvColors.accent.withValues(alpha: 0.20)
|
||||
: PvColors.cardInner,
|
||||
color: selected ? skin.accentSoft : skin.inner,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(
|
||||
color: selected ? PvColors.accent : PvColors.cardBorder,
|
||||
color: selected ? skin.accent : skin.border,
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
label,
|
||||
style: PvType.body.copyWith(
|
||||
color: selected
|
||||
? PvColors.accentBright
|
||||
: PvColors.textSecondary,
|
||||
color: selected ? skin.accentText : skin.textSecondary,
|
||||
fontWeight: selected ? FontWeight.w700 : FontWeight.w400,
|
||||
),
|
||||
),
|
||||
@@ -215,6 +218,7 @@ class PvSettingsSheet extends StatelessWidget {
|
||||
required bool value,
|
||||
required ValueChanged<bool> onChanged,
|
||||
}) {
|
||||
final skin = _skin;
|
||||
return InkWell(
|
||||
onTap: () => onChanged(!value),
|
||||
child: Padding(
|
||||
@@ -227,10 +231,16 @@ class PvSettingsSheet extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(title, style: PvType.cardTitle),
|
||||
Text(
|
||||
title,
|
||||
style: PvType.cardTitle.copyWith(color: skin.textPrimary),
|
||||
),
|
||||
Text(
|
||||
subtitle,
|
||||
style: PvType.caption.copyWith(height: 1.3),
|
||||
style: PvType.caption.copyWith(
|
||||
color: skin.textSecondary,
|
||||
height: 1.3,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -240,8 +250,10 @@ class PvSettingsSheet extends StatelessWidget {
|
||||
child: Switch(
|
||||
value: value,
|
||||
onChanged: (_) {},
|
||||
activeThumbColor: PvColors.accentBright,
|
||||
activeTrackColor: PvColors.accent.withValues(alpha: 0.35),
|
||||
activeThumbColor: skin.switchActiveThumb,
|
||||
activeTrackColor: skin.switchActiveTrack,
|
||||
inactiveThumbColor: skin.switchInactiveThumb,
|
||||
inactiveTrackColor: skin.switchInactiveTrack,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -250,3 +262,83 @@ class PvSettingsSheet extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 设置面板两套皮肤取色:`light` = 手动控制 HUD 的浅色玻璃卡,
|
||||
/// `dark` = 普通态大屏的深蓝面板(数值与改造前完全一致)。
|
||||
class _SheetSkin {
|
||||
const _SheetSkin({
|
||||
required this.panel,
|
||||
required this.inner,
|
||||
required this.border,
|
||||
required this.accent,
|
||||
required this.accentSoft,
|
||||
required this.accentText,
|
||||
required this.textPrimary,
|
||||
required this.textSecondary,
|
||||
required this.textTertiary,
|
||||
required this.danger,
|
||||
required this.switchActiveThumb,
|
||||
required this.switchActiveTrack,
|
||||
this.switchInactiveThumb,
|
||||
this.switchInactiveTrack,
|
||||
this.panelShadow,
|
||||
});
|
||||
|
||||
/// 面板底 / 药丸未选中底 / 描边
|
||||
final Color panel;
|
||||
final Color inner;
|
||||
final Color border;
|
||||
|
||||
/// 强调色(图标、选中描边)/ 选中浅底 / 选中文字
|
||||
final Color accent;
|
||||
final Color accentSoft;
|
||||
final Color accentText;
|
||||
|
||||
final Color textPrimary;
|
||||
final Color textSecondary;
|
||||
final Color textTertiary;
|
||||
final Color danger;
|
||||
|
||||
final Color switchActiveThumb;
|
||||
final Color switchActiveTrack;
|
||||
final Color? switchInactiveThumb;
|
||||
final Color? switchInactiveTrack;
|
||||
|
||||
/// 面板投影(深色皮肤保持无投影)
|
||||
final List<BoxShadow>? panelShadow;
|
||||
|
||||
static const dark = _SheetSkin(
|
||||
panel: PvColors.card,
|
||||
inner: PvColors.cardInner,
|
||||
border: PvColors.cardBorder,
|
||||
accent: PvColors.accent,
|
||||
accentSoft: Color(0x3322D3EE), // accent @ 20%
|
||||
accentText: PvColors.accentBright,
|
||||
textPrimary: PvColors.textPrimary,
|
||||
textSecondary: PvColors.textSecondary,
|
||||
textTertiary: PvColors.textTertiary,
|
||||
danger: PvColors.danger,
|
||||
switchActiveThumb: PvColors.accentBright,
|
||||
switchActiveTrack: Color(0x5922D3EE), // accent @ 35%
|
||||
);
|
||||
|
||||
static const light = _SheetSkin(
|
||||
panel: PvHudColors.panelSolid,
|
||||
inner: PvHudColors.pill,
|
||||
border: PvHudColors.border,
|
||||
accent: PvHudColors.blue,
|
||||
accentSoft: PvHudColors.blueBg,
|
||||
accentText: PvHudColors.blue,
|
||||
textPrimary: PvHudColors.textPrimary,
|
||||
textSecondary: PvHudColors.textSecondary,
|
||||
textTertiary: PvHudColors.textTertiary,
|
||||
danger: PvHudColors.danger,
|
||||
switchActiveThumb: Colors.white,
|
||||
switchActiveTrack: Color(0xFF2F6BFF),
|
||||
switchInactiveThumb: Colors.white,
|
||||
switchInactiveTrack: Color(0xFFDDE4EC),
|
||||
panelShadow: [
|
||||
BoxShadow(color: Color(0x1F0E2233), blurRadius: 24, offset: Offset(0, 8)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -37,6 +37,24 @@ class PvWorkMap extends StatefulWidget {
|
||||
this.deviceSn = '',
|
||||
this.interactive = true,
|
||||
this.scale = 1,
|
||||
this.floatInset = 4,
|
||||
this.previewRoute = const <LatLng>[],
|
||||
this.previewOuter = const <LatLng>[],
|
||||
this.previewCoverage = true,
|
||||
this.previewSignature = '',
|
||||
this.draftPoints = const <LatLng>[],
|
||||
this.draftHoles = const <List<LatLng>>[],
|
||||
this.draftHolePoints = const <LatLng>[],
|
||||
this.draftPolygon = const <LatLng>[],
|
||||
this.draftCenter,
|
||||
this.draftCompleted = false,
|
||||
this.draftObstacle = false,
|
||||
this.draftCrosshair = false,
|
||||
this.followDevice = true,
|
||||
this.recenterSignal = 0,
|
||||
this.clearTraceSignal = 0,
|
||||
this.onCenterChanged,
|
||||
this.onDevicePosition,
|
||||
});
|
||||
|
||||
/// 设备 SN:用于过滤路线推送(deviceId 不匹配的消息直接丢弃)。
|
||||
@@ -50,6 +68,71 @@ class PvWorkMap extends StatefulWidget {
|
||||
/// HUD 的缩放系数(与 pv_manual_control_view 的 _sc 一致),只影响两个浮动按钮大小。
|
||||
final double scale;
|
||||
|
||||
/// 浮动按钮(图层 / 定位)距图表边距。页面底部叠了操作条时调大,
|
||||
/// 让「定位回中」按钮向上避让;默认 4 与原有 HUD 表现一致。
|
||||
final double floatInset;
|
||||
|
||||
/// 选中路线的预览轨迹(本地数据,非 MQTT):实时路线为空时用它画线,
|
||||
/// 让「选中一件作业」在地图上立即可见。实时路线优先。
|
||||
final List<LatLng> previewRoute;
|
||||
|
||||
/// 选中路线的预览边界框(覆盖模式才传):
|
||||
/// 与路径规划页一致——灰色半透明多边形 + 灰色细边框。
|
||||
final List<LatLng> previewOuter;
|
||||
|
||||
/// 是否覆盖模式:true 画灰色多边形区域框,false 画绿色边界线
|
||||
/// (对应路径规划 WorkMode.bow / WorkMode.custom 两种画法)。
|
||||
final bool previewCoverage;
|
||||
|
||||
/// 选中路线的标识(一般传 routeId):变化时代表“换了另一件作业”,
|
||||
/// 需要清掉上一件作业的实时路线与已走轨迹(同路径规划选中时的 reset)。
|
||||
final String previewSignature;
|
||||
|
||||
// ===== 圈地草稿层(区域编辑页专用,默认全空=不绘制,不影响既有页面)=====
|
||||
// 配色/线宽/编号 marker 尺寸全部照抄路径规划 testmap_pages 的绘制层。
|
||||
|
||||
/// 作业区域已打点:橙色连线 + 绿色圆形编号 marker。
|
||||
final List<LatLng> draftPoints;
|
||||
|
||||
/// 已完成的禁行区(每组一个多边形):红色半透明填充 + 红色边框。
|
||||
final List<List<LatLng>> draftHoles;
|
||||
|
||||
/// 正在绘制的禁行区打点:红色虚线 + 橙色圆形编号 marker。
|
||||
final List<LatLng> draftHolePoints;
|
||||
|
||||
/// 作业区域草稿多边形(打点 + 当前准星中心):绿色半透明。
|
||||
final List<LatLng> draftPolygon;
|
||||
|
||||
/// 当前地图中心(准星落点):用于画蓝线到末点并显示距离。
|
||||
final LatLng? draftCenter;
|
||||
|
||||
/// 作业区域是否已完成:完成后隐藏草稿多边形与打点标记(同路径规划)。
|
||||
final bool draftCompleted;
|
||||
|
||||
/// 是否处于禁行区编辑:显示红色多边形 / 红色虚线 / 红色打点编号。
|
||||
final bool draftObstacle;
|
||||
|
||||
/// 是否准星打点模式:画「中心 → 末点」蓝色连线、距离文字、草稿多边形。
|
||||
final bool draftCrosshair;
|
||||
|
||||
/// 是否让地图随设备位置自动居中。区域编辑时传 false:
|
||||
/// 否则每次定位推送都会把地图挪走,正在打的位置就跑了。
|
||||
final bool followDevice;
|
||||
|
||||
/// 外部「回到设备位置」信号:每次 +1 就把地图移回设备当前坐标
|
||||
/// (与路径规划竖浮菜单的「定位」同一个行为)。
|
||||
final int recenterSignal;
|
||||
|
||||
/// 外部「清空已走轨迹」信号:每次 +1 就把绿色行走轨迹清掉
|
||||
/// (对应路径规划刷新时的 traceManager.reset())。
|
||||
final int clearTraceSignal;
|
||||
|
||||
/// 地图中心变化(拖拽/缩放/程序移动都会回调),供准星打点取当前中心。
|
||||
final ValueChanged<LatLng>? onCenterChanged;
|
||||
|
||||
/// 设备实时位置变化(无效/清空时回调 null),供「设备位置打点」取当前坐标。
|
||||
final ValueChanged<LatLng?>? onDevicePosition;
|
||||
|
||||
@override
|
||||
State<PvWorkMap> createState() => _PvWorkMapState();
|
||||
}
|
||||
@@ -59,6 +142,7 @@ class _PvWorkMapState extends State<PvWorkMap> {
|
||||
static const _esriUrl =
|
||||
'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}';
|
||||
static const _centerZoom = 18.0; // 路径规划回中/跟随都用 18 级
|
||||
static const _previewZoom = 21.0; // 与路径规划选中路线后的定位级别一致
|
||||
static const _maxTrace = 600; // 绿线最多保留的点数(约 5 分钟推送)
|
||||
static const _minTraceStep = 0.3; // 米:小于此间距的点丢弃(抖动过滤)
|
||||
|
||||
@@ -103,6 +187,51 @@ class _PvWorkMapState extends State<PvWorkMap> {
|
||||
_pos = null;
|
||||
_follow = true;
|
||||
}
|
||||
// 预览路线/边界框换了:把视野挪到新路线中心(引用比较,避免无谓 move)
|
||||
if (!identical(oldWidget.previewRoute, widget.previewRoute) ||
|
||||
!identical(oldWidget.previewOuter, widget.previewOuter)) {
|
||||
_fitPreviewRoute();
|
||||
}
|
||||
// 换了一件作业:上一件的实时路线与绿色轨迹都作废(同路径规划选中时的 reset)
|
||||
if (oldWidget.previewSignature != widget.previewSignature) {
|
||||
_route = const [];
|
||||
_routeTaskId = -1;
|
||||
_trace.clear();
|
||||
_fitPreviewRoute();
|
||||
}
|
||||
// 页面点了「定位」:移回设备坐标(帧后执行,避开 build 阶段的 setState 断言)
|
||||
if (oldWidget.recenterSignal != widget.recenterSignal) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted && _ready) _recenter();
|
||||
});
|
||||
}
|
||||
// 页面点了「刷新」:已走轨迹作废(同路径规划 traceManager.reset())
|
||||
if (oldWidget.clearTraceSignal != widget.clearTraceSignal) {
|
||||
_trace.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// 预览的全部几何(轨迹 + 边界框):视野与定位都以它为准
|
||||
List<LatLng> get _previewPoints => <LatLng>[
|
||||
...widget.previewOuter,
|
||||
...widget.previewRoute,
|
||||
];
|
||||
|
||||
/// 把视野移到预览几何中心。刻意不用 CameraFit:
|
||||
/// 只要 center + 固定 zoom,跟 flutter_map 版本差异无关。
|
||||
void _fitPreviewRoute() {
|
||||
final points = _previewPoints;
|
||||
if (points.isEmpty) return;
|
||||
_follow = false;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted || !_ready) return;
|
||||
final target = _previewPoints;
|
||||
if (target.isEmpty) return;
|
||||
// 与路径规划一致:取 path+outer 的 bounding box 几何中心 + 固定 21 级
|
||||
final bounds = LatLngBounds.fromPoints(target);
|
||||
_map.move(bounds.center, _previewZoom);
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -119,12 +248,11 @@ class _PvWorkMapState extends State<PvWorkMap> {
|
||||
}
|
||||
|
||||
/// 规划路线(金黄线):后端在任务执行时推送整条覆盖清扫路线
|
||||
///
|
||||
/// 与路径规划页一致:**不按 payload.deviceId 校验**。
|
||||
/// MQTT 数据源已按 `device/{sn}/route/post` 单设备订阅,
|
||||
/// 多一道过滤反而会因为 payload 字段格式不同把运行中的路线丢掉。
|
||||
void _onRouteMessage(RouteStatusEntity msg) {
|
||||
if (widget.deviceSn.isNotEmpty &&
|
||||
msg.deviceId.isNotEmpty &&
|
||||
msg.deviceId != widget.deviceSn) {
|
||||
return; // 别的设备的路线不画
|
||||
}
|
||||
if (msg.data.isEmpty || !mounted) return;
|
||||
setState(() {
|
||||
// 新任务 = 上一段的行走轨迹作废(路径规划选中任务时同样会 reset 轨迹)
|
||||
@@ -142,8 +270,9 @@ class _PvWorkMapState extends State<PvWorkMap> {
|
||||
if (p == null) return; // 无效坐标不画点、不追(与路径规划一致)
|
||||
if (p == _pos) return;
|
||||
_pos = p;
|
||||
widget.onDevicePosition?.call(p);
|
||||
_appendTrace(p);
|
||||
if (_follow) _scheduleMove(p);
|
||||
if (_follow && widget.followDevice) _scheduleMove(p);
|
||||
}
|
||||
|
||||
void _appendTrace(LatLng p) {
|
||||
@@ -191,6 +320,21 @@ class _PvWorkMapState extends State<PvWorkMap> {
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
/// 地图中心变化 → 交给页面做准星打点与草稿多边形
|
||||
void _notifyCenter(MapPosition position, bool hasGesture) {
|
||||
final c = position.center;
|
||||
if (c == null) return;
|
||||
widget.onCenterChanged?.call(LatLng(c.latitude, c.longitude));
|
||||
}
|
||||
|
||||
/// 中心到末点的距离文本(与路径规划同一套显示:1 公里内用米)
|
||||
String _distanceText(LatLng a, LatLng b) {
|
||||
final d = _dist(a, b);
|
||||
return d < 1000
|
||||
? '${d.toStringAsFixed(1)} 米'
|
||||
: '${(d / 1000).toStringAsFixed(2)} 千米';
|
||||
}
|
||||
|
||||
/// 进场中心:优先当前选中场站高清图层中心,无有效场站兜底到苏州地块(同路径规划)
|
||||
LatLng _fallbackCenter() =>
|
||||
stationLayerCenter(sl<SiteCubit>().state.selectedSite?.siteMapName) ??
|
||||
@@ -232,7 +376,14 @@ class _PvWorkMapState extends State<PvWorkMap> {
|
||||
? InteractiveFlag.all & ~InteractiveFlag.rotate
|
||||
: InteractiveFlag.none,
|
||||
),
|
||||
onMapReady: () => _ready = true,
|
||||
onMapReady: () {
|
||||
_ready = true;
|
||||
_fitPreviewRoute();
|
||||
// 进场先把当前中心告诉页面:准星还没动过时也能取到中心
|
||||
widget.onCenterChanged?.call(LatLng(_map.camera.center.latitude,
|
||||
_map.camera.center.longitude));
|
||||
},
|
||||
onPositionChanged: _notifyCenter,
|
||||
onMapEvent: _onMapEvent,
|
||||
onTap: (_, _) {}, // 空实现:地图本身不响应点击
|
||||
),
|
||||
@@ -248,7 +399,38 @@ class _PvWorkMapState extends State<PvWorkMap> {
|
||||
/// 场站无人机高清影像:滑到哪个场站区域(zoom>=16)就叠哪个
|
||||
if (_showStation) ..._stationLayers,
|
||||
|
||||
/// 规划路线(金黄 + 白描边),参数与路径规划完全相同
|
||||
/// ① 作业区域边界框(与路径规划同一套画法):
|
||||
/// 覆盖模式 = 灰色半透明多边形;自定义模式 = 绿色边界线。
|
||||
/// 与实时路线无关,运行中也一直保留。
|
||||
if (widget.previewOuter.isNotEmpty && widget.previewCoverage)
|
||||
PolygonLayer(
|
||||
key: const ValueKey('pv_preview_area'),
|
||||
polygons: [
|
||||
Polygon(
|
||||
points: widget.previewOuter,
|
||||
color: Colors.grey.withValues(alpha: 0.15),
|
||||
borderColor: Colors.grey.withValues(alpha: 0.6),
|
||||
borderStrokeWidth: 1.5,
|
||||
isFilled: true,
|
||||
),
|
||||
],
|
||||
)
|
||||
else if (widget.previewOuter.isNotEmpty)
|
||||
PolylineLayer(
|
||||
key: const ValueKey('pv_preview_outer'),
|
||||
polylines: [
|
||||
Polyline(
|
||||
points: widget.previewOuter,
|
||||
color: Colors.green,
|
||||
strokeWidth: 3.0,
|
||||
borderColor: Colors.white,
|
||||
borderStrokeWidth: 0.5,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
/// ② 覆盖清扫路线(金黄 + 白描边,白描边与路径规划完全相同):
|
||||
/// 后端推送到达后覆盖预览轨迹;还没推送时先画选中路线的预览轨迹。
|
||||
if (_route.isNotEmpty)
|
||||
PolylineLayer(
|
||||
polylines: [
|
||||
@@ -260,6 +442,161 @@ class _PvWorkMapState extends State<PvWorkMap> {
|
||||
borderStrokeWidth: 1,
|
||||
),
|
||||
],
|
||||
)
|
||||
else if (widget.previewRoute.isNotEmpty)
|
||||
PolylineLayer(
|
||||
key: const ValueKey('pv_preview_route'),
|
||||
polylines: [
|
||||
Polyline(
|
||||
points: widget.previewRoute,
|
||||
color: const Color.fromARGB(255, 255, 204, 0),
|
||||
strokeWidth: 1.0,
|
||||
borderColor: Colors.white,
|
||||
borderStrokeWidth: 1,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
/// ===== 圈地草稿层(与路径规划同图层、同配色)=====
|
||||
/// 顺序:打点连线 → 准星连线/距离 → 草稿多边形 → 禁行区
|
||||
|
||||
/// 打点之间的橙色连线(路径规划:橙色 0.5,宽 1.5)
|
||||
if (!widget.draftCompleted && widget.draftPoints.length > 1)
|
||||
PolylineLayer(
|
||||
key: const ValueKey('pv_draft_points'),
|
||||
polylines: [
|
||||
for (var i = 0;
|
||||
i < widget.draftPoints.length - 1;
|
||||
i++)
|
||||
Polyline(
|
||||
points: [
|
||||
widget.draftPoints[i],
|
||||
widget.draftPoints[i + 1],
|
||||
],
|
||||
color: Colors.orange.withValues(alpha: 0.5),
|
||||
strokeWidth: 1.5,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
/// 准星到末点的蓝色连线(路径规划:蓝色 0.5,宽 1.5)
|
||||
if (!widget.draftCompleted &&
|
||||
widget.draftCrosshair &&
|
||||
widget.draftPoints.isNotEmpty &&
|
||||
widget.draftCenter != null)
|
||||
PolylineLayer(
|
||||
key: const ValueKey('pv_draft_crosshair_line'),
|
||||
polylines: [
|
||||
Polyline(
|
||||
points: [
|
||||
widget.draftCenter!,
|
||||
widget.draftPoints.last,
|
||||
],
|
||||
color: Colors.blue.withValues(alpha: 0.5),
|
||||
strokeWidth: 1.5,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
/// 准星/末点中点处的距离文字(红色粗体)
|
||||
if (!widget.draftCompleted &&
|
||||
widget.draftCrosshair &&
|
||||
widget.draftPoints.isNotEmpty &&
|
||||
widget.draftCenter != null)
|
||||
MarkerLayer(
|
||||
key: const ValueKey('pv_draft_distance'),
|
||||
markers: [
|
||||
Marker(
|
||||
point: LatLng(
|
||||
(widget.draftCenter!.latitude +
|
||||
widget.draftPoints.last.latitude) /
|
||||
2,
|
||||
(widget.draftCenter!.longitude +
|
||||
widget.draftPoints.last.longitude) /
|
||||
2,
|
||||
),
|
||||
width: 100,
|
||||
height: 30,
|
||||
child: Center(
|
||||
child: Text(
|
||||
_distanceText(
|
||||
widget.draftCenter!,
|
||||
widget.draftPoints.last,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
color: Colors.red,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
/// 作业区域草稿多边形(绿 0.2 填充 / 0.5 边框 / 宽 1)
|
||||
/// 只在准星打点模式画(同路径规划:设备打点不画草稿面)
|
||||
if (!widget.draftCompleted &&
|
||||
widget.draftCrosshair &&
|
||||
widget.draftPolygon.length >= 3)
|
||||
PolygonLayer(
|
||||
key: const ValueKey('pv_draft_polygon'),
|
||||
polygons: [
|
||||
Polygon(
|
||||
points: widget.draftPolygon,
|
||||
color: Colors.green.withValues(alpha: 0.2),
|
||||
borderColor: Colors.green.withValues(alpha: 0.5),
|
||||
borderStrokeWidth: 1,
|
||||
isFilled: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
/// 已完成的禁行区(红 0.2 填充 / 红边框 1.5)
|
||||
if (widget.draftObstacle && widget.draftHoles.isNotEmpty)
|
||||
PolygonLayer(
|
||||
key: const ValueKey('pv_draft_holes'),
|
||||
polygons: [
|
||||
for (final hole in widget.draftHoles)
|
||||
Polygon(
|
||||
points: hole,
|
||||
color: Colors.red.withValues(alpha: 0.2),
|
||||
borderColor: Colors.red,
|
||||
borderStrokeWidth: 1.5,
|
||||
isFilled: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
/// 正在绘制的禁行区打点连线(红虚线 + 到中心的虚线)
|
||||
if (widget.draftObstacle && widget.draftHolePoints.isNotEmpty)
|
||||
PolylineLayer(
|
||||
key: const ValueKey('pv_draft_hole_points'),
|
||||
polylines: [
|
||||
for (var i = 0;
|
||||
i < widget.draftHolePoints.length - 1;
|
||||
i++)
|
||||
Polyline(
|
||||
points: [
|
||||
widget.draftHolePoints[i],
|
||||
widget.draftHolePoints[i + 1],
|
||||
],
|
||||
color: Colors.red.withValues(alpha: 0.8),
|
||||
strokeWidth: 1.5,
|
||||
isDotted: true,
|
||||
),
|
||||
if (widget.draftCrosshair && widget.draftCenter != null)
|
||||
Polyline(
|
||||
points: [
|
||||
widget.draftCenter!,
|
||||
widget.draftHolePoints.last,
|
||||
],
|
||||
color: Colors.red.withValues(alpha: 0.5),
|
||||
strokeWidth: 1.5,
|
||||
isDotted: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
/// 已走轨迹(绿色实线,本地按定位推送累积)
|
||||
@@ -292,6 +629,62 @@ class _PvWorkMapState extends State<PvWorkMap> {
|
||||
),
|
||||
],
|
||||
),
|
||||
/// 禁行区打点编号(已完成:红底「组号-点号」;绘制中:橙底「点号」)
|
||||
if (widget.draftObstacle)
|
||||
MarkerLayer(
|
||||
key: const ValueKey('pv_draft_hole_markers'),
|
||||
markers: [
|
||||
for (var holeIndex = 0;
|
||||
holeIndex < widget.draftHoles.length;
|
||||
holeIndex++)
|
||||
for (var pointIndex = 0;
|
||||
pointIndex <
|
||||
widget.draftHoles[holeIndex].length;
|
||||
pointIndex++)
|
||||
Marker(
|
||||
point: widget.draftHoles[holeIndex][pointIndex],
|
||||
width: 80,
|
||||
height: 40,
|
||||
child: _draftBadge(
|
||||
'${holeIndex + 1}-${pointIndex + 1}',
|
||||
Colors.red,
|
||||
8,
|
||||
),
|
||||
),
|
||||
for (var pointIndex = 0;
|
||||
pointIndex < widget.draftHolePoints.length;
|
||||
pointIndex++)
|
||||
Marker(
|
||||
point: widget.draftHolePoints[pointIndex],
|
||||
width: 80,
|
||||
height: 40,
|
||||
child: _draftBadge(
|
||||
'${pointIndex + 1}',
|
||||
Colors.orange,
|
||||
10,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
/// 作业区域打点编号(绿底白字,序号从 1 开始)
|
||||
if (!widget.draftCompleted && widget.draftPoints.isNotEmpty)
|
||||
MarkerLayer(
|
||||
key: const ValueKey('pv_draft_point_markers'),
|
||||
markers: [
|
||||
for (var i = 0; i < widget.draftPoints.length; i++)
|
||||
Marker(
|
||||
point: widget.draftPoints[i],
|
||||
width: 80,
|
||||
height: 40,
|
||||
child: _draftBadge(
|
||||
'${i + 1}',
|
||||
const Color.fromARGB(255, 10, 218, 55),
|
||||
10,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
// 还没收到定位推送时的提示(此时图面停在场站中心,机器不出现)
|
||||
@@ -318,7 +711,7 @@ class _PvWorkMapState extends State<PvWorkMap> {
|
||||
// 恢复跟随并回中
|
||||
Positioned(
|
||||
right: ds(4),
|
||||
bottom: ds(4),
|
||||
bottom: ds(widget.floatInset),
|
||||
child: _floatButton(
|
||||
Icons.my_location,
|
||||
active: _follow,
|
||||
@@ -332,6 +725,36 @@ class _PvWorkMapState extends State<PvWorkMap> {
|
||||
);
|
||||
}
|
||||
|
||||
/// 打点编号徽标:与路径规划完全一致
|
||||
/// (16×16 圆、白字、顶部预留 8px 把圆心压到打点位置上)
|
||||
Widget _draftBadge(String text, Color color, double fontSize) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const SizedBox(height: 8),
|
||||
Container(
|
||||
width: 16,
|
||||
height: 16,
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
shape: BoxShape.circle,
|
||||
boxShadow: const [BoxShadow(color: Colors.black12, blurRadius: 2)],
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: fontSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _badge(String text) {
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: ds(6), vertical: ds(2)),
|
||||
|
||||
Reference in New Issue
Block a user