|
|
|
@ -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,14 +313,17 @@ 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, |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
if (!_hasFocus) |
|
|
|
Obx( |
|
|
|
() => Positioned( |
|
|
|
bottom: 20.w, |
|
|
|
@ -366,6 +390,7 @@ class _SummaryTabState extends State<SummaryTab> { |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
if (_hasFocus) |
|
|
|
Positioned( |
|
|
|
bottom: 0, |
|
|
|
left: -12.w, |
|
|
|
|