完成远程遥控页面的优化,包括 折叠功能栏 点击振动反馈 ,急停的读秒进度条 ,左右的振动反馈 ,锁屏的功能按钮的开发(禁用上下左右的滑轮)
This commit is contained in:
@@ -17,6 +17,7 @@ class TopStatusBar extends StatelessWidget {
|
||||
// 监听全局设备状态
|
||||
final deviceState = context.watch<DevicesCubit>().state;
|
||||
final device = deviceState.selectedDevice;
|
||||
var _remoteControlCubit = context.read<RemoteControlCubit>();
|
||||
ControlMode _parseControlMode(String modeString) {
|
||||
switch (modeString.toUpperCase()) {
|
||||
case 'BLE':
|
||||
@@ -38,12 +39,12 @@ class TopStatusBar extends StatelessWidget {
|
||||
final remoteState = context.watch<RemoteControlCubit>().state;
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
padding: const EdgeInsets.fromLTRB(1, 12, 1, 12),
|
||||
child: Row(
|
||||
children: [
|
||||
// 1. 返回按钮 (对应 SimpleSmallFunctionButton)
|
||||
_buildIconButton("assets/svgs/remote_back.svg", () => context.pop()),
|
||||
const SizedBox(width: 16),
|
||||
const SizedBox(width: 8),
|
||||
|
||||
// 2. 控制状态 (对应 StatusChipLeft)
|
||||
StatusChip(
|
||||
@@ -74,28 +75,81 @@ class TopStatusBar extends StatelessWidget {
|
||||
|
||||
// 4. 刷新按钮
|
||||
_buildIconButton("assets/svgs/remote_refresh.svg", () {}),
|
||||
const SizedBox(width: 25),
|
||||
// const SizedBox(width: 8),
|
||||
// 5. 火技能按钮 (对应 SmallFunctionButton)
|
||||
//_buildIconButton("assets/svgs/fire.svg", () {}),
|
||||
_buildSliderBox("割刀", false,context),
|
||||
_buildSliderBox("火技能按钮", false,context),
|
||||
|
||||
const Spacer(),
|
||||
const Spacer(),
|
||||
_buildExpandIconButton(
|
||||
iconPath: "assets/svgs/remote_expand.svg",
|
||||
selectedIconPath: "assets/svgs/remote_unexpand.svg",
|
||||
isSelected: remoteState.topRightIsExpanded,
|
||||
onTap: (){
|
||||
_remoteControlCubit.toggleTopLeftExpand();
|
||||
},
|
||||
),
|
||||
|
||||
AnimatedSize(
|
||||
duration: const Duration(milliseconds: 100),
|
||||
curve: Curves.easeInOut,
|
||||
child: Row(
|
||||
children: !remoteState.topRightIsExpanded
|
||||
? [
|
||||
const SizedBox(width: 8),
|
||||
_buildSwitchIconButton(
|
||||
iconPath: "assets/svgs/remote_recognition_off.svg",
|
||||
selectedIconPath: "assets/svgs/remote_recognition_on.svg",
|
||||
isSelected: remoteState.obstacleRecognitionFlag,
|
||||
onTap: (){
|
||||
_remoteControlCubit.toggleObstacleRecognition();
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
_buildSwitchIconButton(
|
||||
iconPath: "assets/svgs/remote_video_left_off.svg",
|
||||
selectedIconPath: "assets/svgs/remote_video_left.svg",
|
||||
isSelected: remoteState.showLeftPip,
|
||||
onTap: (){
|
||||
_remoteControlCubit.toggleLeftPip();
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
_buildSwitchIconButton(
|
||||
iconPath: "assets/svgs/remote_video_right_off.svg",
|
||||
selectedIconPath: "assets/svgs/remote_video_right.svg",
|
||||
isSelected: remoteState.showRightPip,
|
||||
onTap: (){
|
||||
_remoteControlCubit.toggleRightPip();
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
_buildControlModeChip(remoteState.runningStatusModel.controlMode),
|
||||
const SizedBox(width: 8),
|
||||
_buildVoltageChip(remoteState.runningStatusModel.voltage),
|
||||
const SizedBox(width: 8),
|
||||
_buildPingChip(remoteState.ping),
|
||||
const SizedBox(width: 8),
|
||||
]
|
||||
: [], // 折叠时数组为空
|
||||
),
|
||||
),
|
||||
// TODO
|
||||
_buildControlModeChip( _parseControlMode(remoteState.runningStatusModel.controlMode)),
|
||||
// _buildControlModeChip( _parseControlMode(remoteState.runningStatusModel.controlMode)),
|
||||
|
||||
const SizedBox(width: 8),
|
||||
// const SizedBox(width: 8),
|
||||
|
||||
_buildVoltageChip(remoteState.voltage),
|
||||
//_buildVoltageChip(remoteState.voltage),
|
||||
|
||||
const SizedBox(width: 8),
|
||||
// const SizedBox(width: 8),
|
||||
|
||||
// 5. 信号延迟 (对应 pingStatusChip)
|
||||
_buildPingChip(remoteState.ping),
|
||||
const SizedBox(width: 8),
|
||||
//_buildPingChip(remoteState.ping),
|
||||
// const SizedBox(width: 8),
|
||||
|
||||
// 6. 电量 (对应 StatusChipRight)
|
||||
_buildBatteryChip(remoteState.battery),
|
||||
const SizedBox(width: 8),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -129,6 +183,53 @@ class TopStatusBar extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSwitchIconButton({
|
||||
required String iconPath, // 默认图标路径
|
||||
required String selectedIconPath, // 选中后的图标路径
|
||||
required VoidCallback onTap, // 点击事件
|
||||
bool isSelected = false, // 是否选中状态
|
||||
double size = 32, // 按钮尺寸
|
||||
}) {
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
// 增加颜色切换动画
|
||||
width: size,
|
||||
height: size,
|
||||
decoration: BoxDecoration(
|
||||
// 选中时为深蓝色,未选中时为半透明灰色
|
||||
color: isSelected
|
||||
? const Color(0xFF0078D4)
|
||||
: Colors.grey.withOpacity(0.4),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(
|
||||
color: isSelected
|
||||
? Colors.transparent
|
||||
: Colors.white.withOpacity(0.3),
|
||||
width: 0.5,
|
||||
),
|
||||
boxShadow: isSelected
|
||||
? [
|
||||
BoxShadow(
|
||||
color: const Color(0xFF0078D4).withOpacity(0.4),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
]
|
||||
: null,
|
||||
),
|
||||
padding: const EdgeInsets.all(7),
|
||||
child: SvgPicture.asset(
|
||||
// 根据状态切换图片
|
||||
isSelected ? selectedIconPath : iconPath,
|
||||
colorFilter: const ColorFilter.mode(Colors.white, BlendMode.srcIn),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPingChip(int ping) {
|
||||
Color color = ping < 100
|
||||
? Colors.green
|
||||
@@ -141,27 +242,32 @@ class TopStatusBar extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildControlModeChip(ControlMode mode) {
|
||||
Widget _buildControlModeChip(String mode) {
|
||||
String displayText;
|
||||
switch (mode) {
|
||||
case ControlMode.BLE:
|
||||
displayText = '蓝牙模式';
|
||||
break;
|
||||
case ControlMode.LOCAL:
|
||||
displayText = '本地模式';
|
||||
break;
|
||||
case ControlMode.TCP:
|
||||
displayText = 'TCP模式';
|
||||
break;
|
||||
case ControlMode.NONE:
|
||||
displayText = '无模式';
|
||||
break;
|
||||
case ControlMode.OTHER:
|
||||
displayText = '其他模式';
|
||||
break;
|
||||
default:
|
||||
displayText = '未知模式';
|
||||
if(mode == ''){
|
||||
displayText = '无模式';
|
||||
}else{
|
||||
displayText = mode;
|
||||
}
|
||||
// switch (mode) {
|
||||
// case "蓝牙模式":
|
||||
// displayText = '蓝牙模式';
|
||||
// break;
|
||||
// case "本地模式":
|
||||
// displayText = '本地模式';
|
||||
// break;
|
||||
// case "TCP模式":
|
||||
// displayText = 'TCP模式';
|
||||
// break;
|
||||
// case "":
|
||||
// displayText = '无模式';
|
||||
// break;
|
||||
// case "其他模式":
|
||||
// displayText = '其他模式';
|
||||
// break;
|
||||
// default:
|
||||
// displayText = '未知模式';
|
||||
// }
|
||||
|
||||
return StatusChip(
|
||||
text: displayText,
|
||||
@@ -171,7 +277,43 @@ class TopStatusBar extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildVoltageChip(int voltage) {
|
||||
Widget _buildExpandIconButton({
|
||||
required String iconPath, // 默认图标路径
|
||||
required String selectedIconPath, // 选中后的图标路径
|
||||
required VoidCallback onTap, // 点击事件
|
||||
bool isSelected = false, // 是否选中状态
|
||||
double size = 28, // 按钮尺寸
|
||||
}) {
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
// 增加颜色切换动画
|
||||
width: size,
|
||||
height: size,
|
||||
decoration: BoxDecoration(
|
||||
// 选中时为深蓝色,未选中时为半透明灰色
|
||||
color: Colors.grey.withOpacity(0.4),
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
border: Border.all(
|
||||
color: Colors.white.withOpacity(0.3),
|
||||
width: 0.5,
|
||||
),
|
||||
boxShadow: null,
|
||||
),
|
||||
padding: const EdgeInsets.all(7),
|
||||
child: SvgPicture.asset(
|
||||
// 根据状态切换图片
|
||||
isSelected ? selectedIconPath : iconPath,
|
||||
colorFilter: const ColorFilter.mode(Colors.white, BlendMode.srcIn),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Widget _buildVoltageChip(String voltage) {
|
||||
return StatusChip(
|
||||
text: "$voltage V",
|
||||
color: Color(0xFFFACC15).withValues(alpha: 0.6),
|
||||
@@ -205,7 +347,7 @@ class TopStatusBar extends StatelessWidget {
|
||||
// 2. 使用 StatusChip 包装,但 icon 传入 SvgPicture
|
||||
return StatusChip(
|
||||
text: "$level%",
|
||||
color: color.withValues(alpha: 0.6),
|
||||
color: color.withValues(alpha: 0.5),
|
||||
svgColor: color,
|
||||
// 如果你的 StatusChip 已经改为接受 Widget,则直接传 SvgPicture
|
||||
// 如果 StatusChip 目前只接受 IconData,你需要按我之前的建议给它加个 leading 参数
|
||||
@@ -215,7 +357,7 @@ class TopStatusBar extends StatelessWidget {
|
||||
|
||||
Widget _buildSliderBox(String label, bool isLeft, BuildContext context) {
|
||||
// 1. 核心尺寸调整:足够宽的容器解决拥挤,高度匹配状态栏
|
||||
const double boxWidth = 96; // 水平宽度放大,容纳左右图标
|
||||
const double boxWidth = 76; // 水平宽度放大,容纳左右图标
|
||||
const double boxHeight = 32; // 高度和其他按钮保持一致
|
||||
const double iconSize = 20; // 图标尺寸放大,避免过小拥挤
|
||||
|
||||
|
||||
Reference in New Issue
Block a user