img_picker_widget.dart 27.2 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684
import 'dart:convert';

import 'dart:io';
import 'dart:async';

import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/upload_img_model.dart';
import 'package:one_key/pages/online_check/photo_view_wiget.dart';
import 'package:one_key/pages/online_check/progress.dart';

import 'package:one_key/provider/online_check_edit_provider.dart';
import 'package:one_key/provider/upload_img_provider.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/dialog_util.dart';
import 'package:one_key/utils/misc.dart';
import 'package:one_key/utils/upload_image_util.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/MyDivider.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:permission_handler/permission_handler.dart';
// import 'package:photo/photo.dart';
import 'package:provider/provider.dart';

import 'package:image_picker/image_picker.dart';
// import 'package:qiniu_flutter_sdk/qiniu_flutter_sdk.dart';
import 'package:qiniu_flutter_sdk_diox/qiniu_flutter_sdk_diox.dart';
import 'package:wechat_assets_picker/wechat_assets_picker.dart';
import './dispose.dart';
import 'package:photo_manager/photo_manager.dart';
import 'package:flutter_native_image/flutter_native_image.dart';

typedef void OnPickImageCallback(
    double maxWidth, double maxHeight, int quality);
typedef void DeleteCallback(int index);

class ImgPickerWidget extends StatefulWidget {
  final ScrollController scrollController;
  final Color borderColor;
  final VoidCallback callback;
  final int maxImageNumber;
  final UploadImageProvider model;
  final UploadType uploadType;
  final DeleteCallback deleteCallback;
  final String maxRemind;
  final List<UploadImgModel> imageList;
  ImgPickerWidget(
      {Key key,
      this.scrollController,
      this.borderColor = Colors.blue,
      this.callback,
      this.maxImageNumber = 5,
      this.model,
      this.uploadType,
      this.deleteCallback,
      this.maxRemind,
      this.imageList})
      : super(key: key);

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

class _ImgPickerWidgetState extends DisposableState<ImgPickerWidget> {
  final picker = ImagePicker();
  // OnlineCheckEditProvider _onlineCheckEditProvider;
  // UploadImageProvider _uploadImageProvider;

  // 用户输入的文件名
  String key;
  // 用户输入的 partSize
  int partSize = 4;
  // 用户输入的 token
  String token;

  /// storage 实例
  final Storage storage = Storage();
  // 控制器,可以用于取消任务、获取上述的状态,进度等信息
  //  PutController putController = PutController();
  // 当前的任务状态

