|
|
@@ -1,5 +1,4 @@
|
|
|
import 'dart:async';
|
|
|
-import 'dart:ffi';
|
|
|
import 'dart:io';
|
|
|
import 'package:connectivity_plus/connectivity_plus.dart';
|
|
|
import 'package:dsbridge_flutter/dsbridge_flutter.dart';
|
|
|
@@ -43,6 +42,7 @@ import '../../data/repositories/agenda_repository.dart';
|
|
|
import '../../data/repositories/talk_repository.dart';
|
|
|
import '../../dialog/add_agenda_dialog.dart';
|
|
|
import '../../dialog/alert_dialog.dart';
|
|
|
+import '../../dialog/loading_dialog.dart';
|
|
|
import '../../dialog/rename_dialog.dart';
|
|
|
import '../../dialog/talk_share_dialog.dart';
|
|
|
import '../../utils/common_utils.dart';
|
|
|
@@ -645,7 +645,7 @@ class TalkController extends BaseController {
|
|
|
_shareSummaryOrOriginal(
|
|
|
talkBean.value!.id, fileName, type, shareTo, tag);
|
|
|
} else if (type == ShareTalkType.mindMap) {
|
|
|
- _shareMindMap(fileName, talkBean.value?.summary.value, tag);
|
|
|
+ _shareMindMap(fileName, talkBean.value?.summary.value, shareTo, tag);
|
|
|
}
|
|
|
} catch (error) {
|
|
|
if (error is SystemShareException) {
|
|
|
@@ -677,22 +677,33 @@ class TalkController extends BaseController {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- void _shareMindMap(String title, String? summary, String tag) {
|
|
|
+ void _shareMindMap(
|
|
|
+ String title, String? summary, ShareTo shareTo, String tag) {
|
|
|
+ LoadingDialog.show(StringName.mindMapExport.tr, backDismiss: true);
|
|
|
if (_temporaryController.value != null) {
|
|
|
_temporaryController.value?.dispose();
|
|
|
_temporaryController.value = null;
|
|
|
}
|
|
|
final temporaryController = MindUtil.createMindWebViewController();
|
|
|
+
|
|
|
+ VoidCallback? errorCallback = () {
|
|
|
+ LoadingDialog.hide();
|
|
|
+ temporaryController.dispose();
|
|
|
+ ToastUtil.showToast('思维导图导出失败');
|
|
|
+ };
|
|
|
+
|
|
|
try {
|
|
|
_temporaryController.value = temporaryController;
|
|
|
temporaryController.loadFlutterAsset(Assets.html.indexExport);
|
|
|
temporaryController.setNavigationDelegate(
|
|
|
NavigationDelegate(
|
|
|
onHttpError: (error) {
|
|
|
- temporaryController.dispose();
|
|
|
+ errorCallback?.call();
|
|
|
+ errorCallback = null;
|
|
|
},
|
|
|
onWebResourceError: (error) {
|
|
|
- temporaryController.dispose();
|
|
|
+ errorCallback?.call();
|
|
|
+ errorCallback = null;
|
|
|
},
|
|
|
onPageFinished: (String url) {
|
|
|
temporaryController.callHandler(MindUtil.functionToJsExport,
|
|
|
@@ -700,16 +711,30 @@ class TalkController extends BaseController {
|
|
|
if (value == null) {
|
|
|
throw Exception('data is null');
|
|
|
}
|
|
|
- await MindUtil.saveToFile(value, title);
|
|
|
+ File file = await MindUtil.saveToFile(value, title);
|
|
|
temporaryController.dispose();
|
|
|
- ToastUtil.showToast('下载成功');
|
|
|
+ if (shareTo == ShareTo.wechat) {
|
|
|
+ await SystemShareUtil.shareSystemFile(
|
|
|
+ SystemShareUtil.wechatPageName, file.path,
|
|
|
+ shareTitle: '分享到微信', shareFileType: 'image/*');
|
|
|
+ } else if (shareTo == ShareTo.qq) {
|
|
|
+ await SystemShareUtil.shareSystemFile(
|
|
|
+ SystemShareUtil.qqPageName, file.path,
|
|
|
+ shareTitle: '分享到QQ', shareFileType: 'image/*');
|
|
|
+ } else if (shareTo == ShareTo.ios) {
|
|
|
+ await Share.shareXFiles([XFile(file.path)], subject: title);
|
|
|
+ } else {
|
|
|
+ throw Exception('不支持该分享方式');
|
|
|
+ }
|
|
|
+ SmartDialog.dismiss(tag: tag);
|
|
|
+ LoadingDialog.hide();
|
|
|
});
|
|
|
},
|
|
|
),
|
|
|
);
|
|
|
} catch (e) {
|
|
|
- temporaryController.dispose();
|
|
|
- ToastUtil.showToast('思维导图导出失败');
|
|
|
+ errorCallback?.call();
|
|
|
+ errorCallback = null;
|
|
|
}
|
|
|
}
|
|
|
|