|
@@ -12,6 +12,7 @@ import 'package:flutter/rendering.dart'; |
|
|
import 'package:flutter/services.dart'; |
|
|
import 'package:flutter/services.dart'; |
|
|
import 'package:flutter_swiper/flutter_swiper.dart'; |
|
|
import 'package:flutter_swiper/flutter_swiper.dart'; |
|
|
import 'package:fluttertoast/fluttertoast.dart'; |
|
|
import 'package:fluttertoast/fluttertoast.dart'; |
|
|
|
|
|
import 'package:more_picture_share/more_picture_share.dart'; |
|
|
import 'package:path_provider/path_provider.dart'; |
|
|
import 'package:path_provider/path_provider.dart'; |
|
|
import 'package:permission_handler/permission_handler.dart'; |
|
|
import 'package:permission_handler/permission_handler.dart'; |
|
|
import 'package:share_extend/share_extend.dart'; |
|
|
import 'package:share_extend/share_extend.dart'; |
|
@@ -143,15 +144,19 @@ class _ShareAlertSelectState extends State<ShareAlertSelect> { |
|
|
itemBuilder: (BuildContext context, int index) { |
|
|
itemBuilder: (BuildContext context, int index) { |
|
|
Widget picWidget; |
|
|
Widget picWidget; |
|
|
if (index == 0) { |
|
|
if (index == 0) { |
|
|
picWidget = Expanded( |
|
|
|
|
|
child: Transform.scale( |
|
|
|
|
|
alignment: Alignment.center, |
|
|
|
|
|
scale: 0.75, |
|
|
|
|
|
child: GoodsShareTemplate( |
|
|
|
|
|
selectPicModel.posterModel, |
|
|
|
|
|
contentKey: _globalKey, |
|
|
|
|
|
|
|
|
picWidget = Column( |
|
|
|
|
|
children: [ |
|
|
|
|
|
Expanded( |
|
|
|
|
|
child: Transform.scale( |
|
|
|
|
|
alignment: Alignment.center, |
|
|
|
|
|
scale: 0.75, |
|
|
|
|
|
child: GoodsShareTemplate( |
|
|
|
|
|
selectPicModel.posterModel, |
|
|
|
|
|
contentKey: _globalKey, |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
|
|
|
|
|
|
], |
|
|
); |
|
|
); |
|
|
} else { |
|
|
} else { |
|
|
picWidget = CachedNetworkImage( |
|
|
picWidget = CachedNetworkImage( |
|
@@ -382,7 +387,7 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { |
|
|
} else if (item.type == 'weibo') { |
|
|
} else if (item.type == 'weibo') { |
|
|
_shareByMob(ShareSDKPlatforms.sina); |
|
|
_shareByMob(ShareSDKPlatforms.sina); |
|
|
} else if (item.type == 'more_setting') { |
|
|
} else if (item.type == 'more_setting') { |
|
|
_shareBySystem(); |
|
|
|
|
|
|
|
|
_shareBySystem(item.type); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
); |
|
|
); |
|
@@ -397,16 +402,6 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { |
|
|
Fluttertoast.showToast(msg: '请选择分享图片'); |
|
|
Fluttertoast.showToast(msg: '请选择分享图片'); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
int count = 0; |
|
|
|
|
|
if (_shareDataModel.poster != null) { |
|
|
|
|
|
count++; |
|
|
|
|
|
} |
|
|
|
|
|
count += (_shareDataModel?.image?.length ?? 0); |
|
|
|
|
|
// 多图分享 |
|
|
|
|
|
if (count > 1) { |
|
|
|
|
|
_shareMultipleImages(); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Loading.show(context); |
|
|
Loading.show(context); |
|
|
Timer(Duration(milliseconds: 2000), () { |
|
|
Timer(Duration(milliseconds: 2000), () { |
|
@@ -442,7 +437,7 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { |
|
|
} else if (_shareDataModel?.title != null || _shareDataModel?.content != null) { |
|
|
} else if (_shareDataModel?.title != null || _shareDataModel?.content != null) { |
|
|
type = SSDKContentTypes.text; |
|
|
type = SSDKContentTypes.text; |
|
|
} |
|
|
} |
|
|
if (plateform == ShareSDKPlatforms.qZone) { |
|
|
|
|
|
|
|
|
if (plateform == ShareSDKPlatforms.qZone && type == SSDKContentTypes.text) { |
|
|
_shareDataModel?.title = null; |
|
|
_shareDataModel?.title = null; |
|
|
type = SSDKContentTypes.message; |
|
|
type = SSDKContentTypes.message; |
|
|
} |
|
|
} |
|
@@ -462,8 +457,7 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { |
|
|
type, |
|
|
type, |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
SharesdkPlugin.share(plateform, params, |
|
|
|
|
|
(SSDKResponseState state, Map userdata, Map contentEntity, SSDKError error) { |
|
|
|
|
|
|
|
|
SharesdkPlugin.share(plateform, params, (SSDKResponseState state, Map userdata, Map contentEntity, SSDKError error) { |
|
|
print(error); |
|
|
print(error); |
|
|
if (state == SSDKResponseState.Fail) { |
|
|
if (state == SSDKResponseState.Fail) { |
|
|
Fluttertoast.showToast(msg: '分享失败'); |
|
|
Fluttertoast.showToast(msg: '分享失败'); |
|
@@ -478,7 +472,7 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 系统分享,只能分享图片或者文字,不能组合分享 |
|
|
// 系统分享,只能分享图片或者文字,不能组合分享 |
|
|
void _shareBySystem() async { |
|
|
|
|
|
|
|
|
void _shareBySystem(String type) async { |
|
|
if (isSelectPic && |
|
|
if (isSelectPic && |
|
|
EmptyUtil.isEmpty(_shareDataModel) && |
|
|
EmptyUtil.isEmpty(_shareDataModel) && |
|
|
EmptyUtil.isEmpty(_shareDataModel?.poster) && |
|
|
EmptyUtil.isEmpty(_shareDataModel?.poster) && |
|
@@ -486,6 +480,7 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { |
|
|
Fluttertoast.showToast(msg: '请选择分享图片'); |
|
|
Fluttertoast.showToast(msg: '请选择分享图片'); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int count = 0; |
|
|
int count = 0; |
|
|
if (_shareDataModel.poster != null) { |
|
|
if (_shareDataModel.poster != null) { |
|
|
count++; |
|
|
count++; |
|
@@ -493,7 +488,7 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { |
|
|
count += (_shareDataModel?.image?.length ?? 0); |
|
|
count += (_shareDataModel?.image?.length ?? 0); |
|
|
// 多图分享 |
|
|
// 多图分享 |
|
|
if (count > 1) { |
|
|
if (count > 1) { |
|
|
_shareMultipleImages(); |
|
|
|
|
|
|
|
|
_shareMultipleImages(type); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -505,6 +500,7 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { |
|
|
} else { |
|
|
} else { |
|
|
ShareExtend.share(_shareDataModel.content, 'text'); |
|
|
ShareExtend.share(_shareDataModel.content, 'text'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Future<String> _savePoster() async { |
|
|
Future<String> _savePoster() async { |
|
@@ -538,17 +534,22 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 多图分享,调用系统分享 |
|
|
// 多图分享,调用系统分享 |
|
|
void _shareMultipleImages() async { |
|
|
|
|
|
|
|
|
void _shareMultipleImages(String type) async { |
|
|
List<String> paths = List(); |
|
|
List<String> paths = List(); |
|
|
String path = await _savePoster(); |
|
|
String path = await _savePoster(); |
|
|
if (path != null && path != '') { |
|
|
if (path != null && path != '') { |
|
|
paths.add(path); |
|
|
paths.add(path); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Loading.show(context); |
|
|
Loading.show(context); |
|
|
List<String> downPaths = await ImageDownloadUtil.download(_shareDataModel.image); |
|
|
List<String> downPaths = await ImageDownloadUtil.download(_shareDataModel.image); |
|
|
paths.addAll(downPaths); |
|
|
paths.addAll(downPaths); |
|
|
ShareExtend.shareMultiple(paths, "image", subject: ""); |
|
|
|
|
|
|
|
|
if (Platform.isAndroid && type == 'wx') { |
|
|
|
|
|
MorePictureShare.shareWeixinPics(paths); |
|
|
|
|
|
} else if (Platform.isAndroid && type == 'pyq') { |
|
|
|
|
|
MorePictureShare.shareWeixinPicsCirlc(paths); |
|
|
|
|
|
} else { |
|
|
|
|
|
ShareExtend.shareMultiple(paths, "image", subject: ""); |
|
|
|
|
|
} |
|
|
Loading.dismiss(); |
|
|
Loading.dismiss(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |