Merge branch 'feature/my' of http://1.95.137.212:57001/APP/FlutterApp into feature/my

This commit is contained in:
mmc
2026-03-25 09:48:25 +08:00
28 changed files with 904 additions and 167 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();
}