You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
393 lines
13 KiB
393 lines
13 KiB
import 'package:common_utils/common_utils.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:haptic_feedback/haptic_feedback.dart';
|
|
|
|
import '../../../core/theme/app_colors.dart';
|
|
import '../../../routes/app_routes.dart';
|
|
import '../controllers/meeting_controller.dart';
|
|
import '../model/meeting_model.dart';
|
|
|
|
class MeetingView extends GetView<MeetingController> {
|
|
const MeetingView({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final isDarkMode = Theme.of(context).brightness == Brightness.dark;
|
|
|
|
return Scaffold(
|
|
backgroundColor: isDarkMode ? Colors.black : Colors.grey[50],
|
|
appBar: _buildAppBar(isDarkMode),
|
|
body: _buildBody(context, isDarkMode),
|
|
floatingActionButton: FloatingActionButton(
|
|
onPressed: controller.addAudio,
|
|
child: const Icon(Icons.add),
|
|
),
|
|
);
|
|
}
|
|
|
|
// 构建应用栏
|
|
PreferredSizeWidget _buildAppBar(bool isDarkMode) {
|
|
return AppBar(
|
|
backgroundColor: isDarkMode ? Colors.black : Colors.white,
|
|
elevation: 0.5,
|
|
leading: IconButton(
|
|
icon: Icon(
|
|
Icons.arrow_back_ios,
|
|
color: isDarkMode ? Colors.white : Colors.black,
|
|
size: 20.sp,
|
|
),
|
|
onPressed: () => Get.back(),
|
|
),
|
|
title: Text(
|
|
'conferenceAssistant'.tr, // 商务会议助手
|
|
style: TextStyle(
|
|
fontSize: 17.sp,
|
|
fontWeight: FontWeight.w600,
|
|
color: isDarkMode ? Colors.white : Colors.black,
|
|
),
|
|
),
|
|
centerTitle: true,
|
|
);
|
|
}
|
|
|
|
// 构建主体内容
|
|
Widget _buildBody(BuildContext context, bool isDarkMode) {
|
|
return Obx(
|
|
() => ListView.builder(
|
|
controller: controller.listController,
|
|
itemCount: controller.dataList.length,
|
|
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 5.w),
|
|
itemBuilder: (BuildContext context, int index) {
|
|
MeetingModel data = MeetingModel.fromJson(controller.dataList[index]);
|
|
return _item(context, isDarkMode, data);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _item(BuildContext context, bool isDarkMode, MeetingModel data) {
|
|
return GestureDetector(
|
|
onTap: () {
|
|
controller.isDisposed = true;
|
|
Get.toNamed(Routes.meetingDetails, arguments: {
|
|
'id': data.id,
|
|
});
|
|
},
|
|
onLongPressStart: (LongPressStartDetails details) {
|
|
_onLongPressItem(context, isDarkMode, details, data);
|
|
},
|
|
child: Container(
|
|
padding: EdgeInsets.symmetric(horizontal: 15.w, vertical: 10.w),
|
|
margin: EdgeInsets.symmetric(vertical: 5.w),
|
|
decoration: BoxDecoration(
|
|
color: isDarkMode ? Colors.white.withOpacity(0.05) : Colors.white,
|
|
borderRadius: BorderRadius.circular(12.w),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: isDarkMode
|
|
? Colors.black.withOpacity(0.2)
|
|
: Colors.black.withOpacity(0.05),
|
|
blurRadius: 10,
|
|
offset: const Offset(0, 2),
|
|
),
|
|
],
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
data.title,
|
|
style: TextStyle(
|
|
color: isDarkMode ? Colors.white : Colors.black87,
|
|
fontSize: 18.sp,
|
|
),
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
Padding(
|
|
padding: EdgeInsets.symmetric(vertical: 5.w),
|
|
child: Row(
|
|
children: [
|
|
Icon(
|
|
Icons.calendar_month,
|
|
size: 14.w,
|
|
color: isDarkMode ? Colors.grey[400] : Colors.grey[500],
|
|
),
|
|
2.horizontalSpace,
|
|
Text(
|
|
DateUtil.formatDateMs(
|
|
data.creationtime,
|
|
format: DateFormats.y_mo_d_h_m,
|
|
),
|
|
style: TextStyle(
|
|
color: isDarkMode ? Colors.grey[400] : Colors.grey[500],
|
|
fontSize: 12.sp,
|
|
),
|
|
),
|
|
20.horizontalSpace,
|
|
Icon(
|
|
Icons.access_time,
|
|
size: 14.w,
|
|
color: isDarkMode ? Colors.grey[400] : Colors.grey[500],
|
|
),
|
|
2.horizontalSpace,
|
|
Text(
|
|
'${data.seconds}s',
|
|
style: TextStyle(
|
|
color: isDarkMode ? Colors.grey[400] : Colors.grey[500],
|
|
fontSize: 12.sp,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Container(
|
|
padding: EdgeInsets.symmetric(horizontal: 5.w, vertical: 2.w),
|
|
margin: EdgeInsets.only(top: 5.w),
|
|
decoration: BoxDecoration(
|
|
color: isDarkMode ? Colors.grey[900] : Colors.grey[100],
|
|
borderRadius: BorderRadius.circular(4.w),
|
|
),
|
|
child: Text(
|
|
data.type,
|
|
style: TextStyle(
|
|
color: isDarkMode ? Colors.grey[400] : Colors.grey[600],
|
|
fontSize: 10.sp,
|
|
),
|
|
),
|
|
),
|
|
if (data.tasktype == 1)
|
|
Padding(
|
|
padding: EdgeInsets.only(top: 5.w),
|
|
child: Text(
|
|
'正在生成...',
|
|
style: TextStyle(
|
|
color: Colors.blue,
|
|
fontSize: 10.sp,
|
|
),
|
|
),
|
|
),
|
|
if (data.tasktype == 2)
|
|
Padding(
|
|
padding: EdgeInsets.only(top: 5.w),
|
|
child: Text(
|
|
'已生成',
|
|
style: TextStyle(
|
|
color: Colors.blue,
|
|
fontSize: 10.sp,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
void _onLongPressItem(BuildContext context, bool isDarkMode,
|
|
LongPressStartDetails details, MeetingModel data) {
|
|
Haptics.vibrate(HapticsType.success);
|
|
RenderBox? renderBox =
|
|
Overlay.of(context).context.findRenderObject() as RenderBox;
|
|
final RelativeRect position = RelativeRect.fromRect(
|
|
Rect.fromLTRB(
|
|
details.globalPosition.dx,
|
|
details.globalPosition.dy,
|
|
details.globalPosition.dx + 110, // 菜单显示位置X轴坐标
|
|
details.globalPosition.dy - 40, // 菜单显示位置Y轴坐标
|
|
),
|
|
Offset.zero & renderBox.size,
|
|
);
|
|
|
|
showMenu(
|
|
context: context,
|
|
position: position,
|
|
color: isDarkMode ? AppColors.cardBackground : Colors.white,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(12.r),
|
|
),
|
|
items: [
|
|
_popupMenuEntry(
|
|
Icon(
|
|
Icons.edit_calendar,
|
|
size: 20.w,
|
|
color: isDarkMode ? Colors.white : Colors.black87,
|
|
),
|
|
'edit'.tr, // 编辑
|
|
isDarkMode ? Colors.white : Colors.black87,
|
|
() {
|
|
controller.titleController.text = data.title;
|
|
_bottomSheet(context, isDarkMode, data.id);
|
|
},
|
|
),
|
|
_popupMenuEntry(
|
|
Icon(
|
|
Icons.delete_outline,
|
|
size: 20.w,
|
|
color: isDarkMode ? Colors.red[700] : Colors.red,
|
|
),
|
|
'delete'.tr, // 删除
|
|
isDarkMode ? Colors.red[700]! : Colors.red,
|
|
() {
|
|
controller.deleteMeeting(data.id, data.filepath);
|
|
},
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
PopupMenuEntry _popupMenuEntry(
|
|
Icon icon,
|
|
String title,
|
|
Color color,
|
|
Function() onTap,
|
|
) {
|
|
return PopupMenuItem(
|
|
onTap: onTap,
|
|
child: SizedBox(
|
|
width: 140.w,
|
|
child: Row(
|
|
children: [
|
|
icon,
|
|
8.horizontalSpace,
|
|
Text(
|
|
title,
|
|
style: TextStyle(
|
|
color: color,
|
|
fontSize: 14.sp,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
void _bottomSheet(
|
|
BuildContext context,
|
|
bool isDarkMode,
|
|
int id,
|
|
) {
|
|
Get.bottomSheet(
|
|
Padding(
|
|
padding: MediaQuery.of(context).viewInsets,
|
|
child: Container(
|
|
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 20.w),
|
|
color: isDarkMode ? AppColors.darkBackground : Colors.grey[50],
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(
|
|
'editMeetingTitle'.tr, // 编辑会议标题
|
|
style: TextStyle(
|
|
color: isDarkMode ? Colors.white : Colors.black87,
|
|
fontSize: 16.sp,
|
|
),
|
|
),
|
|
Container(
|
|
height: 48.w,
|
|
margin: EdgeInsets.only(top: 10.w, bottom: 20.w),
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(
|
|
color: isDarkMode
|
|
? Colors.white.withOpacity(0.05)
|
|
: Colors.white,
|
|
borderRadius: BorderRadius.circular(12.w),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: isDarkMode
|
|
? Colors.black.withOpacity(0.2)
|
|
: Colors.black.withOpacity(0.05),
|
|
blurRadius: 10,
|
|
offset: const Offset(0, 2),
|
|
),
|
|
],
|
|
),
|
|
child: TextField(
|
|
controller: controller.titleController,
|
|
style: TextStyle(
|
|
color: isDarkMode ? Colors.white : Colors.black87,
|
|
fontSize: 16.sp,
|
|
),
|
|
decoration: InputDecoration(
|
|
hintText: 'maxCharacters'.tr,
|
|
hintStyle: TextStyle(
|
|
color: isDarkMode ? Colors.white70 : Colors.black54,
|
|
fontSize: 16.sp,
|
|
),
|
|
fillColor: Colors.transparent,
|
|
border: InputBorder.none,
|
|
contentPadding: EdgeInsets.symmetric(horizontal: 10.w),
|
|
),
|
|
),
|
|
),
|
|
Padding(
|
|
padding: EdgeInsets.only(top: 30.w),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
children: [
|
|
GestureDetector(
|
|
onTap: () {
|
|
Get.back();
|
|
},
|
|
child: Container(
|
|
width: 120.w,
|
|
height: 40.w,
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(
|
|
border: Border.all(
|
|
width: 2.w,
|
|
color: isDarkMode ? AppColors.primary : Colors.blue,
|
|
),
|
|
borderRadius: BorderRadius.circular(12.w),
|
|
),
|
|
child: Text(
|
|
'cancel'.tr, // 取消
|
|
style: TextStyle(
|
|
fontSize: 14.sp,
|
|
color: isDarkMode ? AppColors.primary : Colors.blue,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
GestureDetector(
|
|
onTap: () {
|
|
String title = controller.titleController.text;
|
|
controller.editMeetingTitle(id, title);
|
|
},
|
|
child: Container(
|
|
width: 120.w,
|
|
height: 40.w,
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(
|
|
color: isDarkMode ? AppColors.primary : Colors.blue,
|
|
borderRadius: BorderRadius.circular(12.w),
|
|
),
|
|
child: Text(
|
|
'confirm'.tr, // 确认
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 14.sp,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
isScrollControlled: true,
|
|
clipBehavior: Clip.hardEdge,
|
|
);
|
|
}
|
|
}
|
|
|