@@ -614,7 +614,7 @@ | |||||
"languageVersion": "2.1" | "languageVersion": "2.1" | ||||
} | } | ||||
], | ], | ||||
"generated": "2020-10-13T02:42:36.621853Z", | |||||
"generated": "2020-10-13T08:45:20.936142Z", | |||||
"generator": "pub", | "generator": "pub", | ||||
"generatorVersion": "2.8.2" | "generatorVersion": "2.8.2" | ||||
} | } |
@@ -92,50 +92,50 @@ android { | |||||
// | // | ||||
// // 签名配置 | // // 签名配置 | ||||
signingConfigs { | |||||
// 智夜生活 | |||||
zhiying { | |||||
storeFile file('zhiying.jks') | |||||
storePassword 'zhioscom' | |||||
keyAlias 'zysh' | |||||
keyPassword 'zhioscom' | |||||
v1SigningEnabled true | |||||
v2SigningEnabled true | |||||
} | |||||
} | |||||
flavorDimensions "app" | |||||
// 应用信息配置 | |||||
productFlavors { | |||||
// 智夜生活 | |||||
zhiying { | |||||
applicationId "cn.zhios.zhiying" | |||||
versionCode 1 | |||||
dimension "app" | |||||
versionName '1.0.0' | |||||
// 签名信息 | |||||
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") | |||||
} | |||||
// signingConfigs { | |||||
// // 智夜生活 | |||||
// zhiying { | |||||
// storeFile file('zhiying.jks') | |||||
// storePassword 'zhioscom' | |||||
// keyAlias 'zysh' | |||||
// keyPassword 'zhioscom' | |||||
// v1SigningEnabled true | |||||
// v2SigningEnabled true | |||||
// } | |||||
// | |||||
// } | |||||
// | |||||
// flavorDimensions "app" | |||||
// | |||||
// | |||||
// // 应用信息配置 | |||||
// productFlavors { | |||||
// // 智夜生活 | |||||
// zhiying { | |||||
// applicationId "cn.zhios.zhiying" | |||||
// versionCode 1 | |||||
// dimension "app" | |||||
// versionName '1.0.0' | |||||
// // 签名信息 | |||||
// signingConfig signingConfigs.zhiying | |||||
// } | |||||
// } | |||||
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 | |||||
} | |||||
} | |||||
} | |||||
// // 打包脚本 | |||||
// 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 { | configurations.all { | ||||
resolutionStrategy.eachDependency { DependencyResolveDetails details -> | resolutionStrategy.eachDependency { DependencyResolveDetails details -> | ||||
@@ -24,6 +24,8 @@ import 'package:zhiying_base_widget/widgets/public/custom_button/custom_button_m | |||||
import 'package:zhiying_base_widget/widgets/share/models/share_data_model.dart'; | import 'package:zhiying_base_widget/widgets/share/models/share_data_model.dart'; | ||||
import 'package:zhiying_base_widget/widgets/share/share_alert.dart'; | import 'package:zhiying_base_widget/widgets/share/share_alert.dart'; | ||||
import 'package:permission_handler/permission_handler.dart'; | |||||
class GoodsShareImage extends StatefulWidget { | class GoodsShareImage extends StatefulWidget { | ||||
final Map<String, dynamic> model; | final Map<String, dynamic> model; | ||||
final GoodsShareTempDataModel datas; | final GoodsShareTempDataModel datas; | ||||
@@ -195,51 +197,51 @@ class _GoodsShareImageState extends State<GoodsShareImage> | |||||
btnCopy == null | btnCopy == null | ||||
? Container() | ? Container() | ||||
: GestureDetector( | : GestureDetector( | ||||
child: Container( | |||||
width: 95, | |||||
height: 36, | |||||
decoration: BoxDecoration( | |||||
borderRadius: BorderRadius.circular(18), | |||||
), | |||||
child: CustomButton(btnCopy)), | |||||
onTap: () { | |||||
Clipboard.setData(ClipboardData(text: _content)); | |||||
Fluttertoast.showToast(msg: '文案已复制'); | |||||
}, | |||||
child: Container( | |||||
width: 95, | |||||
height: 36, | |||||
decoration: BoxDecoration( | |||||
borderRadius: BorderRadius.circular(18), | |||||
), | ), | ||||
child: CustomButton(btnCopy)), | |||||
onTap: () { | |||||
Clipboard.setData(ClipboardData(text: _content)); | |||||
Fluttertoast.showToast(msg: '文案已复制'); | |||||
}, | |||||
), | |||||
btnSave == null | btnSave == null | ||||
? Container() | ? Container() | ||||
: GestureDetector( | : GestureDetector( | ||||
child: Container( | |||||
margin: EdgeInsets.only(left: 5), | |||||
width: 95, | |||||
height: 36, | |||||
decoration: BoxDecoration( | |||||
borderRadius: BorderRadius.circular(18), | |||||
), | |||||
child: CustomButton(btnSave), | |||||
), | |||||
onTap: () { | |||||
_saveImages(); | |||||
}, | |||||
), | |||||
child: Container( | |||||
margin: EdgeInsets.only(left: 5), | |||||
width: 95, | |||||
height: 36, | |||||
decoration: BoxDecoration( | |||||
borderRadius: BorderRadius.circular(18), | |||||
), | |||||
child: CustomButton(btnSave), | |||||
), | |||||
onTap: () { | |||||
_saveImages(); | |||||
}, | |||||
), | |||||
btnShare == null | btnShare == null | ||||
? Container() | ? Container() | ||||
: Expanded( | : Expanded( | ||||
child: GestureDetector( | |||||
child: Container( | |||||
margin: EdgeInsets.only(left: 5), | |||||
// width: 95, | |||||
height: 36, | |||||
decoration: BoxDecoration( | |||||
borderRadius: BorderRadius.circular(18), | |||||
), | |||||
child: CustomButton(btnShare)), | |||||
onTap: () { | |||||
_showShareAlert(); | |||||
}, | |||||
child: GestureDetector( | |||||
child: Container( | |||||
margin: EdgeInsets.only(left: 5), | |||||
// width: 95, | |||||
height: 36, | |||||
decoration: BoxDecoration( | |||||
borderRadius: BorderRadius.circular(18), | |||||
), | ), | ||||
), | |||||
child: CustomButton(btnShare)), | |||||
onTap: () { | |||||
_showShareAlert(); | |||||
}, | |||||
), | |||||
), | |||||
], | ], | ||||
), | ), | ||||
), | ), | ||||
@@ -266,6 +268,17 @@ class _GoodsShareImageState extends State<GoodsShareImage> | |||||
Fluttertoast.showToast(msg: '请选择要保存的图片'); | Fluttertoast.showToast(msg: '请选择要保存的图片'); | ||||
return; | return; | ||||
} | } | ||||
//检查是否有存储权限 | |||||
var status = await Permission.photos.status; | |||||
if (status != PermissionStatus.granted) { | |||||
status = await Permission.photos.request(); | |||||
} | |||||
if (status == PermissionStatus.denied) { | |||||
Fluttertoast.showToast(msg: '暂无权限,保存失败'); | |||||
return null; | |||||
} | |||||
bool isSaveSuccess = false; | bool isSaveSuccess = false; | ||||
if (_shareModel.poster != null) { | if (_shareModel.poster != null) { | ||||
isSaveSuccess = await SaveImage.save(imageBytes: _shareModel.poster); | isSaveSuccess = await SaveImage.save(imageBytes: _shareModel.poster); | ||||
@@ -290,7 +303,7 @@ class _GoodsShareImageState extends State<GoodsShareImage> | |||||
ui.Image image = await boundary.toImage(pixelRatio: 2.0); | ui.Image image = await boundary.toImage(pixelRatio: 2.0); | ||||
// 注意:png是压缩后格式,如果需要图片的原始像素数据,请使用rawRgba | // 注意:png是压缩后格式,如果需要图片的原始像素数据,请使用rawRgba | ||||
ByteData byteData = | ByteData byteData = | ||||
await image.toByteData(format: ui.ImageByteFormat.png); | |||||
await image.toByteData(format: ui.ImageByteFormat.png); | |||||
Uint8List pngBytes = byteData.buffer.asUint8List(); | Uint8List pngBytes = byteData.buffer.asUint8List(); | ||||
_shareModel.poster = pngBytes; | _shareModel.poster = pngBytes; | ||||
} | } | ||||
@@ -327,11 +340,12 @@ class _GoodsShareImageState extends State<GoodsShareImage> | |||||
showCupertinoModalPopup( | showCupertinoModalPopup( | ||||
context: context, | context: context, | ||||
builder: (context) => ShareAlert( | |||||
_shareModel, | |||||
'pub.flutter.share_icon', | |||||
// child: GoodsShareAlertContent(), | |||||
), | |||||
builder: (context) => | |||||
ShareAlert( | |||||
_shareModel, | |||||
'pub.flutter.share_icon', | |||||
// child: GoodsShareAlertContent(), | |||||
), | |||||
); | ); | ||||
} | } | ||||
} | } |
@@ -3,6 +3,7 @@ class GoodsSharePosterModel { | |||||
String avatar; | String avatar; | ||||
String title; | String title; | ||||
String provider; | String provider; | ||||
String providerName; | |||||
String posterImage; | String posterImage; | ||||
String inviteCode; | String inviteCode; | ||||
String couponPrice; | String couponPrice; | ||||
@@ -15,6 +16,7 @@ class GoodsSharePosterModel { | |||||
this.avatar, | this.avatar, | ||||
this.title, | this.title, | ||||
this.provider, | this.provider, | ||||
this.providerName, | |||||
this.posterImage, | this.posterImage, | ||||
this.inviteCode, | this.inviteCode, | ||||
this.couponPrice, | this.couponPrice, | ||||
@@ -27,6 +29,7 @@ class GoodsSharePosterModel { | |||||
avatar = json['avatar']; | avatar = json['avatar']; | ||||
title = json['title']; | title = json['title']; | ||||
provider = json['provider']; | provider = json['provider']; | ||||
providerName = json['provider_name']; | |||||
posterImage = json['poster_image']; | posterImage = json['poster_image']; | ||||
inviteCode = json['invite_code']; | inviteCode = json['invite_code']; | ||||
couponPrice = json['coupon_price']; | couponPrice = json['coupon_price']; | ||||
@@ -41,6 +44,7 @@ class GoodsSharePosterModel { | |||||
data['avatar'] = this.avatar; | data['avatar'] = this.avatar; | ||||
data['title'] = this.title; | data['title'] = this.title; | ||||
data['provider'] = this.provider; | data['provider'] = this.provider; | ||||
data['provider_name'] = this.providerName; | |||||
data['poster_image'] = this.posterImage; | data['poster_image'] = this.posterImage; | ||||
data['invite_code'] = this.inviteCode; | data['invite_code'] = this.inviteCode; | ||||
data['coupon_price'] = this.couponPrice; | data['coupon_price'] = this.couponPrice; | ||||
@@ -156,7 +156,7 @@ class GoodsShareTemplate extends StatelessWidget { | |||||
padding: EdgeInsets.only(left: 2, right: 2, top: 3, bottom: 3), | padding: EdgeInsets.only(left: 2, right: 2, top: 3, bottom: 3), | ||||
margin: EdgeInsets.only(right: 4), | margin: EdgeInsets.only(right: 4), | ||||
child: Text( | child: Text( | ||||
model?.provider ?? '', | |||||
model?.providerName ?? '', | |||||
style: TextStyle( | style: TextStyle( | ||||
fontSize: 9, | fontSize: 9, | ||||
height: 1, | height: 1, | ||||
@@ -66,10 +66,10 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { | |||||
void initState() { | void initState() { | ||||
NetUtil.request('/api/v1/mod/${widget.skipIdentifier}', | NetUtil.request('/api/v1/mod/${widget.skipIdentifier}', | ||||
method: NetMethod.GET, onCache: (data) { | method: NetMethod.GET, onCache: (data) { | ||||
_parseData(data); | |||||
}, onSuccess: (data) { | |||||
_parseData(data); | |||||
}, onError: (err) {}); | |||||
_parseData(data); | |||||
}, onSuccess: (data) { | |||||
_parseData(data); | |||||
}, onError: (err) {}); | |||||
super.initState(); | super.initState(); | ||||
} | } | ||||
@@ -121,7 +121,7 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { | |||||
), | ), | ||||
Container( | Container( | ||||
margin: | margin: | ||||
EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10), | |||||
EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10), | |||||
child: _createIcons(), | child: _createIcons(), | ||||
), | ), | ||||
GestureDetector( | GestureDetector( | ||||
@@ -229,50 +229,30 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { | |||||
} | } | ||||
SSDKMap params; | SSDKMap params; | ||||
if (widget.model.poster != null) { | 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); | |||||
Logger.debug(file.path); | |||||
String path = await _savePoster(); | |||||
if (path != null && path != '') { | |||||
params = SSDKMap() | params = SSDKMap() | ||||
..setGeneral( | ..setGeneral( | ||||
widget.model.title, | |||||
widget.model.content, | |||||
file.path, | |||||
widget.model?.title ?? '', | |||||
widget.model?.content ?? '', | |||||
Platform.isIOS ? path : null, | |||||
null, | null, | ||||
Platform.isAndroid ? path : null, | |||||
null, | null, | ||||
widget.model.url, | |||||
null, | null, | ||||
null, | null, | ||||
null, | null, | ||||
null, | null, | ||||
SSDKContentTypes.auto, | |||||
SSDKContentTypes.image, | |||||
); | ); | ||||
} catch (err, s) { | |||||
Logger.error(err.toString(), s.toString()); | |||||
Fluttertoast.showToast(msg: '分享失败'); | |||||
return; | |||||
} | } | ||||
} else { | } else { | ||||
params = SSDKMap() | params = SSDKMap() | ||||
..setGeneral( | ..setGeneral( | ||||
widget.model.title, | |||||
widget.model.content, | |||||
widget.model.image, | |||||
null, | |||||
widget.model?.title ?? '', | |||||
widget.model?.content ?? '', | |||||
Platform.isIOS ? widget.model.image : null, | |||||
Platform.isAndroid ? widget.model.image.first : null, | |||||
null, | null, | ||||
widget.model.url, | widget.model.url, | ||||
null, | null, | ||||
@@ -291,17 +271,29 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { | |||||
// 系统分享,只能分享图片或者文字,不能组合分享 | // 系统分享,只能分享图片或者文字,不能组合分享 | ||||
void _shareBySystem() async { | void _shareBySystem() async { | ||||
if (widget.model.image.length >= 1) { | |||||
int count = 0; | |||||
if (widget.model.poster != null) { | |||||
count++; | |||||
} | |||||
count += (widget.model?.image?.length ?? 0); | |||||
// 多图分享 | |||||
if (count > 1) { | |||||
_shareMultipleImages(); | _shareMultipleImages(); | ||||
return; | return; | ||||
} | |||||
if (widget.model.poster != null) { | |||||
String path = await _savePoster(); | |||||
if (path != null && path != '') { | |||||
ShareExtend.share(path, 'image'); | |||||
} | |||||
} else { | } else { | ||||
ShareExtend.share(widget.model.content, 'text'); | ShareExtend.share(widget.model.content, 'text'); | ||||
} | } | ||||
} | } | ||||
// 多图分享,调用系统分享 | |||||
void _shareMultipleImages() async { | |||||
List<String> paths = List(); | |||||
Future<String> _savePoster() async { | |||||
String path; | |||||
if (widget.model.poster != null) { | if (widget.model.poster != null) { | ||||
// 检查并请求权限 | // 检查并请求权限 | ||||
var status = await Permission.storage.status; | var status = await Permission.storage.status; | ||||
@@ -310,7 +302,7 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { | |||||
} | } | ||||
if (status == PermissionStatus.denied) { | if (status == PermissionStatus.denied) { | ||||
Fluttertoast.showToast(msg: '暂无权限,分享失败'); | Fluttertoast.showToast(msg: '暂无权限,分享失败'); | ||||
return; | |||||
return null; | |||||
} | } | ||||
try { | try { | ||||
@@ -319,17 +311,27 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { | |||||
final file = await File('${tempDir.path}/image.jpg').create(); | final file = await File('${tempDir.path}/image.jpg').create(); | ||||
file.writeAsBytesSync(widget.model.poster); | file.writeAsBytesSync(widget.model.poster); | ||||
paths.add(file.path); | |||||
path = file.path; | |||||
Logger.debug(file.path); | Logger.debug(file.path); | ||||
} catch (err, s) { | } catch (err, s) { | ||||
Logger.error(err.toString(), s.toString()); | Logger.error(err.toString(), s.toString()); | ||||
Fluttertoast.showToast(msg: '分享失败'); | Fluttertoast.showToast(msg: '分享失败'); | ||||
return; | |||||
return null; | |||||
} | } | ||||
} | } | ||||
return path; | |||||
} | |||||
// 多图分享,调用系统分享 | |||||
void _shareMultipleImages() async { | |||||
List<String> paths = List(); | |||||
String path = await _savePoster(); | |||||
if (path != null && path != '') { | |||||
paths.add(path); | |||||
} | |||||
List<String> downPaths = | List<String> downPaths = | ||||
await ImageDownloadUtil.download(widget.model.image); | |||||
await ImageDownloadUtil.download(widget.model.image); | |||||
paths.addAll(downPaths); | paths.addAll(downPaths); | ||||
ShareExtend.shareMultiple(paths, "image", subject: ""); | ShareExtend.shareMultiple(paths, "image", subject: ""); | ||||
} | } | ||||