瀏覽代碼

1.优化分享,修复新浪微博无法分享图片的问题

tags/0.0.16+10
“yanghuaxuan” 3 年之前
父節點
當前提交
a05d9cd9d3
共有 2 個文件被更改,包括 70 次插入4 次删除
  1. +38
    -4
      lib/widgets/share/share_alert.dart
  2. +32
    -0
      lib/widgets/share/share_alert_select.dart

+ 38
- 4
lib/widgets/share/share_alert.dart 查看文件

@@ -278,8 +278,8 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {
if (path != null && path != '') {
params = SSDKMap()
..setGeneral(
widget.model?.title ?? '',
widget.model?.content ?? '',
widget.model?.title ?? '图片分享',
widget.model?.content ?? '更多好事物',
Platform.isIOS ? path : null,
null,
Platform.isAndroid ? path : null,
@@ -300,6 +300,8 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {
type = SSDKContentTypes.image;
} else if (widget?.model?.title != null || widget.model?.content != null) {
type = SSDKContentTypes.text;
} else if (widget?.model?.poster != null) {
type = SSDKContentTypes.image;
}
if (plateform == ShareSDKPlatforms.qZone && widget?.model?.content != null) {
widget?.model?.title = null;
@@ -340,8 +342,8 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {

params = SSDKMap()
..setGeneral(
widget.model?.title ?? '',
widget?.model?.content ?? '',
widget.model?.title ?? '~',
widget?.model?.content ?? '~',
Platform.isIOS ? widget.model.image : null,
Platform.isAndroid ? (isExistImage ? widget?.model?.image?.first : null) : null,
null,
@@ -353,6 +355,38 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {
type,
);
}

var isExistImage = false;

if (widget?.model?.image != null && widget?.model?.image?.length > 0) {
isExistImage = true;
}

///新浪分享图片
if (plateform == ShareSDKPlatforms.sina &&
(isExistImage || widget?.model?.poster != null) &&
EmptyUtil.isEmpty(widget?.model?.content) &&
EmptyUtil.isEmpty(widget?.model?.url)) {
SSDKMap params2 = SSDKMap()
..setSina(
"图片分享",
null,
null,
null,
null,
null,
null,
null,
false,
(isExistImage ? widget?.model?.image.first : null),
params.map["imagePath_android"],
SSDKContentTypes.image,
);
print(params2);
SharesdkPlugin.share(ShareSDKPlatforms.sina, params2, (SSDKResponseState state, Map userdata, Map contentEntity, SSDKError error) {});
return;
}

SharesdkPlugin.share(plateform, params, (SSDKResponseState state, Map userdata, Map contentEntity, SSDKError error) {
print(error);
if (state == SSDKResponseState.Fail) {


+ 32
- 0
lib/widgets/share/share_alert_select.dart 查看文件

@@ -493,6 +493,38 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {
type,
);
}

var isExistImage = false;

if (widget?.model?.image != null && widget?.model?.image?.length > 0) {
isExistImage = true;
}

///新浪分享图片
if (plateform == ShareSDKPlatforms.sina &&
(isExistImage || widget?.model?.poster != null) &&
EmptyUtil.isEmpty(widget?.model?.content) &&
EmptyUtil.isEmpty(widget?.model?.url)) {
SSDKMap params2 = SSDKMap()
..setSina(
"图片分享",
null,
null,
null,
null,
null,
null,
null,
false,
(isExistImage ? widget?.model?.image.first : null),
params.map["imagePath_android"],
SSDKContentTypes.image,
);
print(params2);
SharesdkPlugin.share(ShareSDKPlatforms.sina, params2, (SSDKResponseState state, Map userdata, Map contentEntity, SSDKError error) {});
return;
}

SharesdkPlugin.share(plateform, params, (SSDKResponseState state, Map userdata, Map contentEntity, SSDKError error) {
print(error);
if (state == SSDKResponseState.Fail) {


Loading…
取消
儲存