From 304b8a81e0bfb225e3db58363a5a85c26a2c4973 Mon Sep 17 00:00:00 2001 From: tanlongsheng <252620078@qq.com> Date: Sat, 24 May 2025 19:06:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=80=89=E6=8B=A9=E6=A8=A1?= =?UTF-8?q?=E7=89=88=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../meeting/bindings/template_binding.dart | 10 - .../controllers/template_controller.dart | 3 - .../meeting/views/generate_bottom_sheet.dart | 58 ++- lib/modules/meeting/views/template_view.dart | 365 +++++++++++++++++- lib/routes/app_pages.dart | 9 - lib/routes/app_routes.dart | 1 - pubspec.yaml | 2 +- 7 files changed, 404 insertions(+), 44 deletions(-) delete mode 100644 lib/modules/meeting/bindings/template_binding.dart delete mode 100644 lib/modules/meeting/controllers/template_controller.dart diff --git a/lib/modules/meeting/bindings/template_binding.dart b/lib/modules/meeting/bindings/template_binding.dart deleted file mode 100644 index 414f2f659..000000000 --- a/lib/modules/meeting/bindings/template_binding.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:get/get.dart'; -import '../controllers/template_controller.dart'; - -class TemplateBinding extends Bindings { - @override - void dependencies() { - // 注册控制器 - Get.lazyPut(() => TemplateController()); - } -} diff --git a/lib/modules/meeting/controllers/template_controller.dart b/lib/modules/meeting/controllers/template_controller.dart deleted file mode 100644 index e61cec694..000000000 --- a/lib/modules/meeting/controllers/template_controller.dart +++ /dev/null @@ -1,3 +0,0 @@ -import 'package:get/get.dart'; - -class TemplateController extends GetxController {} diff --git a/lib/modules/meeting/views/generate_bottom_sheet.dart b/lib/modules/meeting/views/generate_bottom_sheet.dart index e3a14eb60..413e81bc2 100644 --- a/lib/modules/meeting/views/generate_bottom_sheet.dart +++ b/lib/modules/meeting/views/generate_bottom_sheet.dart @@ -2,9 +2,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import '../../../routes/app_routes.dart'; import '../controllers/meeting_details_controller.dart'; import 'record_language_bottom_sheet.dart'; +import 'template_view.dart'; class GenerateBottomSheet extends StatefulWidget { const GenerateBottomSheet({super.key}); @@ -15,14 +15,13 @@ class GenerateBottomSheet extends StatefulWidget { class _GenerateBottomSheetState extends State { final _controller = Get.find(); + final ScrollController _scrollController = ScrollController(); bool _isSpeaker = true; String _languageText = '中文普通话(简体)'; String _language = 'zh-CN'; - int _templateId = 0; - int _lastTemplateId = 0; - final List _templateList = [ + final List _originalTemplate = [ { 'id': 1, 'name': '会议纪要', @@ -51,15 +50,29 @@ class _GenerateBottomSheetState extends State { 'tag': ['主题', '代办事项'], 'desc': '', }, - { - 'id': 5, - 'name': '自定义', - 'icon': Icons.auto_fix_high, - 'tag': [], - 'desc': '自定义模版', - }, ]; + int _templateId = 0; + int _lastTemplateId = 0; + List _templateList = []; + + @override + void initState() { + super.initState(); + if (_lastTemplateId != 0) { + _templateId = _lastTemplateId; + } else { + _templateId = _originalTemplate[0]['id']; + } + _templateList = List.from(_originalTemplate); + } + + @override + void dispose() { + _scrollController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { return Column( @@ -138,12 +151,24 @@ class _GenerateBottomSheetState extends State { ), GestureDetector( onTap: () async { - var result = await Get.toNamed(Routes.template, arguments: { - 'id': _templateId, - }); + var result = await Get.to(TemplateView( + _templateId, + _lastTemplateId, + )); if (result != null) { + _scrollController.jumpTo(0); + List list = List.from(_originalTemplate); + int index = list + .indexWhere((element) => element['id'] == result['id']); + if (index != -1) { + Map itemToMove = list.removeAt(index); + list.insert(0, itemToMove); + } else { + list.insert(0, result); + } setState(() { - _templateId = result; + _templateId = result['id']; + _templateList = list; }); } }, @@ -170,6 +195,7 @@ class _GenerateBottomSheetState extends State { height: 130.w, margin: EdgeInsets.only(bottom: 16.w), child: ListView.builder( + controller: _scrollController, itemCount: _templateList.length, scrollDirection: Axis.horizontal, padding: EdgeInsets.symmetric(horizontal: 4.w), @@ -237,7 +263,7 @@ class _GenerateBottomSheetState extends State { child: GestureDetector( onTap: () { Get.back(); - // _controller.summaryCreate(); + _controller.summaryCreate(); }, child: Container( height: 48.w, diff --git a/lib/modules/meeting/views/template_view.dart b/lib/modules/meeting/views/template_view.dart index 0e8c963cf..28e381f5a 100644 --- a/lib/modules/meeting/views/template_view.dart +++ b/lib/modules/meeting/views/template_view.dart @@ -2,10 +2,151 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import '../controllers/template_controller.dart'; +class TemplateView extends StatefulWidget { + final int templateId; + final int lastTemplateId; -class TemplateView extends GetView { - const TemplateView({super.key}); + const TemplateView(this.templateId, this.lastTemplateId, {super.key}); + + @override + State createState() => _TemplateViewState(); +} + +class _TemplateViewState extends State { + final List _categoryList = [ + { + 'id': 1, + 'name': '通用', + 'template': [ + { + 'id': 1, + 'name': '会议纪要', + 'icon': Icons.auto_stories, + 'tag': ['主题', '代办事项'], + 'desc': '', + }, + { + 'id': 2, + 'name': 'Autopilot', + 'icon': Icons.auto_graph, + 'tag': ['自适应结构', '全场景适配'], + 'desc': '', + }, + { + 'id': 3, + 'name': '推理Autopilot', + 'icon': Icons.add_to_drive_outlined, + 'tag': ['推理模型', '自动结构化'], + 'desc': '', + }, + { + 'id': 4, + 'name': '通话', + 'icon': Icons.perm_phone_msg, + 'tag': ['主题', '代办事项'], + 'desc': '', + }, + ], + }, + { + 'id': 2, + 'name': '会议', + 'template': [ + { + 'id': 5, + 'name': '咨询', + 'icon': Icons.auto_stories, + 'tag': ['主题', '代办事项'], + 'desc': '', + }, + { + 'id': 6, + 'name': '讨论', + 'icon': Icons.auto_graph, + 'tag': ['自适应结构', '全场景适配'], + 'desc': '', + }, + { + 'id': 7, + 'name': '汇报', + 'icon': Icons.add_to_drive_outlined, + 'tag': ['推理模型', '自动结构化'], + 'desc': '', + }, + { + 'id': 8, + 'name': '任务分配', + 'icon': Icons.perm_phone_msg, + 'tag': ['主题', '代办事项'], + 'desc': '', + }, + ], + }, + { + 'id': 3, + 'name': '演讲', + 'template': [ + { + 'id': 9, + 'name': '课堂笔记', + 'icon': Icons.auto_stories, + 'tag': ['主题', '代办事项'], + 'desc': '', + }, + { + 'id': 10, + 'name': '讲座', + 'icon': Icons.auto_graph, + 'tag': ['自适应结构', '全场景适配'], + 'desc': '', + }, + { + 'id': 11, + 'name': '培训', + 'icon': Icons.add_to_drive_outlined, + 'tag': ['推理模型', '自动结构化'], + 'desc': '', + }, + { + 'id': 12, + 'name': 'Sermon', + 'icon': Icons.perm_phone_msg, + 'tag': ['主题', '代办事项'], + 'desc': '', + }, + ], + }, + { + 'id': 4, + 'name': '自定义', + 'template': [ + { + 'id': 13, + 'name': '自定义', + 'icon': Icons.auto_fix_high, + 'tag': [], + 'desc': '自定义模版', + }, + ], + }, + ]; + + Map _templateData = {}; + + @override + void initState() { + super.initState(); + outerLoop: + for (var element in _categoryList) { + List template = element['template']; + for (var item in template) { + if (item['id'] == widget.templateId) { + _templateData = item; + break outerLoop; + } + } + } + } @override Widget build(BuildContext context) { @@ -45,6 +186,222 @@ class TemplateView extends GetView { // 构建主体内容 Widget _buildBody(BuildContext context, bool isDarkMode) { - return Container(); + return Column( + children: [ + Expanded( + child: ListView.builder( + itemCount: _categoryList.length, + itemBuilder: (BuildContext context, int index) { + Map data = _categoryList[index]; + return _item(data); + }, + ), + ), + Padding( + padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 20.w), + child: GestureDetector( + onTap: () { + Get.back(result: _templateData); + }, + child: Container( + height: 48.w, + alignment: Alignment.center, + decoration: BoxDecoration( + color: Colors.black, + borderRadius: BorderRadius.circular(12.r), + ), + child: Text( + '就用这个模版', + style: TextStyle( + fontSize: 16.sp, + color: Colors.white, + ), + ), + ), + ), + ), + ], + ); + } + + Widget _item(Map data) { + return Column( + children: [ + Padding( + padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 10.w), + child: Row( + children: [ + Text( + data['name'], + style: TextStyle( + fontSize: 18.sp, + color: Colors.black87, + fontWeight: FontWeight.bold, + ), + ), + const Icon( + Icons.keyboard_arrow_right, + color: Colors.grey, + ) + ], + ), + ), + Container( + height: 150.w, + margin: EdgeInsets.only(bottom: 15.w), + child: ListView.builder( + itemCount: data['template'].length, + scrollDirection: Axis.horizontal, + padding: EdgeInsets.symmetric(horizontal: 8.w), + itemBuilder: (BuildContext context, int index) { + Map template = data['template'][index]; + return _template(template); + }, + ), + ), + ], + ); + } + + Widget _template(Map template) { + return Container( + width: 200.w, + margin: EdgeInsets.symmetric(horizontal: 4.w), + clipBehavior: Clip.hardEdge, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(14.w), + ), + child: GestureDetector( + onTap: () { + setState(() { + _templateData = template; + }); + }, + child: Stack( + children: [ + Container( + padding: EdgeInsets.all(5.w), + decoration: BoxDecoration( + color: Colors.white, + gradient: _templateData['id'] == template['id'] + ? const LinearGradient( + colors: [Colors.blue, Colors.pinkAccent], + begin: Alignment.centerLeft, + end: Alignment.centerRight, + ) + : null, + ), + child: Container( + width: double.infinity, + padding: EdgeInsets.all(10.w), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10.w), + color: Colors.white, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only(top: 5.w), + child: Icon( + template['icon'], + color: Colors.orange, + size: 30.w, + ), + ), + Padding( + padding: EdgeInsets.symmetric(vertical: 10.w), + child: Text( + template['name'], + style: TextStyle( + fontSize: 16.sp, + color: Colors.black87, + fontWeight: FontWeight.bold, + ), + ), + ), + template['tag'].isNotEmpty + ? Wrap( + spacing: 5.w, + children: List.generate( + template['tag'].length, + (int idx) { + return Container( + padding: EdgeInsets.symmetric( + horizontal: 5.w, vertical: 2.w), + decoration: BoxDecoration( + color: Colors.grey[200], + borderRadius: BorderRadius.circular(4.r), + ), + child: Text( + template['tag'][idx], + style: TextStyle( + fontSize: 10.sp, + color: Colors.grey[600], + ), + ), + ); + }, + ), + ) + : Text( + template['desc'], + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 12.sp, + color: Colors.grey[600], + ), + ), + ], + ), + ), + ), + if (widget.lastTemplateId == template['id']) + Positioned( + top: 0, + left: 0, + child: Container( + padding: EdgeInsets.symmetric(horizontal: 5.w, vertical: 1.w), + decoration: BoxDecoration( + color: Colors.blue, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(12.w), + bottomRight: Radius.circular(4.w), + ), + ), + child: Text( + '上次使用', + style: TextStyle( + color: Colors.white, + fontSize: 12.sp, + fontWeight: FontWeight.bold, + ), + ), + ), + ), + if (_templateData['id'] == template['id']) + Positioned( + right: -18.w, + bottom: -18.w, + child: Container( + width: 40.w, + height: 40.w, + padding: EdgeInsets.all(2.w), + alignment: Alignment.topLeft, + decoration: BoxDecoration( + color: Colors.pinkAccent, + borderRadius: BorderRadius.circular(40.r), + ), + child: Icon( + Icons.check, + color: Colors.white, + size: 18.w, + ), + ), + ), + ], + ), + ), + ); } } diff --git a/lib/routes/app_pages.dart b/lib/routes/app_pages.dart index 0918b9a72..0cf57c7b1 100644 --- a/lib/routes/app_pages.dart +++ b/lib/routes/app_pages.dart @@ -7,10 +7,8 @@ import '../modules/explore/views/explore_view.dart'; import '../modules/explore/bindings/explore_binding.dart'; import '../modules/meeting/bindings/meeting_binding.dart'; import '../modules/meeting/bindings/meeting_details_binding.dart'; -import '../modules/meeting/bindings/template_binding.dart'; import '../modules/meeting/views/meeting_details_view.dart'; import '../modules/meeting/views/meeting_view.dart'; -import '../modules/meeting/views/template_view.dart'; import '../modules/profile/views/profile_view.dart'; import '../modules/profile/bindings/profile_binding.dart'; import '../modules/chat/bindings/chat_binding.dart'; @@ -142,13 +140,6 @@ abstract class AppPages { transition: Transition.rightToLeft, transitionDuration: Duration(milliseconds: 250), ), - GetPage( - name: Routes.template, - page: () => const TemplateView(), - binding: TemplateBinding(), - transition: Transition.rightToLeft, - transitionDuration: Duration(milliseconds: 250), - ), GetPage( name: Routes.timbre, page: () => const TimbreView(), diff --git a/lib/routes/app_routes.dart b/lib/routes/app_routes.dart index d1bb1c277..ca88986e8 100644 --- a/lib/routes/app_routes.dart +++ b/lib/routes/app_routes.dart @@ -22,7 +22,6 @@ abstract class Routes { // 会议相关 static const meeting = '/meeting'; static const meetingDetails = '/meetingDetails'; - static const template = '/template'; // 语言功能 static const translation = '/translation'; // 实时翻译 diff --git a/pubspec.yaml b/pubspec.yaml index 7a8bbb5c2..4cc804bcb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -25,7 +25,7 @@ dependencies: web_socket_channel: ^3.0.2 flutter_dotenv: ^5.1.0 synchronized: ^3.1.0 - intl: ^0.19.0 + intl: ^0.20.2 crypto: ^3.0.3 flutter_tts: ^4.2.2 logger: ^2.0.2+1