Преглед изворни кода

1.优化多图片分享

tags/0.0.5
“yanghuaxuan” пре 3 година
родитељ
комит
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"
ndk {
//选择要添加的对应cpu类型的.so库。
abiFilters 'armeabi', 'armeabi-v7a', 'x86', 'x86_64', 'mips', 'mips64', 'arm64-v8a'
// abiFilters 'armeabi-v7a','x86_64'
//abiFilters 'armeabi', 'armeabi-v7a', 'x86', 'x86_64', 'mips', 'mips64', 'arm64-v8a'
abiFilters 'armeabi-v7a','x86_64'
}
}

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


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

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


+ 2
- 2
example/pubspec.yaml Прегледај датотеку

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


+ 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_swiper/flutter_swiper.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:more_picture_share/more_picture_share.dart';
import 'package:path_provider/path_provider.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:share_extend/share_extend.dart';
@@ -143,15 +144,19 @@ class _ShareAlertSelectState extends State<ShareAlertSelect> {
itemBuilder: (BuildContext context, int index) {
Widget picWidget;
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 {
picWidget = CachedNetworkImage(
@@ -382,7 +387,7 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {
} else if (item.type == 'weibo') {
_shareByMob(ShareSDKPlatforms.sina);
} else if (item.type == 'more_setting') {
_shareBySystem();
_shareBySystem(item.type);
}
},
);
@@ -397,16 +402,6 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {
Fluttertoast.showToast(msg: '请选择分享图片');
return;
}
int count = 0;
if (_shareDataModel.poster != null) {
count++;
}
count += (_shareDataModel?.image?.length ?? 0);
// 多图分享
if (count > 1) {
_shareMultipleImages();
return;
}

Loading.show(context);
Timer(Duration(milliseconds: 2000), () {
@@ -442,7 +437,7 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {
} else if (_shareDataModel?.title != null || _shareDataModel?.content != null) {
type = SSDKContentTypes.text;
}
if (plateform == ShareSDKPlatforms.qZone) {
if (plateform == ShareSDKPlatforms.qZone && type == SSDKContentTypes.text) {
_shareDataModel?.title = null;
type = SSDKContentTypes.message;
}
@@ -462,8 +457,7 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {
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);
if (state == SSDKResponseState.Fail) {
Fluttertoast.showToast(msg: '分享失败');
@@ -478,7 +472,7 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {
}

// 系统分享,只能分享图片或者文字,不能组合分享
void _shareBySystem() async {
void _shareBySystem(String type) async {
if (isSelectPic &&
EmptyUtil.isEmpty(_shareDataModel) &&
EmptyUtil.isEmpty(_shareDataModel?.poster) &&
@@ -486,6 +480,7 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {
Fluttertoast.showToast(msg: '请选择分享图片');
return;
}

int count = 0;
if (_shareDataModel.poster != null) {
count++;
@@ -493,7 +488,7 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {
count += (_shareDataModel?.image?.length ?? 0);
// 多图分享
if (count > 1) {
_shareMultipleImages();
_shareMultipleImages(type);
return;
}

@@ -505,6 +500,7 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {
} else {
ShareExtend.share(_shareDataModel.content, 'text');
}

}

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();
String path = await _savePoster();
if (path != null && path != '') {
paths.add(path);
}

Loading.show(context);
List<String> downPaths = await ImageDownloadUtil.download(_shareDataModel.image);
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…
Откажи
Сачувај