远程遥控页面中遗漏的语言切换支持部分
This commit is contained in:
@@ -42,7 +42,7 @@ class CenterControlArea extends StatelessWidget {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
_buildSliderBox(expandedWidth, AppLocalizations.of(context).translate('remote_control.chassis'), true,context),
|
||||
_buildSliderBox(expandedWidth, 'chassis', true,context),
|
||||
SizedBox(height: totalWidth * 0.01),
|
||||
],
|
||||
),
|
||||
@@ -72,7 +72,7 @@ class CenterControlArea extends StatelessWidget {
|
||||
width: expandedWidth,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [_buildSliderBox(expandedWidth, AppLocalizations.of(context).translate('remote_control.mower'), false,context)],
|
||||
children: [_buildSliderBox(expandedWidth, 'mower', false,context)],
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -82,7 +82,12 @@ class CenterControlArea extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSliderBox(double boxWidth, String label, bool isLeft,BuildContext context) {
|
||||
Widget _buildSliderBox(double boxWidth, String deviceKey, bool isLeft,BuildContext context) {
|
||||
// 🔥 使用deviceKey作为唯一标识,不依赖显示文本
|
||||
final label = deviceKey == 'chassis'
|
||||
? AppLocalizations.of(context).translate('remote_control.chassis')
|
||||
: AppLocalizations.of(context).translate('remote_control.mower');
|
||||
|
||||
return SizedBox(
|
||||
width: boxWidth,
|
||||
child: Center(
|
||||
@@ -92,17 +97,13 @@ class CenterControlArea extends StatelessWidget {
|
||||
child: CCExpandSlider(
|
||||
label: label,
|
||||
svgStart: "assets/svgs/remote_up.svg",
|
||||
svgCenter: switch (label) {
|
||||
"割刀" => "assets/svgs/remote_scissors.svg",
|
||||
"Mower" => "assets/svgs/remote_scissors.svg",
|
||||
"底盘" => "assets/svgs/remote_layers.svg",
|
||||
"Chassis" => "assets/svgs/remote_layers.svg",
|
||||
_ => "assets/svgs/remote_layers.svg", // 下划线表示默认值
|
||||
},
|
||||
svgCenter: deviceKey == 'mower'
|
||||
? "assets/svgs/remote_scissors.svg"
|
||||
: "assets/svgs/remote_layers.svg",
|
||||
svgEnd: "assets/svgs/remote_down.svg",
|
||||
onStart: () => _handleSliderAction(label, "start", context),
|
||||
onCenter: () => _handleSliderAction(label, "center", context),
|
||||
onEnd: () => _handleSliderAction(label, "end", context),
|
||||
onStart: () => _handleSliderAction(deviceKey, "start", context),
|
||||
onCenter: () => _handleSliderAction(deviceKey, "center", context),
|
||||
onEnd: () => _handleSliderAction(deviceKey, "end", context),
|
||||
iconSize: boxWidth * 0.6 * 0.35,
|
||||
),
|
||||
),
|
||||
@@ -111,22 +112,19 @@ class CenterControlArea extends StatelessWidget {
|
||||
}
|
||||
|
||||
// 🔥 新增:统一的业务逻辑分发方法
|
||||
void _handleSliderAction(String label, String action, BuildContext context) {
|
||||
debugPrint('🎯 [Slider 业务] label: $label, action: $action');
|
||||
void _handleSliderAction(String deviceKey, String action, BuildContext context) {
|
||||
debugPrint('🎯 [Slider 业务] deviceKey: $deviceKey, action: $action');
|
||||
|
||||
final loc = AppLocalizations.of(context);
|
||||
// 🔥 根据 label 区分不同的设备
|
||||
switch (label) {
|
||||
case "底盘":
|
||||
case "Chassis":
|
||||
// 🔥 使用deviceKey进行判断,不依赖显示文本
|
||||
switch (deviceKey) {
|
||||
case 'chassis':
|
||||
_handleChassisAction(action, context);
|
||||
break;
|
||||
case "割刀":
|
||||
case "Mower":
|
||||
case 'mower':
|
||||
_handleMowerAction(action, context);
|
||||
break;
|
||||
default:
|
||||
debugPrint('⚠️ 未知的 label: $label');
|
||||
debugPrint('⚠️ 未知的 deviceKey: $deviceKey');
|
||||
}
|
||||
// 🔥 在指令执行后触发震动反馈(增强手感)
|
||||
HapticFeedback.mediumImpact();
|
||||
|
||||
Reference in New Issue
Block a user