Browse Source

修改总结内容

weicu
tanlongsheng 1 year ago
parent
commit
a353f177c4
  1. 157
      lib/modules/meeting/views/tabs/summary_tab.dart

157
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<SummaryTab> {
final GlobalKey<EditorState> _editorKey = GlobalKey();
FleatherController? _fleatherController;
bool _hasFocus = false;
@override
void initState() {
super.initState();
@ -112,10 +113,30 @@ class _SummaryTabState extends State<SummaryTab> {
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<SummaryTab> {
),
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<SummaryTab> {
);
},
),
),
],
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,
),
),
),
),
],
);
}

Loading…
Cancel
Save