|
|
@@ -638,17 +638,46 @@ class TalkController extends BaseController {
|
|
|
}
|
|
|
eventReport(EventId.event_101004);
|
|
|
showTalkShareDialog(talkBean.value?.title.value,
|
|
|
- (type, shareTo, fileName, tag) {
|
|
|
- if (type == ShareTalkType.summary || type == ShareTalkType.original) {
|
|
|
- _shareSummaryOrOriginal(
|
|
|
- talkBean.value!.id, fileName, type, shareTo, tag);
|
|
|
- } else if (type == ShareTalkType.mindMap) {
|
|
|
- _shareMindMap(fileName, talkBean.value?.summary.value);
|
|
|
+ (type, shareTo, fileName, tag) async {
|
|
|
+ try {
|
|
|
+ await isInstalled(shareTo);
|
|
|
+ if (type == ShareTalkType.summary || type == ShareTalkType.original) {
|
|
|
+ _shareSummaryOrOriginal(
|
|
|
+ talkBean.value!.id, fileName, type, shareTo, tag);
|
|
|
+ } else if (type == ShareTalkType.mindMap) {
|
|
|
+ _shareMindMap(fileName, talkBean.value?.summary.value, tag);
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ if (error is SystemShareException) {
|
|
|
+ ToastUtil.showToast(error.message);
|
|
|
+ } else {
|
|
|
+ ErrorHandler.toastError(error);
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- void _shareMindMap(String title, String? summary) {
|
|
|
+ Future<bool> isInstalled(ShareTo shareTo) async {
|
|
|
+ if (shareTo == ShareTo.wechat) {
|
|
|
+ bool isInstalled =
|
|
|
+ await SystemShareUtil.isInstalled(SystemShareUtil.wechatPageName);
|
|
|
+ if (!isInstalled) {
|
|
|
+ throw SystemShareException('未安装微信');
|
|
|
+ }
|
|
|
+ } else if (shareTo == ShareTo.qq) {
|
|
|
+ bool isInstalled =
|
|
|
+ await SystemShareUtil.isInstalled(SystemShareUtil.qqPageName);
|
|
|
+ if (!isInstalled) {
|
|
|
+ throw SystemShareException('未安装QQ');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // else if(shareTo == ShareTo.ios){
|
|
|
+ // //ios不用判断
|
|
|
+ // }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ void _shareMindMap(String title, String? summary, String tag) {
|
|
|
if (_temporaryController.value != null) {
|
|
|
_temporaryController.value?.dispose();
|
|
|
_temporaryController.value = null;
|
|
|
@@ -690,17 +719,17 @@ class TalkController extends BaseController {
|
|
|
if (shareTo == ShareTo.ios) {
|
|
|
await Share.shareXFiles([XFile(file.path)], subject: fileName);
|
|
|
} else if (shareTo == ShareTo.wechat) {
|
|
|
- await SystemShareUtil.shareWechatFile(file.path);
|
|
|
+ await SystemShareUtil.shareSystemFile(
|
|
|
+ SystemShareUtil.wechatPageName, file.path,
|
|
|
+ shareTitle: '分享到微信', shareFileType: 'text/*');
|
|
|
} else if (shareTo == ShareTo.qq) {
|
|
|
- await SystemShareUtil.shareQQFile(file.path);
|
|
|
+ await SystemShareUtil.shareSystemFile(
|
|
|
+ SystemShareUtil.qqPageName, file.path,
|
|
|
+ shareTitle: '分享到QQ', shareFileType: 'text/*');
|
|
|
}
|
|
|
SmartDialog.dismiss(tag: tag);
|
|
|
}).catchError((error) {
|
|
|
- if (error is SystemShareException) {
|
|
|
- ToastUtil.showToast(error.message);
|
|
|
- } else {
|
|
|
- ErrorHandler.toastError(error);
|
|
|
- }
|
|
|
+ throw error;
|
|
|
});
|
|
|
}
|
|
|
|