优化和路径规划新适配
This commit is contained in:
@@ -24,6 +24,49 @@ class LeftJoystickArea extends StatefulWidget {
|
||||
class _LeftJoystickAreaState extends State<LeftJoystickArea> {
|
||||
int _lastSentY = 0;
|
||||
bool _isTouching = false;
|
||||
bool _hasShownNoPushDialog = false; // 防止重复弹窗
|
||||
|
||||
/// 检查是否可以控制,不能则弹出提示
|
||||
bool _checkCanControl(BuildContext context) {
|
||||
final cubit = context.read<RemoteControlCubit>();
|
||||
if (!cubit.isStatusPushActive()) {
|
||||
if (!_hasShownNoPushDialog) {
|
||||
_hasShownNoPushDialog = true;
|
||||
_showNoStatusPushDialog(context);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
_hasShownNoPushDialog = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// 显示暂未收到推送的提示弹窗(小圆角)
|
||||
void _showNoStatusPushDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => Dialog(
|
||||
backgroundColor: Colors.transparent,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xE5333333),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
'暂未收到该机器的推送,不能控制',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
// 1.5秒后自动关闭
|
||||
Future.delayed(const Duration(milliseconds: 1500), () {
|
||||
Navigator.of(context).pop();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -39,6 +82,7 @@ class _LeftJoystickAreaState extends State<LeftJoystickArea> {
|
||||
radius: widget.width,
|
||||
axisHint: AxisHint.forwardBackward,
|
||||
onValueChanged: (value) {
|
||||
if (!_checkCanControl(context)) return;
|
||||
// 标记:正在触摸
|
||||
_isTouching = true;
|
||||
|
||||
@@ -50,11 +94,13 @@ class _LeftJoystickAreaState extends State<LeftJoystickArea> {
|
||||
}
|
||||
},
|
||||
onPress: () {
|
||||
if (!_checkCanControl(context)) return;
|
||||
_isTouching = true;
|
||||
debugPrint('onPress');
|
||||
_triggerVibration();
|
||||
},
|
||||
onPanEnd: () async {
|
||||
_hasShownNoPushDialog = false; // 松手重置,下次触摸重新检查
|
||||
// 🔥 松手 100% 归零
|
||||
debugPrint('onPanEnd');
|
||||
await _stopJoystick();
|
||||
|
||||
Reference in New Issue
Block a user