自习室优化ok
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
import 'package:app/pages/student/room/viewmodel/stu_room_vm.dart';
|
||||
import 'package:app/widgets/room/file_drawer.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:remixicon/remixicon.dart';
|
||||
|
||||
import '../viewmodel/stu_room_vm.dart';
|
||||
|
||||
class BottomBar extends StatefulWidget {
|
||||
const BottomBar({super.key});
|
||||
final void Function()? onTap;
|
||||
|
||||
const BottomBar({super.key, this.onTap});
|
||||
|
||||
@override
|
||||
State<BottomBar> createState() => _BottomBarState();
|
||||
@@ -15,51 +16,77 @@ class BottomBar extends StatefulWidget {
|
||||
class _BottomBarState extends State<BottomBar> {
|
||||
///显示文件
|
||||
void _handShowFile() {
|
||||
showFileDialog(context);
|
||||
final vm = context.read<StuRoomVM>();
|
||||
if (vm.selfInfo == null) return;
|
||||
showFileDialog(
|
||||
context,
|
||||
files: vm.selfInfo!.filesList,
|
||||
onConfirm: (file) {
|
||||
vm.uploadFile(file);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final vm = context.watch<StuRoomVM>();
|
||||
|
||||
if (vm.roomInfo.roomStatus != 1) {
|
||||
return SizedBox();
|
||||
}
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xff232426),
|
||||
),
|
||||
height: 70,
|
||||
child: Consumer<StuRoomVM>(
|
||||
builder: (context,vm,_) {
|
||||
builder: (context, vm, _) {
|
||||
//摄像头开关
|
||||
return Row(
|
||||
children: [
|
||||
BarItem(
|
||||
title: "摄像头",
|
||||
icon: vm.cameraOpen ? RemixIcons.video_on_fill : RemixIcons.video_off_fill,
|
||||
isOff: !vm.cameraOpen,
|
||||
onTap: vm.changeCameraSwitch,
|
||||
icon: vm.cameraClose ? RemixIcons.video_off_fill : RemixIcons.video_on_fill,
|
||||
isOff: vm.cameraClose,
|
||||
onTap: () {
|
||||
vm.changeCameraSwitch(value: vm.cameraClose);
|
||||
},
|
||||
),
|
||||
BarItem(
|
||||
title: "麦克风",
|
||||
icon: vm.micOpen ? RemixIcons.mic_fill : RemixIcons.mic_off_fill,
|
||||
isOff: !vm.micOpen,
|
||||
onTap: vm.changeMicSwitch,
|
||||
icon: vm.micClose ? RemixIcons.mic_off_fill : RemixIcons.mic_fill,
|
||||
isOff: vm.micClose,
|
||||
onTap: () {
|
||||
vm.changeMicSwitch(value: vm.micClose);
|
||||
},
|
||||
),
|
||||
BarItem(
|
||||
title: "声音",
|
||||
icon: vm.speakerOpen ? RemixIcons.volume_up_fill : RemixIcons.volume_mute_fill,
|
||||
isOff: !vm.speakerOpen,
|
||||
onTap: vm.changeSpeakerSwitch,
|
||||
icon: vm.speakerClose
|
||||
? RemixIcons.volume_mute_fill
|
||||
: RemixIcons.volume_up_fill,
|
||||
isOff: vm.speakerClose,
|
||||
onTap: () {
|
||||
vm.changeSpeakerSwitch(value: vm.speakerClose);
|
||||
},
|
||||
),
|
||||
BarItem(
|
||||
title: "举手",
|
||||
icon: RemixIcons.hand,
|
||||
onTap: () {
|
||||
vm.changeHandSwitch();
|
||||
widget.onTap?.call();
|
||||
},
|
||||
),
|
||||
BarItem(
|
||||
title: "拍照",
|
||||
title: "上传",
|
||||
icon: RemixIcons.upload_2_fill,
|
||||
onTap: _handShowFile,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:app/utils/time.dart';
|
||||
import 'package:app/widgets/base/dialog/config_dialog.dart';
|
||||
import 'package:app/widgets/room/core/count_down_vm.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:remixicon/remixicon.dart';
|
||||
|
||||
import '../viewmodel/stu_room_vm.dart';
|
||||
|
||||
class TopBar extends StatefulWidget implements PreferredSizeWidget {
|
||||
class TopBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
final bool showOther;
|
||||
final void Function()? onOther;
|
||||
|
||||
@@ -17,67 +16,63 @@ class TopBar extends StatefulWidget implements PreferredSizeWidget {
|
||||
this.onOther,
|
||||
});
|
||||
|
||||
@override
|
||||
State<TopBar> createState() => _TopBarState();
|
||||
|
||||
@override
|
||||
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
|
||||
}
|
||||
|
||||
class _TopBarState extends State<TopBar> {
|
||||
Timer? _timer;
|
||||
int seconds = 0;
|
||||
late DateTime startTime;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final vm = context.read<StuRoomVM>();
|
||||
startTime = parseTime(vm.roomInfo.startTime);
|
||||
|
||||
_timer = Timer.periodic(const Duration(seconds: 1), (_) {
|
||||
final diff = DateTime.now().difference(startTime).inSeconds;
|
||||
setState(() {
|
||||
seconds = diff < 0 ? 0 : diff;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/// 你若想外面主动停,可以暴露这个方法
|
||||
void stopTimer() {
|
||||
_timer?.cancel();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_timer?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final vm = context.read<StuRoomVM>();
|
||||
|
||||
return AppBar(
|
||||
foregroundColor: Colors.white,
|
||||
titleTextStyle: const TextStyle(color: Colors.white, fontSize: 18),
|
||||
backgroundColor: const Color(0xff232426),
|
||||
centerTitle: true,
|
||||
title: Column(
|
||||
children: [
|
||||
Text(vm.roomInfo.roomName),
|
||||
Text(
|
||||
formatSeconds(seconds),
|
||||
style: const TextStyle(fontSize: 12, color: Colors.white24),
|
||||
leadingWidth: 100,
|
||||
leading: Container(
|
||||
padding: EdgeInsets.only(left: 10),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) {
|
||||
return ConfigDialog(
|
||||
content: "请确认是否退出自习室",
|
||||
onCancel: () {
|
||||
context.pop();
|
||||
},
|
||||
onConfirm: () {
|
||||
context.pop();
|
||||
context.pop();
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Text(
|
||||
"退出自习室",
|
||||
style: TextStyle(color: Colors.red),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
title: Consumer<CountDownVM>(
|
||||
builder: (context, vm, _) {
|
||||
return Column(
|
||||
children: [
|
||||
Text(vm.roomInfo!.roomName),
|
||||
Text(
|
||||
formatSeconds(vm.studyTime),
|
||||
style: const TextStyle(fontSize: 12, color: Colors.white24),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: widget.onOther,
|
||||
icon: Icon(widget.showOther ? RemixIcons.team_fill : RemixIcons.team_line),
|
||||
onPressed: onOther,
|
||||
icon: Icon(showOther ? RemixIcons.team_fill : RemixIcons.team_line),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user