优化 自定义模式不显示航线选项 自定义模式显示和弓子显示的默认选择从缓存获取

This commit is contained in:
mmc
2026-04-17 10:59:48 +08:00
parent fb3591bd59
commit 4ee48a115e
3 changed files with 79 additions and 42 deletions

View File

@@ -10,6 +10,7 @@ class BottomOperationPanel extends StatefulWidget {
// 新增:外部控制初始选中的标签(默认地块)
final String initialSelectedTab;
final WorkMode initialWorkMode;
final bool isShowButton; //是否显示地块航线
final bool? canUndo; // 是否可以撤回(控制撤回按钮状态)
// 回调函数:向外部传递事件
final VoidCallback onComplete; // 完成按钮点击回调
@@ -32,6 +33,7 @@ class BottomOperationPanel extends StatefulWidget {
this.initialAreaMode = AreaMode.work,
this.initialSelectedTab = '地块', // 默认选中地块
this.initialWorkMode = WorkMode.bow,
this.isShowButton = true,
required this.onComplete, // 完成按钮必须传
this.onRobotModeChanged,
this.onAreaModeChanged,
@@ -85,51 +87,52 @@ class _BottomOperationPanelState extends State<BottomOperationPanel> {
children: [
_buildTabContent(),
// 底部标签页切换(修复背景色切换+状态更新)
Container(
decoration: BoxDecoration(color: Colors.grey[200], borderRadius: BorderRadius.circular(8)),
child: Row(
children: [
Expanded(
child: GestureDetector(
onTap: () {
setState(() {
_currentTab = '地块'; // 更新选中状态
});
debugPrint('切换到地块标签');
widget.onLandTap?.call();
},
child: Container(
padding: const EdgeInsets.symmetric(vertical: 10),
// 选中地块时背景为白色,否则透明
decoration: BoxDecoration(color: _currentTab == '地块' ? Colors.white : Colors.transparent, borderRadius: BorderRadius.circular(8)),
child: const Center(
child: Text('地块', style: TextStyle(color: Colors.black87, fontSize: 16)),
if (widget.isShowButton)
Container(
decoration: BoxDecoration(color: Colors.grey[200], borderRadius: BorderRadius.circular(8)),
child: Row(
children: [
Expanded(
child: GestureDetector(
onTap: () {
setState(() {
_currentTab = '地块'; // 更新选中状态
});
debugPrint('切换到地块标签');
widget.onLandTap?.call();
},
child: Container(
padding: const EdgeInsets.symmetric(vertical: 10),
// 选中地块时背景为白色,否则透明
decoration: BoxDecoration(color: _currentTab == '地块' ? Colors.white : Colors.transparent, borderRadius: BorderRadius.circular(8)),
child: const Center(
child: Text('地块', style: TextStyle(color: Colors.black87, fontSize: 16)),
),
),
),
),
),
Expanded(
child: GestureDetector(
onTap: () {
setState(() {
_currentTab = '航线'; // 更新选中状态
});
debugPrint('切换到航线标签');
widget.onRouteTap?.call();
},
child: Container(
padding: const EdgeInsets.symmetric(vertical: 10),
// 选中航线时背景为白色,否则透明
decoration: BoxDecoration(color: _currentTab == '航线' ? Colors.white : Colors.transparent, borderRadius: BorderRadius.circular(8)),
child: const Center(
child: Text('航线', style: TextStyle(color: Colors.black87, fontSize: 16)),
Expanded(
child: GestureDetector(
onTap: () {
setState(() {
_currentTab = '航线'; // 更新选中状态
});
debugPrint('切换到航线标签');
widget.onRouteTap?.call();
},
child: Container(
padding: const EdgeInsets.symmetric(vertical: 10),
// 选中航线时背景为白色,否则透明
decoration: BoxDecoration(color: _currentTab == '航线' ? Colors.white : Colors.transparent, borderRadius: BorderRadius.circular(8)),
child: const Center(
child: Text('航线', style: TextStyle(color: Colors.black87, fontSize: 16)),
),
),
),
),
),
],
],
),
),
),
const SizedBox(height: 5),
],
),