优化 自定义模式不显示航线选项 自定义模式显示和弓子显示的默认选择从缓存获取
This commit is contained in:
@@ -2520,6 +2520,7 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
|||||||
child: FloatingActionButton(
|
child: FloatingActionButton(
|
||||||
onPressed: _moveToCurrentLocation,
|
onPressed: _moveToCurrentLocation,
|
||||||
child: VerticalFloatMenu(
|
child: VerticalFloatMenu(
|
||||||
|
selectedWorkModeIn: _currentWorkMode ?? WorkMode.bow,
|
||||||
onEditTap: (bool isOpen) {
|
onEditTap: (bool isOpen) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isPanelOpen = isOpen;
|
_isPanelOpen = isOpen;
|
||||||
@@ -2545,7 +2546,12 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
|||||||
},
|
},
|
||||||
|
|
||||||
onWorkModeSelected: (mode) {
|
onWorkModeSelected: (mode) {
|
||||||
_currentWorkMode = mode;
|
debugPrint('外部收到作业模式选择:$mode');
|
||||||
|
setState(() {
|
||||||
|
_currentWorkMode = mode;
|
||||||
|
_saveDataToLocal();
|
||||||
|
});
|
||||||
|
|
||||||
debugPrint('外部收到作业模式:$mode');
|
debugPrint('外部收到作业模式:$mode');
|
||||||
},
|
},
|
||||||
handleGotoLocation: _handleGotoLocation,
|
handleGotoLocation: _handleGotoLocation,
|
||||||
@@ -2565,6 +2571,7 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
|||||||
initialRobotMode: _currentRobotMode,
|
initialRobotMode: _currentRobotMode,
|
||||||
initialAreaMode: _currentAreaMode,
|
initialAreaMode: _currentAreaMode,
|
||||||
initialWorkMode: _currentWorkMode!,
|
initialWorkMode: _currentWorkMode!,
|
||||||
|
isShowButton: _currentWorkMode == WorkMode.bow ? true : false,
|
||||||
canUndo: _isWorkAreaCompleted && _currentAreaMode == AreaMode.work ? false : true,
|
canUndo: _isWorkAreaCompleted && _currentAreaMode == AreaMode.work ? false : true,
|
||||||
onComplete: () async {
|
onComplete: () async {
|
||||||
debugPrint(
|
debugPrint(
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ class VerticalFloatMenu extends StatefulWidget {
|
|||||||
final VoidCallback? handleGotoLocation;
|
final VoidCallback? handleGotoLocation;
|
||||||
final ValueChanged<bool>? onDjShow;
|
final ValueChanged<bool>? onDjShow;
|
||||||
|
|
||||||
|
// ===================== 只开放这一个外部传入 =====================
|
||||||
|
final WorkMode selectedWorkModeIn;
|
||||||
|
|
||||||
const VerticalFloatMenu({
|
const VerticalFloatMenu({
|
||||||
super.key,
|
super.key,
|
||||||
this.onItemTap,
|
this.onItemTap,
|
||||||
@@ -23,6 +26,8 @@ class VerticalFloatMenu extends StatefulWidget {
|
|||||||
this.onVideoTap,
|
this.onVideoTap,
|
||||||
this.handleGotoLocation,
|
this.handleGotoLocation,
|
||||||
this.onDjShow,
|
this.onDjShow,
|
||||||
|
// 外部传入,默认值 robot
|
||||||
|
this.selectedWorkModeIn = WorkMode.bow,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -37,6 +42,27 @@ class _VerticalFloatMenuState extends State<VerticalFloatMenu> {
|
|||||||
RobotMode _robotMode = RobotMode.point;
|
RobotMode _robotMode = RobotMode.point;
|
||||||
AreaMode _areaMode = AreaMode.work;
|
AreaMode _areaMode = AreaMode.work;
|
||||||
|
|
||||||
|
// 用外部传入的值
|
||||||
|
late WorkMode _selectedWorkModeIn;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didUpdateWidget(covariant VerticalFloatMenu oldWidget) {
|
||||||
|
super.didUpdateWidget(oldWidget);
|
||||||
|
// 外部传入的 selectedWorkModeIn 变化时,内部同步更新
|
||||||
|
if (oldWidget.selectedWorkModeIn != widget.selectedWorkModeIn) {
|
||||||
|
setState(() {
|
||||||
|
_selectedWorkModeIn = widget.selectedWorkModeIn;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
// 初始化:取外部传进来的值
|
||||||
|
_selectedWorkModeIn = widget.selectedWorkModeIn;
|
||||||
|
}
|
||||||
|
|
||||||
final List<Map<String, dynamic>> _menuItems = const [
|
final List<Map<String, dynamic>> _menuItems = const [
|
||||||
{"icon": Icons.crop_free, "name": "圈地"},
|
{"icon": Icons.crop_free, "name": "圈地"},
|
||||||
{"icon": Icons.format_list_bulleted, "name": "列表"},
|
{"icon": Icons.format_list_bulleted, "name": "列表"},
|
||||||
@@ -68,7 +94,7 @@ class _VerticalFloatMenuState extends State<VerticalFloatMenu> {
|
|||||||
widget.onItemTap?.call(index, name);
|
widget.onItemTap?.call(index, name);
|
||||||
//圈地
|
//圈地
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
final result = await _showModeDialog();
|
final result = await _showModeDialog(_selectedWorkModeIn);
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
_selectedWorkMode = result;
|
_selectedWorkMode = result;
|
||||||
@@ -125,8 +151,9 @@ class _VerticalFloatMenuState extends State<VerticalFloatMenu> {
|
|||||||
|
|
||||||
/// ================= 弹窗 =================
|
/// ================= 弹窗 =================
|
||||||
|
|
||||||
Future<WorkMode?> _showModeDialog() {
|
Future<WorkMode?> _showModeDialog(_selectedWorkModeIn) {
|
||||||
WorkMode selectedMode = WorkMode.bow;
|
WorkMode selectedMode = _selectedWorkModeIn;
|
||||||
|
debugPrint("打开模式选择弹窗,当前选中模式:$selectedMode,$_selectedWorkModeIn");
|
||||||
|
|
||||||
return showDialog<WorkMode>(
|
return showDialog<WorkMode>(
|
||||||
context: context,
|
context: context,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ class BottomOperationPanel extends StatefulWidget {
|
|||||||
// 新增:外部控制初始选中的标签(默认地块)
|
// 新增:外部控制初始选中的标签(默认地块)
|
||||||
final String initialSelectedTab;
|
final String initialSelectedTab;
|
||||||
final WorkMode initialWorkMode;
|
final WorkMode initialWorkMode;
|
||||||
|
final bool isShowButton; //是否显示地块航线
|
||||||
final bool? canUndo; // 是否可以撤回(控制撤回按钮状态)
|
final bool? canUndo; // 是否可以撤回(控制撤回按钮状态)
|
||||||
// 回调函数:向外部传递事件
|
// 回调函数:向外部传递事件
|
||||||
final VoidCallback onComplete; // 完成按钮点击回调
|
final VoidCallback onComplete; // 完成按钮点击回调
|
||||||
@@ -32,6 +33,7 @@ class BottomOperationPanel extends StatefulWidget {
|
|||||||
this.initialAreaMode = AreaMode.work,
|
this.initialAreaMode = AreaMode.work,
|
||||||
this.initialSelectedTab = '地块', // 默认选中地块
|
this.initialSelectedTab = '地块', // 默认选中地块
|
||||||
this.initialWorkMode = WorkMode.bow,
|
this.initialWorkMode = WorkMode.bow,
|
||||||
|
this.isShowButton = true,
|
||||||
required this.onComplete, // 完成按钮必须传
|
required this.onComplete, // 完成按钮必须传
|
||||||
this.onRobotModeChanged,
|
this.onRobotModeChanged,
|
||||||
this.onAreaModeChanged,
|
this.onAreaModeChanged,
|
||||||
@@ -85,51 +87,52 @@ class _BottomOperationPanelState extends State<BottomOperationPanel> {
|
|||||||
children: [
|
children: [
|
||||||
_buildTabContent(),
|
_buildTabContent(),
|
||||||
// 底部标签页切换(修复背景色切换+状态更新)
|
// 底部标签页切换(修复背景色切换+状态更新)
|
||||||
Container(
|
if (widget.isShowButton)
|
||||||
decoration: BoxDecoration(color: Colors.grey[200], borderRadius: BorderRadius.circular(8)),
|
Container(
|
||||||
child: Row(
|
decoration: BoxDecoration(color: Colors.grey[200], borderRadius: BorderRadius.circular(8)),
|
||||||
children: [
|
child: Row(
|
||||||
Expanded(
|
children: [
|
||||||
child: GestureDetector(
|
Expanded(
|
||||||
onTap: () {
|
child: GestureDetector(
|
||||||
setState(() {
|
onTap: () {
|
||||||
_currentTab = '地块'; // 更新选中状态
|
setState(() {
|
||||||
});
|
_currentTab = '地块'; // 更新选中状态
|
||||||
debugPrint('切换到地块标签');
|
});
|
||||||
widget.onLandTap?.call();
|
debugPrint('切换到地块标签');
|
||||||
},
|
widget.onLandTap?.call();
|
||||||
child: Container(
|
},
|
||||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
child: Container(
|
||||||
// 选中地块时背景为白色,否则透明
|
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||||
decoration: BoxDecoration(color: _currentTab == '地块' ? Colors.white : Colors.transparent, borderRadius: BorderRadius.circular(8)),
|
// 选中地块时背景为白色,否则透明
|
||||||
child: const Center(
|
decoration: BoxDecoration(color: _currentTab == '地块' ? Colors.white : Colors.transparent, borderRadius: BorderRadius.circular(8)),
|
||||||
child: Text('地块', style: TextStyle(color: Colors.black87, fontSize: 16)),
|
child: const Center(
|
||||||
|
child: Text('地块', style: TextStyle(color: Colors.black87, fontSize: 16)),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
Expanded(
|
||||||
Expanded(
|
child: GestureDetector(
|
||||||
child: GestureDetector(
|
onTap: () {
|
||||||
onTap: () {
|
setState(() {
|
||||||
setState(() {
|
_currentTab = '航线'; // 更新选中状态
|
||||||
_currentTab = '航线'; // 更新选中状态
|
});
|
||||||
});
|
debugPrint('切换到航线标签');
|
||||||
debugPrint('切换到航线标签');
|
widget.onRouteTap?.call();
|
||||||
widget.onRouteTap?.call();
|
},
|
||||||
},
|
child: Container(
|
||||||
child: Container(
|
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
// 选中航线时背景为白色,否则透明
|
||||||
// 选中航线时背景为白色,否则透明
|
decoration: BoxDecoration(color: _currentTab == '航线' ? Colors.white : Colors.transparent, borderRadius: BorderRadius.circular(8)),
|
||||||
decoration: BoxDecoration(color: _currentTab == '航线' ? Colors.white : Colors.transparent, borderRadius: BorderRadius.circular(8)),
|
child: const Center(
|
||||||
child: const Center(
|
child: Text('航线', style: TextStyle(color: Colors.black87, fontSize: 16)),
|
||||||
child: Text('航线', style: TextStyle(color: Colors.black87, fontSize: 16)),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user