优化了老师端的等待状态判断逻辑
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
import 'package:agora_rtc_engine/agora_rtc_engine.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../viewmodel/stu_room_vm.dart';
|
||||
|
||||
class TeacherVideo extends StatefulWidget {
|
||||
const TeacherVideo({super.key});
|
||||
@@ -10,10 +14,44 @@ class TeacherVideo extends StatefulWidget {
|
||||
class _TeacherVideoState extends State<TeacherVideo> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final vm = context.read<StuRoomVM>();
|
||||
final teacherInfo = vm.teacherInfo;
|
||||
|
||||
///没开始
|
||||
if (vm.roomStatus == 0) {
|
||||
return _empty("自习室还没开始");
|
||||
}
|
||||
|
||||
///开始
|
||||
if (vm.roomStatus == 1 && vm.engine != null) {
|
||||
if (teacherInfo == null) {
|
||||
return _empty("老师不在自习室内");
|
||||
}
|
||||
if (teacherInfo.online == 0) {
|
||||
return _empty("老师掉线了,请耐心等待");
|
||||
}
|
||||
return AgoraVideoView(
|
||||
controller: VideoViewController(
|
||||
rtcEngine: vm.engine!,
|
||||
canvas: VideoCanvas(
|
||||
uid: vm.teacherInfo!.userId,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
///结束
|
||||
if (vm.roomStatus == 2) {
|
||||
return _empty("自习室已结束");
|
||||
}
|
||||
return _empty("加载中");
|
||||
}
|
||||
|
||||
Widget _empty(String title) {
|
||||
return SafeArea(
|
||||
child: Align(
|
||||
child: Text(
|
||||
"画面准备中",
|
||||
title,
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user