  @override
  void initState() {
    // storage = Storage();
    // putController = PutController();
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  ///#相机拍照,单图选择
  Future _getFromPictureOrCamera(imageSource) async {
    final pickedFile = await picker.pickImage(
        source: imageSource, preferredCameraDevice: CameraDevice.rear);

    //从相册选取照片后进行裁剪压缩
    File yourFile = File(pickedFile.path);
    Uint8List afterImg = await yourFile.readAsBytes();
    Uint8List newImg = await Utils.testFromFileComporessList(context, afterImg);
    String path = await Utils.saveImage(newImg);
    if (path == null) {
      File compressedFile = await FlutterNativeImage.compressImage(
          yourFile.path,
          quality: 50,
          percentage: 50);
      path = compressedFile.path;
    }

    setState(() {
      if (pickedFile != null) {
        UploadImgModel imgModel = UploadImgModel();
        imgModel.file = File(path);
        imgModel.process = 0.01;
        if (widget.uploadType == UploadType.ConsumptionUploadType) {
          widget.model.imageList.add(imgModel);
        } else if (widget.uploadType == UploadType.StoreFrontUploadType) {
          widget.model.imageListFront.add(imgModel);
        } else if (widget.uploadType == UploadType.EnvironmentUploadType) {
          widget.model.imageListDenvironment.add(imgModel);
        } else if (widget.uploadType == UploadType.TableManagerType) {
          widget.model.tableImageList.add(imgModel);
        } else if (widget.uploadType == UploadType.WineManageType) {
          widget.imageList.add(imgModel);
        } else if (widget.uploadType == UploadType.CouponDishType) {
          widget.imageList.add(imgModel);
        } else if (widget.uploadType == UploadType.RemarkImagesType) {
          widget.imageList.add(imgModel);
        }
      } else {
        print('No image selected.');
      }
    });
    if (pickedFile != null) {
      List<UploadImgModel> temp = [];

      if (widget.uploadType == UploadType.ConsumptionUploadType) {
        temp = widget.model.imageList;
      } else if (widget.uploadType == UploadType.StoreFrontUploadType) {
        temp = widget.model.imageListFront;
      } else if (widget.uploadType == UploadType.EnvironmentUploadType) {
        temp = widget.model.imageListDenvironment;
      } else if (widget.uploadType == UploadType.TableManagerType) {
        temp = widget.model.tableImageList;
      } else if (widget.uploadType == UploadType.WineManageType) {
        temp = widget.imageList;
      } else if (widget.uploadType == UploadType.CouponDishType) {
        temp = widget.imageList;
      } else if (widget.uploadType == UploadType.RemarkImagesType) {
        temp = widget.imageList;
      }
      bool need = await Utils.sizeNeed(File(pickedFile.path));
      File file = File(pickedFile.path);
      if (need) {
        file = File(path);
      }
      UploadImageUtil().startUpload(
          context, file, temp.length - 1, true, widget.model, widget.uploadType,
          callback: widget.callback, countAll: 1, imageList: widget.imageList);
    }
  }

  ///多图片选择
  void pickAsset(RequestType type, {List<AssetPathEntity> pathList}) async {
    List<UploadImgModel> temp = [];
    if (widget.uploadType == UploadType.ConsumptionUploadType) {
      temp = widget.model.imageList;
    } else if (widget.uploadType == UploadType.StoreFrontUploadType) {
      temp = widget.model.imageListFront;
    } else if (widget.uploadType == UploadType.EnvironmentUploadType) {
      temp = widget.model.imageListDenvironment;
    } else if (widget.uploadType == UploadType.TableManagerType) {
      temp = widget.model.tableImageList;
    } else if (widget.uploadType == UploadType.WineManageType) {
      temp = widget.imageList;
    } else if (widget.uploadType == UploadType.CouponDishType) {
      temp = widget.imageList;
    } else if (widget.uploadType == UploadType.RemarkImagesType) {
      temp = widget.imageList;
    }
    List<AssetEntity> imgList = await AssetPicker.pickAssets(context,
        pickerConfig: AssetPickerConfig(
            maxAssets: widget.maxImageNumber - temp.length,
            // selectedAssets: assets,
            requestType: type,
            themeColor: MyColours.color_199095));

    /// context is required, other params is optional.
    // List<AssetEntity> imgList = await PhotoPicker.pickAsset(
    //   // BuildContext required
    //   context: context,

    //   /// The following are optional parameters.
    //   themeColor: MyColours.color_199095,
    //   // the title color and bottom color
    //   textColor: Colors.white,
    //   // text color
    //   padding: 1.0,
    //   // item padding
    //   dividerColor: Colors.grey,
    //   // divider color
    //   disableColor: Colors.grey.shade300,
    //   // the check box disable color
    //   itemRadio: 0.88,
    //   // the content item radio
    //   maxSelected: widget.maxImageNumber - temp.length,
    //   // max picker image count
    //   // provider: I18nProvider.english,
    //   provider: I18nProvider.chinese,
    //   // i18n provider ,default is chinese. , you can custom I18nProvider or use ENProvider()
    //   rowCount: 3,
    //   // item row count
    //   thumbSize: 150,
    //   // preview thumb size , default is 64
    //   sortDelegate: SortDelegate.common,
    //   // default is common ,or you make custom delegate to sort your gallery
    //   checkBoxBuilderDelegate: DefaultCheckBoxBuilderDelegate(
    //     activeColor: MyColours.color_353535,
    //     unselectedColor: Colors.white,
    //     checkColor: MyColours.color_199095,
    //   ),
    //   // default is DefaultCheckBoxBuilderDelegate ,or you make custom delegate to create checkbox
    //   // loadingDelegate: this,
    //   // if you want to build custom loading widget,extends LoadingDelegate, [see example/lib/main.dart]
    //   badgeDelegate: const DurationBadgeDelegate(),
    //   // badgeDelegate to show badge widget
    //   pickType: type,
    //   photoPathList: pathList,
    // );
    if (imgList == null || imgList.isEmpty) {
      print("No pick item.");
      return;
    } else {
      for (int i = 0; i < imgList.length; i++) {
        var file = await imgList[i].file;
        //从相册选取照片后进行裁剪压缩
        File yourFile = file;
        Uint8List afterImg = await yourFile.readAsBytes();
        Uint8List newImg =
            await Utils.testFromFileComporessList(context, afterImg);
        String path = await Utils.saveImage(newImg);
        // File compressedFile;
        if (path == null) {
          File compressedFile = await FlutterNativeImage.compressImage(
              file.path,
              quality: 50,
              percentage: 50);
          path = compressedFile.path;
        }
        // File compressedFile = await FlutterNativeImage.compressImage(
        //     file.absolute.path,
        //     quality: 50,
        //     percentage: 50);
        setState(() {
          UploadImgModel imgModel = UploadImgModel();
          imgModel.file = File(path);
          imgModel.process = 0.01;

          temp.add(imgModel);
        });
        bool need = await Utils.sizeNeed(file);

        if (need) {
          file = File(path);
        }
        UploadImageUtil().startUpload(context, File(path), temp.length - 1,
            false, widget.model, widget.uploadType,
            countAll: imgList.length,
            callback: widget.callback,
            imageList: widget.imageList);
        // startUpload(File(file.absolute.path),
        //     _uploadImageProvider.imageList.length - 1, false);
      }
    }
  }

  // ///上传到七牛云
  // void startUpload(File selectedFile, int index, bool needInit) async {
  //   final PutController putController = PutController();
  //   print(index);

  //   // 添加状态监听
  //   putController.addStatusListener((StorageStatus status) {
  //     print('状态变化: 当前任务状态:${status.toString()}');
  //   });
  //   // 添加整体进度监听
  //   putController.addProgressListener((percent) {
  //     print('${index}任务进度变化:进度:${percent.toStringAsFixed(4)}');
  //     _uploadImageProvider.imageList[index].process = percent;
  //     _uploadImageProvider.notifyListeners();
  //   });
  //   // 添加实际发送进度订阅
  //   putController.addSendProgressListener((percent) {
  //     // _onlineCheckEditProvider.imageList[index].process = percent;
  //     // setState(() {});
  //     print('${index}实际发送变化:进度:${percent.toStringAsFixed(4)}');
  //   });
  //   if (token == null || token == '') {
  //     await _uploadImageProvider.getQiniuInfo(context, {});
  //   }
  //   var usedToken = _uploadImageProvider.qiniuInfoSunModel.token;
  //   if (usedToken == null || usedToken == '') {
  //     print('token 不能为空');
  //     return;
  //   }
  //   print('开始上传文件');
  //   storage.putFile(
  //     selectedFile,
  //     usedToken,
  //     options: PutOptions(
  //       key: key,
  //       partSize: partSize,
  //       controller: putController,
  //     ),
  //   )
  //     ..then((PutResponse response) {
  //       print('${index}上传已完成: 原始响应数据: ${jsonEncode(response.rawData)}');
  //       print('------------------------');
  //       String imgUrl = _uploadImageProvider.qiniuInfoSunModel.domain +
  //           '/' +
  //           response.rawData['key'];
  //       _uploadImageProvider.imageList[index].process = 1;
  //       _uploadImageProvider.imageList[index].qiniuUrl = imgUrl;
  //       // 取消当前任务
  //       putController.cancel();
  //       // _image
  //       _uploadImageProvider.notifyListeners();
  //     })
  //     ..catchError((dynamic error) {
  //       if (error is StorageError) {
  //         switch (error.type) {
  //           case StorageErrorType.CONNECT_TIMEOUT:
  //             print('发生错误: 连接超时');
  //             break;
  //           case StorageErrorType.SEND_TIMEOUT:
  //             print('发生错误: 发送数据超时');
  //             break;
  //           case StorageErrorType.RECEIVE_TIMEOUT:
  //             print('发生错误: 响应数据超时');
  //             break;
  //           case StorageErrorType.RESPONSE:
  //             print('发生错误: ${error.message}');
  //             break;
  //           case StorageErrorType.CANCEL:
  //             print('发生错误: 请求取消');
  //             break;
  //           case StorageErrorType.UNKNOWN:
  //             print('发生错误: 未知错误');
  //             break;
  //           case StorageErrorType.NO_AVAILABLE_HOST:
  //             print('发生错误: 无可用 Host');
  //             break;
  //           case StorageErrorType.IN_PROGRESS:
  //             print('发生错误: 已在队列中');
  //             break;
  //         }
  //       } else {
  //         print('发生错误: ${error.toString()}');
  //       }

  //       print('------------------------');
  //     });
  // }

  ///添加图片UI弹出
  Future _openModalBottomSheet(context) async {
    final option = await showModalBottomSheet(
        context: context,
        backgroundColor: Colors.transparent,
        isDismissible: false,
        builder: (BuildContext context) {
          return Container(
            // height: ScreenUtil().setWidth(180 * 2),
            decoration: BoxDecoration(
                color: MyColours.color_ffffff,
                borderRadius: BorderRadius.only(
                    topLeft: Radius.circular(ScreenUtil().setWidth(24)),
                    topRight: Radius.circular(ScreenUtil().setWidth(24)))),
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: <Widget>[
                InkWell(
                  onTap: () {
                    Utils.getPickPermission(context, () {
                      _getFromPictureOrCamera(ImageSource.camera);
                      Navigator.pop(context);
                    }, Permission.camera);
                  },
                  child: Container(
                      width: double.infinity,
                      height: ScreenUtil().setWidth(58 * 2),
                      child: Center(
                        child: Text(
                          '拍摄',
                          style: TextStyle(
                              fontSize: ScreenUtil().setSp(32),
                              color: MyColours.color_353535,
                              fontWeight: FontWeight.bold),
                        ),
                      )),
                ),
                MyDivider(
                  double.infinity,
                  ScreenUtil().setWidth(2),
                  color: MyColours.color_EEEEEE,
                ),
                InkWell(
                  onTap: () {
                    Utils.getPickPermission(context, () {
                      pickAsset(RequestType.image);
                      // _getFromPictureOrCamera(ImageSource.gallery);
                      Navigator.pop(context);
                    },
                        Platform.isAndroid
                            ? Permission.storage
                            : Permission.photos);
                  },
                  child: Container(
                      width: double.infinity,
                      height: ScreenUtil().setWidth(58 * 2),
                      child: Center(
                        child: Text(
                          '从相册选择',
                          style: TextStyle(
                              fontSize: ScreenUtil().setSp(32),
                              color: MyColours.color_353535,
                              fontWeight: FontWeight.bold),
                        ),
                      )),
                ),
                MyDivider(
                  double.infinity,
                  ScreenUtil().setWidth(10),
                  color: MyColours.color_EEEEEE,
                ),
                InkWell(
                    onTap: () {
                      Navigator.pop(context, '取消');
                    },
                    child: Container(
                        width: double.infinity,
                        height: ScreenUtil().setWidth(58 * 2),
                        child: Center(
                          child: Text(
                            '取消',
                            style: TextStyle(
                                fontSize: ScreenUtil().setSp(32),
                                color: MyColours.color_353535,
                                fontWeight: FontWeight.bold),
                          ),
                        )))
              ],
            ),
          );
        });
  }

