路径规划

This commit is contained in:
mmc
2026-02-25 14:59:46 +08:00
parent d81d0c04ea
commit 5e93550b22
3 changed files with 354 additions and 10 deletions

View File

@@ -17,8 +17,8 @@ class HomePage extends StatelessWidget {
final deviceState = context.watch<DevicesCubit>().state;
final currentDevice = deviceState.selectedDevice;
if (currentDevice == null)
return const Scaffold(body: Center(child: Text("加载中...")));
//if (currentDevice == null)
// return const Scaffold(body: Center(child: Text("加载中...")));
return Scaffold(
backgroundColor: const Color(0xFFF7F7F7),
@@ -26,7 +26,7 @@ class HomePage extends StatelessWidget {
physics: const BouncingScrollPhysics(),
slivers: [
// 1. 沉浸式顶部展示区
SliverToBoxAdapter(child: ImmersionHeader(device: currentDevice)),
//SliverToBoxAdapter(child: ImmersionHeader(device: currentDevice)),
// 2. 功能网格(保持原有逻辑,但背景建议改为纯白)
const SliverToBoxAdapter(child: QuickActionsGrid()),

View File

@@ -36,11 +36,13 @@ class _VerticalFloatMenuState extends State<VerticalFloatMenu> {
children: _menuItems
.asMap()
.entries
.map((entry) => _buildMenuItem(
entry.value["icon"],
entry.key,
entry.value["name"],
))
.map(
(entry) => _buildMenuItem(
entry.value["icon"],
entry.key,
entry.value["name"],
),
)
.toList(),
),
);
@@ -51,9 +53,17 @@ class _VerticalFloatMenuState extends State<VerticalFloatMenu> {
final isSelected = _selectedIndex == index;
return InkWell(
// 点击切换选中状态+触发外部回调
onTap: () {
onTap: () async {
setState(() => _selectedIndex = index);
if (widget.onItemTap != null) widget.onItemTap!(index, name);
if (index == 0) {
final result = await _showModeDialog(context);
if (result == true) {
// 点击了确定 → 弹出底部面板
_showBottomPanel(context);
}
}
},
child: Container(
width: double.infinity, // 撑满父容器宽度,保证点击区域
@@ -83,4 +93,140 @@ class _VerticalFloatMenuState extends State<VerticalFloatMenu> {
),
);
}
}
}
Future<bool?> _showModeDialog(BuildContext context) {
int selectedMode = 0; // 0: 弓字模式 1: 自定义模式
return showDialog<bool>(
context: context,
barrierDismissible: false,
builder: (context) {
return StatefulBuilder(
builder: (context, setState) {
return Dialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
child: Container(
padding: const EdgeInsets.all(20),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Text(
"选择作业模式",
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
const SizedBox(height: 20),
/// 弓字模式
_modeItem(
title: "弓字模式",
subtitle: "标准全覆盖路径规划",
isSelected: selectedMode == 0,
onTap: () => setState(() => selectedMode = 0),
),
const SizedBox(height: 12),
/// 自定义模式
_modeItem(
title: "自定义模式",
subtitle: "手动设定作业区域",
isSelected: selectedMode == 1,
onTap: () => setState(() => selectedMode = 1),
),
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TextButton(
onPressed: () {
Navigator.pop(context, false); // 取消
},
child: const Text("取消"),
),
ElevatedButton(
onPressed: () {
Navigator.pop(context, true); // 确定
},
child: const Text("确定"),
),
],
),
],
),
),
);
},
);
},
);
}
Widget _modeItem({
required String title,
required String subtitle,
required bool isSelected,
required VoidCallback onTap,
}) {
return InkWell(
onTap: onTap,
child: Container(
padding: const EdgeInsets.all(14),
decoration: BoxDecoration(
border: Border.all(
color: isSelected ? Colors.lightBlue : Colors.grey.shade300,
),
borderRadius: BorderRadius.circular(12),
color: isSelected ? Colors.lightBlue.shade50 : Colors.white,
),
child: Row(
children: [
Icon(
isSelected ? Icons.check_circle : Icons.circle_outlined,
color: isSelected ? Colors.lightBlue : Colors.grey,
),
const SizedBox(width: 12),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(title, style: const TextStyle(fontWeight: FontWeight.bold)),
Text(
subtitle,
style: const TextStyle(fontSize: 12, color: Colors.grey),
),
],
),
],
),
),
);
}
void _showBottomPanel(BuildContext context) {
showModalBottomSheet(
context: context,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
),
builder: (context) {
return Container(
height: 200,
padding: const EdgeInsets.all(20),
child: Column(
children: const [
Text(
"圈地操作面板",
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
SizedBox(height: 20),
Text("这里放你的圈地操作按钮"),
],
),
);
},
);
}