Commit 2c92901135f5c3c0fb324022e6645580e6bd3b86

Authored by wdn127929
1 parent 7880d535

店铺信息页面上传闷头照片前进行裁剪为5:4

@@ -12,14 +12,14 @@ if (flutterRoot == null) { @@ -12,14 +12,14 @@ if (flutterRoot == null) {
12 } 12 }
13 13
14 14
15 -def flutterVersionCode = "444" 15 +def flutterVersionCode = "445"
16 if (flutterVersionCode == null) { 16 if (flutterVersionCode == null) {
17 - flutterVersionCode = '444' 17 + flutterVersionCode = '445'
18 } 18 }
19 19
20 -def flutterVersionName = "4.4.4" 20 +def flutterVersionName = "4.4.5"
21 if (flutterVersionName == null) { 21 if (flutterVersionName == null) {
22 - flutterVersionName = '4.4.4' 22 + flutterVersionName = '4.4.5'
23 } 23 }
24 apply plugin: 'com.android.application' 24 apply plugin: 'com.android.application'
25 apply plugin: 'kotlin-android' 25 apply plugin: 'kotlin-android'
@@ -597,9 +597,19 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> { @@ -597,9 +597,19 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> {
597 Future _getFromPictureOrCamera( 597 Future _getFromPictureOrCamera(
598 String title, UploadImgModel imgModel, imageSource) async { 598 String title, UploadImgModel imgModel, imageSource) async {
599 final pickedFile = await picker.getImage(source: imageSource); 599 final pickedFile = await picker.getImage(source: imageSource);
  600 +
  601 + //从相册选取照片后进行裁剪压缩
  602 + File yourFile = File(pickedFile.path);
  603 + Uint8List afterImg = await yourFile.readAsBytes();
  604 + Uint8List newImg = await Utils.testFromFileComporessList(context, afterImg);
  605 + String path = await Utils.saveImage(newImg);
  606 + if (path == null) {
  607 + path = pickedFile.path;
  608 + }
  609 + //更新本地存储,上传中展示
600 setState(() { 610 setState(() {
601 if (pickedFile != null) { 611 if (pickedFile != null) {
602 - imgModel.file = File(pickedFile.path); 612 + imgModel.file = File(path);
603 imgModel.process = 0.01; 613 imgModel.process = 0.01;
604 } else { 614 } else {
605 print('No image selected.'); 615 print('No image selected.');
@@ -607,119 +617,119 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> { @@ -607,119 +617,119 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> {
607 }); 617 });
608 if (pickedFile != null) { 618 if (pickedFile != null) {
609 _uploadImageProvider.mentou.qiniuUrl = null; 619 _uploadImageProvider.mentou.qiniuUrl = null;
610 - _uploadImageProvider.mentou.file = File(pickedFile.path);  
611 - _uploadImageProvider.mentou.path = pickedFile.path;  
612 - UploadImageUtil().startUploadOnly(  
613 - context, File(pickedFile.path), 2, true, _uploadImageProvider); 620 + _uploadImageProvider.mentou.file = File(path);
  621 + _uploadImageProvider.mentou.path = path;
  622 + UploadImageUtil()
  623 + .startUploadOnly(context, File(path), 2, true, _uploadImageProvider);
614 } 624 }
615 } 625 }
616 626
617 - ///图片 头像和二维码  
618 - Widget _imageWidget(  
619 - String title, UploadImgModel model, double imgSize, double radius) {  
620 - return InkWell(  
621 - onTap: () {  
622 - Utils.getPickPermission(context, () {  
623 - _getFromPictureOrCamera(title, model, ImageSource.gallery);  
624 - }, Platform.isAndroid ? Permission.storage : Permission.photos);  
625 - },  
626 - child: Container(  
627 - margin: EdgeInsets.only(  
628 - top: ScreenUtil().setWidth(40),  
629 - left: ScreenUtil().setWidth(40),  
630 - right: ScreenUtil().setWidth(40)),  
631 - height: ScreenUtil().setWidth(imgSize * 2),  
632 - child: Row(  
633 - mainAxisAlignment: MainAxisAlignment.spaceBetween,  
634 - children: [  
635 - Text(  
636 - title,  
637 - textAlign: TextAlign.left,  
638 - style: TextStyle(  
639 - color: MyColours.color_333333,  
640 - fontWeight: FontWeight.bold,  
641 - fontSize: ScreenUtil().setSp(34)),  
642 - ),  
643 - Spacer(),  
644 - Stack(  
645 - children: [  
646 - InkWell(  
647 - onTap: () {  
648 - double process;  
649 - String qiniuUrl;  
650 - List<String> tempList = [];  
651 -  
652 - process = _uploadImageProvider.mentou.process;  
653 - qiniuUrl = _uploadImageProvider.mentou.qiniuUrl;  
654 -  
655 - if (qiniuUrl != null && qiniuUrl != '') {  
656 - tempList.add(qiniuUrl);  
657 -  
658 - ///没有上传完成的不可以点击  
659 - _showPhotoView(context, 0, tempList);  
660 - } else {  
661 - Utils.getPickPermission(context, () {  
662 - _getFromPictureOrCamera(  
663 - title, model, ImageSource.gallery);  
664 - },  
665 - Platform.isAndroid  
666 - ? Permission.storage  
667 - : Permission.photos);  
668 - }  
669 - },  
670 - child: ClipRRect(  
671 - borderRadius:  
672 - BorderRadius.circular(ScreenUtil().setWidth(radius)),  
673 - child: model.file == null  
674 - ? model.qiniuUrl != null && model.qiniuUrl != ''  
675 - ? Image.network(  
676 - model.qiniuUrl,  
677 - fit: BoxFit.cover,  
678 - width: ScreenUtil().setWidth(imgSize * 2),  
679 - height: ScreenUtil().setWidth(imgSize * 2),  
680 - )  
681 - : Image.asset(  
682 - Utils.getImgPath('no_image'),  
683 - fit: BoxFit.cover,  
684 - width: ScreenUtil().setWidth(imgSize * 2),  
685 - height: ScreenUtil().setWidth(imgSize * 2),  
686 - )  
687 - : Image.file(  
688 - model.file,  
689 - fit: BoxFit.cover,  
690 - width: ScreenUtil().setWidth(imgSize * 2),  
691 - height: ScreenUtil().setWidth(imgSize * 2),  
692 - ),  
693 - ),  
694 - ),  
695 - (model.file != null) &&  
696 - model.process != 1 &&  
697 - model.process != 0.01  
698 - ? Container(  
699 - width: ScreenUtil().setWidth(imgSize * 2),  
700 - height: ScreenUtil().setWidth(imgSize * 2),  
701 - decoration: BoxDecoration(  
702 - borderRadius: BorderRadius.circular(radius),  
703 - color: Color.fromRGBO(0, 0, 0, 0.6)),  
704 - child: Center(  
705 - child: Text('上传中',  
706 - style:  
707 - TextStyle(color: MyColours.color_999999)),  
708 - ),  
709 - )  
710 - : Container(),  
711 - ],  
712 - ),  
713 - HEmptyView(30),  
714 - Image.asset(  
715 - "assets/arr_right_gray.png",  
716 - width: ScreenUtil().setWidth(14),  
717 - height: ScreenUtil().setWidth(22),  
718 - )  
719 - ],  
720 - ),  
721 - ));  
722 - } 627 + // ///图片 头像和二维码
  628 + // Widget _imageWidget(
  629 + // String title, UploadImgModel model, double imgSize, double radius) {
  630 + // return InkWell(
  631 + // onTap: () {
  632 + // Utils.getPickPermission(context, () {
  633 + // _getFromPictureOrCamera(title, model, ImageSource.gallery);
  634 + // }, Platform.isAndroid ? Permission.storage : Permission.photos);
  635 + // },
  636 + // child: Container(
  637 + // margin: EdgeInsets.only(
  638 + // top: ScreenUtil().setWidth(40),
  639 + // left: ScreenUtil().setWidth(40),
  640 + // right: ScreenUtil().setWidth(40)),
  641 + // height: ScreenUtil().setWidth(imgSize * 2),
  642 + // child: Row(
  643 + // mainAxisAlignment: MainAxisAlignment.spaceBetween,
  644 + // children: [
  645 + // Text(
  646 + // title,
  647 + // textAlign: TextAlign.left,
  648 + // style: TextStyle(
  649 + // color: MyColours.color_333333,
  650 + // fontWeight: FontWeight.bold,
  651 + // fontSize: ScreenUtil().setSp(34)),
  652 + // ),
  653 + // Spacer(),
  654 + // Stack(
  655 + // children: [
  656 + // InkWell(
  657 + // onTap: () {
  658 + // double process;
  659 + // String qiniuUrl;
  660 + // List<String> tempList = [];
  661 +
  662 + // process = _uploadImageProvider.mentou.process;
  663 + // qiniuUrl = _uploadImageProvider.mentou.qiniuUrl;
  664 +
  665 + // if (qiniuUrl != null && qiniuUrl != '') {
  666 + // tempList.add(qiniuUrl);
  667 +
  668 + // ///没有上传完成的不可以点击
  669 + // _showPhotoView(context, 0, tempList);
  670 + // } else {
  671 + // Utils.getPickPermission(context, () {
  672 + // _getFromPictureOrCamera(
  673 + // title, model, ImageSource.gallery);
  674 + // },
  675 + // Platform.isAndroid
  676 + // ? Permission.storage
  677 + // : Permission.photos);
  678 + // }
  679 + // },
  680 + // child: ClipRRect(
  681 + // borderRadius:
  682 + // BorderRadius.circular(ScreenUtil().setWidth(radius)),
  683 + // child: model.file == null
  684 + // ? model.qiniuUrl != null && model.qiniuUrl != ''
  685 + // ? Image.network(
  686 + // model.qiniuUrl,
  687 + // fit: BoxFit.cover,
  688 + // width: ScreenUtil().setWidth(imgSize * 2),
  689 + // height: ScreenUtil().setWidth(imgSize * 2),
  690 + // )
  691 + // : Image.asset(
  692 + // Utils.getImgPath('no_image'),
  693 + // fit: BoxFit.cover,
  694 + // width: ScreenUtil().setWidth(imgSize * 2),
  695 + // height: ScreenUtil().setWidth(imgSize * 2),
  696 + // )
  697 + // : Image.file(
  698 + // model.file,
  699 + // fit: BoxFit.cover,
  700 + // width: ScreenUtil().setWidth(imgSize * 2),
  701 + // height: ScreenUtil().setWidth(imgSize * 2),
  702 + // ),
  703 + // ),
  704 + // ),
  705 + // (model.file != null) &&
  706 + // model.process != 1 &&
  707 + // model.process != 0.01
  708 + // ? Container(
  709 + // width: ScreenUtil().setWidth(imgSize * 2),
  710 + // height: ScreenUtil().setWidth(imgSize * 2),
  711 + // decoration: BoxDecoration(
  712 + // borderRadius: BorderRadius.circular(radius),
  713 + // color: Color.fromRGBO(0, 0, 0, 0.6)),
  714 + // child: Center(
  715 + // child: Text('上传中',
  716 + // style:
  717 + // TextStyle(color: MyColours.color_999999)),
  718 + // ),
  719 + // )
  720 + // : Container(),
  721 + // ],
  722 + // ),
  723 + // HEmptyView(30),
  724 + // Image.asset(
  725 + // "assets/arr_right_gray.png",
  726 + // width: ScreenUtil().setWidth(14),
  727 + // height: ScreenUtil().setWidth(22),
  728 + // )
  729 + // ],
  730 + // ),
  731 + // ));
  732 + // }
723 733
724 ///地图地址选择 734 ///地图地址选择
725 Widget _select(String title, String hintText) { 735 Widget _select(String title, String hintText) {
@@ -1168,7 +1168,7 @@ class Utils { @@ -1168,7 +1168,7 @@ class Utils {
1168 String _userName = "gh_487873d353b3"; 1168 String _userName = "gh_487873d353b3";
1169 String _path = "pack-cookbook/pages/index?rid=$rid&identity=2&sid=$sid"; 1169 String _path = "pack-cookbook/pages/index?rid=$rid&identity=2&sid=$sid";
1170 String _description = "OneKey"; 1170 String _description = "OneKey";
1171 - Uint8List source = await testComporessList(context, _thumbnail); 1171 + // Uint8List source = await testComporessList(context, _thumbnail);
1172 var model = new WeChatShareMiniProgramModel( 1172 var model = new WeChatShareMiniProgramModel(
1173 webPageUrl: _webPageUrl, 1173 webPageUrl: _webPageUrl,
1174 userName: _userName, 1174 userName: _userName,
@@ -1176,10 +1176,9 @@ class Utils { @@ -1176,10 +1176,9 @@ class Utils {
1176 path: _path, 1176 path: _path,
1177 // thumbnail: WeChatImage.asset(Utils.getImgPath('mini_image')), 1177 // thumbnail: WeChatImage.asset(Utils.getImgPath('mini_image')),
1178 description: _description, 1178 description: _description,
1179 - thumbnail: WeChatImage.binary(source) 1179 + // thumbnail: WeChatImage.binary(source)
1180 1180
1181 - // thumbnail: WeChatImage.network(_thumbnail)  
1182 - ); 1181 + thumbnail: WeChatImage.network(_thumbnail));
1183 bool isShare = await shareToWeChat(model); 1182 bool isShare = await shareToWeChat(model);
1184 print(isShare); 1183 print(isShare);
1185 Loading.hideLoading(context); 1184 Loading.hideLoading(context);
@@ -1202,14 +1201,16 @@ class Utils { @@ -1202,14 +1201,16 @@ class Utils {
1202 String _path = 1201 String _path =
1203 "pack-cookbook/pages/success?rid=$rid&identity=2&hasOnlyShow=1"; 1202 "pack-cookbook/pages/success?rid=$rid&identity=2&hasOnlyShow=1";
1204 String _description = "OneKey"; 1203 String _description = "OneKey";
1205 - Uint8List source = await testComporessList(context, _thumbnail); 1204 + // Uint8List source = await testComporessList(context, _thumbnail);
1206 var model = new WeChatShareMiniProgramModel( 1205 var model = new WeChatShareMiniProgramModel(
1207 webPageUrl: _webPageUrl, 1206 webPageUrl: _webPageUrl,
1208 userName: _userName, 1207 userName: _userName,
1209 title: _title, 1208 title: _title,
1210 path: _path, 1209 path: _path,
1211 description: _description, 1210 description: _description,
1212 - thumbnail: WeChatImage.binary(source)); 1211 + thumbnail: WeChatImage.network(_thumbnail)
  1212 + // thumbnail: WeChatImage.binary(source)
  1213 + );
1213 bool isShare = await shareToWeChat(model); 1214 bool isShare = await shareToWeChat(model);
1214 print(isShare); 1215 print(isShare);
1215 Loading.hideLoading(context); 1216 Loading.hideLoading(context);
@@ -1280,6 +1281,24 @@ class Utils { @@ -1280,6 +1281,24 @@ class Utils {
1280 // } 1281 // }
1281 } 1282 }
1282 1283
  1284 + ///本地选择 图片压缩 Uint8List -> Uint8List
  1285 + static Future<Uint8List> testFromFileComporessList(
  1286 + BuildContext context, Uint8List list) async {
  1287 + Loading.showLoading(context);
  1288 +
  1289 + Uint8List result = await resizeImage(list); //重置图片尺寸
  1290 + Uint8List resultnew = await realComporessList(result); //压缩图片
  1291 +
  1292 + Loading.hideLoading(context);
  1293 + return resultnew;
  1294 + // if (result.length < 128 * 1024) {
  1295 + // return result;
  1296 + // } else {
  1297 + // result = await realComporessList(result);
  1298 + // return result;
  1299 + // }
  1300 + }
  1301 +
1283 /// 图片压缩 Uint8List -> Uint8List 1302 /// 图片压缩 Uint8List -> Uint8List
1284 static Future<Uint8List> testComporessList( 1303 static Future<Uint8List> testComporessList(
1285 BuildContext context, String url) async { 1304 BuildContext context, String url) async {
@@ -1371,13 +1390,34 @@ class Utils { @@ -1371,13 +1390,34 @@ class Utils {
1371 Uint8List afterImg = data; 1390 Uint8List afterImg = data;
1372 if (imgPath != null) { 1391 if (imgPath != null) {
1373 final croppedImage = await ImageCropper().cropImage( 1392 final croppedImage = await ImageCropper().cropImage(
1374 - sourcePath: imgPath,  
1375 - cropStyle: CropStyle.rectangle,  
1376 - compressQuality: 100,  
1377 - compressFormat: ImageCompressFormat.jpg,  
1378 - aspectRatioPresets: [CropAspectRatioPreset.ratio5x4],  
1379 - // aspectRatio: const CropAspectRatio(ratioX: 0.8, ratioY: 1.0)  
1380 - ); 1393 + sourcePath: imgPath,
  1394 + cropStyle: CropStyle.rectangle,
  1395 + compressQuality: 100,
  1396 + compressFormat: ImageCompressFormat.jpg,
  1397 + aspectRatioPresets: [CropAspectRatioPreset.ratio5x4],
  1398 + aspectRatio: const CropAspectRatio(ratioX: 5, ratioY: 4),
  1399 + uiSettings: [
  1400 + AndroidUiSettings(
  1401 + // toolbarTitle: 'Cropper',
  1402 + // toolbarColor: Colors.deepOrange,
  1403 + // toolbarWidgetColor: Colors.white,
  1404 + // initAspectRatio: CropAspectRatioPreset.ratio5x4,
  1405 +
  1406 + hideBottomControls: true,
  1407 + lockAspectRatio: true),
  1408 + IOSUiSettings(
  1409 + // title: 'Cropper',
  1410 + // rotateButtonsHidden: true,
  1411 + // rotateClockwiseButtonHidden: true,
  1412 + resetAspectRatioEnabled: false,
  1413 + doneButtonTitle: '确定',
  1414 + cancelButtonTitle: '取消',
  1415 + aspectRatioLockEnabled: true),
  1416 + // WebUiSettings(
  1417 + // context: context,
  1418 + // ),
  1419 + ],
  1420 + );
1381 print(croppedImage); 1421 print(croppedImage);
1382 File yourFile = File(croppedImage.path); 1422 File yourFile = File(croppedImage.path);
1383 1423
@@ -1462,7 +1502,7 @@ class Utils { @@ -1462,7 +1502,7 @@ class Utils {
1462 String _path = 1502 String _path =
1463 "pages/customer/index?id=$rid&hasInvitation=1&hasSellerShare=1&uid=$uid"; 1503 "pages/customer/index?id=$rid&hasInvitation=1&hasSellerShare=1&uid=$uid";
1464 String _description = "进入查看包间详情,转发同行好友,还可一键导航到饭店"; 1504 String _description = "进入查看包间详情,转发同行好友,还可一键导航到饭店";
1465 - Uint8List source = await testComporessList(context, _thumbnail); 1505 + // Uint8List source = await testComporessList(context, _thumbnail);
1466 1506
1467 //跳转小程序 1507 //跳转小程序
1468 var model = new WeChatShareMiniProgramModel( 1508 var model = new WeChatShareMiniProgramModel(
@@ -1471,8 +1511,8 @@ class Utils { @@ -1471,8 +1511,8 @@ class Utils {
1471 title: _title, 1511 title: _title,
1472 path: _path, 1512 path: _path,
1473 description: _description, 1513 description: _description,
1474 - thumbnail: WeChatImage.binary(source)  
1475 - // thumbnail: WeChatImage.network(_thumbnail) 1514 + // thumbnail: WeChatImage.binary(source)
  1515 + thumbnail: WeChatImage.network(_thumbnail)
1476 // thumbnail: WeChatImage.binary(image) 1516 // thumbnail: WeChatImage.binary(image)
1477 ); 1517 );
1478 //分享链接 1518 //分享链接
@@ -177,7 +177,6 @@ dependencies: @@ -177,7 +177,6 @@ dependencies:
177 flutter_ex_widget: ^0.0.7 177 flutter_ex_widget: ^0.0.7
178 crypto: ^3.0.1 178 crypto: ^3.0.1
179 flutter_keyboard_visibility: ^5.3.0 179 flutter_keyboard_visibility: ^5.3.0
180 - #  
181 extended_text_field: ^10.1.1 180 extended_text_field: ^10.1.1
182 image_gallery_saver: ^1.7.1 181 image_gallery_saver: ^1.7.1
183 flutter_image_compress: ^1.1.3 182 flutter_image_compress: ^1.1.3