57 lines
1.6 KiB
Dart
57 lines
1.6 KiB
Dart
import 'package:cc_ui_kit/cc_ui_kit.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
import '../bloc/remote_control_cubit.dart';
|
|
|
|
class LeftJoystickArea extends StatelessWidget {
|
|
final bool isLocked;
|
|
final double width;
|
|
|
|
const LeftJoystickArea({
|
|
Key? key,
|
|
required this.isLocked,
|
|
required this.width,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
mainAxisSize: MainAxisSize.min, // 紧凑布局
|
|
children: [
|
|
// 使用 IgnorePointer 处理锁定逻辑,对应 Android 的 isLocked 判断
|
|
IgnorePointer(
|
|
ignoring: isLocked,
|
|
child: AnimatedOpacity(
|
|
duration: const Duration(milliseconds: 300),
|
|
opacity: isLocked ? 0.3 : 1.0, // 锁定后变透明
|
|
child: CCJoystick(
|
|
radius: width, // 对应 size(200.dp)
|
|
axisHint: AxisHint.forwardBackward,
|
|
onValueChanged: (value) {
|
|
// 对应 viewModel.updateOriginY(y)
|
|
context.read<RemoteControlCubit>().updateOriginY(value.y);
|
|
},
|
|
onPress: () {
|
|
// 对应 VibrateOnce(current, 100)
|
|
HapticFeedback.mediumImpact();
|
|
},
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 18),
|
|
Text(
|
|
"前后控制",
|
|
style: TextStyle(
|
|
color: Colors.white.withValues(alpha: 0.5),
|
|
fontSize: 12,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
const SizedBox(height: 2),
|
|
],
|
|
);
|
|
}
|
|
}
|