  //查看大图
  _showPhotoView(BuildContext context, int index, List<String> imgs,
      {isShow = false, List dashName}) async {
    // if (imgs.length == 1 &&
    //     imgs[0] ==
    //         'http://nosqn.colorcun.com/custom/lite-online/image/def-banner.png') {
    //   imgs[0] = 'http://nosqn.colorcun.com/app/seller-hj-empty.png';
    // }
    Utils.setBarStatus(false, color: Colors.black);
    dynamic result = await showGeneralDialog(
        context: context,
        barrierDismissible: false,
        // barrierColor: Colors.red,
        barrierLabel:
            MaterialLocalizations.of(context).modalBarrierDismissLabel,
        transitionDuration: const Duration(milliseconds: 150),
        pageBuilder: (BuildContext context, Animation animation,
            Animation secondaryAnimation) {
          Widget child = Stack(
            children: <Widget>[
              PhotoPreview(
                  initialIndex: index,
                  photoList: imgs,
                  isShow: isShow,
                  dashName: dashName)
            ],
          );
          return child;
        });
    Utils.setBarStatus(true, color: Colors.white);
  }

  @override
  Widget build(BuildContext context) {
    // _uploadImageProvider =
    //     Provider.of<UploadImageProvider>(context, listen: true);
    List<UploadImgModel> temp = [];
    if (widget.uploadType == UploadType.ConsumptionUploadType) {
      temp = widget.model.imageList;
    } else if (widget.uploadType == UploadType.StoreFrontUploadType) {
      temp = widget.model.imageListFront;
    } else if (widget.uploadType == UploadType.EnvironmentUploadType) {
      temp = widget.model.imageListDenvironment;
    } else if (widget.uploadType == UploadType.TableManagerType) {
      temp = widget.model.tableImageList;
    } else if (widget.uploadType == UploadType.WineManageType) {
      temp = widget.imageList;
    } else if (widget.uploadType == UploadType.CouponDishType) {
      temp = widget.imageList;
    } else if (widget.uploadType == UploadType.RemarkImagesType) {
      temp = widget.imageList;
    }
    return _getGridImg(
        temp.length < widget.maxImageNumber ? temp.length + 1 : temp.length,
        context,
        temp.length == widget.maxImageNumber ? true : false,
        temp);
  }

