自习室优化ok
This commit is contained in:
@@ -1,43 +1,23 @@
|
||||
import 'package:app/utils/time.dart';
|
||||
import 'package:app/widgets/base/button/index.dart';
|
||||
import 'package:app/widgets/base/config/config.dart';
|
||||
import 'package:app/widgets/base/dialog/config_dialog.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:remixicon/remixicon.dart';
|
||||
|
||||
import '../../../../widgets/room/core/count_down_vm.dart';
|
||||
import '../viewmodel/tch_room_vm.dart';
|
||||
import '../viewmodel/type.dart';
|
||||
|
||||
class TopBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
const TopBar({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
//标题子显示内容
|
||||
Widget infoItem({required String title, required IconData icon}) {
|
||||
return Row(
|
||||
spacing: 4,
|
||||
children: [
|
||||
Icon(icon, color: Colors.white54, size: 14),
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(fontSize: 12, color: Colors.white54),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
//操作按钮
|
||||
Widget actionButton({required IconData icon, required String title}) {
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
||||
margin: EdgeInsets.only(right: 15),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xff4a4f4f),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Icon(icon, size: 16),
|
||||
Text(title, style: TextStyle(fontSize: 14)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
final vm = context.watch<TchRoomVM>();
|
||||
|
||||
return AppBar(
|
||||
backgroundColor: Color(0xff373c3e),
|
||||
@@ -46,29 +26,144 @@ class TopBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
spacing: 5,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text("高三数学重置版", style: TextStyle(color: Colors.white, fontSize: 18)),
|
||||
Text(vm.roomInfo.roomName, style: TextStyle(color: Colors.white, fontSize: 18)),
|
||||
Row(
|
||||
spacing: 15,
|
||||
children: [
|
||||
infoItem(title: "剩余 1小时23分钟", icon: RemixIcons.time_line),
|
||||
infoItem(title: "8 名学生", icon: RemixIcons.group_line),
|
||||
Consumer<CountDownVM>(
|
||||
builder: (context, countVM, __) {
|
||||
return _infoItem(
|
||||
context,
|
||||
title: "剩余 ${formatSeconds(countVM.endCountDown)}",
|
||||
icon: RemixIcons.time_line,
|
||||
);
|
||||
},
|
||||
),
|
||||
_infoItem(
|
||||
context,
|
||||
title: "${vm.students.length} 名学生",
|
||||
icon: RemixIcons.group_line,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
actionButton(
|
||||
_actionButton(
|
||||
context,
|
||||
icon: RemixIcons.video_on_ai_line,
|
||||
title: "关闭全部",
|
||||
onPressed: () {
|
||||
_closeAll(context, StudentAction.camera);
|
||||
},
|
||||
),
|
||||
actionButton(
|
||||
_actionButton(
|
||||
context,
|
||||
icon: RemixIcons.volume_up_line,
|
||||
title: "全部静音",
|
||||
onPressed: () {
|
||||
_closeAll(context, StudentAction.speaker);
|
||||
},
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.only(right: 15),
|
||||
child: Button(
|
||||
text: "白板",
|
||||
textStyle: TextStyle(fontSize: 14),
|
||||
onPressed: (){},
|
||||
),
|
||||
),
|
||||
Consumer<TchRoomVM>(
|
||||
builder: (context, vm, _) {
|
||||
if (vm.roomInfo.roomStatus != 1) {
|
||||
return SizedBox();
|
||||
}
|
||||
return Button(
|
||||
type: ThemeType.danger,
|
||||
textStyle: TextStyle(fontSize: 14),
|
||||
text: "结束自习室",
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) {
|
||||
return ConfigDialog(
|
||||
content: '是否结束自习室?结束后无法在进入',
|
||||
onCancel: () {
|
||||
context.pop();
|
||||
},
|
||||
onConfirm: () {
|
||||
context.pop();
|
||||
vm.endRoom();
|
||||
EasyLoading.showToast("会议室已结束");
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _infoItem(BuildContext context, {required String title, required IconData icon}) {
|
||||
return Row(
|
||||
children: [
|
||||
Icon(icon, color: Colors.white54, size: 14),
|
||||
SizedBox(width: 4),
|
||||
Text(title, style: TextStyle(fontSize: 12, color: Colors.white54)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _actionButton(
|
||||
BuildContext context, {
|
||||
required IconData icon,
|
||||
required String title,
|
||||
required VoidCallback onPressed,
|
||||
}) {
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
||||
margin: EdgeInsets.only(right: 15),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xff4a4f4f),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: onPressed,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(icon, size: 16),
|
||||
SizedBox(width: 8),
|
||||
Text(title, style: TextStyle(fontSize: 14)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _closeAll(BuildContext context, StudentAction action) {
|
||||
final vm = context.read<TchRoomVM>();
|
||||
String content = (action == StudentAction.camera) ? '是否关闭所有学生的摄像头?' : '是否关闭所有学生的扬声器?';
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) {
|
||||
return ConfigDialog(
|
||||
content: content,
|
||||
onCancel: () => context.pop(),
|
||||
onConfirm: () {
|
||||
context.pop();
|
||||
vm.closeAllStudentAction(action);
|
||||
EasyLoading.showToast("操作已完成");
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user