|
|
@@ -1,4 +1,5 @@
|
|
|
import 'dart:async';
|
|
|
+import 'dart:ffi';
|
|
|
import 'dart:io';
|
|
|
import 'package:connectivity_plus/connectivity_plus.dart';
|
|
|
import 'package:dsbridge_flutter/dsbridge_flutter.dart';
|
|
|
@@ -134,6 +135,9 @@ class TalkController extends BaseController {
|
|
|
|
|
|
final RxBool isShowMindFullScreen = false.obs;
|
|
|
|
|
|
+ //模板最大数量
|
|
|
+ int? maxTemplateCount;
|
|
|
+
|
|
|
final mindFullDuration = const Duration(milliseconds: 250);
|
|
|
|
|
|
GlobalKey headGlobalKey = GlobalKey();
|
|
|
@@ -147,6 +151,10 @@ class TalkController extends BaseController {
|
|
|
final DWebViewController webViewController =
|
|
|
MindUtil.createMindWebViewController();
|
|
|
|
|
|
+ final Rxn<DWebViewController> _temporaryController = Rxn();
|
|
|
+
|
|
|
+ DWebViewController? get temporaryController => _temporaryController.value;
|
|
|
+
|
|
|
@override
|
|
|
void onInit() {
|
|
|
super.onInit();
|
|
|
@@ -635,42 +643,45 @@ class TalkController extends BaseController {
|
|
|
_shareSummaryOrOriginal(
|
|
|
talkBean.value!.id, fileName, type, shareTo, tag);
|
|
|
} else if (type == ShareTalkType.mindMap) {
|
|
|
- _shareMindMap(
|
|
|
- talkBean.value?.title.value, talkBean.value?.summary.value);
|
|
|
+ _shareMindMap(fileName, talkBean.value?.summary.value);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- Future<String> loadSvgFromAssets() async {
|
|
|
- String svgString = await rootBundle.loadString('assets/images/test2.svg');
|
|
|
- return svgString;
|
|
|
- }
|
|
|
-
|
|
|
- void _shareMindMap(String? title, String? summary) async {
|
|
|
- // String svgString = await loadSvgFromAssets();
|
|
|
- // final pngBytes = await MindUtil.svgToPng(svgString, Get.context!);
|
|
|
- // MindUtil.convertToFile(pngBytes, 'test.png');
|
|
|
- // webViewController.callHandler(MindUtil.functionToJsExport, args: ['test'],
|
|
|
- // handler: (value) async {
|
|
|
- // if (value == null) {
|
|
|
- // throw Exception('Unable to convert SVG to PNG');
|
|
|
- // }
|
|
|
- // debugPrint('mindMap summary: $value');
|
|
|
- //
|
|
|
- // ToastUtil.showToast('思维导图svg下载成功');
|
|
|
- // });
|
|
|
-
|
|
|
- // await webViewController.loadFlutterAsset(Assets.html.index);
|
|
|
- // webViewController.setNavigationDelegate(
|
|
|
- // NavigationDelegate(
|
|
|
- // onPageFinished: (String url) {
|
|
|
- //
|
|
|
- // },
|
|
|
- // onNavigationRequest: (NavigationRequest request) {
|
|
|
- // return NavigationDecision.navigate;
|
|
|
- // },
|
|
|
- // ),
|
|
|
- // );
|
|
|
+ void _shareMindMap(String title, String? summary) {
|
|
|
+ if (_temporaryController.value != null) {
|
|
|
+ _temporaryController.value?.dispose();
|
|
|
+ _temporaryController.value = null;
|
|
|
+ }
|
|
|
+ final temporaryController = MindUtil.createMindWebViewController();
|
|
|
+ try {
|
|
|
+ _temporaryController.value = temporaryController;
|
|
|
+ temporaryController.loadFlutterAsset(Assets.html.indexExport);
|
|
|
+ temporaryController.setNavigationDelegate(
|
|
|
+ NavigationDelegate(
|
|
|
+ onHttpError: (error) {
|
|
|
+ temporaryController.dispose();
|
|
|
+ },
|
|
|
+ onWebResourceError: (error) {
|
|
|
+ temporaryController.dispose();
|
|
|
+ },
|
|
|
+ onPageFinished: (String url) {
|
|
|
+ temporaryController.callHandler(MindUtil.functionToJsExport,
|
|
|
+ args: [title, summary], handler: (value) async {
|
|
|
+ if (value == null) {
|
|
|
+ throw Exception('data is null');
|
|
|
+ }
|
|
|
+ await MindUtil.saveToFile(value, title);
|
|
|
+ temporaryController.dispose();
|
|
|
+ ToastUtil.showToast('下载成功');
|
|
|
+ });
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ } catch (e) {
|
|
|
+ temporaryController.dispose();
|
|
|
+ ToastUtil.showToast('思维导图导出失败');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void _shareSummaryOrOriginal(String id, String fileName, ShareTalkType type,
|
|
|
@@ -713,6 +724,7 @@ class TalkController extends BaseController {
|
|
|
} else {
|
|
|
talkBean.value?.updateBean(bean);
|
|
|
}
|
|
|
+ maxTemplateCount = data.maxTemplateCount;
|
|
|
templateSelectId.value = bean.templateId;
|
|
|
}
|
|
|
templateList.value = data.templateList;
|