完善遥控权限、控制发送和急停反馈

This commit is contained in:
2026-11-21 14:37:46 +08:00
parent c284aefc7d
commit 9a8a42a0a1
55 changed files with 5009 additions and 1308 deletions

View File

@@ -1,6 +1,8 @@
import '../../../../core/logging/remote_control_diagnostics.dart';
import 'dart:async';
import 'package:cc_ui_kit/cc_ui_kit.dart';
import 'package:flutter/material.dart';
import 'remote_control_link_feedback.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:vibration/vibration.dart';
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
@@ -28,6 +30,10 @@ class _LeftJoystickAreaState extends State<LeftJoystickArea> {
/// 检查是否可以控制,不能则弹出提示
bool _checkCanControl(BuildContext context) {
if (!_hasShownNoPushDialog &&
RemoteControlLinkNotice.showIfDisconnected(context)) {
_hasShownNoPushDialog = true;
}
// 🔥 临时关闭「未收到推送不能控制」门槛,便于机器未开时用 Mock 假数据联调倒车影像。
// 联调完成后取消下面注释即可恢复。切勿删除本段逻辑。
// final cubit = context.read<RemoteControlCubit>();
@@ -88,6 +94,7 @@ class _LeftJoystickAreaState extends State<LeftJoystickArea> {
child: CCJoystick(
radius: widget.width,
axisHint: AxisHint.forwardBackward,
onDiagnostic: (event, fields) => RemoteControlDiagnostics.instance.event('joystick_' + event, fields),
onValueChanged: (value) {
if (!_checkCanControl(context)) return;
// 标记:正在触摸
@@ -135,7 +142,7 @@ class _LeftJoystickAreaState extends State<LeftJoystickArea> {
debugPrint('✅ 摇杆已停止 -> 强制 X=0, Y=0 停车');
// 🔥 使用安全方法,一次性清零双轴,确保只发送 (X=0, Y=0)
await context.read<RemoteControlCubit>().stopAllMovement();
await context.read<RemoteControlCubit>().stopAllMovement(reason: 'forward_release');
}
void _triggerVibration() {
@@ -143,4 +150,4 @@ class _LeftJoystickAreaState extends State<LeftJoystickArea> {
if (has ?? false) Vibration.vibrate(duration: 12);
});
}
}
}