|
|
@@ -8,6 +8,7 @@ import 'package:flutter/widgets.dart';
|
|
|
import 'package:get/get.dart';
|
|
|
import 'package:get/get_core/src/get_main.dart';
|
|
|
import 'package:webview_flutter/webview_flutter.dart';
|
|
|
+import '../../../data/bean/talks.dart';
|
|
|
import '../../../data/bean/template_bean.dart';
|
|
|
import '../controller.dart';
|
|
|
|
|
|
@@ -25,37 +26,69 @@ class MindMapController extends BaseController {
|
|
|
RxBool get isShowMindFullScreen => talkController.isShowMindFullScreen;
|
|
|
|
|
|
StreamSubscription? _talkSummaryListener;
|
|
|
+ StreamSubscription? _talkStatusListener;
|
|
|
GlobalKey repaintKey = GlobalKey();
|
|
|
|
|
|
+ bool _isWebViewLoaded = false;
|
|
|
+
|
|
|
@override
|
|
|
void onReady() async {
|
|
|
super.onReady();
|
|
|
+
|
|
|
+ _talkStatusListener =
|
|
|
+ talkController.talkBean.value?.status.listen((status) {
|
|
|
+ if (status == TalkStatus.analysisSuccess) {
|
|
|
+ _dealTalkSummaryUpdate(talkController.talkBean.value?.summary.value);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ _dealTalkSummaryUpdate(talkController.talkBean.value?.summary.value);
|
|
|
+ _talkSummaryListener =
|
|
|
+ talkController.talkBean.value?.summary.listen((summary) {
|
|
|
+ _dealTalkSummaryUpdate(summary);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ void _loadWebMindData(String summary) {
|
|
|
talkController.webViewController.loadFlutterAsset(Assets.html.index);
|
|
|
talkController.webViewController.setNavigationDelegate(
|
|
|
NavigationDelegate(
|
|
|
onPageFinished: (String url) async {
|
|
|
- _dealTalkSummaryUpdate(talkController.talkBean.value?.summary.value);
|
|
|
+ _isWebViewLoaded = true;
|
|
|
+ _callUpdateMind(summary);
|
|
|
},
|
|
|
onNavigationRequest: (NavigationRequest request) {
|
|
|
return NavigationDecision.navigate;
|
|
|
},
|
|
|
),
|
|
|
);
|
|
|
- _talkSummaryListener =
|
|
|
- talkController.talkBean.value?.summary.listen((summary) {
|
|
|
- _dealTalkSummaryUpdate(summary);
|
|
|
- });
|
|
|
}
|
|
|
|
|
|
- void _dealTalkSummaryUpdate(String? summary) {
|
|
|
- debugPrint('mindMap summary: $summary');
|
|
|
+ void _callUpdateMind(String summary) {
|
|
|
talkController.webViewController
|
|
|
.callHandler(MindUtil.functionToJsUpdateMind, args: [summary],
|
|
|
handler: (value) {
|
|
|
- debugPrint('mindMap update success: $value');
|
|
|
+ debugPrint('_dealTalkSummaryUpdate mindMap update success: $value');
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ void _updateMindData(String summary) {
|
|
|
+ if (_isWebViewLoaded) {
|
|
|
+ _callUpdateMind(summary);
|
|
|
+ } else {
|
|
|
+ _loadWebMindData(summary);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ void _dealTalkSummaryUpdate(String? summary) {
|
|
|
+ if (summary == null ||
|
|
|
+ summary.isEmpty ||
|
|
|
+ talkController.talkBean.value?.status.value !=
|
|
|
+ TalkStatus.analysisSuccess) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ _updateMindData(summary);
|
|
|
+ }
|
|
|
+
|
|
|
void addTemplateClick() {}
|
|
|
|
|
|
void fullScreenClick() {
|
|
|
@@ -69,6 +102,7 @@ class MindMapController extends BaseController {
|
|
|
@override
|
|
|
void onClose() {
|
|
|
super.onClose();
|
|
|
+ _talkStatusListener?.cancel();
|
|
|
_talkSummaryListener?.cancel();
|
|
|
}
|
|
|
}
|