路景观规划视频 初步ui
This commit is contained in:
@@ -14,6 +14,7 @@ import 'package:latlong2/latlong.dart';
|
||||
import 'package:maibu_satabot_v2/components/confrim_dialog.dart';
|
||||
import 'package:maibu_satabot_v2/components/toast.dart';
|
||||
import 'package:maibu_satabot_v2/core/app/app_user_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/core/consts/tcp_consts.dart';
|
||||
import 'package:maibu_satabot_v2/core/di/injection.dart';
|
||||
import 'package:maibu_satabot_v2/core/network/net_message_dispatcher.dart';
|
||||
import 'package:maibu_satabot_v2/core/network/protocol_decoder.dart';
|
||||
@@ -32,6 +33,7 @@ import 'package:maibu_satabot_v2/features/home/presentation/widgets/map/CenterLo
|
||||
import 'package:maibu_satabot_v2/features/home/presentation/widgets/map/HeadingPointer.dart';
|
||||
import 'package:maibu_satabot_v2/features/home/presentation/widgets/startpoint_area.dart';
|
||||
import 'package:image/image.dart' as _image; // 注意命名空间冲突,使用 as img
|
||||
import 'package:maibu_satabot_v2/features/home/presentation/widgets/video.dart';
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import '../path_list_pages.dart';
|
||||
@@ -66,6 +68,9 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
final _dispatcher = sl<NetMessageDispatcher>();
|
||||
late StreamSubscription<RawPacket> _sub;
|
||||
bool _isRefreshing = false; // 新增:页面刷新状态标志
|
||||
bool _isVideoDialogOpen = false; // 控制视频弹窗显示
|
||||
String _videoStreamUrl = "";
|
||||
Offset _videoPopupPos = const Offset(0, 100); // 弹窗初始位置
|
||||
// 🔥 关键修复:添加截图全局Key
|
||||
final GlobalKey _mapRepaintKey = GlobalKey();
|
||||
|
||||
@@ -73,6 +78,7 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
// 初始化轨迹管理器(泛型指定为LatLng)
|
||||
late final TracePoint<PlotPoint> _traceManager;
|
||||
late String workMode = "弓字模式"; // 作业模式:默认值为"弓字模式"
|
||||
|
||||
WorkStatus _workStatus = WorkStatus.idle;
|
||||
|
||||
LatLng? _currentLatLng;
|
||||
@@ -772,6 +778,12 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _handleVideo() {
|
||||
setState(() {
|
||||
_isVideoDialogOpen = true; // 打开视频弹窗
|
||||
});
|
||||
}
|
||||
|
||||
// 模拟添加完成点
|
||||
void _addCompletePoint() {
|
||||
final newPoint = LatLng(39.9042 + (DateTime.now().millisecond / 10000), 116.4074 + (DateTime.now().millisecond / 10000));
|
||||
@@ -784,6 +796,38 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
_traceManager.upsert(newPoint);
|
||||
}
|
||||
|
||||
// 构建视频弹窗
|
||||
// 构建视频小弹窗(可拖拽)
|
||||
// 构建视频小弹窗(可拖拽)
|
||||
Widget _buildVideoPopup() {
|
||||
return Positioned(
|
||||
left: _videoPopupPos.dx,
|
||||
top: _videoPopupPos.dy,
|
||||
child: GestureDetector(
|
||||
// 拖拽区域(整个弹窗可拖拽)
|
||||
onPanUpdate: (details) {
|
||||
setState(() {
|
||||
_videoPopupPos = Offset(_videoPopupPos.dx + details.delta.dx, _videoPopupPos.dy + details.delta.dy);
|
||||
});
|
||||
},
|
||||
child: WebRTCMapPlayer(
|
||||
streamUrl: _videoStreamUrl,
|
||||
width: 320,
|
||||
height: 180,
|
||||
showLeftPip: true,
|
||||
showRightPip: true,
|
||||
onClose: _closeVideoDialog, // 关闭回调
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _closeVideoDialog() {
|
||||
setState(() {
|
||||
_isVideoDialogOpen = false;
|
||||
});
|
||||
}
|
||||
|
||||
// 🔥 改动2:修改 _buildPlotListItem 方法,增加删除时调用Bloc的逻辑
|
||||
Widget _buildPlotListItem(PlotData plot, Function(PlotData) onDelete) {
|
||||
return GestureDetector(
|
||||
@@ -1539,7 +1583,14 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
final screenHeight = MediaQuery.of(context).size.height;
|
||||
final menuHeight = 16 * 6; // 假设 VerticalFloatMenu 有 6 个选项,每个高度为 56
|
||||
final maxTop = screenHeight - menuHeight;
|
||||
|
||||
final userState = context.watch<AppUserCubit>().state;
|
||||
final deviceId = context.watch<DevicesCubit>().state.selectedDevice?.deviceName;
|
||||
if (deviceId != null && userState.user?.token != null) {
|
||||
_videoStreamUrl = "webrtc://${TCPConsts.TCP_IP}/live/livestream/$deviceId?token=${userState.user!.token}";
|
||||
} else {
|
||||
_videoStreamUrl = ''; // 无设备/用户信息时置空
|
||||
print("设备未选中或用户未登录,无法生成视频流地址");
|
||||
}
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: Stack(
|
||||
@@ -1902,6 +1953,7 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
debugPrint('外部收到作业模式:$mode');
|
||||
},
|
||||
onRefreshTap: _handleRefresh, // 推荐用局部刷新
|
||||
onVideoTap: _handleVideo,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -2101,6 +2153,7 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
),
|
||||
|
||||
if (_isWorkPanelOpen) _buildWorkPanel(),
|
||||
if (_isVideoDialogOpen) _buildVideoPopup(),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user