Commit 78af95bea9cb1d395e55418d0525ceb38efdc300

Authored by wdn127929
1 parent 7c929e7b

自定义预定安排 UI OK

@@ -26,7 +26,7 @@ import 'dart:io'; @@ -26,7 +26,7 @@ import 'dart:io';
26 class AdditionModel { 26 class AdditionModel {
27 String content; 27 String content;
28 String type; // 1图片 2文本 28 String type; // 1图片 2文本
29 - int order; //顺序 29 + // int order; //顺序
30 UploadImgModel image; 30 UploadImgModel image;
31 TextEditingController infoC = TextEditingController(); 31 TextEditingController infoC = TextEditingController();
32 32
@@ -34,11 +34,13 @@ class AdditionModel { @@ -34,11 +34,13 @@ class AdditionModel {
34 34
35 factory AdditionModel.fromJson(Map<String, dynamic> json) => AdditionModel() 35 factory AdditionModel.fromJson(Map<String, dynamic> json) => AdditionModel()
36 ..content = json["content"] 36 ..content = json["content"]
37 - ..type = json["type"]  
38 - ..order = json['order']; 37 + ..type = json["type"];
  38 + // ..order = json['order'];
39 39
40 - Map<String, dynamic> toJson() =>  
41 - <String, dynamic>{"content": content, "type": type, 'order': order}; 40 + Map<String, dynamic> toJson() => <String, dynamic>{
  41 + "content": content, "type": type,
  42 + // 'order': order
  43 + };
42 } 44 }
43 45
44 class InvicationAdditionPage extends StatefulWidget { 46 class InvicationAdditionPage extends StatefulWidget {
@@ -59,23 +61,23 @@ class _InvicationAdditionPageState extends State<InvicationAdditionPage> { @@ -59,23 +61,23 @@ class _InvicationAdditionPageState extends State<InvicationAdditionPage> {
59 void initState() { 61 void initState() {
60 super.initState(); 62 super.initState();
61 63
62 - AdditionModel additionModel = AdditionModel();  
63 - additionModel.content =  
64 - 'https://inews.gtimg.com/om_bt/OGlQWfsaAoKkuCcMZ2o9IVEPqd-72DQy5EAN02XBHUwfYAA/641';  
65 - additionModel.type = '1';  
66 - additionModel.order = 0;  
67 - additionModel.image = UploadImgModel();  
68 - additionModel.image.process = 1;  
69 - additionModel.image.qiniuUrl =  
70 - 'https://inews.gtimg.com/om_bt/OGlQWfsaAoKkuCcMZ2o9IVEPqd-72DQy5EAN02XBHUwfYAA/641'; 64 + // AdditionModel additionModel = AdditionModel();
  65 + // additionModel.content =
  66 + // 'https://inews.gtimg.com/om_bt/OGlQWfsaAoKkuCcMZ2o9IVEPqd-72DQy5EAN02XBHUwfYAA/641';
  67 + // additionModel.type = '1';
  68 + // additionModel.order = 0;
  69 + // additionModel.image = UploadImgModel();
  70 + // additionModel.image.process = 1;
  71 + // additionModel.image.qiniuUrl =
  72 + // 'https://inews.gtimg.com/om_bt/OGlQWfsaAoKkuCcMZ2o9IVEPqd-72DQy5EAN02XBHUwfYAA/641';
71 73
72 - AdditionModel additionModel1 = AdditionModel();  
73 - additionModel1.content = 'webenkjfkdfjakdfjaldfkjaldfjaldf';  
74 - additionModel1.type = '2';  
75 - additionModel1.order = 1; 74 + // AdditionModel additionModel1 = AdditionModel();
  75 + // additionModel1.content = 'webenkjfkdfjakdfjaldfkjaldfjaldf';
  76 + // additionModel1.type = '2';
  77 + // additionModel1.order = 1;
76 78
77 - data.add(additionModel);  
78 - data.add(additionModel1); 79 + // data.add(additionModel);
  80 + // data.add(additionModel1);
79 81
80 WidgetsBinding.instance.addPostFrameCallback((_) async { 82 WidgetsBinding.instance.addPostFrameCallback((_) async {
81 _getQiniuInfo(); 83 _getQiniuInfo();
@@ -95,12 +97,13 @@ class _InvicationAdditionPageState extends State<InvicationAdditionPage> { @@ -95,12 +97,13 @@ class _InvicationAdditionPageState extends State<InvicationAdditionPage> {
95 } 97 }
96 98
97 ///#相机拍照,单图选择 99 ///#相机拍照,单图选择
98 - Future _getFromPictureOrCamera(UploadImgModel imgModel, imageSource) async { 100 + Future _getFromPictureOrCamera(int index, imageSource) async {
99 final pickedFile = await picker.pickImage(source: imageSource); 101 final pickedFile = await picker.pickImage(source: imageSource);
100 File compressedFile = await FlutterNativeImage.compressImage( 102 File compressedFile = await FlutterNativeImage.compressImage(
101 pickedFile.path, 103 pickedFile.path,
102 quality: 50, 104 quality: 50,
103 percentage: 50); 105 percentage: 50);
  106 + UploadImgModel imgModel = _uploadImageProvider.getDynamicValue('${index}');
104 setState(() { 107 setState(() {
105 if (pickedFile != null) { 108 if (pickedFile != null) {
106 imgModel.file = File(pickedFile.path); 109 imgModel.file = File(pickedFile.path);
@@ -115,20 +118,34 @@ class _InvicationAdditionPageState extends State<InvicationAdditionPage> { @@ -115,20 +118,34 @@ class _InvicationAdditionPageState extends State<InvicationAdditionPage> {
115 // _uploadImageProvider.touxiang.qiniuUrl = null; 118 // _uploadImageProvider.touxiang.qiniuUrl = null;
116 // } else { 119 // } else {
117 // _uploadImageProvider.imgSizeErweima = 76; 120 // _uploadImageProvider.imgSizeErweima = 76;
118 - _uploadImageProvider.firstImage.qiniuUrl = null; 121 + imgModel.qiniuUrl = null;
119 // } 122 // }
120 bool need = await Utils.sizeNeed(File(pickedFile.path)); 123 bool need = await Utils.sizeNeed(File(pickedFile.path));
121 File file = File(pickedFile.path); 124 File file = File(pickedFile.path);
122 if (need) { 125 if (need) {
123 file = File(compressedFile.absolute.path); 126 file = File(compressedFile.absolute.path);
124 } 127 }
125 - UploadImageUtil()  
126 - .startUploadOnly(context, file, 4, true, _uploadImageProvider); 128 + UploadImageUtil().startUploadOnlyAddition(
  129 + context, file, index, true, _uploadImageProvider, () {
  130 + UploadImgModel imgModel =
  131 + _uploadImageProvider.getDynamicValue('${index}');
  132 + AdditionModel additionModel = AdditionModel();
  133 + additionModel.content = imgModel.qiniuUrl;
  134 + additionModel.type = '1';
  135 + // additionModel.order = index;
  136 + additionModel.image = imgModel;
  137 + // additionModel.image.process = 1;
  138 + // additionModel.image.qiniuUrl =
  139 + // 'https://inews.gtimg.com/om_bt/OGlQWfsaAoKkuCcMZ2o9IVEPqd-72DQy5EAN02XBHUwfYAA/641';
  140 +
  141 + data[index] = additionModel;
  142 + setState(() {});
  143 + });
127 } 144 }
128 } 145 }
129 146
130 ///添加图片UI弹出 147 ///添加图片UI弹出
131 - Future _openModalBottomSheet(context) async { 148 + Future _openModalBottomSheet(context, int index) async {
132 final option = await showModalBottomSheet( 149 final option = await showModalBottomSheet(
133 context: context, 150 context: context,
134 backgroundColor: Colors.transparent, 151 backgroundColor: Colors.transparent,
@@ -146,15 +163,8 @@ class _InvicationAdditionPageState extends State<InvicationAdditionPage> { @@ -146,15 +163,8 @@ class _InvicationAdditionPageState extends State<InvicationAdditionPage> {
146 children: <Widget>[ 163 children: <Widget>[
147 InkWell( 164 InkWell(
148 onTap: () { 165 onTap: () {
149 - // Utils.getPickPermission(context, () {  
150 - // _getFromPictureOrCamera(  
151 - // _uploadImageProvider.firstImage, ImageSource.camera);  
152 -  
153 - // Navigator.pop(context);  
154 - // }, Permission.camera);  
155 Utils.getPickPermission(context, () { 166 Utils.getPickPermission(context, () {
156 - _getFromPictureOrCamera(  
157 - _uploadImageProvider.firstImage, ImageSource.camera); 167 + _getFromPictureOrCamera(index, ImageSource.camera);
158 Navigator.pop(context); 168 Navigator.pop(context);
159 }, 169 },
160 Platform.isAndroid 170 Platform.isAndroid
@@ -190,9 +200,9 @@ class _InvicationAdditionPageState extends State<InvicationAdditionPage> { @@ -190,9 +200,9 @@ class _InvicationAdditionPageState extends State<InvicationAdditionPage> {
190 // Platform.isAndroid 200 // Platform.isAndroid
191 // ? Permission.storage 201 // ? Permission.storage
192 // : Permission.photos); 202 // : Permission.photos);
  203 +
193 Utils.getPickPermission(context, () { 204 Utils.getPickPermission(context, () {
194 - _getFromPictureOrCamera(  
195 - _uploadImageProvider.firstImage, ImageSource.gallery); 205 + _getFromPictureOrCamera(index, ImageSource.gallery);
196 Navigator.pop(context); 206 Navigator.pop(context);
197 }, 207 },
198 Platform.isAndroid 208 Platform.isAndroid
@@ -246,382 +256,461 @@ class _InvicationAdditionPageState extends State<InvicationAdditionPage> { @@ -246,382 +256,461 @@ class _InvicationAdditionPageState extends State<InvicationAdditionPage> {
246 return Scaffold( 256 return Scaffold(
247 backgroundColor: MyColours.color_ffffff, 257 backgroundColor: MyColours.color_ffffff,
248 appBar: SystemAppBar('自定义图文'), 258 appBar: SystemAppBar('自定义图文'),
249 - body: SingleChildScrollView(  
250 - controller: controller,  
251 - child: Column(  
252 - children: [  
253 - Container(  
254 - padding:  
255 - EdgeInsets.symmetric(horizontal: w(16), vertical: w(12)),  
256 - child: Row(  
257 - children: [  
258 - Text(  
259 - '区域标题',  
260 - style: TextStyle(  
261 - color: MyColours.color_515151, fontSize: font(16)),  
262 - ),  
263 - // HEmptyView(44),  
264 -  
265 - Expanded(  
266 - child: Container(  
267 - height: w(24),  
268 - // color: Colors.red,  
269 - child: TextField(  
270 - controller: titleC,  
271 - textAlign: TextAlign.right,  
272 - // focusNode: _cusdemNode,  
273 - style: TextStyle(  
274 - color: MyColours.color_515151,  
275 - fontSize: ScreenUtil().setSp(32),  
276 - // textBaseline: TextBaseline.alphabetic  
277 - ),  
278 - // textAlignVertical: TextAlignVertical.center,  
279 - maxLines: 1,  
280 - // inputFormatters: [  
281 - // LengthLimitingTextInputFormatter(10), // 设置输入长度限制  
282 - // ],  
283 - decoration: InputDecoration(  
284 - hintText: "点击输入区域标题(不超过10个字)",  
285 - hintStyle: TextStyle(  
286 - color: MyColours.color_999999,  
287 - fontSize: ScreenUtil().setSp(32), 259 + body: Column(
  260 + children: [
  261 + Expanded(
  262 + child: SingleChildScrollView(
  263 + controller: controller,
  264 + child: Column(
  265 + children: [
  266 + Container(
  267 + padding: EdgeInsets.symmetric(
  268 + horizontal: w(16), vertical: w(12)),
  269 + child: Row(
  270 + children: [
  271 + Text(
  272 + '区域标题',
  273 + style: TextStyle(
  274 + color: MyColours.color_515151,
  275 + fontSize: font(16)),
288 ), 276 ),
289 - contentPadding: EdgeInsets.zero,  
290 - border: OutlineInputBorder(  
291 - borderSide: BorderSide.none),  
292 - ),  
293 - keyboardType: TextInputType.text,  
294 - onChanged: (value) {}),  
295 - ))  
296 - ],  
297 - ),  
298 - ),  
299 - Padding(  
300 - padding: EdgeInsets.only(left: w(16)),  
301 - child: MyDivider(  
302 - double.infinity,  
303 - w(0.5),  
304 - color: MyColours.color_E7E7E7,  
305 - ),  
306 - ),  
307 - // Expanded(  
308 - // child:  
309 - Padding(  
310 - padding: EdgeInsets.symmetric(  
311 - // horizontal: ScreenUtil().setWidth(32),  
312 - vertical: ScreenUtil().setWidth(26)),  
313 - child: ReorderableListView(  
314 - shrinkWrap: true,  
315 - scrollController: controller,  
316 - children: <Widget>[  
317 - for (AdditionModel item in data)  
318 - item.type == '1'  
319 - ? Container(  
320 - key: ValueKey(item),  
321 - child: InkWell(  
322 - onTap: () {  
323 - double process;  
324 - String qiniuUrl;  
325 - List<String> tempList = [];  
326 - // if (title == '头像') {  
327 - process = item.image.process;  
328 - qiniuUrl = item.image.qiniuUrl;  
329 - // } else {  
330 - // process = _uploadImageProvider.erweima.process;  
331 - // qiniuUrl = _uploadImageProvider.erweima.qiniuUrl;  
332 - // }  
333 -  
334 - if (qiniuUrl != null &&  
335 - qiniuUrl != '') {  
336 - // tempList.add(qiniuUrl);  
337 -  
338 - // ///没有上传完成的不可以点击  
339 - // _showPhotoView(context, 0, tempList);  
340 -  
341 - // _uploadImageProvider.firstImage.qiniuUrl = null;  
342 - // _uploadImageProvider.firstImage.process = 0;  
343 - // setState(() {});  
344 - _openModalBottomSheet(context);  
345 - // Utils.getPickPermission(context, () {  
346 - // _getFromPictureOrCamera(  
347 - // _uploadImageProvider.firstImage,  
348 - // ImageSource.gallery);  
349 - // },  
350 - // Platform.isAndroid  
351 - // ? Permission.storage  
352 - // : Permission.photos);  
353 - }  
354 - },  
355 - child: Stack(  
356 - alignment: Alignment.bottomCenter,  
357 - children: [  
358 - Stack(  
359 - clipBehavior: Clip.none,  
360 - children: [  
361 - item.image.qiniuUrl != null &&  
362 - item.image.qiniuUrl !=  
363 - ''  
364 - ? Image.network(  
365 - item.image.qiniuUrl,  
366 - fit: BoxFit.contain,  
367 - width:  
368 - double.infinity,  
369 - // width: ScreenUtil()  
370 - // .setWidth(imgSize * 2),  
371 - // height: ScreenUtil().setWidth(  
372 - // _uploadImageProvider  
373 - // .imgSizefirstImage *  
374 - // 2),  
375 - )  
376 - : Image.file(  
377 - item.image.file,  
378 - fit: BoxFit.contain,  
379 - width:  
380 - double.infinity,  
381 - // width: ScreenUtil()  
382 - // .setWidth(imgSize * 2),  
383 - // height: ScreenUtil().setWidth(  
384 - // _uploadImageProvider  
385 - // .imgSizefirstImage *  
386 - // 2),  
387 - ),  
388 - Positioned(  
389 - left: 0,  
390 - top: 0,  
391 - child: (item.image.file !=  
392 - null) &&  
393 - item.image  
394 - .process !=  
395 - 1 &&  
396 - item.image  
397 - .process !=  
398 - 0.01  
399 - ? Container(  
400 - width: ScreenUtil()  
401 - .screenWidth,  
402 - height: w(  
403 - _uploadImageProvider  
404 - .imgSizefirstImage),  
405 - color: MyColours  
406 - .color_4D000000,  
407 - child: Center(  
408 - child: Text(  
409 - '上传中',  
410 - style: TextStyle(  
411 - color: MyColours  
412 - .color_F8F9FD)),  
413 - ),  
414 - )  
415 - : Container()),  
416 - ]),  
417 - // item.image.process == 1  
418 - // ? Container(  
419 - // width: w(150),  
420 - // height: w(30),  
421 - // color: MyColours.color_4D000000,  
422 - // alignment: Alignment.center,  
423 - // child: Text(  
424 - // '点击图片可以更换',  
425 - // style: TextStyle(  
426 - // color: MyColours  
427 - // .color_F8F9FD,  
428 - // fontSize: font(14),  
429 - // fontWeight:  
430 - // FontWeight.bold),  
431 - // ))  
432 - // : SizedBox(),  
433 - item.image.process == 1  
434 - ? Positioned(  
435 - top: w(15),  
436 - right: w(15),  
437 - child: InkWell(  
438 - onTap: () {  
439 - data.remove(item);  
440 - setState(() {});  
441 - },  
442 - child: Container(  
443 - width: w(30),  
444 - height: w(30),  
445 - color: Colors  
446 - .transparent,  
447 - alignment: Alignment  
448 - .center,  
449 - child: Image.asset(  
450 - Utils.getImgPath(  
451 - 'add_close')))))  
452 - : SizedBox(),  
453 - ])))  
454 - : Container(  
455 - key: ValueKey(item),  
456 - decoration: BoxDecoration(  
457 - border: Border.all(  
458 - width: w(1),  
459 - color: MyColours.color_DBDBDB)),  
460 - // child: Text(item.content),  
461 -  
462 - // color: Colors.red,  
463 - child: Stack(  
464 - children: [  
465 - Container(  
466 - // height: w(152), 277 + // HEmptyView(44),
  278 +
  279 + Expanded(
  280 + child: Container(
  281 + height: w(24),
  282 + // color: Colors.red,
  283 + child: TextField(
  284 + controller: titleC,
  285 + textAlign: TextAlign.right,
  286 + // focusNode: _cusdemNode,
  287 + style: TextStyle(
  288 + color: MyColours.color_515151,
  289 + fontSize: ScreenUtil().setSp(32),
  290 + // textBaseline: TextBaseline.alphabetic
  291 + ),
  292 + // textAlignVertical: TextAlignVertical.center,
  293 + maxLines: 1,
  294 + // inputFormatters: [
  295 + // LengthLimitingTextInputFormatter(10), // 设置输入长度限制
  296 + // ],
  297 + decoration: InputDecoration(
  298 + hintText: "点击输入区域标题(不超过10个字)",
  299 + hintStyle: TextStyle(
  300 + color: MyColours.color_999999,
  301 + fontSize: ScreenUtil().setSp(32),
  302 + ),
  303 + contentPadding: EdgeInsets.zero,
  304 + border: OutlineInputBorder(
  305 + borderSide: BorderSide.none),
  306 + ),
  307 + keyboardType: TextInputType.text,
  308 + onChanged: (value) {}),
  309 + ))
  310 + ],
  311 + ),
  312 + ),
  313 + Padding(
  314 + padding: EdgeInsets.only(left: w(16)),
  315 + child: MyDivider(
  316 + double.infinity,
  317 + w(0.5),
  318 + color: MyColours.color_E7E7E7,
  319 + ),
  320 + ),
  321 + // Expanded(
  322 + // child:
  323 + Padding(
  324 + padding: EdgeInsets.symmetric(
  325 + // horizontal: ScreenUtil().setWidth(32),
  326 + vertical: ScreenUtil().setWidth(26)),
  327 + child: ReorderableListView(
  328 + shrinkWrap: true,
  329 + scrollController: controller,
  330 + children: <Widget>[
  331 + for (AdditionModel item in data)
  332 + item.type == '1'
  333 + ? item.image.qiniuUrl == null &&
  334 + item.image.file == null
  335 + ? SizedBox()
  336 + : Container(
  337 + key: ValueKey(item),
  338 + child: InkWell(
  339 + onTap: () {
  340 + // double process;
  341 + // String qiniuUrl;
  342 + // List<String> tempList = [];
  343 + // // if (title == '头像') {
  344 + // process = item.image.process;
  345 + // qiniuUrl = item.image.qiniuUrl;
  346 + // // } else {
  347 + // // process = _uploadImageProvider.erweima.process;
  348 + // // qiniuUrl = _uploadImageProvider.erweima.qiniuUrl;
  349 + // // }
  350 +
  351 + // if (qiniuUrl != null &&
  352 + // qiniuUrl != '') {
  353 + // // tempList.add(qiniuUrl);
  354 +
  355 + // // ///没有上传完成的不可以点击
  356 + // // _showPhotoView(context, 0, tempList);
  357 +
  358 + // // _uploadImageProvider.firstImage.qiniuUrl = null;
  359 + // // _uploadImageProvider.firstImage.process = 0;
  360 + // // setState(() {});
  361 + // _openModalBottomSheet(context);
  362 + // // Utils.getPickPermission(context, () {
  363 + // // _getFromPictureOrCamera(
  364 + // // _uploadImageProvider.firstImage,
  365 + // // ImageSource.gallery);
  366 + // // },
  367 + // // Platform.isAndroid
  368 + // // ? Permission.storage
  369 + // // : Permission.photos);
  370 + // }
  371 + },
  372 + child: Stack(
  373 + alignment: Alignment
  374 + .bottomCenter,
  375 + children: [
  376 + Stack(
  377 + clipBehavior:
  378 + Clip.none,
  379 + children: [
  380 + item.image.qiniuUrl !=
  381 + null &&
  382 + item.image
  383 + .qiniuUrl !=
  384 + ''
  385 + ? Image
  386 + .network(
  387 + item.image
  388 + .qiniuUrl,
  389 + fit: BoxFit
  390 + .contain,
  391 + width: double
  392 + .infinity,
  393 + // width: ScreenUtil()
  394 + // .setWidth(imgSize * 2),
  395 + // height: ScreenUtil().setWidth(
  396 + // _uploadImageProvider
  397 + // .imgSizefirstImage *
  398 + // 2),
  399 + )
  400 + : Image.file(
  401 + item.image
  402 + .file,
  403 + fit: BoxFit
  404 + .contain,
  405 + width: double
  406 + .infinity,
  407 + // width: ScreenUtil()
  408 + // .setWidth(imgSize * 2),
  409 + // height: ScreenUtil().setWidth(
  410 + // _uploadImageProvider
  411 + // .imgSizefirstImage *
  412 + // 2),
  413 + ),
  414 + Positioned(
  415 + left: 0,
  416 + top: 0,
  417 + child: (item.image.file != null) &&
  418 + item.image.process !=
  419 + 1 &&
  420 + item.image.process !=
  421 + 0.01
  422 + ? Container(
  423 + width:
  424 + ScreenUtil().screenWidth,
  425 + height:
  426 + w(_uploadImageProvider.imgSizefirstImage),
  427 + color:
  428 + MyColours.color_4D000000,
  429 + child:
  430 + Center(
  431 + child:
  432 + Text('上传中', style: TextStyle(color: MyColours.color_F8F9FD)),
  433 + ),
  434 + )
  435 + : Container()),
  436 + ]),
  437 + // item.image.process == 1
  438 + // ? Container(
  439 + // width: w(150),
  440 + // height: w(30),
  441 + // color: MyColours.color_4D000000,
  442 + // alignment: Alignment.center,
  443 + // child: Text(
  444 + // '点击图片可以更换',
  445 + // style: TextStyle(
  446 + // color: MyColours
  447 + // .color_F8F9FD,
  448 + // fontSize: font(14),
  449 + // fontWeight:
  450 + // FontWeight.bold),
  451 + // ))
  452 + // : SizedBox(),
  453 + item.image.process == 1
  454 + ? Positioned(
  455 + top: w(15),
  456 + right: w(15),
  457 + child: InkWell(
  458 + onTap: () {
  459 + data.remove(
  460 + item);
  461 + setState(
  462 + () {});
  463 + },
  464 + child: Container(
  465 + width: w(
  466 + 30),
  467 + height: w(
  468 + 30),
  469 + color: Colors
  470 + .transparent,
  471 + alignment:
  472 + Alignment
  473 + .center,
  474 + child: Image.asset(
  475 + Utils.getImgPath('add_close')))))
  476 + : SizedBox(),
  477 + ])))
  478 + : Container(
  479 + key: ValueKey(item),
467 decoration: BoxDecoration( 480 decoration: BoxDecoration(
468 - borderRadius:  
469 - BorderRadius.circular(r(5)),  
470 border: Border.all( 481 border: Border.all(
471 width: w(1), 482 width: w(1),
472 color: 483 color:
473 MyColours.color_DBDBDB)), 484 MyColours.color_DBDBDB)),
474 - margin: EdgeInsets.only(  
475 - left: w(10),  
476 - top: w(10),  
477 - bottom: w(10),  
478 - right: w(60)),  
479 - padding: EdgeInsets.only(  
480 - top: w(16),  
481 - bottom: w(16),  
482 - left: w(14),  
483 - right: w(10)),  
484 - child: TextField(  
485 - controller: item.infoC,  
486 - // textAlign: TextAlign.right,  
487 - // focusNode: _cusdemNode,  
488 - style: TextStyle(  
489 - color: MyColours.color_515151,  
490 - fontSize:  
491 - ScreenUtil().setSp(28),  
492 - // textBaseline: TextBaseline.alphabetic  
493 - ),  
494 - // textAlignVertical: TextAlignVertical.center,  
495 - maxLines: 5,  
496 - maxLength: 50,  
497 - // inputFormatters: [  
498 - // LengthLimitingTextInputFormatter(10), // 设置输入长度限制  
499 - // ],  
500 - decoration: InputDecoration(  
501 - hintText: "点击录入文字",  
502 - hintStyle: TextStyle(  
503 - color: MyColours.color_999999,  
504 - fontSize:  
505 - ScreenUtil().setSp(28),  
506 - ),  
507 - contentPadding: EdgeInsets.zero,  
508 - border: OutlineInputBorder(  
509 - borderSide:  
510 - BorderSide.none),  
511 - ),  
512 - keyboardType: TextInputType.text,  
513 - onChanged: (value) {})),  
514 - Positioned(  
515 - top: w(10),  
516 - right: w(10),  
517 - child: InkWell(  
518 - onTap: () {  
519 - data.remove(item);  
520 - setState(() {});  
521 - },  
522 - child: Container(  
523 - width: w(30),  
524 - height: w(30),  
525 - color: Colors.transparent,  
526 - alignment: Alignment.center,  
527 - child: Image.asset(  
528 - Utils.getImgPath(  
529 - 'add_close_b')))))  
530 - ],  
531 - ),  
532 - ), 485 + // child: Text(item.content),
  486 +
  487 + // color: Colors.red,
  488 + child: Stack(
  489 + children: [
  490 + Container(
  491 + // height: w(152),
  492 + decoration: BoxDecoration(
  493 + borderRadius:
  494 + BorderRadius.circular(
  495 + r(5)),
  496 + border: Border.all(
  497 + width: w(1),
  498 + color: MyColours
  499 + .color_DBDBDB)),
  500 + margin: EdgeInsets.only(
  501 + left: w(10),
  502 + top: w(10),
  503 + bottom: w(10),
  504 + right: w(60)),
  505 + padding: EdgeInsets.only(
  506 + top: w(16),
  507 + bottom: w(16),
  508 + left: w(14),
  509 + right: w(10)),
  510 + child: TextField(
  511 + controller: item.infoC,
  512 + // textAlign: TextAlign.right,
  513 + // focusNode: _cusdemNode,
  514 + style: TextStyle(
  515 + color: MyColours
  516 + .color_515151,
  517 + fontSize: ScreenUtil()
  518 + .setSp(28),
  519 + // textBaseline: TextBaseline.alphabetic
  520 + ),
  521 + // textAlignVertical: TextAlignVertical.center,
  522 + maxLines: 5,
  523 + maxLength: 50,
  524 + // inputFormatters: [
  525 + // LengthLimitingTextInputFormatter(10), // 设置输入长度限制
  526 + // ],
  527 + decoration:
  528 + InputDecoration(
  529 + hintText: "点击录入文字",
  530 + hintStyle: TextStyle(
  531 + color: MyColours
  532 + .color_999999,
  533 + fontSize: ScreenUtil()
  534 + .setSp(28),
  535 + ),
  536 + contentPadding:
  537 + EdgeInsets.zero,
  538 + border:
  539 + OutlineInputBorder(
  540 + borderSide:
  541 + BorderSide
  542 + .none),
  543 + ),
  544 + keyboardType:
  545 + TextInputType.text,
  546 + onChanged: (value) {
  547 + item.content = value;
  548 + })),
  549 + Positioned(
  550 + top: w(10),
  551 + right: w(10),
  552 + child: InkWell(
  553 + onTap: () {
  554 + data.remove(item);
  555 + setState(() {});
  556 + },
  557 + child: Container(
  558 + width: w(30),
  559 + height: w(30),
  560 + color: Colors
  561 + .transparent,
  562 + alignment:
  563 + Alignment.center,
  564 + child: Image.asset(
  565 + Utils.getImgPath(
  566 + 'add_close_b')))))
  567 + ],
  568 + ),
  569 + ),
  570 + ],
  571 + onReorder: (int oldIndex, int newIndex) async {
  572 + if (oldIndex < newIndex) {
  573 + newIndex -= 1;
  574 + }
  575 +
  576 + // var childold = tableManagerModel.areas[oldIndex];
  577 + // Map<String, String> params = {
  578 + // 'sid': Provider.of<UserModel>(context, listen: false)
  579 + // .user
  580 + // .sellerid,
  581 + // 'regionid': childold.rid,
  582 + // 'order_o': tableManagerModel.areas[newIndex].orderId,
  583 + // 'sort': oldIndex < newIndex ? '2' : '1'
  584 + // };
  585 + var child = data.removeAt(oldIndex);
  586 + data.insert(newIndex, child);
  587 + setState(() {});
  588 + // await tableManagerModel.sortByRegion(context, params);
  589 + // //刷新前一页数据
  590 + // bus.emit('refresh_table_area');
  591 + },
  592 + )),
  593 + Container(
  594 + padding: EdgeInsets.only(top: w(15)),
  595 + child: Row(
  596 + mainAxisAlignment: MainAxisAlignment.center,
  597 + children: [
  598 + InkWell(
  599 + onTap: () {
  600 + UploadImgModel uploadImgModel =
  601 + UploadImgModel(); //图
  602 + _uploadImageProvider.setDynamicValue(
  603 + '${data.length}', uploadImgModel);
  604 +
  605 + AdditionModel additionModel =
  606 + AdditionModel();
  607 + // additionModel.content = imgModel.qiniuUrl;
  608 + additionModel.type = '1';
  609 + // additionModel.order = data.length;
  610 + additionModel.image = uploadImgModel;
  611 + // additionModel.image.process = 1;
  612 + // additionModel.image.qiniuUrl =
  613 + // 'https://inews.gtimg.com/om_bt/OGlQWfsaAoKkuCcMZ2o9IVEPqd-72DQy5EAN02XBHUwfYAA/641';
  614 +
  615 + data.add(additionModel);
  616 + _openModalBottomSheet(
  617 + context, data.length - 1);
  618 + },
  619 + child: Container(
  620 + width: w(77),
  621 + height: w(34),
  622 + alignment: Alignment.center,
  623 + decoration: BoxDecoration(
  624 + borderRadius:
  625 + BorderRadius.circular(r(5)),
  626 + border: Border.all(
  627 + width: w(1),
  628 + color: MyColours.color_438E93)),
  629 + child: Text(
  630 + '+图片',
  631 + style: TextStyle(
  632 + color: MyColours.color_000000,
  633 + fontSize: font(14)),
  634 + ),
  635 + )),
  636 + HEmptyView(20),
  637 + InkWell(
  638 + onTap: () {
  639 + AdditionModel additionModel1 =
  640 + AdditionModel();
  641 + // additionModel1.content =
  642 + // 'webenkjfkdfjakdfjaldfkjaldfjaldf';
  643 + additionModel1.type = '2';
  644 + // additionModel1.order = data.length;
  645 +
  646 + data.add(additionModel1);
  647 + setState(() {});
  648 + },
  649 + child: Container(
  650 + width: w(77),
  651 + height: w(34),
  652 + alignment: Alignment.center,
  653 + decoration: BoxDecoration(
  654 + borderRadius:
  655 + BorderRadius.circular(r(5)),
  656 + border: Border.all(
  657 + width: w(1),
  658 + color: MyColours.color_438E93)),
  659 + child: Text(
  660 + '+文字',
  661 + style: TextStyle(
  662 + color: MyColours.color_000000,
  663 + fontSize: font(14)),
  664 + ),
  665 + )),
  666 + ],
  667 + ),
  668 + )
  669 + // )
533 ], 670 ],
534 - onReorder: (int oldIndex, int newIndex) async {  
535 - // if (oldIndex < newIndex) {  
536 - // newIndex -= 1;  
537 - // }  
538 -  
539 - // var childold = tableManagerModel.areas[oldIndex];  
540 - // Map<String, String> params = {  
541 - // 'sid': Provider.of<UserModel>(context, listen: false)  
542 - // .user  
543 - // .sellerid,  
544 - // 'regionid': childold.rid,  
545 - // 'order_o': tableManagerModel.areas[newIndex].orderId,  
546 - // 'sort': oldIndex < newIndex ? '2' : '1'  
547 - // };  
548 - // var child = tableManagerModel.areas.removeAt(oldIndex);  
549 - // tableManagerModel.areas.insert(newIndex, child);  
550 - // setState(() {});  
551 - // await tableManagerModel.sortByRegion(context, params);  
552 - // //刷新前一页数据  
553 - // bus.emit('refresh_table_area');  
554 - },  
555 - )),  
556 - Container(  
557 - padding: EdgeInsets.only(top: w(15)),  
558 - child: Row(  
559 - mainAxisAlignment: MainAxisAlignment.center,  
560 - children: [  
561 - InkWell(  
562 - onTap: () {  
563 - AdditionModel additionModel = AdditionModel();  
564 - additionModel.content =  
565 - 'https://inews.gtimg.com/om_bt/OGlQWfsaAoKkuCcMZ2o9IVEPqd-72DQy5EAN02XBHUwfYAA/641';  
566 - additionModel.type = '1';  
567 - additionModel.order = 0;  
568 - additionModel.image = UploadImgModel();  
569 - additionModel.image.process = 1;  
570 - additionModel.image.qiniuUrl =  
571 - 'https://inews.gtimg.com/om_bt/OGlQWfsaAoKkuCcMZ2o9IVEPqd-72DQy5EAN02XBHUwfYAA/641';  
572 -  
573 - data.add(additionModel);  
574 - setState(() {});  
575 - },  
576 - child: Container(  
577 - width: w(77),  
578 - height: w(34),  
579 - alignment: Alignment.center,  
580 - decoration: BoxDecoration(  
581 - borderRadius: BorderRadius.circular(r(5)),  
582 - border: Border.all(  
583 - width: w(1),  
584 - color: MyColours.color_438E93)),  
585 - child: Text(  
586 - '+图片',  
587 - style: TextStyle(  
588 - color: MyColours.color_000000,  
589 - fontSize: font(14)),  
590 - ),  
591 - )),  
592 - HEmptyView(20),  
593 - InkWell(  
594 - onTap: () {  
595 - AdditionModel additionModel1 = AdditionModel();  
596 - additionModel1.content =  
597 - 'webenkjfkdfjakdfjaldfkjaldfjaldf';  
598 - additionModel1.type = '2';  
599 - additionModel1.order = 1;  
600 -  
601 - data.add(additionModel1);  
602 - setState(() {});  
603 - },  
604 - child: Container(  
605 - width: w(77),  
606 - height: w(34),  
607 - alignment: Alignment.center,  
608 - decoration: BoxDecoration(  
609 - borderRadius: BorderRadius.circular(r(5)),  
610 - border: Border.all(  
611 - width: w(1),  
612 - color: MyColours.color_438E93)),  
613 - child: Text(  
614 - '+文字',  
615 - style: TextStyle(  
616 - color: MyColours.color_000000,  
617 - fontSize: font(14)),  
618 - ),  
619 - )),  
620 - ], 671 + ))),
  672 + Container(
  673 + padding: EdgeInsets.symmetric(horizontal: w(24), vertical: w(35)),
  674 + child: Row(
  675 + children: [
  676 + RoundButton(
  677 + text: '返回',
  678 + width: w(100),
  679 + height: w(43),
  680 + radius: r(5),
  681 + fontSize: 32,
  682 + isBold: true,
  683 + gradientStart: MyColours.color_ffffff,
  684 + gradientEnd: MyColours.color_ffffff,
  685 + textColor: MyColours.color_438E93,
  686 + borderColor: MyColours.color_438E93,
  687 + onPressed: () {
  688 + Navigator.pop(context);
  689 + },
621 ), 690 ),
622 - )  
623 - // )  
624 - ],  
625 - ))); 691 + HEmptyView(24),
  692 + Expanded(
  693 + child: RoundButton(
  694 + text: '保存并返回',
  695 + height: w(43),
  696 + radius: r(5),
  697 + isBold: true,
  698 + fontSize: 32,
  699 + gradientStart: MyColours.color_438E93,
  700 + gradientEnd: MyColours.color_438E93,
  701 + textColor: MyColours.color_ffffff,
  702 + borderColor: MyColours.color_438E93,
  703 + onPressed: () {
  704 + // _createReserveDeposit();
  705 + print(data);
  706 + print(titleC.text);
  707 + print(data);
  708 + },
  709 + )),
  710 + ],
  711 + ),
  712 + )
  713 + ],
  714 + ));
626 } 715 }
627 } 716 }
@@ -45,6 +45,16 @@ class UploadImageProvider extends ChangeNotifier { @@ -45,6 +45,16 @@ class UploadImageProvider extends ChangeNotifier {
45 45
46 int countUpload = 0; 46 int countUpload = 0;
47 47
  48 + Map<String, UploadImgModel> _data = {};
  49 +
  50 + void setDynamicValue(String key, UploadImgModel value) {
  51 + _data[key] = value;
  52 + }
  53 +
  54 + UploadImgModel getDynamicValue(String key) {
  55 + return _data[key];
  56 + }
  57 +
48 UploadImageProvider() { 58 UploadImageProvider() {
49 touxiang.process = 0.01; 59 touxiang.process = 0.01;
50 erweima.process = 0.01; 60 erweima.process = 0.01;
@@ -115,7 +115,7 @@ class UploadImageUtil { @@ -115,7 +115,7 @@ class UploadImageUtil {
115 uploadImageProvider.notifyListeners(); 115 uploadImageProvider.notifyListeners();
116 }); 116 });
117 // 添加实际发送进度订阅 117 // 添加实际发送进度订阅
118 - 118 +
119 putController.addSendProgressListener((percent) { 119 putController.addSendProgressListener((percent) {
120 // _onlineCheckEditProvider.imageList[index].process = percent; 120 // _onlineCheckEditProvider.imageList[index].process = percent;
121 // setState(() {}); 121 // setState(() {});
@@ -130,7 +130,7 @@ class UploadImageUtil { @@ -130,7 +130,7 @@ class UploadImageUtil {
130 return; 130 return;
131 } 131 }
132 print('开始上传文件'); 132 print('开始上传文件');
133 - 133 +
134 storage.putFile( 134 storage.putFile(
135 selectedFile, 135 selectedFile,
136 usedToken, 136 usedToken,
@@ -313,6 +313,120 @@ class UploadImageUtil { @@ -313,6 +313,120 @@ class UploadImageUtil {
313 } 313 }
314 314
315 ///上传到七牛云 315 ///上传到七牛云
  316 + void startUploadOnlyAddition(BuildContext context, File selectedFile,
  317 + int index, bool needInit, UploadImageProvider uploadImageProvider,VoidCallback callback) async {
  318 + final PutController putController = PutController();
  319 + print(index);
  320 +
  321 + // 添加状态监听
  322 + putController.addStatusListener((StorageStatus status) {
  323 + print('状态变化: 当前任务状态:${status.toString()}');
  324 + });
  325 + // 添加整体进度监听
  326 + putController.addProgressListener((percent) {
  327 + print('${index}任务进度变化:进度:${percent.toStringAsFixed(4)}');
  328 + UploadImgModel imgModel = uploadImageProvider.getDynamicValue('${index}');
  329 + imgModel.process = percent;
  330 + uploadImageProvider.notifyListeners();
  331 + });
  332 + // 添加实际发送进度订阅
  333 + putController.addSendProgressListener((percent) {
  334 + // _onlineCheckEditProvider.imageList[index].process = percent;
  335 + // setState(() {});
  336 + print('${index}实际发送变化:进度:${percent.toStringAsFixed(4)}');
  337 + });
  338 + if (token == null || token == '') {
  339 + await uploadImageProvider.getQiniuInfo(context, {});
  340 + }
  341 + var usedToken = uploadImageProvider.qiniuInfoSunModel.token;
  342 + if (usedToken == null || usedToken == '') {
  343 + print('token 不能为空');
  344 + return;
  345 + }
  346 + print('开始上传文件');
  347 + storage.putFile(
  348 + selectedFile,
  349 + usedToken,
  350 + options: PutOptions(
  351 + key: key,
  352 + partSize: partSize,
  353 + controller: putController,
  354 + ),
  355 + )
  356 + ..then((PutResponse response) {
  357 + print('${index}上传已完成: 原始响应数据: ${jsonEncode(response.rawData)}');
  358 + print('------------------------');
  359 + String imgUrl = uploadImageProvider.qiniuInfoSunModel.domain +
  360 + '/' +
  361 + response.rawData['key'];
  362 +
  363 + // 取消当前任务
  364 + // putController.cancel();
  365 + UploadImgModel imgModel = uploadImageProvider.getDynamicValue('${index}');
  366 + imgModel.process = 1;
  367 + imgModel.qiniuUrl = imgUrl;
  368 + imgModel.file = null;
  369 + uploadImageProvider.notifyListeners();
  370 + callback();
  371 +
  372 +
  373 + })
  374 + ..catchError((dynamic error) {
  375 + UploadImgModel imgModel = uploadImageProvider.getDynamicValue('${index}');
  376 + imgModel.process = 0;
  377 + imgModel.qiniuUrl = null;
  378 + imgModel.file = null;
  379 + uploadImageProvider.notifyListeners();
  380 +
  381 + // 取消当前任务
  382 + putController.cancel();
  383 + uploadImageProvider.notifyListeners();
  384 + if (error is StorageError) {
  385 + switch (error.type) {
  386 + case StorageErrorType.CONNECT_TIMEOUT:
  387 + Utils.showToast('发生错误: 连接超时');
  388 + break;
  389 + case StorageErrorType.SEND_TIMEOUT:
  390 + print('发生错误: 发送数据超时');
  391 + Utils.showToast('发生错误: 发送数据超时');
  392 + break;
  393 + case StorageErrorType.RECEIVE_TIMEOUT:
  394 + print('发生错误: 响应数据超时');
  395 + Utils.showToast('发生错误: 响应数据超时');
  396 + break;
  397 + case StorageErrorType.RESPONSE:
  398 + print('发生错误: ${error.message}');
  399 + // Utils.showToast('发生错误000: ${error}');
  400 + // Utils.showToast('发生错误000: ${error.code}');
  401 + Utils.showToast('发生错误: ${error.message}');
  402 + break;
  403 + case StorageErrorType.CANCEL:
  404 + print('发生错误: 请求取消');
  405 + Utils.showToast('发生错误: 请求取消');
  406 + break;
  407 + case StorageErrorType.UNKNOWN:
  408 + print('发生错误: ');
  409 + Utils.showToast('发生错误: 未知错误');
  410 + break;
  411 + case StorageErrorType.NO_AVAILABLE_HOST:
  412 + print('发生错误: 无可用 Host');
  413 + Utils.showToast('发生错误: 无可用 Host');
  414 + break;
  415 + case StorageErrorType.IN_PROGRESS:
  416 + print('发生错误: 已在队列中');
  417 + Utils.showToast('发生错误: 已在队列中');
  418 + break;
  419 + }
  420 + } else {
  421 + print('发生错误: ${error.toString()}');
  422 + Utils.showToast('发生错误: ${error.toString()}');
  423 + }
  424 +
  425 + print('------------------------');
  426 + });
  427 + }
  428 +
  429 + ///上传到七牛云
316 void startUploadOnly(BuildContext context, File selectedFile, int index, 430 void startUploadOnly(BuildContext context, File selectedFile, int index,
317 bool needInit, UploadImageProvider uploadImageProvider) async { 431 bool needInit, UploadImageProvider uploadImageProvider) async {
318 final PutController putController = PutController(); 432 final PutController putController = PutController();
@@ -352,13 +466,13 @@ class UploadImageUtil { @@ -352,13 +466,13 @@ class UploadImageUtil {
352 } else if (index == 9) { 466 } else if (index == 9) {
353 //9 预订安排logo 467 //9 预订安排logo
354 uploadImageProvider.logo.process = percent; 468 uploadImageProvider.logo.process = percent;
355 - }else if (index == 10) { 469 + } else if (index == 10) {
356 //4 预订安排首图 470 //4 预订安排首图
357 uploadImageProvider.storeImage5.process = percent; 471 uploadImageProvider.storeImage5.process = percent;
358 } else if (index == 11) { 472 } else if (index == 11) {
359 //4 预订安排首图 473 //4 预订安排首图
360 uploadImageProvider.storeImage6.process = percent; 474 uploadImageProvider.storeImage6.process = percent;
361 - } else { 475 + } else {
362 //1 二维码 476 //1 二维码
363 uploadImageProvider.erweima.process = percent; 477 uploadImageProvider.erweima.process = percent;
364 } 478 }
@@ -447,7 +561,7 @@ class UploadImageUtil { @@ -447,7 +561,7 @@ class UploadImageUtil {
447 uploadImageProvider.logo.qiniuUrl = imgUrl; 561 uploadImageProvider.logo.qiniuUrl = imgUrl;
448 uploadImageProvider.logo.file = null; 562 uploadImageProvider.logo.file = null;
449 uploadImageProvider.notifyListeners(); 563 uploadImageProvider.notifyListeners();
450 - }else if (index == 10) { 564 + } else if (index == 10) {
451 uploadImageProvider.storeImage5.process = 1; 565 uploadImageProvider.storeImage5.process = 1;
452 uploadImageProvider.storeImage5.qiniuUrl = imgUrl; 566 uploadImageProvider.storeImage5.qiniuUrl = imgUrl;
453 uploadImageProvider.storeImage5.file = null; 567 uploadImageProvider.storeImage5.file = null;
@@ -457,7 +571,7 @@ class UploadImageUtil { @@ -457,7 +571,7 @@ class UploadImageUtil {
457 uploadImageProvider.storeImage6.qiniuUrl = imgUrl; 571 uploadImageProvider.storeImage6.qiniuUrl = imgUrl;
458 uploadImageProvider.storeImage6.file = null; 572 uploadImageProvider.storeImage6.file = null;
459 uploadImageProvider.notifyListeners(); 573 uploadImageProvider.notifyListeners();
460 - } 574 + }
461 }) 575 })
462 ..catchError((dynamic error) { 576 ..catchError((dynamic error) {
463 if (index == 0) { 577 if (index == 0) {
@@ -510,17 +624,17 @@ class UploadImageUtil { @@ -510,17 +624,17 @@ class UploadImageUtil {
510 uploadImageProvider.logo.qiniuUrl = null; 624 uploadImageProvider.logo.qiniuUrl = null;
511 uploadImageProvider.logo.file = null; 625 uploadImageProvider.logo.file = null;
512 uploadImageProvider.notifyListeners(); 626 uploadImageProvider.notifyListeners();
513 - }else if (index == 10) {  
514 - uploadImageProvider.storeImage5.process = 0; 627 + } else if (index == 10) {
  628 + uploadImageProvider.storeImage5.process = 0;
515 uploadImageProvider.storeImage5.qiniuUrl = null; 629 uploadImageProvider.storeImage5.qiniuUrl = null;
516 uploadImageProvider.storeImage5.file = null; 630 uploadImageProvider.storeImage5.file = null;
517 uploadImageProvider.notifyListeners(); 631 uploadImageProvider.notifyListeners();
518 } else if (index == 11) { 632 } else if (index == 11) {
519 - uploadImageProvider.storeImage6.process = 0; 633 + uploadImageProvider.storeImage6.process = 0;
520 uploadImageProvider.storeImage6.qiniuUrl = null; 634 uploadImageProvider.storeImage6.qiniuUrl = null;
521 uploadImageProvider.storeImage6.file = null; 635 uploadImageProvider.storeImage6.file = null;
522 uploadImageProvider.notifyListeners(); 636 uploadImageProvider.notifyListeners();
523 - } 637 + }
524 // 取消当前任务 638 // 取消当前任务
525 putController.cancel(); 639 putController.cancel();
526 uploadImageProvider.notifyListeners(); 640 uploadImageProvider.notifyListeners();