  /// 九宫格
  Widget _getGridImg(count, context, isLinjie, List<UploadImgModel> temp) {
    return GridView.builder(
        controller: widget.scrollController,
        // padding: EdgeInsets.only(top: ScreenUtil().getAdapterSize(10)),
        shrinkWrap: true,
        itemCount: count,

        //SliverGridDelegateWithFixedCrossAxisCount 构建一个横轴固定数量Widget
        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
            //横轴元素个数
            crossAxisCount: 3,
            //纵轴间距
            mainAxisSpacing: ScreenUtil().setWidth(40),
            //横轴间距
            crossAxisSpacing: ScreenUtil().setWidth(36),
            //子组件宽高长度比例
            childAspectRatio: 1.0),
        itemBuilder: (BuildContext context, int index) {
          //Widget Function(BuildContext context, int index)
          var linjie = widget.maxImageNumber;
          if (isLinjie) {
            linjie = widget.maxImageNumber - 1;
          }
          if (index == count - 1 && index < linjie) {
            return InkWell(
              onTap: () {
                // 触摸收起键盘
                FocusScope.of(context).requestFocus(FocusNode());
                _openModalBottomSheet(context);
              },
              child: Container(
                  width: ScreenUtil().setWidth(90 * 2),
                  height: ScreenUtil().setWidth(90 * 2),
                  decoration: BoxDecoration(
                    border: Border.all(
                        color: MyColours.color_E0E0E0,
                        width: ScreenUtil().setWidth(2)),
                  ),
                  child: Column(
                    children: [
                      VEmptyView(46),
                      Image.asset(
                        Utils.getImgPath('add_image'),
                        width: ScreenUtil().setWidth(44),
                        height: ScreenUtil().setWidth(40),
                      ),
                      VEmptyView(10),
                      Text(
                        '上传照片',
                        style: TextStyle(
                            fontSize: ScreenUtil().setSp(24),
                            color: MyColours.color_999999),
                      ),
                      widget.maxRemind != null ? VEmptyView(10) : SizedBox(),
                      widget.maxRemind != null
                          ? Text(
                              '最多${widget.maxRemind}张照片',
                              style: TextStyle(
                                  fontSize: ScreenUtil().setSp(18),
                                  color: MyColours.color_999999),
                            )
                          : SizedBox()
                    ],
                  )),
            );
          }
          return temp.length < 1
              ? Text('')
              : InkWell(
                  onTap: () {
                    if (temp[index].process == 1) {
                      widget.model.imageQiniuUrlList = [];
                      if (temp[index].qiniuUrl != null) {
                        for (int i = 0; i < temp.length; i++) {
                          widget.model.imageQiniuUrlList.add(temp[i].qiniuUrl);
                        }

                        ///没有上传完成的不可以点击
                        _showPhotoView(
                            context, index, widget.model.imageQiniuUrlList);
                      }
                    }
                  },
                  child: Stack(
                    children: [
                      Stack(
                        // alignment: Alignment.topRight,
                        children: [
                          temp[index].file != null
                              ? Container(
                                  child: Image.file(
                                    temp[index].file,
                                    fit: BoxFit.cover,
                                    width: ScreenUtil().setWidth(100 * 2),
                                    height: ScreenUtil().setWidth(100 * 2),
                                  ),
                                )
                              : CachedNetworkImage(
                                  imageUrl: temp[index].qiniuUrl,
                                  fit: BoxFit.cover,
                                  width: ScreenUtil().setWidth(100 * 2),
                                  height: ScreenUtil().setWidth(100 * 2),
                                ),
                          Offstage(
                            offstage: temp[index].process < 1,
                            child: Align(
                                alignment: Alignment.topRight,
                                child: GestureDetector(
                                  child: Image.asset(
                                    Utils.getImgPath("delete"),
                                    width: ScreenUtil().setWidth(40),
                                    height: ScreenUtil().setWidth(40),
                                  ),
                                  onTap: () {
                                    if (widget.uploadType ==
                                            UploadType.TableManagerType ||
                                        widget.uploadType ==
                                            UploadType.RemarkImagesType) {
                                      if (temp[index].isUpload) {
                                        //已经传到服务器,弹提醒窗口,是否删除
                                        //修改之前有内容,则弹框
                                        DialogUtil.cupertinoAlertDialog(context,
                                            title: "确认删除",
                                            content: "是否确定删除该照片,删除操作不可逆转,请谨慎操作",
                                            lCallback: () {
                                          print("取消");
                                        }, rCallback: () {
                                          print("确定");
                                          widget.deleteCallback(index);
                                        });
                                      } else {
                                        //直接删除
                                        setState(() {
                                          temp.removeWhere((element) =>
                                              element == temp[index]);
                                        });
                                      }
                                    } else {
                                      //点击删除按钮
                                      setState(() {
                                        temp.removeWhere((element) =>
                                            element == temp[index]);
                                        widget.model.imageQiniuUrlList
                                            .removeWhere((element) =>
                                                element ==
                                                widget.model
                                                    .imageQiniuUrlList[index]);
                                      });
                                    }
                                  },
                                )),
                          ),
                        ],
                      ),
                      Offstage(
                        offstage: temp[index].process == 1,
                        child: Progress(temp[index].process),
                      )
                    ],
                  ));
        });
  }
}