完成远程遥控页面的优化,包括 折叠功能栏 点击振动反馈 ,急停的读秒进度条 ,左右的振动反馈 ,锁屏的功能按钮的开发(禁用上下左右的滑轮)

This commit is contained in:
2026-03-24 17:09:12 +08:00
parent f7523a943d
commit 8772b1cb43
17 changed files with 525 additions and 119 deletions

View File

@@ -1,3 +1,5 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@@ -25,6 +27,7 @@ class RemoteControlPage extends StatefulWidget {
class _RemoteControlPageState extends State<RemoteControlPage> {
String _videoStreamUrl = "";
StreamSubscription? _deviceStatusSubscription;
@override
void initState() {
super.initState();
@@ -33,8 +36,17 @@ class _RemoteControlPageState extends State<RemoteControlPage> {
// 2. 隐藏状态栏和虚拟按键
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
// 🔥 关键:订阅 DeviceStatusBloc 的状态流
WidgetsBinding.instance.addPostFrameCallback((_) {
context.read<RemoteControlCubit>().startControlLoop();
final remoteCubit = context.read<RemoteControlCubit>();
final devicesCubit = context.read<DevicesCubit>();
remoteCubit.startControlLoop();
// 🔥 关键:订阅 DeviceStatusBloc 的状态流
remoteCubit.subscribeToDeviceStatus(devicesCubit.stream);
debugPrint('🚀 [遥控页面] 已启动控制循环和设备状态监听');
});
}
@@ -42,6 +54,8 @@ class _RemoteControlPageState extends State<RemoteControlPage> {
void dispose() {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
_deviceStatusSubscription?.cancel();
context.read<RemoteControlCubit>().stopControlLoop();
super.dispose();
}