完成远程控制页面中点火和熄火的长按选中类别的操作
完成远程控制页面中割刀的长按选中类别的操作
This commit is contained in:
@@ -40,7 +40,7 @@ class CenterControlArea extends StatelessWidget {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
_buildSliderBox(expandedWidth, "底盘", true),
|
||||
_buildSliderBox(expandedWidth, "底盘", true,context),
|
||||
SizedBox(height: totalWidth * 0.01),
|
||||
],
|
||||
),
|
||||
@@ -70,7 +70,7 @@ class CenterControlArea extends StatelessWidget {
|
||||
width: expandedWidth,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [_buildSliderBox(expandedWidth, "割刀", false)],
|
||||
children: [_buildSliderBox(expandedWidth, "割刀", false,context)],
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -80,7 +80,7 @@ class CenterControlArea extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSliderBox(double boxWidth, String label, bool isLeft) {
|
||||
Widget _buildSliderBox(double boxWidth, String label, bool isLeft,BuildContext context) {
|
||||
return SizedBox(
|
||||
width: boxWidth,
|
||||
child: Center(
|
||||
@@ -90,10 +90,14 @@ class CenterControlArea extends StatelessWidget {
|
||||
child: CCExpandSlider(
|
||||
label: label,
|
||||
svgStart: "assets/svgs/remote_up.svg",
|
||||
svgCenter: "assets/svgs/remote_layers.svg",
|
||||
svgCenter: switch (label) {
|
||||
"割刀" => "assets/svgs/remote_scissors.svg",
|
||||
"底盘" => "assets/svgs/remote_layers.svg",
|
||||
_ => "assets/svgs/remote_layers.svg", // 下划线表示默认值
|
||||
},
|
||||
svgEnd: "assets/svgs/remote_down.svg",
|
||||
onStart: () => debugPrint("$label start"),
|
||||
onCenter: () => debugPrint("$label center"),
|
||||
onStart: () => _handleSliderAction(label, "start", context),
|
||||
onCenter: () => _handleSliderAction(label, "center", context),
|
||||
onEnd: () => debugPrint("$label end"),
|
||||
iconSize: boxWidth * 0.6 * 0.35,
|
||||
),
|
||||
@@ -101,4 +105,67 @@ class CenterControlArea extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 🔥 新增:统一的业务逻辑分发方法
|
||||
void _handleSliderAction(String label, String action, BuildContext context) {
|
||||
debugPrint('🎯 [Slider 业务] label: $label, action: $action');
|
||||
|
||||
// 🔥 根据 label 区分不同的设备
|
||||
switch (label) {
|
||||
case "底盘":
|
||||
_handleChassisAction(action, context);
|
||||
break;
|
||||
case "割刀":
|
||||
_handleMowerAction(action, context);
|
||||
break;
|
||||
default:
|
||||
debugPrint('⚠️ 未知的 label: $label');
|
||||
}
|
||||
}
|
||||
|
||||
// 🔥 底盘的业务逻辑(左滑块)
|
||||
void _handleChassisAction(String action, BuildContext context) {
|
||||
final cubit = context.read<RemoteControlCubit>();
|
||||
|
||||
switch (action) {
|
||||
case "start":
|
||||
debugPrint('⬆️ 底盘 - 向上(例如:前进)');
|
||||
// TODO: 发送底盘前进指令
|
||||
// cubit.sendChassisCommand(ChassisCommand.forward);
|
||||
break;
|
||||
case "center":
|
||||
debugPrint('️ 底盘 - 中间(例如:停止)');
|
||||
// TODO: 发送底盘停止指令
|
||||
// cubit.sendChassisCommand(ChassisCommand.stop);
|
||||
break;
|
||||
case "end":
|
||||
debugPrint('⬇️ 底盘 - 向下(例如:后退)');
|
||||
// TODO: 发送底盘后退指令
|
||||
// cubit.sendChassisCommand(ChassisCommand.backward);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 🔥 割刀的业务逻辑(右滑块)
|
||||
void _handleMowerAction(String action, BuildContext context) {
|
||||
final cubit = context.read<RemoteControlCubit>();
|
||||
|
||||
switch (action) {
|
||||
case "start":
|
||||
debugPrint('⬆️ 割刀 - 向上(例如:抬刀)');
|
||||
// TODO: 发送抬刀指令
|
||||
// cubit.sendMowerCommand(MowerCommand.lift);
|
||||
break;
|
||||
case "center":
|
||||
debugPrint('⏹️ 割刀 - 中间(例如:保持)');
|
||||
// TODO: 发送保持指令
|
||||
// cubit.sendMowerCommand(MowerCommand.hold);
|
||||
break;
|
||||
case "end":
|
||||
debugPrint('⬇️ 割刀 - 向下(例如:降刀)');
|
||||
// TODO: 发送降刀指令
|
||||
// cubit.sendMowerCommand(MowerCommand.lower);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user