USB 摄像头+远程遥控+中英的适配+topic的集成和状态的使用到相应页面

This commit is contained in:
2026-10-20 17:03:37 +08:00
parent 178cd2533c
commit 582242e9aa
144 changed files with 15759 additions and 406 deletions

View File

@@ -2,9 +2,12 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:video_player/video_player.dart';
import 'package:maibu_satabot_v2/features/pv_control/presentation/pages/pv_control_page.dart';
import '../../domain/entities/onvif_camera.dart';
import '../cubit/local_camera_cubit.dart';
import '../cubit/local_camera_state.dart';
import '../widgets/rtsp_tuning_panel.dart';
/// 本地视频页:ONVIF 自动发现 + RTSP 播放(搜索与播放合一)。
/// 上方为播放器 / 搜索状态 / 摄像头列表,下方为链路状态"链条"实时展示。
@@ -37,7 +40,8 @@ class _LocalCameraViewState extends State<_LocalCameraView> {
return BlocBuilder<LocalCameraCubit, LocalCameraState>(
builder: (context, state) {
return PopScope(
canPop: state.phase != LocalCameraPhase.playing &&
canPop:
state.phase != LocalCameraPhase.playing &&
state.phase != LocalCameraPhase.connecting,
onPopInvokedWithResult: (didPop, result) {
if (!didPop) {
@@ -61,7 +65,10 @@ class _LocalCameraViewState extends State<_LocalCameraView> {
),
title: const Text(
'本地视频',
style: TextStyle(color: Colors.white, fontWeight: FontWeight.w600),
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600,
),
),
centerTitle: true,
actions: [
@@ -71,12 +78,34 @@ class _LocalCameraViewState extends State<_LocalCameraView> {
icon: const Icon(Icons.refresh, color: Colors.white),
onPressed: () => cubit.runDiscovery(),
),
// 🔥 入口:进入光伏电站机器人远程控制(横屏动态大屏)页面
IconButton(
tooltip: '远程控制',
icon: const Icon(
Icons.sports_esports_outlined,
color: Colors.white,
),
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => const PvControlPage(deviceId: ''),
),
);
},
),
],
),
body: SafeArea(
child: Column(
children: [
Expanded(child: _buildContent(context, cubit, state)),
// 链路探针:只读结论,放在调参条上方(同样不遮住画面)。
RtspLinkProbeBar(probe: cubit.probe),
// 调参条:固定在链路条上方(不放画面上),改完直接重拉流做 A/B。
RtspTuningBar(
tuning: state.tuning,
onOpen: () => showRtspTuningSheet(context, cubit),
),
_buildChain(context, state),
],
),
@@ -128,9 +157,7 @@ class _LocalCameraViewState extends State<_LocalCameraView> {
) {
return Stack(
children: [
Positioned.fill(
child: _buildPlayer(cubit),
),
Positioned.fill(child: _buildPlayer(cubit)),
// 连接中遮罩
if (state.phase == LocalCameraPhase.connecting)
Positioned.fill(
@@ -171,10 +198,7 @@ class _LocalCameraViewState extends State<_LocalCameraView> {
? size.width / size.height
: 16 / 9;
return Center(
child: AspectRatio(
aspectRatio: ratio,
child: VideoPlayer(controller),
),
child: AspectRatio(aspectRatio: ratio, child: VideoPlayer(controller)),
);
}
@@ -229,45 +253,49 @@ class _LocalCameraViewState extends State<_LocalCameraView> {
return Container(
color: dark ? Colors.black.withValues(alpha: 0.65) : Colors.black,
alignment: Alignment.center,
child: Padding(
padding: const EdgeInsets.all(24),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
if (spinning)
const SizedBox(
width: 42,
height: 42,
child: CircularProgressIndicator(
color: Color(0xFF165DFF),
strokeWidth: 3,
// FittedBox:嵌入受限高度容器时整组等比缩小,避免「重试」按钮溢出
child: FittedBox(
fit: BoxFit.scaleDown,
child: Padding(
padding: const EdgeInsets.all(24),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
if (spinning)
const SizedBox(
width: 42,
height: 42,
child: CircularProgressIndicator(
color: Color(0xFF165DFF),
strokeWidth: 3,
),
)
else
Icon(icon, color: Colors.white54, size: 52),
const SizedBox(height: 18),
Text(
message,
textAlign: TextAlign.center,
style: const TextStyle(
color: Colors.white,
fontSize: 15,
height: 1.5,
),
)
else
Icon(icon, color: Colors.white54, size: 52),
const SizedBox(height: 18),
Text(
message,
textAlign: TextAlign.center,
style: const TextStyle(
color: Colors.white,
fontSize: 15,
height: 1.5,
),
),
if (actionLabel != null && onAction != null) ...[
const SizedBox(height: 22),
ElevatedButton.icon(
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF165DFF),
foregroundColor: Colors.white,
if (actionLabel != null && onAction != null) ...[
const SizedBox(height: 22),
ElevatedButton.icon(
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF165DFF),
foregroundColor: Colors.white,
),
onPressed: onAction,
icon: const Icon(Icons.refresh, size: 18),
label: Text(actionLabel),
),
onPressed: onAction,
icon: const Icon(Icons.refresh, size: 18),
label: Text(actionLabel),
),
],
],
],
),
),
),
);
@@ -346,7 +374,10 @@ class _ChainNode extends StatelessWidget {
child: loading
? Padding(
padding: const EdgeInsets.all(3),
child: CircularProgressIndicator(color: color, strokeWidth: 3),
child: CircularProgressIndicator(
color: color,
strokeWidth: 3,
),
)
: CircleAvatar(
backgroundColor: color,
@@ -360,7 +391,9 @@ class _ChainNode extends StatelessWidget {
Text(
step.label,
style: TextStyle(
color: step.status == ChainStatus.idle ? Colors.white38 : Colors.white,
color: step.status == ChainStatus.idle
? Colors.white38
: Colors.white,
fontSize: 12,
),
),
@@ -435,7 +468,10 @@ class _CameraTile extends StatelessWidget {
: (camera.manufacturer.isNotEmpty
? camera.manufacturer
: '未知型号'),
style: const TextStyle(color: Colors.white54, fontSize: 13),
style: const TextStyle(
color: Colors.white54,
fontSize: 13,
),
),
],
),