主界面 作业里成接入

This commit is contained in:
mmc
2026-04-16 10:33:52 +08:00
parent 4c11f06513
commit aec24027db
4 changed files with 143 additions and 199 deletions

View File

@@ -10,11 +10,7 @@ class LeftJoystickArea extends StatelessWidget {
final bool isLocked;
final double width;
const LeftJoystickArea({
Key? key,
required this.isLocked,
required this.width,
}) : super(key: key);
const LeftJoystickArea({Key? key, required this.isLocked, required this.width}) : super(key: key);
@override
Widget build(BuildContext context) {
@@ -31,6 +27,7 @@ class LeftJoystickArea extends StatelessWidget {
radius: width, // 对应 size(200.dp)
axisHint: AxisHint.forwardBackward,
onValueChanged: (value) {
debugPrint('🎮 [左摇杆] value: ${value.y},${value.x}');
// 对应 viewModel.updateOriginY(y)
context.read<RemoteControlCubit>().updateOriginY(value.y);
Future.delayed(const Duration(milliseconds: 50), () {
@@ -48,26 +45,25 @@ class LeftJoystickArea extends StatelessWidget {
const SizedBox(height: 18),
Text(
"前后控制",
style: TextStyle(
color: Colors.white.withValues(alpha: 0.5),
fontSize: 12,
fontWeight: FontWeight.w500,
),
style: TextStyle(color: Colors.white.withValues(alpha: 0.5), fontSize: 12, fontWeight: FontWeight.w500),
),
const SizedBox(height: 2),
],
);
}
void _triggerVibration() {
Vibration.hasVibrator().then((hasVibrator) {
if (hasVibrator ?? false) {
Vibration.vibrate(duration: 12);
debugPrint('📳 [右摇杆] 震动执行 - 10ms');
} else {
debugPrint('⚠️ [右摇杆] 设备不支持震动');
}
}).catchError((e) {
debugPrint('❌ [右摇杆] 震动失败:$e');
});
Vibration.hasVibrator()
.then((hasVibrator) {
if (hasVibrator ?? false) {
Vibration.vibrate(duration: 12);
debugPrint('📳 [右摇杆] 震动执行 - 10ms');
} else {
debugPrint('⚠️ [右摇杆] 设备不支持震动');
}
})
.catchError((e) {
debugPrint('❌ [右摇杆] 震动失败:$e');
});
}
}