Explorar el Código

1.微信增加多图分享

tags/0.0.5
“yanghuaxuan” hace 3 años
padre
commit
f0d5a7364f
Se han modificado 7 ficheros con 87 adiciones y 48 borrados
  1. +27
    -27
      example/android/app/build.gradle
  2. +20
    -1
      example/android/app/src/main/AndroidManifest.xml
  3. +3
    -0
      example/android/app/src/main/res/xml/zhiying_file_path.xml
  4. +8
    -0
      example/lib/util/localizations_delegate.dart
  5. +1
    -1
      example/pubspec.yaml
  6. +24
    -18
      lib/widgets/share/share_alert.dart
  7. +4
    -1
      pubspec.yaml

+ 27
- 27
example/android/app/build.gradle Ver fichero

@@ -108,33 +108,33 @@ android {


// 应用信息配置
productFlavors {
// 智夜生活
zhiying {
applicationId "cn.zhios.zhiying"
versionCode 39
dimension "app"
versionName '1.2.39'
// 签名信息
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 39
// dimension "app"
// versionName '1.2.39'
// // 签名信息
// 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 ->


+ 20
- 1
example/android/app/src/main/AndroidManifest.xml Ver fichero

@@ -24,13 +24,20 @@
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />

<uses-permission android:name="android.permission.INTERNET" />

<!-- Permissions options for the `ignoreBatteryOptimizations` group -->
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />


<application
android:name="cn.zhios.zhiying_base_widget_example.MyFlutterApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:allowBackup="true"
android:usesCleartextTraffic="true"
tools:replace="android:name, android:allowBackup">

<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
@@ -61,6 +68,18 @@
<meta-data
android:name="flutterEmbedding"
android:value="2" />

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.zhiying.demo.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/zhiying_file_path" />
</provider>


</application>

</manifest>

+ 3
- 0
example/android/app/src/main/res/xml/zhiying_file_path.xml Ver fichero

@@ -0,0 +1,3 @@
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<files-path name="my_images" path="cache/"/>
</paths>

+ 8
- 0
example/lib/util/localizations_delegate.dart Ver fichero

@@ -144,4 +144,12 @@ class _DefaultCupertinoLocalizations extends CupertinoLocalizations {

@override
String get todayLabel => "今天";

@override
// TODO: implement modalBarrierDismissLabel
String get modalBarrierDismissLabel => "关闭";

@override
String tabSemanticsLabel({int tabIndex, int tabCount}) {
}
}

+ 1
- 1
example/pubspec.yaml Ver fichero

@@ -38,7 +38,7 @@ dev_dependencies:
zhiying_moments:
#path: ../zhiying_moments
git:
ref: 0.1.0
ref: 0.1.1
url: http://192.168.0.138:3000/FnuoOS_ZhiYing/zhiying_moments.git

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


+ 24
- 18
lib/widgets/share/share_alert.dart Ver fichero

@@ -6,6 +6,7 @@ import 'dart:ui';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.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';
@@ -17,6 +18,7 @@ import 'package:zhiying_base_widget/widgets/share/models/share_data_model.dart';
import 'package:zhiying_base_widget/widgets/share/models/share_icon_model.dart';
import 'package:zhiying_base_widget/widgets/share/share_alert_content.dart';
import 'package:zhiying_comm/zhiying_comm.dart';
import 'dart:io';

class ShareAlert extends StatefulWidget {
final String skipIdentifier;
@@ -202,7 +204,16 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {
print(status);
return;
}

int count = 0;
if (widget.model.poster != null) {
count++;
}
count += (widget.model?.image?.length ?? 0);
// 多图分享
if (count > 1) {
_shareMultipleImages(item.type);
return;
}
if (item.type == 'wx') {
_shareByMob(ShareSDKPlatforms.wechatSession);
} else if (item.type == 'pyq') {
@@ -214,7 +225,7 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {
} else if (item.type == 'weibo') {
_shareByMob(ShareSDKPlatforms.sina);
} else if (item.type == 'more_setting') {
_shareBySystem();
_shareBySystem(item.type);
}
},
);
@@ -222,16 +233,8 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {

// mob分享,只能单图分享,多图分享调用系统分享
void _shareByMob(ShareSDKPlatform plateform) async {
int count = 0;
if (widget.model.poster != null) {
count++;
}
count += (widget.model?.image?.length ?? 0);
// 多图分享
if (count > 1) {
_shareMultipleImages();
return;
}



Loading.show(context);
Timer(Duration(milliseconds: 2000),(){
@@ -303,7 +306,7 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {
}

// 系统分享,只能分享图片或者文字,不能组合分享
void _shareBySystem() async {
void _shareBySystem(String type) async {
int count = 0;
if (widget.model.poster != null) {
count++;
@@ -311,7 +314,7 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {
count += (widget.model?.image?.length ?? 0);
// 多图分享
if (count > 1) {
_shareMultipleImages();
_shareMultipleImages(type);
return;
}

@@ -341,7 +344,7 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {
try {
// 保存到本地路径
final tempDir = await getTemporaryDirectory();
final file = await File('${tempDir.path}/image.jpg').create();
final file = await File('${tempDir.path}/image.png').create();
file.writeAsBytesSync(widget.model.poster);

path = file.path;
@@ -356,17 +359,20 @@ 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(widget.model.image);
paths.addAll(downPaths);
ShareExtend.shareMultiple(paths, "image", subject: "");
if(Platform.isAndroid&&type=='wx'){
MorePictureShare.shareWeixinPics(paths);
}else{
ShareExtend.shareMultiple(paths, "image", subject: "");
}
Loading.dismiss();
}
}

+ 4
- 1
pubspec.yaml Ver fichero

@@ -14,7 +14,8 @@ dependencies:
flutter_swiper: ^1.1.6
bloc: ^4.0.0
event_bus: ^1.1.1
pull_to_refresh: ^1.6.1
pull_to_refresh:
path: ../../1.22.0_master/flutter_pulltorefresh
flutter_cupertino_date_picker:
path: ../../1.22.0_master/flutter-cupertino-date-picker
image_picker: ^0.6.7+3
@@ -39,6 +40,8 @@ dependencies:
ref: 0.0.1
url: http://192.168.0.138:3000/FnuoOS_Flutter_Components/permission_handler.git

more_picture_share:
path: ../more_picture_share

intl: 0.16.1



Cargando…
Cancelar
Guardar