From ec1e89bfc0919e2e5917fafd52404c628709d661 Mon Sep 17 00:00:00 2001 From: tanlongsheng <252620078@qq.com> Date: Fri, 18 Jul 2025 18:43:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=80=BB=E7=BB=93=E5=86=85?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../meeting/views/tabs/summary_tab.dart | 157 ++++++++++-------- 1 file changed, 91 insertions(+), 66 deletions(-) diff --git a/lib/modules/meeting/views/tabs/summary_tab.dart b/lib/modules/meeting/views/tabs/summary_tab.dart index 3838769f0..2ffbaac3b 100644 --- a/lib/modules/meeting/views/tabs/summary_tab.dart +++ b/lib/modules/meeting/views/tabs/summary_tab.dart @@ -1,7 +1,6 @@ import 'package:common_utils/common_utils.dart'; import 'package:fleather/fleather.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_markdown/flutter_markdown.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:parchment/codecs.dart'; @@ -32,6 +31,8 @@ class _SummaryTabState extends State { final GlobalKey _editorKey = GlobalKey(); FleatherController? _fleatherController; + bool _hasFocus = false; + @override void initState() { super.initState(); @@ -112,10 +113,30 @@ class _SummaryTabState extends State { final markdown = const ParchmentMarkdownCodec() .decode(_controller.meetingDetails.value.summary); _fleatherController = FleatherController(document: markdown); + _focusNode.addListener(() { + setState(() { + _hasFocus = _focusNode.hasFocus; + }); + }); + } + + void _saveSummary() async { + final markdown = + const ParchmentMarkdownCodec().encode(_fleatherController!.document); + if (markdown != _controller.meetingDetails.value.summary) { + SqfliteApi.editMeeting( + _controller.id, + {'summary': markdown}, + ); + _controller.meetingDetails.value.summary = markdown; + } + _focusNode.dispose(); + _fleatherController?.dispose(); } @override void dispose() { + _saveSummary(); _addressController.dispose(); _personnelController.dispose(); super.dispose(); @@ -292,67 +313,51 @@ class _SummaryTabState extends State { ), Padding( padding: EdgeInsets.only(top: 10.w), - child: MarkdownBody( - data: _controller.meetingDetails.value.summary, + child: FleatherEditor( + controller: _fleatherController!, + focusNode: _focusNode, + editorKey: _editorKey, ), ), ], ), ), ), - Obx( - () => Positioned( - bottom: 20.w, - left: 0, - right: 0, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - if (_controller.meetingDetails.value.tasktype >= 3) - _button( - Icons.supervisor_account, - '编辑发言者', - () { - Get.bottomSheet( - const SpeakerAllBottomSheet(), - isScrollControlled: true, - backgroundColor: Colors.grey[100], - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.vertical( - top: Radius.circular(12.r), - ), - ), - ); - }, - ), - if (_controller.meetingDetails.value.tasktype >= 3) - _button( - Icons.auto_awesome, - 'Ask AI', - () { - Get.bottomSheet( - const AIBottomSheet(), - isScrollControlled: true, - backgroundColor: Colors.white, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.vertical( - top: Radius.circular(12.r), + if (!_hasFocus) + Obx( + () => Positioned( + bottom: 20.w, + left: 0, + right: 0, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + if (_controller.meetingDetails.value.tasktype >= 3) + _button( + Icons.supervisor_account, + '编辑发言者', + () { + Get.bottomSheet( + const SpeakerAllBottomSheet(), + isScrollControlled: true, + backgroundColor: Colors.grey[100], + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.vertical( + top: Radius.circular(12.r), + ), ), - ), - ); - }, - ), - if (_controller.meetingDetails.value.tasktype == 0) - SizedBox( - width: 150.w, - child: _button( + ); + }, + ), + if (_controller.meetingDetails.value.tasktype >= 3) + _button( Icons.auto_awesome, - '生成', + 'Ask AI', () { Get.bottomSheet( - const GenerateBottomSheet(), + const AIBottomSheet(), isScrollControlled: true, - backgroundColor: Colors.grey[100], + backgroundColor: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.vertical( top: Radius.circular(12.r), @@ -361,25 +366,45 @@ class _SummaryTabState extends State { ); }, ), - ), - ], + if (_controller.meetingDetails.value.tasktype == 0) + SizedBox( + width: 150.w, + child: _button( + Icons.auto_awesome, + '生成', + () { + Get.bottomSheet( + const GenerateBottomSheet(), + isScrollControlled: true, + backgroundColor: Colors.grey[100], + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.vertical( + top: Radius.circular(12.r), + ), + ), + ); + }, + ), + ), + ], + ), ), ), - ), - Positioned( - bottom: 0, - left: -12.w, - right: -12.w, - child: Container( - height: 40, - color: Colors.white, - alignment: Alignment.center, - child: FleatherToolbar.basic( - controller: _fleatherController!, - editorKey: _editorKey, + if (_hasFocus) + Positioned( + bottom: 0, + left: -12.w, + right: -12.w, + child: Container( + height: 40, + color: Colors.white, + alignment: Alignment.center, + child: FleatherToolbar.basic( + controller: _fleatherController!, + editorKey: _editorKey, + ), ), ), - ), ], ); }