Explorar el Código

更新商品海报分享,多图分享

tags/0.0.1
Weller hace 4 años
padre
commit
8519949eeb
Se han modificado 3 ficheros con 66 adiciones y 40 borrados
  1. +2
    -2
      .dart_tool/package_config.json
  2. +1
    -1
      lib/pages/goods_share_page/goods_share_image/goods_share_image.dart
  3. +63
    -37
      lib/widgets/share/share_alert.dart

+ 2
- 2
.dart_tool/package_config.json Ver fichero

@@ -441,7 +441,7 @@
},
{
"name": "shimmer",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/shimmer-1.1.1",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/shimmer-1.1.2",
"packageUri": "lib/",
"languageVersion": "1.20"
},
@@ -614,7 +614,7 @@
"languageVersion": "2.1"
}
],
"generated": "2020-10-13T01:47:29.095085Z",
"generated": "2020-10-13T02:42:36.621853Z",
"generator": "pub",
"generatorVersion": "2.8.2"
}

+ 1
- 1
lib/pages/goods_share_page/goods_share_image/goods_share_image.dart Ver fichero

@@ -247,7 +247,7 @@ class _GoodsShareImageState extends State<GoodsShareImage>
}

void _saveImages() async {
_updateModel();
await _updateModel();

List<String> images = List();
for (int index = 0; index < _style.customImage.length; index++) {


+ 63
- 37
lib/widgets/share/share_alert.dart Ver fichero

@@ -1,9 +1,11 @@
import 'dart:convert';
import 'dart:io';
import 'dart:ui';

import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:path_provider/path_provider.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:share_extend/share_extend.dart';
import 'package:sharesdk_plugin/sharesdk_plugin.dart';
@@ -11,9 +13,6 @@ import 'package:zhiying_base_widget/utils/image_download_util/image_download_uti
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_comm/zhiying_comm.dart';
// import 'package:image_gallery_saver/image_gallery_saver.dart';

import 'package:path_provider/path_provider.dart';

class ShareAlert extends StatelessWidget {
final String skipIdentifier;
@@ -67,10 +66,10 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {
void initState() {
NetUtil.request('/api/v1/mod/${widget.skipIdentifier}',
method: NetMethod.GET, onCache: (data) {
_parseData(data);
}, onSuccess: (data) {
_parseData(data);
}, onError: (err) {});
_parseData(data);
}, onSuccess: (data) {
_parseData(data);
}, onError: (err) {});

super.initState();
}
@@ -122,7 +121,7 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {
),
Container(
margin:
EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10),
EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10),
child: _createIcons(),
),
GestureDetector(
@@ -216,6 +215,7 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {
);
}

// mob分享,只能单图分享,多图分享调用系统分享
void _shareByMob(ShareSDKPlatform plateform) async {
int count = 0;
if (widget.model.poster != null) {
@@ -238,37 +238,34 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {
Fluttertoast.showToast(msg: '暂无权限,分享失败');
return;
}
// PermissionStatus status = await PermissionHandler().checkPermissionStatus(
// PermissionGroup.storage);
// if (PermissionStatus.granted != status) {
// PermissionHandler().requestPermissions(<PermissionGroup>[
// PermissionGroup.storage,
// ]);
// }

// final result = await ImageGallerySaver.saveImage(widget.model.poster);
try {
// 保存到本地路径
final tempDir = await getTemporaryDirectory();
final file = await File('${tempDir.path}/image.jpg').create();
file.writeAsBytesSync(widget.model.poster);

// var appDocDir = await getTemporaryDirectory();
// final result = await ImageGallerySaver.saveImage(
// widget.model.poster,
// quality: 60,
// name: "hello");
// Logger.debug(result);
Logger.debug(file.path);

// params = SSDKMap()
// ..setGeneral(
// widget.model.title,
// widget.model.content,
// widget.model.poster,
// null,
// null,
// widget.model.url,
// null,
// null,
// null,
// null,
// SSDKContentTypes.auto,
// );
params = SSDKMap()
..setGeneral(
widget.model.title,
widget.model.content,
file.path,
null,
null,
widget.model.url,
null,
null,
null,
null,
SSDKContentTypes.auto,
);
} catch (err, s) {
Logger.error(err.toString(), s.toString());
Fluttertoast.showToast(msg: '分享失败');
return;
}
} else {
params = SSDKMap()
..setGeneral(
@@ -304,7 +301,36 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {

// 多图分享,调用系统分享
void _shareMultipleImages() async {
List<String> paths = await ImageDownloadUtil.download(widget.model.image);
List<String> paths = List();
if (widget.model.poster != null) {
// 检查并请求权限
var status = await Permission.storage.status;
if (status != PermissionStatus.granted) {
status = await Permission.storage.request();
}
if (status == PermissionStatus.denied) {
Fluttertoast.showToast(msg: '暂无权限,分享失败');
return;
}

try {
// 保存到本地路径
final tempDir = await getTemporaryDirectory();
final file = await File('${tempDir.path}/image.jpg').create();
file.writeAsBytesSync(widget.model.poster);

paths.add(file.path);
Logger.debug(file.path);
} catch (err, s) {
Logger.error(err.toString(), s.toString());
Fluttertoast.showToast(msg: '分享失败');
return;
}
}

List<String> downPaths =
await ImageDownloadUtil.download(widget.model.image);
paths.addAll(downPaths);
ShareExtend.shareMultiple(paths, "image", subject: "");
}
}

Cargando…
Cancelar
Guardar