告警中心的二级详情页面+信息中心的页面+对接机器人接口
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../domain/usecases/get_drone_station_list_usecase.dart';
|
||||
import '../../domain/usecases/get_video_stream_usecase.dart';
|
||||
import 'drone_station_event.dart';
|
||||
import 'drone_station_state.dart';
|
||||
|
||||
class DroneStationBloc extends Bloc<DroneStationEvent, DroneStationState> {
|
||||
final GetDroneStationListUseCase getDroneStationListUseCase;
|
||||
final GetUAVDetailUseCase getUAVDetailUseCase;
|
||||
final GetVideoStreamUseCase getVideoStreamUseCase;
|
||||
|
||||
DroneStationBloc(
|
||||
this.getDroneStationListUseCase,
|
||||
this.getUAVDetailUseCase,
|
||||
this.getVideoStreamUseCase,
|
||||
) : super(const DroneStationInitial()) {
|
||||
on<DroneStationLoadData>(_onLoadData);
|
||||
on<DroneStationRefresh>(_onRefresh);
|
||||
on<UAVDetailLoad>(_onUAVDetailLoad);
|
||||
on<VideoStreamLoad>(_onVideoStreamLoad);
|
||||
}
|
||||
|
||||
Future<void> _onLoadData(
|
||||
DroneStationLoadData event,
|
||||
Emitter<DroneStationState> emit,
|
||||
) async {
|
||||
emit(const DroneStationLoading());
|
||||
|
||||
final result = await getDroneStationListUseCase(event.siteId);
|
||||
|
||||
result.fold(
|
||||
(failure) => emit(DroneStationError(failure.message)),
|
||||
(stations) => emit(DroneStationLoaded(stations)),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _onRefresh(
|
||||
DroneStationRefresh event,
|
||||
Emitter<DroneStationState> emit,
|
||||
) async {
|
||||
if (state is DroneStationLoaded) {
|
||||
final result = await getDroneStationListUseCase(event.siteId);
|
||||
|
||||
result.fold(
|
||||
(failure) => emit(DroneStationError(failure.message)),
|
||||
(stations) => emit(DroneStationLoaded(stations)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onUAVDetailLoad(
|
||||
UAVDetailLoad event,
|
||||
Emitter<DroneStationState> emit,
|
||||
) async {
|
||||
emit(const UAVDetailLoading());
|
||||
|
||||
final result = await getUAVDetailUseCase(event.gatewaySn, event.deviceSn);
|
||||
|
||||
result.fold(
|
||||
(failure) => emit(UAVDetailError(failure.message)),
|
||||
(detail) => emit(UAVDetailLoaded(detail)),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _onVideoStreamLoad(
|
||||
VideoStreamLoad event,
|
||||
Emitter<DroneStationState> emit,
|
||||
) async {
|
||||
emit(const VideoStreamLoading());
|
||||
|
||||
final result = await getVideoStreamUseCase(
|
||||
sn: event.sn,
|
||||
cameraIndex: event.cameraIndex,
|
||||
cameraPosition: event.cameraPosition,
|
||||
);
|
||||
|
||||
result.fold(
|
||||
(failure) => emit(VideoStreamError(failure.message)),
|
||||
(videoStream) => emit(VideoStreamLoaded(videoStream)),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
abstract class DroneStationEvent extends Equatable {
|
||||
const DroneStationEvent();
|
||||
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class DroneStationLoadData extends DroneStationEvent {
|
||||
final int siteId;
|
||||
|
||||
const DroneStationLoadData(this.siteId);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [siteId];
|
||||
}
|
||||
|
||||
class DroneStationRefresh extends DroneStationEvent {
|
||||
final int siteId;
|
||||
|
||||
const DroneStationRefresh(this.siteId);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [siteId];
|
||||
}
|
||||
|
||||
class UAVDetailLoad extends DroneStationEvent {
|
||||
final String gatewaySn;
|
||||
final String deviceSn;
|
||||
|
||||
const UAVDetailLoad({required this.gatewaySn, required this.deviceSn});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [gatewaySn, deviceSn];
|
||||
}
|
||||
|
||||
class VideoStreamLoad extends DroneStationEvent {
|
||||
final String sn;
|
||||
final String cameraIndex;
|
||||
final String cameraPosition;
|
||||
|
||||
const VideoStreamLoad({
|
||||
required this.sn,
|
||||
required this.cameraIndex,
|
||||
required this.cameraPosition,
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [sn, cameraIndex, cameraPosition];
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import '../../domain/entities/drone_station_entity.dart';
|
||||
|
||||
abstract class DroneStationState extends Equatable {
|
||||
const DroneStationState();
|
||||
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class DroneStationInitial extends DroneStationState {
|
||||
const DroneStationInitial();
|
||||
}
|
||||
|
||||
class DroneStationLoading extends DroneStationState {
|
||||
const DroneStationLoading();
|
||||
}
|
||||
|
||||
class DroneStationLoaded extends DroneStationState {
|
||||
final List<DroneStationEntity> stations;
|
||||
|
||||
const DroneStationLoaded(this.stations);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [stations];
|
||||
}
|
||||
|
||||
class DroneStationError extends DroneStationState {
|
||||
final String message;
|
||||
|
||||
const DroneStationError(this.message);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [message];
|
||||
}
|
||||
|
||||
class UAVDetailLoading extends DroneStationState {
|
||||
const UAVDetailLoading();
|
||||
}
|
||||
|
||||
class UAVDetailLoaded extends DroneStationState {
|
||||
final UAVDetailEntity detail;
|
||||
|
||||
const UAVDetailLoaded(this.detail);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [detail];
|
||||
}
|
||||
|
||||
class UAVDetailError extends DroneStationState {
|
||||
final String message;
|
||||
|
||||
const UAVDetailError(this.message);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [message];
|
||||
}
|
||||
|
||||
class VideoStreamLoading extends DroneStationState {
|
||||
const VideoStreamLoading();
|
||||
}
|
||||
|
||||
class VideoStreamLoaded extends DroneStationState {
|
||||
final VideoStreamEntity videoStream;
|
||||
|
||||
const VideoStreamLoaded(this.videoStream);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [videoStream];
|
||||
}
|
||||
|
||||
class VideoStreamError extends DroneStationState {
|
||||
final String message;
|
||||
|
||||
const VideoStreamError(this.message);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [message];
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../../../../core/consts/http_api_consts.dart';
|
||||
import '../../data/models/robot_data_model.dart';
|
||||
import 'robot_list_event.dart';
|
||||
import 'robot_list_state.dart';
|
||||
|
||||
class RobotListBloc extends Bloc<RobotListEvent, RobotListState> {
|
||||
final Dio dio;
|
||||
|
||||
RobotListBloc(this.dio) : super(const RobotListInitial()) {
|
||||
on<RobotListLoadData>(_onLoadData);
|
||||
on<RobotListRefresh>(_onRefresh);
|
||||
on<RobotListChangeType>(_onChangeType);
|
||||
}
|
||||
|
||||
Future<void> _onLoadData(
|
||||
RobotListLoadData event,
|
||||
Emitter<RobotListState> emit,
|
||||
) async {
|
||||
if (event.siteId == null) {
|
||||
emit(const RobotListError('请先选择场站'));
|
||||
return;
|
||||
}
|
||||
|
||||
emit(const RobotListLoading());
|
||||
|
||||
try {
|
||||
final response = await dio.get(
|
||||
HttpApiConsts.getRobotList,
|
||||
queryParameters: {
|
||||
'siteId': event.siteId,
|
||||
'pageSize': 9999,
|
||||
'pageNum': 1,
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
throw Exception('网络请求失败: ${response.statusCode}');
|
||||
}
|
||||
|
||||
final responseData = response.data;
|
||||
|
||||
if (responseData['code'] != 200) {
|
||||
throw Exception(responseData['msg'] ?? '业务异常');
|
||||
}
|
||||
|
||||
final List<dynamic> rows = responseData['rows'] ?? [];
|
||||
final robots = rows.map((item) => RobotDataModel.fromJson(item)).toList();
|
||||
|
||||
emit(RobotListLoaded(
|
||||
robots: robots,
|
||||
siteId: event.siteId,
|
||||
));
|
||||
} catch (e) {
|
||||
emit(RobotListError(e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onRefresh(
|
||||
RobotListRefresh event,
|
||||
Emitter<RobotListState> emit,
|
||||
) async {
|
||||
if (state is RobotListLoaded) {
|
||||
final currentState = state as RobotListLoaded;
|
||||
|
||||
if (currentState.siteId == null) {
|
||||
emit(const RobotListError('请先选择场站'));
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
final response = await dio.get(
|
||||
HttpApiConsts.getRobotList,
|
||||
queryParameters: {
|
||||
'siteId': currentState.siteId,
|
||||
'pageSize': 9999,
|
||||
'pageNum': 1,
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
throw Exception('网络请求失败: ${response.statusCode}');
|
||||
}
|
||||
|
||||
final responseData = response.data;
|
||||
|
||||
if (responseData['code'] != 200) {
|
||||
throw Exception(responseData['msg'] ?? '业务异常');
|
||||
}
|
||||
|
||||
final List<dynamic> rows = responseData['rows'] ?? [];
|
||||
final robots = rows.map((item) => RobotDataModel.fromJson(item)).toList();
|
||||
|
||||
emit(currentState.copyWith(robots: robots));
|
||||
} catch (e) {
|
||||
emit(RobotListError(e.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _onChangeType(
|
||||
RobotListChangeType event,
|
||||
Emitter<RobotListState> emit,
|
||||
) {
|
||||
if (state is RobotListLoaded) {
|
||||
final currentState = state as RobotListLoaded;
|
||||
emit(currentState.copyWith(selectedType: event.type));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
abstract class RobotListEvent extends Equatable {
|
||||
const RobotListEvent();
|
||||
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class RobotListLoadData extends RobotListEvent {
|
||||
final int? siteId;
|
||||
|
||||
const RobotListLoadData({this.siteId});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [siteId];
|
||||
}
|
||||
|
||||
class RobotListRefresh extends RobotListEvent {
|
||||
const RobotListRefresh();
|
||||
}
|
||||
|
||||
class RobotListChangeType extends RobotListEvent {
|
||||
final String? type;
|
||||
|
||||
const RobotListChangeType(this.type);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [type];
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import '../../data/models/robot_data_model.dart';
|
||||
|
||||
abstract class RobotListState extends Equatable {
|
||||
const RobotListState();
|
||||
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class RobotListInitial extends RobotListState {
|
||||
const RobotListInitial();
|
||||
}
|
||||
|
||||
class RobotListLoading extends RobotListState {
|
||||
const RobotListLoading();
|
||||
}
|
||||
|
||||
class RobotListLoaded extends RobotListState {
|
||||
final List<RobotDataModel> robots;
|
||||
final String? selectedType;
|
||||
final int? siteId;
|
||||
|
||||
const RobotListLoaded({
|
||||
required this.robots,
|
||||
this.selectedType,
|
||||
this.siteId,
|
||||
});
|
||||
|
||||
RobotListLoaded copyWith({
|
||||
List<RobotDataModel>? robots,
|
||||
String? selectedType,
|
||||
int? siteId,
|
||||
}) {
|
||||
return RobotListLoaded(
|
||||
robots: robots ?? this.robots,
|
||||
selectedType: selectedType ?? this.selectedType,
|
||||
siteId: siteId ?? this.siteId,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [robots, selectedType, siteId];
|
||||
}
|
||||
|
||||
class RobotListError extends RobotListState {
|
||||
final String message;
|
||||
|
||||
const RobotListError(this.message);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [message];
|
||||
}
|
||||
@@ -0,0 +1,377 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
// import 'package:volc_engine_rtc/volc_engine_rtc.dart';
|
||||
import '../../../../../core/di/injection.dart';
|
||||
import '../bloc/drone_station_bloc.dart';
|
||||
import '../bloc/drone_station_event.dart';
|
||||
import '../bloc/drone_station_state.dart';
|
||||
|
||||
class DroneMonitorPage extends StatefulWidget {
|
||||
final String gatewaySn;
|
||||
final String cameraIndex;
|
||||
|
||||
const DroneMonitorPage({
|
||||
super.key,
|
||||
required this.gatewaySn,
|
||||
required this.cameraIndex,
|
||||
});
|
||||
|
||||
@override
|
||||
_DroneMonitorPageState createState() => _DroneMonitorPageState();
|
||||
}
|
||||
|
||||
class _DroneMonitorPageState extends State<DroneMonitorPage> {
|
||||
bool isIndoor = false;
|
||||
late DroneStationBloc _bloc;
|
||||
String? videoUrl;
|
||||
bool isLoading = true;
|
||||
String? errorMessage;
|
||||
|
||||
// RTCEngine? _rtcEngine;
|
||||
// RTCRoom? _rtcRoom;
|
||||
// RTCViewContext? _remoteRenderContext;
|
||||
// final IRTCEngineEventHandler _videoHandler = IRTCEngineEventHandler();
|
||||
// final IRTCRoomEventHandler _roomHandler = IRTCRoomEventHandler();
|
||||
|
||||
String? _appId;
|
||||
String? _roomId;
|
||||
String? _token;
|
||||
String? _userId;
|
||||
bool _isJoined = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_bloc = sl<DroneStationBloc>();
|
||||
// _initVideoEventHandler();
|
||||
// _initRoomEventHandler();
|
||||
_loadVideoStream();
|
||||
}
|
||||
|
||||
// void _initVideoEventHandler() {
|
||||
// _videoHandler.onFirstRemoteVideoFrameDecoded =
|
||||
// (String streamId, StreamInfo streamInfo, VideoFrameInfo frameInfo) {
|
||||
// debugPrint('onFirstRemoteVideoFrameDecoded: ${streamInfo.userId}');
|
||||
// if (streamInfo.userId.isNotEmpty && mounted && _roomId != null) {
|
||||
// setState(() {
|
||||
// _remoteRenderContext = RTCViewContext.remoteContext(
|
||||
// roomId: _roomId!,
|
||||
// userId: streamInfo.userId,
|
||||
// streamId: streamId,
|
||||
// );
|
||||
// });
|
||||
// }
|
||||
// };
|
||||
|
||||
// _videoHandler.onWarning = (WarningCode code) {
|
||||
// debugPrint('warningCode: $code');
|
||||
// };
|
||||
|
||||
// _videoHandler.onError = (ErrorCode code) {
|
||||
// debugPrint('errorCode: $code');
|
||||
// if (mounted) {
|
||||
// setState(() {
|
||||
// errorMessage = '视频错误: $code';
|
||||
// isLoading = false;
|
||||
// });
|
||||
// }
|
||||
// };
|
||||
// }
|
||||
|
||||
// void _initRoomEventHandler() {
|
||||
// _roomHandler.onUserJoined = (UserInfo userInfo) {
|
||||
// debugPrint('onUserJoined: ${userInfo.userId}');
|
||||
// };
|
||||
|
||||
// _roomHandler.onUserLeave = (String uid, int reason) {
|
||||
// debugPrint('onUserLeave: $uid reason: $reason');
|
||||
// };
|
||||
// }
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_bloc.close();
|
||||
_leaveRoom();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _loadVideoStream() {
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
errorMessage = null;
|
||||
});
|
||||
_leaveRoom();
|
||||
_bloc.add(
|
||||
VideoStreamLoad(
|
||||
sn: widget.gatewaySn,
|
||||
cameraIndex: widget.cameraIndex,
|
||||
cameraPosition: isIndoor ? 'indoor' : 'outdoor',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _onCameraPositionChanged(bool indoor) {
|
||||
setState(() {
|
||||
isIndoor = indoor;
|
||||
});
|
||||
_loadVideoStream();
|
||||
}
|
||||
|
||||
void _parseUrlParams(String url) {
|
||||
try {
|
||||
final uri = Uri.parse(url.contains('?') ? 'http://host?$url' : url);
|
||||
final params = uri.queryParameters;
|
||||
|
||||
_appId = params['app_id'];
|
||||
_roomId = params['room_id'];
|
||||
_token = params['token'];
|
||||
_userId =
|
||||
params['user_id'] ?? 'user_${DateTime.now().millisecondsSinceEpoch}';
|
||||
|
||||
print(
|
||||
'Parsed RTC params: appId=$_appId, roomId=$_roomId, userId=$_userId',
|
||||
);
|
||||
} catch (e) {
|
||||
print('Failed to parse URL: $e');
|
||||
errorMessage = '解析视频参数失败';
|
||||
isLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Future<void> _joinRoom() async {
|
||||
// if (_appId == null || _roomId == null || _token == null) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// try {
|
||||
// _rtcEngine = await RTCEngine.createRTCEngine(
|
||||
// RTCVideoContext(appId: _appId!, eventHandler: _videoHandler),
|
||||
// );
|
||||
|
||||
// if (_rtcEngine == null) {
|
||||
// setState(() {
|
||||
// errorMessage = '创建引擎失败';
|
||||
// isLoading = false;
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
|
||||
// _rtcRoom = await _rtcEngine?.createRTCRoom(_roomId!);
|
||||
// _rtcRoom?.setRTCRoomEventHandler(_roomHandler);
|
||||
|
||||
// final userInfo = UserInfo(userId: _userId!, extraInfo: "");
|
||||
|
||||
// final roomConfig = RoomConfig(
|
||||
// isPublishAudio: false,
|
||||
// isPublishVideo: false,
|
||||
// isAutoSubscribeAudio: true,
|
||||
// isAutoSubscribeVideo: true,
|
||||
// );
|
||||
|
||||
// await _rtcRoom?.joinRoom(
|
||||
// token: _token!,
|
||||
// userInfo: userInfo,
|
||||
// roomConfig: roomConfig,
|
||||
// userVisibility: true,
|
||||
// );
|
||||
|
||||
// setState(() {
|
||||
// _isJoined = true;
|
||||
// });
|
||||
|
||||
// print('Successfully joined room: $_roomId');
|
||||
// } catch (e) {
|
||||
// print('Failed to join room: $e');
|
||||
// setState(() {
|
||||
// errorMessage = '加入房间失败: $e';
|
||||
// isLoading = false;
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
Future<void> _leaveRoom() async {
|
||||
try {
|
||||
// if (_rtcRoom != null) {
|
||||
// await _rtcRoom!.leaveRoom();
|
||||
// _rtcRoom = null;
|
||||
// }
|
||||
// if (_rtcEngine != null) {
|
||||
// _rtcEngine!.destroy();
|
||||
// _rtcEngine = null;
|
||||
// }
|
||||
setState(() {
|
||||
_isJoined = false;
|
||||
});
|
||||
} catch (e) {
|
||||
print('Failed to leave room: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider.value(
|
||||
value: _bloc,
|
||||
child: Scaffold(
|
||||
backgroundColor: const Color(0xFF1D2129),
|
||||
appBar: AppBar(
|
||||
backgroundColor: const Color(0xFF2A2E34),
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back, color: Colors.white),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
title: const Text('实时监控', style: TextStyle(color: Colors.white)),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: BlocConsumer<DroneStationBloc, DroneStationState>(
|
||||
listener: (context, state) async {
|
||||
if (state is VideoStreamLoaded) {
|
||||
videoUrl = state.videoStream.url;
|
||||
_parseUrlParams(videoUrl!);
|
||||
// await _joinRoom();
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
}
|
||||
} else if (state is VideoStreamError) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
errorMessage = state.message;
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
if (isLoading) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
if (errorMessage != null) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.error, size: 64, color: Colors.red),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
errorMessage!,
|
||||
style: const TextStyle(color: Colors.red),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ElevatedButton(
|
||||
onPressed: _loadVideoStream,
|
||||
child: const Text('重试'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return _buildVideoView();
|
||||
},
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
color: const Color(0xFF2A2E34),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildBtn(
|
||||
Icons.home,
|
||||
'室内',
|
||||
isIndoor,
|
||||
() => _onCameraPositionChanged(true),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: _buildBtn(
|
||||
Icons.sunny,
|
||||
'室外',
|
||||
!isIndoor,
|
||||
() => _onCameraPositionChanged(false),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildVideoView() {
|
||||
// if (!_isJoined || _rtcEngine == null || _userId == null) {
|
||||
// return Center(
|
||||
// child: Column(
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// children: [
|
||||
// const Icon(Icons.video_library, size: 80, color: Colors.grey),
|
||||
// const SizedBox(height: 16),
|
||||
// const Text(
|
||||
// '正在连接...',
|
||||
// style: TextStyle(color: Colors.white, fontSize: 16),
|
||||
// ),
|
||||
// const SizedBox(height: 8),
|
||||
// Text(
|
||||
// '房间: $_roomId',
|
||||
// style: const TextStyle(color: Colors.grey, fontSize: 12),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
|
||||
return Container(
|
||||
color: Colors.black,
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.videocam_off, size: 80, color: Colors.grey),
|
||||
const SizedBox(height: 16),
|
||||
const Text(
|
||||
'RTC 功能已禁用',
|
||||
style: TextStyle(color: Colors.white, fontSize: 16),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'火山引擎 RTC 依赖已注释',
|
||||
style: const TextStyle(color: Colors.grey, fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBtn(
|
||||
IconData icon,
|
||||
String label,
|
||||
bool active,
|
||||
VoidCallback onTap,
|
||||
) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: active ? const Color(0xFF165DFF) : const Color(0xFF3A3E44),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Icon(icon, color: Colors.white),
|
||||
const SizedBox(height: 8),
|
||||
Text(label, style: const TextStyle(color: Colors.white)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user