79 lines
2.2 KiB
Dart
79 lines
2.2 KiB
Dart
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';
|
|
|
|
class TopBar extends StatelessWidget implements PreferredSizeWidget {
|
|
final bool showOther;
|
|
final void Function()? onOther;
|
|
|
|
const TopBar({
|
|
super.key,
|
|
this.showOther = false,
|
|
this.onOther,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AppBar(
|
|
foregroundColor: Colors.white,
|
|
titleTextStyle: const TextStyle(color: Colors.white, fontSize: 18),
|
|
backgroundColor: const Color(0xff232426),
|
|
centerTitle: true,
|
|
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: onOther,
|
|
icon: Icon(showOther ? RemixIcons.team_fill : RemixIcons.team_line),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
@override
|
|
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
|
|
}
|