Showing
7 changed files
with
89 additions
and
41 deletions
| @@ -15,6 +15,7 @@ | @@ -15,6 +15,7 @@ | ||
| 15 | <uses-permission android:name="android.permission.READ_CONTACTS" /> | 15 | <uses-permission android:name="android.permission.READ_CONTACTS" /> |
| 16 | <uses-permission android:name="android.permission.WRITE_CONTACTS" /> | 16 | <uses-permission android:name="android.permission.WRITE_CONTACTS" /> |
| 17 | <uses-permission android:name="android.permission.READ_CONTACTS"/> | 17 | <uses-permission android:name="android.permission.READ_CONTACTS"/> |
| 18 | + <uses-permission android:name="android.permission.CAMERA"/> | ||
| 18 | <uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE"/> | 19 | <uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE"/> |
| 19 | <application | 20 | <application |
| 20 | android:name="io.flutter.app.FlutterApplication" | 21 | android:name="io.flutter.app.FlutterApplication" |
| @@ -35,7 +35,7 @@ typedef void DeleteCallback(int index); | @@ -35,7 +35,7 @@ typedef void DeleteCallback(int index); | ||
| 35 | class ImgPickerWidget extends StatefulWidget { | 35 | class ImgPickerWidget extends StatefulWidget { |
| 36 | final ScrollController scrollController; | 36 | final ScrollController scrollController; |
| 37 | final Color borderColor; | 37 | final Color borderColor; |
| 38 | - final ValueChanged onChange; | 38 | + final VoidCallback callback; |
| 39 | final int maxImageNumber; | 39 | final int maxImageNumber; |
| 40 | final UploadImageProvider model; | 40 | final UploadImageProvider model; |
| 41 | final UploadType uploadType; | 41 | final UploadType uploadType; |
| @@ -44,7 +44,7 @@ class ImgPickerWidget extends StatefulWidget { | @@ -44,7 +44,7 @@ class ImgPickerWidget extends StatefulWidget { | ||
| 44 | {Key key, | 44 | {Key key, |
| 45 | this.scrollController, | 45 | this.scrollController, |
| 46 | this.borderColor = Colors.blue, | 46 | this.borderColor = Colors.blue, |
| 47 | - this.onChange, | 47 | + this.callback, |
| 48 | this.maxImageNumber = 5, | 48 | this.maxImageNumber = 5, |
| 49 | this.model, | 49 | this.model, |
| 50 | this.uploadType, | 50 | this.uploadType, |
| @@ -97,6 +97,10 @@ class _ImgPickerWidgetState extends DisposableState<ImgPickerWidget> { | @@ -97,6 +97,10 @@ class _ImgPickerWidgetState extends DisposableState<ImgPickerWidget> { | ||
| 97 | widget.model.imageList.add(imgModel); | 97 | widget.model.imageList.add(imgModel); |
| 98 | } else if (widget.uploadType == UploadType.StoreFrontUploadType) { | 98 | } else if (widget.uploadType == UploadType.StoreFrontUploadType) { |
| 99 | widget.model.imageListFront.add(imgModel); | 99 | widget.model.imageListFront.add(imgModel); |
| 100 | + } else if (widget.uploadType == UploadType.EnvironmentUploadType) { | ||
| 101 | + widget.model.imageListDenvironment.add(imgModel); | ||
| 102 | + } else if (widget.uploadType == UploadType.TableManagerType) { | ||
| 103 | + widget.model.tableImageList.add(imgModel); | ||
| 100 | } | 104 | } |
| 101 | } else { | 105 | } else { |
| 102 | print('No image selected.'); | 106 | print('No image selected.'); |
| @@ -104,13 +108,19 @@ class _ImgPickerWidgetState extends DisposableState<ImgPickerWidget> { | @@ -104,13 +108,19 @@ class _ImgPickerWidgetState extends DisposableState<ImgPickerWidget> { | ||
| 104 | }); | 108 | }); |
| 105 | if (pickedFile != null) { | 109 | if (pickedFile != null) { |
| 106 | List<UploadImgModel> temp = []; | 110 | List<UploadImgModel> temp = []; |
| 111 | + | ||
| 107 | if (widget.uploadType == UploadType.ConsumptionUploadType) { | 112 | if (widget.uploadType == UploadType.ConsumptionUploadType) { |
| 108 | temp = widget.model.imageList; | 113 | temp = widget.model.imageList; |
| 109 | } else if (widget.uploadType == UploadType.StoreFrontUploadType) { | 114 | } else if (widget.uploadType == UploadType.StoreFrontUploadType) { |
| 110 | temp = widget.model.imageListFront; | 115 | temp = widget.model.imageListFront; |
| 116 | + } else if (widget.uploadType == UploadType.EnvironmentUploadType) { | ||
| 117 | + temp = widget.model.imageListDenvironment; | ||
| 118 | + } else if (widget.uploadType == UploadType.TableManagerType) { | ||
| 119 | + temp = widget.model.tableImageList; | ||
| 111 | } | 120 | } |
| 112 | UploadImageUtil().startUpload(context, File(pickedFile.path), | 121 | UploadImageUtil().startUpload(context, File(pickedFile.path), |
| 113 | - temp.length - 1, true, widget.model, widget.uploadType); | 122 | + temp.length - 1, true, widget.model, widget.uploadType, |
| 123 | + callback: widget.callback, countAll: 1); | ||
| 114 | } | 124 | } |
| 115 | } | 125 | } |
| 116 | 126 | ||
| @@ -183,7 +193,8 @@ class _ImgPickerWidgetState extends DisposableState<ImgPickerWidget> { | @@ -183,7 +193,8 @@ class _ImgPickerWidgetState extends DisposableState<ImgPickerWidget> { | ||
| 183 | temp.add(imgModel); | 193 | temp.add(imgModel); |
| 184 | }); | 194 | }); |
| 185 | UploadImageUtil().startUpload(context, File(file.absolute.path), | 195 | UploadImageUtil().startUpload(context, File(file.absolute.path), |
| 186 | - temp.length - 1, false, widget.model, widget.uploadType); | 196 | + temp.length - 1, false, widget.model, widget.uploadType, |
| 197 | + countAll: imgList.length, callback: widget.callback); | ||
| 187 | // startUpload(File(file.absolute.path), | 198 | // startUpload(File(file.absolute.path), |
| 188 | // _uploadImageProvider.imageList.length - 1, false); | 199 | // _uploadImageProvider.imageList.length - 1, false); |
| 189 | } | 200 | } |
| @@ -226,42 +226,69 @@ class _TablePhotoManagerPageState extends State<TablePhotoManagerPage> { | @@ -226,42 +226,69 @@ class _TablePhotoManagerPageState extends State<TablePhotoManagerPage> { | ||
| 226 | .photoID, | 226 | .photoID, |
| 227 | index); | 227 | index); |
| 228 | }, | 228 | }, |
| 229 | + callback: () { | ||
| 230 | + for (UploadImgModel item | ||
| 231 | + in _uploadImageProvider | ||
| 232 | + .tableImageList) { | ||
| 233 | + if (item.process < 1) { | ||
| 234 | + Utils.showToast('正在上传图片,请稍等'); | ||
| 235 | + return; | ||
| 236 | + } | ||
| 237 | + } | ||
| 238 | + //接口,和桌子绑定 | ||
| 239 | + List imageQiniuUrlList = []; | ||
| 240 | + for (int i = 0; | ||
| 241 | + i < | ||
| 242 | + _uploadImageProvider | ||
| 243 | + .tableImageList.length; | ||
| 244 | + i++) { | ||
| 245 | + if (!_uploadImageProvider | ||
| 246 | + .tableImageList[i].isUpload) { | ||
| 247 | + imageQiniuUrlList.add({ | ||
| 248 | + "url": _uploadImageProvider | ||
| 249 | + .tableImageList[i].qiniuUrl | ||
| 250 | + }); | ||
| 251 | + } | ||
| 252 | + } | ||
| 253 | + _setTablePhoto( | ||
| 254 | + context, imageQiniuUrlList); | ||
| 255 | + }, | ||
| 229 | ); | 256 | ); |
| 230 | }), | 257 | }), |
| 231 | ]))), | 258 | ]))), |
| 232 | - RoundButton( | ||
| 233 | - text: '确定上传', | ||
| 234 | - gradientStart: MyColours.color_199095, | ||
| 235 | - gradientEnd: MyColours.color_199095, | ||
| 236 | - // borderColor: MyColours.color_999999, | ||
| 237 | - radius: ScreenUtil().setWidth(10), | ||
| 238 | - fontSize: 34, | ||
| 239 | - height: ScreenUtil().setWidth(80), | ||
| 240 | - isBold: false, | ||
| 241 | - onPressed: () { | ||
| 242 | - for (UploadImgModel item | ||
| 243 | - in _uploadImageProvider.tableImageList) { | ||
| 244 | - if (item.process < 1) { | ||
| 245 | - Utils.showToast('正在上传图片,请稍等'); | ||
| 246 | - return; | ||
| 247 | - } | ||
| 248 | - } | ||
| 249 | - //接口,和桌子绑定 | ||
| 250 | - List imageQiniuUrlList = []; | ||
| 251 | - for (int i = 0; | ||
| 252 | - i < _uploadImageProvider.tableImageList.length; | ||
| 253 | - i++) { | ||
| 254 | - if (!_uploadImageProvider | ||
| 255 | - .tableImageList[i].isUpload) { | ||
| 256 | - imageQiniuUrlList.add({ | ||
| 257 | - "url": _uploadImageProvider | ||
| 258 | - .tableImageList[i].qiniuUrl | ||
| 259 | - }); | ||
| 260 | - } | ||
| 261 | - } | ||
| 262 | - _setTablePhoto(context, imageQiniuUrlList); | ||
| 263 | - }, | ||
| 264 | - ) | 259 | + // RoundButton( |
| 260 | + // text: '确定上传', | ||
| 261 | + // gradientStart: MyColours.color_199095, | ||
| 262 | + // gradientEnd: MyColours.color_199095, | ||
| 263 | + // // borderColor: MyColours.color_999999, | ||
| 264 | + // radius: ScreenUtil().setWidth(10), | ||
| 265 | + // fontSize: 34, | ||
| 266 | + // height: ScreenUtil().setWidth(80), | ||
| 267 | + // isBold: false, | ||
| 268 | + // onPressed: () { | ||
| 269 | + // for (UploadImgModel item | ||
| 270 | + // in _uploadImageProvider.tableImageList) { | ||
| 271 | + // if (item.process < 1) { | ||
| 272 | + // Utils.showToast('正在上传图片,请稍等'); | ||
| 273 | + // return; | ||
| 274 | + // } | ||
| 275 | + // } | ||
| 276 | + // //接口,和桌子绑定 | ||
| 277 | + // List imageQiniuUrlList = []; | ||
| 278 | + // for (int i = 0; | ||
| 279 | + // i < _uploadImageProvider.tableImageList.length; | ||
| 280 | + // i++) { | ||
| 281 | + // if (!_uploadImageProvider | ||
| 282 | + // .tableImageList[i].isUpload) { | ||
| 283 | + // imageQiniuUrlList.add({ | ||
| 284 | + // "url": _uploadImageProvider | ||
| 285 | + // .tableImageList[i].qiniuUrl | ||
| 286 | + // }); | ||
| 287 | + // } | ||
| 288 | + // } | ||
| 289 | + // _setTablePhoto(context, imageQiniuUrlList); | ||
| 290 | + // }, | ||
| 291 | + // ) | ||
| 265 | ]))))); | 292 | ]))))); |
| 266 | } | 293 | } |
| 267 | } | 294 | } |
| @@ -22,6 +22,7 @@ class UploadImageProvider extends ChangeNotifier { | @@ -22,6 +22,7 @@ class UploadImageProvider extends ChangeNotifier { | ||
| 22 | List<UploadImgModel> imageListDenvironment = []; //环境信息列表 | 22 | List<UploadImgModel> imageListDenvironment = []; //环境信息列表 |
| 23 | List<UploadImgModel> imageListFront = []; //门头信息列表 | 23 | List<UploadImgModel> imageListFront = []; //门头信息列表 |
| 24 | List<UploadImgModel> tableImageList = []; //桌子管理图片信息列表 | 24 | List<UploadImgModel> tableImageList = []; //桌子管理图片信息列表 |
| 25 | + int countUpload = 0; | ||
| 25 | UploadImageProvider() { | 26 | UploadImageProvider() { |
| 26 | touxiang.process = 0.01; | 27 | touxiang.process = 0.01; |
| 27 | erweima.process = 0.01; | 28 | erweima.process = 0.01; |
| @@ -41,7 +41,9 @@ class UploadImageUtil { | @@ -41,7 +41,9 @@ class UploadImageUtil { | ||
| 41 | int index, | 41 | int index, |
| 42 | bool needInit, | 42 | bool needInit, |
| 43 | UploadImageProvider uploadImageProvider, | 43 | UploadImageProvider uploadImageProvider, |
| 44 | - UploadType uploadType) async { | 44 | + UploadType uploadType, |
| 45 | + {int countAll, | ||
| 46 | + VoidCallback callback}) async { | ||
| 45 | final PutController putController = PutController(); | 47 | final PutController putController = PutController(); |
| 46 | print(index); | 48 | print(index); |
| 47 | 49 | ||
| @@ -113,6 +115,12 @@ class UploadImageUtil { | @@ -113,6 +115,12 @@ class UploadImageUtil { | ||
| 113 | uploadImageProvider.tableImageList[index].process = 1; | 115 | uploadImageProvider.tableImageList[index].process = 1; |
| 114 | uploadImageProvider.tableImageList[index].qiniuUrl = imgUrl; | 116 | uploadImageProvider.tableImageList[index].qiniuUrl = imgUrl; |
| 115 | uploadImageProvider.tableImageList[index].isUpload = false; | 117 | uploadImageProvider.tableImageList[index].isUpload = false; |
| 118 | + uploadImageProvider.countUpload++; | ||
| 119 | + if (uploadImageProvider.countUpload == countAll) { | ||
| 120 | + //所有图片上传完成,可以绑定桌位 | ||
| 121 | + uploadImageProvider.countUpload = 0; | ||
| 122 | + callback(); | ||
| 123 | + } | ||
| 116 | } | 124 | } |
| 117 | 125 | ||
| 118 | // 取消当前任务 | 126 | // 取消当前任务 |
| @@ -217,7 +217,7 @@ class TableItemState extends State<TableItem> { | @@ -217,7 +217,7 @@ class TableItemState extends State<TableItem> { | ||
| 217 | ? Container() | 217 | ? Container() |
| 218 | : Container( | 218 | : Container( |
| 219 | width: ScreenUtil().setWidth(160), | 219 | width: ScreenUtil().setWidth(160), |
| 220 | - height: ScreenUtil().setHeight(36), | 220 | + height: ScreenUtil().setHeight(34), |
| 221 | alignment: Alignment.center, | 221 | alignment: Alignment.center, |
| 222 | decoration: BoxDecoration( | 222 | decoration: BoxDecoration( |
| 223 | color: signStr == '已停用' | 223 | color: signStr == '已停用' |
| @@ -255,12 +255,12 @@ class TableItemState extends State<TableItem> { | @@ -255,12 +255,12 @@ class TableItemState extends State<TableItem> { | ||
| 255 | : Container()), | 255 | : Container()), |
| 256 | Positioned( | 256 | Positioned( |
| 257 | left: ScreenUtil().setWidth(8), | 257 | left: ScreenUtil().setWidth(8), |
| 258 | - bottom: ScreenUtil().setWidth(16), | 258 | + bottom: ScreenUtil().setWidth(10), |
| 259 | child: table.isPhoto == 1 | 259 | child: table.isPhoto == 1 |
| 260 | ? Image.asset( | 260 | ? Image.asset( |
| 261 | "assets/photo.png", | 261 | "assets/photo.png", |
| 262 | width: ScreenUtil().setWidth(40), | 262 | width: ScreenUtil().setWidth(40), |
| 263 | - height: ScreenUtil().setWidth(40), | 263 | + height: ScreenUtil().setWidth(50), |
| 264 | ) | 264 | ) |
| 265 | : Container()) | 265 | : Container()) |
| 266 | ], | 266 | ], |
-
Please register or login to post a comment