Przeglądaj źródła

1.优化多图片分享

tags/0.0.5
“yanghuaxuan” 3 lat temu
rodzic
commit
1ad4d86d0c
11 zmienionych plików z 131 dodań i 142 usunięć
  1. +6
    -5
      example/android/app/build.gradle
  2. +2
    -2
      example/android/app/src/main/AndroidManifest.xml
  3. +2
    -0
      example/lib/main.dart
  4. +7
    -1
      example/pubspec.yaml
  5. +30
    -37
      lib/pages/goods_share_page/goods_share_image/goods_share_image.dart
  6. +1
    -1
      lib/pages/goods_share_page/goods_share_link/goods_share_link.dart
  7. +9
    -3
      lib/utils/image_download_util/image_download_util.dart
  8. +39
    -69
      lib/widgets/goods_details/footer/model/goods_details_footer_model.dart
  9. +28
    -20
      lib/widgets/share/share_alert.dart
  10. +1
    -1
      lib/zhiying_base_widget.dart
  11. +6
    -3
      pubspec.yaml

+ 6
- 5
example/android/app/build.gradle Wyświetl plik

@@ -53,7 +53,8 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk {
//选择要添加的对应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'
}
}

@@ -107,14 +108,14 @@ android {
}


// 应用信息配置
// // 应用信息配置
// productFlavors {
// // 智夜生活
// zhiying {
// applicationId "cn.zhios.zhiying"
// versionCode 39
// versionCode 45
// dimension "app"
// versionName '1.2.39'
// versionName '1.3.3'
// // 签名信息
// signingConfig signingConfigs.zhiying
// }
@@ -162,7 +163,7 @@ dependencies {
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'

//登陆
//登陆
implementation 'com.ali.auth.sdk:alibabauth_core:2.0.0.11@aar'
implementation 'com.ali.auth.sdk:alibabauth_ui:2.0.0.11@aar'
implementation 'com.ali.auth.sdk:alibabauth_ext:2.0.0.11@aar'


+ 2
- 2
example/android/app/src/main/AndroidManifest.xml Wyświetl plik

@@ -26,8 +26,8 @@

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

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


<application


+ 2
- 0
example/lib/main.dart Wyświetl plik

@@ -19,6 +19,7 @@ import 'package:zhiying_business_college/register.dart';
import 'package:zhiying_new_user_free/register.dart';
import 'package:zhiying_wechat_teacher/register.dart';
import 'package:zhiying_moments/register.dart';
import 'package:zhiying_member_upgrade/register.dart';

void main() {
FlutterError.onError = (FlutterErrorDetails details) {
@@ -63,6 +64,7 @@ class _MyAppState extends State<MyApp> {
NewUserFreeRegister.init();
WeChatTeachRegister.init();
FriendCircleRegister.init();
MemberUpgradeRegister.init();
print('初始化百川');
FlutterAlibc.initAlibc(version: "", appName: "").then((result) {
print("白川" + '${result.errorCode} ${result.errorMessage}');


+ 7
- 1
example/pubspec.yaml Wyświetl plik

@@ -38,8 +38,14 @@ dev_dependencies:
zhiying_moments:
#path: ../zhiying_moments
git:
ref: 0.1.1
ref: 0.1.5
url: http://192.168.0.138:3000/FnuoOS_ZhiYing/zhiying_moments.git
#会员升级
zhiying_member_upgrade:
#path: ../Zhiying_Member_Upgrade
git:
ref: 0.0.1
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
# following page: https://dart.dev/tools/pub/pubspec


+ 30
- 37
lib/pages/goods_share_page/goods_share_image/goods_share_image.dart Wyświetl plik

@@ -33,8 +33,7 @@ class GoodsShareImage extends StatefulWidget {
final Map<String, dynamic> params;
final String shareType;

const GoodsShareImage(this.model, this.params, this.shareType, {Key key})
: super(key: key);
const GoodsShareImage(this.model, this.params, this.shareType, {Key key}) : super(key: key);

@override
_GoodsShareImageState createState() => _GoodsShareImageState();
@@ -45,8 +44,7 @@ class _GoodsShareImageState extends State<GoodsShareImage> {
Widget build(BuildContext context) {
return BlocProvider<GoodsShareContentBloc>(
bloc: GoodsShareContentBloc(),
child: _GoodsShareImageContent(
widget.model, widget.params, widget.shareType),
child: _GoodsShareImageContent(widget.model, widget.params, widget.shareType),
);
}
}
@@ -56,16 +54,13 @@ class _GoodsShareImageContent extends StatefulWidget {
final Map<String, dynamic> params;
final String shareType;

const _GoodsShareImageContent(this.model, this.params, this.shareType,
{Key key})
: super(key: key);
const _GoodsShareImageContent(this.model, this.params, this.shareType, {Key key}) : super(key: key);

@override
_GoodsShareImageContentState createState() => _GoodsShareImageContentState();
}

class _GoodsShareImageContentState extends State<_GoodsShareImageContent>
with AutomaticKeepAliveClientMixin {
class _GoodsShareImageContentState extends State<_GoodsShareImageContent> with AutomaticKeepAliveClientMixin {
GlobalKey _globalKey = GlobalKey();
GoodsShareImageModel _style;
Map<int, String> _images = Map();
@@ -123,10 +118,7 @@ class _GoodsShareImageContentState extends State<_GoodsShareImageContent>
onEditorClick: () {
Fluttertoast.showToast(msg: '正在开发中');
return;
Navigator.push(
context,
CupertinoPageRoute(
builder: (context) => GoodsShareEditor(_style)));
Navigator.push(context, CupertinoPageRoute(builder: (context) => GoodsShareEditor(_style)));
},
onTempChange: (temp) {
setState(() {
@@ -183,6 +175,17 @@ class _GoodsShareImageContentState extends State<_GoodsShareImageContent>
},
),
);

List<String> moreImageList = List();
try{
moreImageList = List.from(widget?.params['image_url_list']).map((e) => e.toString()).toList();
}catch(e,s){
print(e);
print(s);
}

_style.customImage.addAll(moreImageList);
_style.customImage=_style.customImage.reversed.toList();
for (int index = 0; index < _style.customImage.length; index++) {
String image = _style.customImage[index];
// 分享图片
@@ -211,16 +214,9 @@ class _GoodsShareImageContentState extends State<_GoodsShareImageContent>
child: Container(
margin: EdgeInsets.only(bottom: 4),
padding: EdgeInsets.only(top: 10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(8),
bottomRight: Radius.circular(8))),
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.only(bottomLeft: Radius.circular(8), bottomRight: Radius.circular(8))),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: widgets),
child: Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: widgets),
),
),
),
@@ -235,12 +231,9 @@ class _GoodsShareImageContentState extends State<_GoodsShareImageContent>
if (shareImages == null) {
return Container();
}
CustomButtonModel btnCopy = CustomButtonModel.fromJson(
Map<String, dynamic>.from(shareImages['copy_btn']));
CustomButtonModel btnSave = CustomButtonModel.fromJson(
Map<String, dynamic>.from(shareImages['save_btn']));
CustomButtonModel btnShare = CustomButtonModel.fromJson(
Map<String, dynamic>.from(shareImages['share_btn']));
CustomButtonModel btnCopy = CustomButtonModel.fromJson(Map<String, dynamic>.from(shareImages['copy_btn']));
CustomButtonModel btnSave = CustomButtonModel.fromJson(Map<String, dynamic>.from(shareImages['save_btn']));
CustomButtonModel btnShare = CustomButtonModel.fromJson(Map<String, dynamic>.from(shareImages['share_btn']));
return SafeArea(
child: Container(
margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 4, bottom: 4),
@@ -317,8 +310,7 @@ class _GoodsShareImageContentState extends State<_GoodsShareImageContent>
_shareModel.image = null;
}

if ((_shareModel.image == null || _shareModel.image.length == 0) &&
_shareModel.poster == null) {
if ((_shareModel.image == null || _shareModel.image.length == 0) && _shareModel.poster == null) {
Fluttertoast.showToast(msg: '请选择要保存的图片');
Loading.dismiss();
return;
@@ -352,14 +344,16 @@ class _GoodsShareImageContentState extends State<_GoodsShareImageContent>
}

List<String> paths = await ImageDownloadUtil.download(images);
paths.forEach((path) async {
Uint8List data = File(path).readAsBytesSync();
for(var item in paths){
Uint8List data = File(item).readAsBytesSync();
isSaveSuccess = await SaveImage.save(imageBytes: data);
});
if (isSaveSuccess)
}
if (isSaveSuccess) {
Fluttertoast.showToast(msg: '保存成功');
else
} else{
Fluttertoast.showToast(msg: '保存失败');
}


Loading.dismiss();
}
@@ -371,8 +365,7 @@ class _GoodsShareImageContentState extends State<_GoodsShareImageContent>
RenderRepaintBoundary boundary = buildContext.findRenderObject();
ui.Image image = await boundary.toImage(pixelRatio: 2.0);
// 注意:png是压缩后格式,如果需要图片的原始像素数据,请使用rawRgba
ByteData byteData =
await image.toByteData(format: ui.ImageByteFormat.png);
ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.png);
Uint8List pngBytes = byteData.buffer.asUint8List();
_shareModel.poster = pngBytes;
}


+ 1
- 1
lib/pages/goods_share_page/goods_share_link/goods_share_link.dart Wyświetl plik

@@ -180,7 +180,7 @@ class _GoodsShareLinkContentState extends State<_GoodsShareLinkContent>
}

Widget _createBottom() {
Map<String, dynamic> shareImages = _style?.cssList?.shareImage ?? {};
Map<String, dynamic> shareImages = _style?.cssList?.shareImage;
if (shareImages == null) {
return Container();
}


+ 9
- 3
lib/utils/image_download_util/image_download_util.dart Wyświetl plik

@@ -7,11 +7,17 @@ import 'package:zhiying_comm/zhiying_comm.dart';
class ImageDownloadUtil {
static Future<List<String>> download(List<String> urls) async {
try {
var dict = await getPhoneLocalPath();

// var dict = await getPhoneLocalPath();
// var dict = await getTemporaryDirectory();
Directory dict;
if (Platform.isAndroid) {
dict = await getTemporaryDirectory();
} else {
dict = await getPhoneLocalPath();
}
Dio dio = Dio();
var paths = await Future.wait(urls.map((url) async {
String path = '${dict.path}/${EncodeUtil.generateMd5(url)}.jpg';
String path = '${dict.path}/${EncodeUtil.generateMd5(url)}.png';
Logger.debug('图片下载地址 ${path.toString()}');
await dio.download(url, path);
return path;


+ 39
- 69
lib/widgets/goods_details/footer/model/goods_details_footer_model.dart Wyświetl plik

@@ -1,4 +1,3 @@

import 'package:zhiying_comm/zhiying_comm.dart';

class GoodsDetailsFooterModel {
@@ -56,9 +55,8 @@ class GoodsDetailsFooterModel {
topRightRadius: json['top_right_radius'],
bottomLeftRadius: json['bottom_left_radius'],
bottomRightRadius: json['bottom_right_radius'],
bgColor : json['bg_color'],
listStyle : json['list_style'] != null? new ListStyle.fromJson(json['list_style']): null
);
bgColor: json['bg_color'],
listStyle: json['list_style'] != null ? new ListStyle.fromJson(json['list_style']) : null);
}

GoodsDetailsFooterModel({
@@ -145,21 +143,22 @@ class FavArgs {
String marketPrice;
String currentPrice;
String inorderCount;
Null detailData;

FavArgs({this.provider,
this.providerName,
this.goodId,
this.goodImage,
this.goodTitle,
this.shopName,
this.coupon,
this.couponUrl,
this.commission,
this.marketPrice,
this.currentPrice,
this.inorderCount,
this.detailData});
dynamic detailData;

FavArgs(
{this.provider,
this.providerName,
this.goodId,
this.goodImage,
this.goodTitle,
this.shopName,
this.coupon,
this.couponUrl,
this.commission,
this.marketPrice,
this.currentPrice,
this.inorderCount,
this.detailData});

FavArgs.fromJson(Map<String, dynamic> json) {
provider = json['provider'];
@@ -205,10 +204,14 @@ class ShareUrlArgs {
String selfbuyCommission;
String title;
String type;
List<dynamic> imageUrlList;

ShareUrlArgs({this.buyUrl, this.coupon, this.couponPrice, this.marketPrice, this.posterImage, this.selfbuyCommission, this.title, this.type});
ShareUrlArgs({this.buyUrl, this.coupon, this.couponPrice, this.marketPrice, this.posterImage, this.selfbuyCommission, this.title, this.type,this.imageUrlList});

ShareUrlArgs.fromJson(Map<String, dynamic> json) {
if (json['image_url_list'] != null) {
imageUrlList = List.from(json['image_url_list']).map((e) => e.toString()).toList();
}
buyUrl = json['buy_url'];
coupon = json['coupon'];
couponPrice = json['coupon_price'];
@@ -216,7 +219,9 @@ class ShareUrlArgs {
posterImage = json['poster_image'];
selfbuyCommission = json['selfbuy_commission'];
title = json['title'];

type = json['type'];

}

Map<String, dynamic> toJson() {
@@ -229,6 +234,7 @@ class ShareUrlArgs {
data['selfbuy_commission'] = this.selfbuyCommission;
data['title'] = this.title;
data['type'] = this.type;
data['image_url_list']=this.imageUrlList;
return data;
}
}
@@ -267,7 +273,6 @@ class ConvertArgs {
}
}


class ListStyle {
LeftIcon1 leftIcon1;
LeftIcon1 leftIcon2;
@@ -276,32 +281,15 @@ class ListStyle {
BuyBubbleTip buyBubbleTip;
BuyBubbleTip buyShareTip;

ListStyle({this.leftIcon1,
this.leftIcon2,
this.rightIcon1,
this.rightIcon2,
this.buyBubbleTip,
this.buyShareTip});
ListStyle({this.leftIcon1, this.leftIcon2, this.rightIcon1, this.rightIcon2, this.buyBubbleTip, this.buyShareTip});

ListStyle.fromJson(Map<String, dynamic> json) {
leftIcon1 = json['left_icon1'] != null
? new LeftIcon1.fromJson(json['left_icon1'])
: null;
leftIcon2 = json['left_icon2'] != null
? new LeftIcon1.fromJson(json['left_icon2'])
: null;
rightIcon1 = json['right_icon1'] != null
? new RightIcon1.fromJson(json['right_icon1'])
: null;
rightIcon2 = json['right_icon2'] != null
? new RightIcon1.fromJson(json['right_icon2'])
: null;
buyBubbleTip = json['buy_bubble_tip'] != null
? new BuyBubbleTip.fromJson(json['buy_bubble_tip'])
: null;
buyShareTip = json['buy_share_tip'] != null
? new BuyBubbleTip.fromJson(json['buy_share_tip'])
: null;
leftIcon1 = json['left_icon1'] != null ? new LeftIcon1.fromJson(json['left_icon1']) : null;
leftIcon2 = json['left_icon2'] != null ? new LeftIcon1.fromJson(json['left_icon2']) : null;
rightIcon1 = json['right_icon1'] != null ? new RightIcon1.fromJson(json['right_icon1']) : null;
rightIcon2 = json['right_icon2'] != null ? new RightIcon1.fromJson(json['right_icon2']) : null;
buyBubbleTip = json['buy_bubble_tip'] != null ? new BuyBubbleTip.fromJson(json['buy_bubble_tip']) : null;
buyShareTip = json['buy_share_tip'] != null ? new BuyBubbleTip.fromJson(json['buy_share_tip']) : null;
}

Map<String, dynamic> toJson() {
@@ -328,7 +316,7 @@ class ListStyle {
}
}

class LeftIcon1 extends SkipModel{
class LeftIcon1 extends SkipModel {
String text;
String color;
String beforeIcon;
@@ -339,14 +327,7 @@ class LeftIcon1 extends SkipModel{
String isJump;
String isShow;

LeftIcon1({this.text,
this.color,
this.beforeIcon,
this.afterIcon,
this.skipIdentifier,
this.requiredLogin,
this.requiredTaobaoAuth,
this.isJump});
LeftIcon1({this.text, this.color, this.beforeIcon, this.afterIcon, this.skipIdentifier, this.requiredLogin, this.requiredTaobaoAuth, this.isJump});

LeftIcon1.fromJson(Map<String, dynamic> json) {
super.fromJson(json);
@@ -358,7 +339,7 @@ class LeftIcon1 extends SkipModel{
requiredLogin = json['required_login'];
requiredTaobaoAuth = json['required_taobao_auth'];
isJump = json['is_jump'];
isShow=json['is_show'];
isShow = json['is_show'];
}

Map<String, dynamic> toJson() {
@@ -384,12 +365,7 @@ class RightIcon1 {
List<String> sourceList;
String isShow;

RightIcon1({this.text,
this.color,
this.btnStr,
this.bgImage,
this.functionType,
this.sourceList});
RightIcon1({this.text, this.color, this.btnStr, this.bgImage, this.functionType, this.sourceList});

RightIcon1.fromJson(Map<String, dynamic> json) {
text = json['text'];
@@ -398,7 +374,7 @@ class RightIcon1 {
bgImage = json['bg_image'];
functionType = json['function_type'];
sourceList = json['source_list'].cast<String>();
isShow=json['is_show'];
isShow = json['is_show'];
}

Map<String, dynamic> toJson() {
@@ -422,13 +398,7 @@ class BuyBubbleTip {
String isShow;
List<String> sourceList;

BuyBubbleTip({this.textStr,
this.textColor,
this.priceIcon,
this.bgImage,
this.closeIcon,
this.isShow,
this.sourceList});
BuyBubbleTip({this.textStr, this.textColor, this.priceIcon, this.bgImage, this.closeIcon, this.isShow, this.sourceList});

BuyBubbleTip.fromJson(Map<String, dynamic> json) {
textStr = json['text_str'];


+ 28
- 20
lib/widgets/share/share_alert.dart Wyświetl plik

@@ -42,7 +42,6 @@ class _ShareAlertState extends State<ShareAlert> {
// }catch(e){
// print(e);
// }

}, onSuccess: (data) {
print(data);
_parseData(data);
@@ -107,6 +106,17 @@ class _ShareAlertContent extends StatefulWidget {
}

class _ShareAlertContentState extends State<_ShareAlertContent> {
@override
void initState() {
Future.delayed(Duration(milliseconds: 100), () async {
var status = await Permission.storage.status;
if (status != PermissionStatus.granted) {
status = await Permission.storage.request();
}
});
super.initState();
}

@override
Widget build(BuildContext context) {
return GestureDetector(
@@ -233,11 +243,8 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {

// mob分享,只能单图分享,多图分享调用系统分享
void _shareByMob(ShareSDKPlatform plateform) async {



Loading.show(context);
Timer(Duration(milliseconds: 2000),(){
Timer(Duration(milliseconds: 2000), () {
Loading.dismiss();
});

@@ -261,25 +268,24 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {
);
}
} else {
var type = SSDKContentTypes.auto;

var type=SSDKContentTypes.auto;

if(widget?.model?.image?.first!=null&&widget.model?.url!=null){
type=SSDKContentTypes.webpage;
}else if(widget?.model?.image?.first!=null){
type=SSDKContentTypes.image;
}else if(widget?.model?.title!=null||widget.model?.content!=null){
type=SSDKContentTypes.text;
if (widget?.model?.image?.first != null && widget.model?.url != null) {
type = SSDKContentTypes.webpage;
} else if (widget?.model?.image?.first != null) {
type = SSDKContentTypes.image;
} else if (widget?.model?.title != null || widget.model?.content != null) {
type = SSDKContentTypes.text;
}
if(plateform==ShareSDKPlatforms.qZone){
widget?.model?.title=null;
type=SSDKContentTypes.message;
if (plateform == ShareSDKPlatforms.qZone && type == SSDKContentTypes.text) {
widget?.model?.title = null;
type = SSDKContentTypes.message;
}

params = SSDKMap()
..setGeneral(
widget.model?.title ?? '',
widget?.model?.content??'',
widget?.model?.content ?? '',
Platform.isIOS ? widget.model.image : null,
Platform.isAndroid ? widget?.model?.image?.first : null,
null,
@@ -336,7 +342,7 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {
if (status != PermissionStatus.granted) {
status = await Permission.storage.request();
}
if (status == PermissionStatus.denied) {
if (status != PermissionStatus.granted) {
Fluttertoast.showToast(msg: '暂无权限,分享失败');
return null;
}
@@ -368,9 +374,11 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {
Loading.show(context);
List<String> downPaths = await ImageDownloadUtil.download(widget.model.image);
paths.addAll(downPaths);
if(Platform.isAndroid&&type=='wx'){
if (Platform.isAndroid && type == 'wx') {
MorePictureShare.shareWeixinPics(paths);
}else{
} else if (Platform.isAndroid && type == 'pyq') {
MorePictureShare.shareWeixinPicsCirlc(paths);
} else {
ShareExtend.shareMultiple(paths, "image", subject: "");
}
Loading.dismiss();


+ 1
- 1
lib/zhiying_base_widget.dart Wyświetl plik

@@ -3,4 +3,4 @@ library zhiying_base_widget;
export 'dialog/loading/loading.dart';
export 'package:flutter_swiper/flutter_swiper.dart';
export 'package:zhiying_base_widget/pages/main_page/model/background_model.dart';
export 'package:zhiying_base_widget/pages/custom_page/bloc/background_bloc.dart';
export 'package:zhiying_base_widget/pages/custom_page/bloc/background_bloc.dart';

+ 6
- 3
pubspec.yaml Wyświetl plik

@@ -15,13 +15,16 @@ dependencies:
bloc: ^4.0.0
event_bus: ^1.1.1
pull_to_refresh:
path: ../../1.22.0_master/flutter_pulltorefresh
git:
url: 'http://192.168.0.138:3000/FnuoOS_ZhiYing/flutter_pulltorefresh.git'
ref: '0.0.1'
flutter_cupertino_date_picker:
path: ../../1.22.0_master/flutter-cupertino-date-picker
git:
url: 'http://192.168.0.138:3000/FnuoOS_ZhiYing/flutter-cupertino-date-picker.git'
ref: '0.0.1'
image_picker: ^0.6.7+3
tab_indicator_styler: 1.0.0
connectivity: ^0.4.9+3
save_image: ^1.0.1
image_cropper:
git:
url: 'http://192.168.0.138:3000/FnuoOS_Flutter_Components/Image_Cropper.git'


Ładowanie…
Anuluj
Zapisz