瀏覽代碼

1.优化多图片分享

tags/0.0.5
“yanghuaxuan” 4 年之前
父節點
當前提交
dd1c455a2e
共有 3 個檔案被更改,包括 59 行新增58 行删除
  1. +29
    -29
      example/android/app/build.gradle
  2. +2
    -2
      example/pubspec.yaml
  3. +28
    -27
      lib/widgets/share/share_alert_select.dart

+ 29
- 29
example/android/app/build.gradle 查看文件

@@ -53,8 +53,8 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk { ndk {
//选择要添加的对应cpu类型的.so库。 //选择要添加的对应cpu类型的.so库。
abiFilters 'armeabi', 'armeabi-v7a', 'x86', 'x86_64', 'mips', 'mips64', 'arm64-v8a' //abiFilters 'armeabi', 'armeabi-v7a', 'x86', 'x86_64', 'mips', 'mips64', 'arm64-v8a'
// abiFilters 'armeabi-v7a','x86_64' abiFilters 'armeabi-v7a','x86_64'
} }
} }


@@ -109,33 +109,33 @@ android {




// // 应用信息配置 // // 应用信息配置
// productFlavors { productFlavors {
// // 智夜生活 // 智夜生活
// zhiying { zhiying {
// applicationId "cn.zhios.zhiying" applicationId "cn.zhios.zhiying"
// versionCode 45 versionCode 45
// dimension "app" dimension "app"
// versionName '1.3.3' versionName '1.3.3'
// // 签名信息 // 签名信息
// signingConfig signingConfigs.zhiying signingConfig signingConfigs.zhiying
// } }
// } }
// // 打包脚本
// // 打包脚本 android.applicationVariants.all { variant ->
// android.applicationVariants.all { variant -> if (variant.buildType.name != "debug") {
// if (variant.buildType.name != "debug") { variant.getPackageApplicationProvider().get().outputDirectory = new File(project.rootDir.absolutePath + "/app/build/outputs/apk")
// variant.getPackageApplicationProvider().get().outputDirectory = new File(project.rootDir.absolutePath + "/app/build/outputs/apk") }
// } variant.outputs.all { output ->
// def outputFile = output.outputFile
// variant.outputs.all { output -> if (outputFile != null && outputFile.name.endsWith('.apk')) {
// def outputFile = output.outputFile //这里修改apk文件名
// if (outputFile != null && outputFile.name.endsWith('.apk')) { def fileName = "${variant.productFlavors[0].name}_${releaseTime()}01_&V${variant.productFlavors[0].versionCode}.apk"
// //这里修改apk文件名 outputFileName = fileName
// def fileName = "${variant.productFlavors[0].name}_${releaseTime()}01_&V${variant.productFlavors[0].versionCode}.apk" }
// outputFileName = fileName }
// } }
// }
// }


configurations.all { configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details -> resolutionStrategy.eachDependency { DependencyResolveDetails details ->


+ 2
- 2
example/pubspec.yaml 查看文件

@@ -38,13 +38,13 @@ dev_dependencies:
zhiying_moments: zhiying_moments:
#path: ../zhiying_moments #path: ../zhiying_moments
git: git:
ref: 0.1.5 ref: 0.1.6
url: http://192.168.0.138:3000/FnuoOS_ZhiYing/zhiying_moments.git url: http://192.168.0.138:3000/FnuoOS_ZhiYing/zhiying_moments.git
#会员升级 #会员升级
zhiying_member_upgrade: zhiying_member_upgrade:
#path: ../Zhiying_Member_Upgrade #path: ../Zhiying_Member_Upgrade
git: git:
ref: 0.0.1 ref: 0.0.2
url: http://192.168.0.138:3000/FnuoOS_ZhiYing/Zhiying_Member_Upgrade.git url: http://192.168.0.138:3000/FnuoOS_ZhiYing/Zhiying_Member_Upgrade.git


# For information on the generic Dart part of this file, see the # For information on the generic Dart part of this file, see the


+ 28
- 27
lib/widgets/share/share_alert_select.dart 查看文件

@@ -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( picWidget = Column(
child: Transform.scale( children: [
alignment: Alignment.center, Expanded(
scale: 0.75, child: Transform.scale(
child: GoodsShareTemplate( alignment: Alignment.center,
selectPicModel.posterModel, scale: 0.75,
contentKey: _globalKey, 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, SharesdkPlugin.share(plateform, params, (SSDKResponseState state, Map userdata, Map contentEntity, SSDKError error) {
(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();
} }
} }

||||||
x
 
000:0
Loading…
取消
儲存