58 lines
1.7 KiB
Dart
58 lines
1.7 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 RightJoystickArea extends StatelessWidget {
|
|
final bool isLocked;
|
|
final double width;
|
|
|
|
const RightJoystickArea({
|
|
Key? key,
|
|
required this.isLocked,
|
|
required this.width,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
mainAxisSize: MainAxisSize.min, // 垂直方向紧凑布局
|
|
children: [
|
|
// 1. 交互锁定逻辑:对应 Compose 的 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.leftRight, // 关键:指定为左右控制
|
|
onValueChanged: (value) {
|
|
// 对应 viewModel.updateOriginX(x)
|
|
context.read<RemoteControlCubit>().updateOriginY(value.x);
|
|
},
|
|
onPress: () {
|
|
// 对应 VibrateOnce(current, 100)
|
|
HapticFeedback.mediumImpact();
|
|
},
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 18),
|
|
// 2. 底部文字:对应 Text("左右控制", color = Color.Gray)
|
|
Text(
|
|
"左右控制",
|
|
style: TextStyle(
|
|
color: Colors.white.withValues(alpha: 0.5),
|
|
fontSize: 12,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
const SizedBox(height: 2),
|
|
],
|
|
);
|
|
}
|
|
}
|