修改初始化 弹窗

This commit is contained in:
mmc
2026-03-13 08:50:45 +08:00
parent 00c5e736bd
commit 879701e07f
2 changed files with 70 additions and 34 deletions

View File

@@ -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),
);
}

View File

@@ -331,8 +331,6 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
return LatLngBounds.fromPoints(points);
}
// ========== 新增:移动地图到坐标中心 ==========
// ========== 移动地图到坐标中心(无需修改) ==========
void moveMapToPointsCenter(List<LatLng> points) {
if (points.isEmpty || !mounted) return;
@@ -522,9 +520,6 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
debugPrint('====================================');
}
// 3. 保存地块数据的核心方法(这里写你的实际保存逻辑)
// 🔥 关键修改:增加 imgBase64 参数
// 🔥 新的保存方法,严格匹配后端结构
Future<void> _savePlotData(String plotName, String? imgBase64) async {
// 1. 获取用户ID
final userId = context.read<AppUserCubit>().state.user?.userId ?? "";
@@ -973,7 +968,6 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
});
}
// 🔥 改动2:修改 _buildPlotListItem 方法,增加删除时调用Bloc的逻辑
Widget _buildPlotListItem(PlotData plot, Function(PlotData) onDelete) {
return GestureDetector(
// 核心:点击列表项触发选中逻辑
@@ -1646,30 +1640,73 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
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<MapPageEnterprise> {
width: double.infinity,
height: 50,
child: ElevatedButton(
onPressed: state.isLoading || startWorkList.isEmpty
onPressed: state.isLoading || startWorkList.isEmpty || _showHeadingWarn
? null
: () {
// 开始作业逻辑
_startWork();
},
style: ElevatedButton.styleFrom(