From 879701e07f7b1bbecd4a5976a6883bd54636cec1 Mon Sep 17 00:00:00 2001 From: mmc <1556375442@qq.com> Date: Fri, 13 Mar 2026 08:50:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=20=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/components/toast.dart | 4 +- .../widgets/map/testmap_pages.dart | 100 ++++++++++++------ 2 files changed, 70 insertions(+), 34 deletions(-) diff --git a/lib/components/toast.dart b/lib/components/toast.dart index c73c74dd..8672b948 100644 --- a/lib/components/toast.dart +++ b/lib/components/toast.dart @@ -77,13 +77,13 @@ class ToastUtils { } /// 显示错误提示(红色背景 + 85%不透明度) - static void showError(BuildContext context, String message) { + static void showError(BuildContext context, String message, {int seconds = 1}) { showToast( context, message, // 红色:0xFFFF5252 → 调整为 0xD9FF5252(D9=85%不透明度) backgroundColor: const Color(0xD9FF5252), - duration: const Duration(seconds: 1), + duration: Duration(seconds: seconds), ); } diff --git a/lib/features/home/presentation/widgets/map/testmap_pages.dart b/lib/features/home/presentation/widgets/map/testmap_pages.dart index b679466f..0bef4120 100644 --- a/lib/features/home/presentation/widgets/map/testmap_pages.dart +++ b/lib/features/home/presentation/widgets/map/testmap_pages.dart @@ -331,8 +331,6 @@ class _MapPageEnterpriseState extends State { return LatLngBounds.fromPoints(points); } - // ========== 新增:移动地图到坐标中心 ========== - // ========== 移动地图到坐标中心(无需修改) ========== void moveMapToPointsCenter(List points) { if (points.isEmpty || !mounted) return; @@ -522,9 +520,6 @@ class _MapPageEnterpriseState extends State { debugPrint('===================================='); } - // 3. 保存地块数据的核心方法(这里写你的实际保存逻辑) - // 🔥 关键修改:增加 imgBase64 参数 - // 🔥 新的保存方法,严格匹配后端结构 Future _savePlotData(String plotName, String? imgBase64) async { // 1. 获取用户ID final userId = context.read().state.user?.userId ?? ""; @@ -973,7 +968,6 @@ class _MapPageEnterpriseState extends State { }); } - // 🔥 改动2:修改 _buildPlotListItem 方法,增加删除时调用Bloc的逻辑 Widget _buildPlotListItem(PlotData plot, Function(PlotData) onDelete) { return GestureDetector( // 核心:点击列表项触发选中逻辑 @@ -1646,30 +1640,73 @@ class _MapPageEnterpriseState extends State { const SizedBox(height: 16), // 2. 错误提示(如果加载失败) - //if (state.errorMessage != null) - // Container( - // padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), - // margin: const EdgeInsets.only(bottom: 12), - // decoration: BoxDecoration( - // color: Colors.red[50], - // borderRadius: BorderRadius.circular(6), - // border: Border.all(color: Colors.red[200]!), - // ), - // child: Row( - // children: [ - // const Icon(Icons.error_outline, color: Colors.redAccent, size: 16), - // const SizedBox(width: 8), - // Expanded( - // child: Text( - // state.errorMessage!, - // style: const TextStyle(fontSize: 14, color: Colors.redAccent), - // maxLines: 2, - // overflow: TextOverflow.ellipsis, - // ), - // ), - // ], - // ), - // ), + if (startWorkList.isEmpty || _showHeadingWarn) + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // 路径为空提示 50% + if (startWorkList.isEmpty) + Expanded( + flex: 1, + child: Container( + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + margin: const EdgeInsets.only(right: 6, bottom: 12), + decoration: BoxDecoration( + color: Colors.red[50], + borderRadius: BorderRadius.circular(6), + border: Border.all(color: Colors.red[200]!), + ), + child: const Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Icon(Icons.error_outline, color: Colors.redAccent, size: 16), + SizedBox(width: 8), + Expanded( + child: Text( + "路径区域为空", + style: TextStyle(fontSize: 14, color: Colors.redAccent), + softWrap: true, + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + ), + ], + ), + ), + ), + + // 航向异常提示 50% + if (_showHeadingWarn) + Expanded( + flex: 1, + child: Container( + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + margin: const EdgeInsets.only(left: 6, bottom: 12), + decoration: BoxDecoration( + color: Colors.red[50], + borderRadius: BorderRadius.circular(6), + border: Border.all(color: Colors.red[200]!), + ), + child: const Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Icon(Icons.error_outline, color: Colors.redAccent, size: 16), + SizedBox(width: 8), + Expanded( + child: Text( + "航向信息异常", + style: TextStyle(fontSize: 14, color: Colors.redAccent), + softWrap: true, + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + ), + ], + ), + ), + ), + ], + ), // 3. 开始作业按钮(加载中禁用) // 放在 Column/Row 的 children: [ ... ] 内部 @@ -1678,10 +1715,9 @@ class _MapPageEnterpriseState extends State { width: double.infinity, height: 50, child: ElevatedButton( - onPressed: state.isLoading || startWorkList.isEmpty + onPressed: state.isLoading || startWorkList.isEmpty || _showHeadingWarn ? null : () { - // 开始作业逻辑 _startWork(); }, style: ElevatedButton.styleFrom(