自习室优化ok
This commit is contained in:
@@ -1,46 +1,52 @@
|
||||
import 'package:app/config/config.dart';
|
||||
import 'package:app/request/dto/room/room_user_dto.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:agora_rtc_engine/agora_rtc_engine.dart';
|
||||
import '../../request/dto/room/rtc_token_dto.dart';
|
||||
|
||||
/// 视频画面显示状态
|
||||
enum VideoState {
|
||||
/// 正常显示视频
|
||||
normal,
|
||||
|
||||
/// 摄像头关闭
|
||||
closed,
|
||||
|
||||
/// 掉线 / 未连接
|
||||
offline,
|
||||
|
||||
/// 加载中(进房、拉流等)
|
||||
loading,
|
||||
|
||||
/// 错误状态(拉流失败等)
|
||||
error,
|
||||
}
|
||||
|
||||
class VideoSurface extends StatelessWidget {
|
||||
final VideoState state;
|
||||
final RoomUserDto user;
|
||||
final Widget child;
|
||||
|
||||
const VideoSurface({super.key, this.state = VideoState.normal});
|
||||
const VideoSurface({
|
||||
super.key,
|
||||
required this.user,
|
||||
required this.child,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
String stateText = switch (state) {
|
||||
VideoState.closed => "摄像头已关闭",
|
||||
VideoState.offline => "掉线",
|
||||
VideoState.loading => "加载中",
|
||||
VideoState.error => "错误",
|
||||
_ => "未知",
|
||||
};
|
||||
//如果不是正常
|
||||
if (state != VideoState.normal) {
|
||||
//摄像头是否关闭
|
||||
if (user.cameraStatus == 0) {
|
||||
return Align(
|
||||
child: Text(stateText, style: TextStyle(color: Colors.white70)),
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
maxWidth: 70,
|
||||
),
|
||||
child: AspectRatio(
|
||||
aspectRatio: 1,
|
||||
child: Container(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(color: Colors.white, width: 1),
|
||||
),
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: user.avatar,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return Container();
|
||||
if (user.online == 0) {
|
||||
return _empty('暂时离开');
|
||||
}
|
||||
return child;
|
||||
}
|
||||
|
||||
Widget _empty(String title) {
|
||||
return Center(
|
||||
child: Text(title, style: TextStyle(color: Colors.white70)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user