Commit 7d57d9f74f7f462dd14e2713f3213ed62dead809

Authored by wdn127929
1 parent b2a53782

部分店铺信息UI

1 import 'dart:io'; 1 import 'dart:io';
  2 +import 'dart:ui';
2 3
3 import 'package:cached_network_image/cached_network_image.dart'; 4 import 'package:cached_network_image/cached_network_image.dart';
4 import 'package:dio/dio.dart'; 5 import 'package:dio/dio.dart';
@@ -21,8 +22,10 @@ import 'package:one_key/utils/event_bus.dart'; @@ -21,8 +22,10 @@ import 'package:one_key/utils/event_bus.dart';
21 import 'package:one_key/utils/upload_image_util.dart'; 22 import 'package:one_key/utils/upload_image_util.dart';
22 import 'package:one_key/utils/utils.dart'; 23 import 'package:one_key/utils/utils.dart';
23 import 'package:one_key/widgets/h_empty_view.dart'; 24 import 'package:one_key/widgets/h_empty_view.dart';
  25 +import 'package:one_key/widgets/max_word_textinput_formater.dart';
24 import 'package:one_key/widgets/round_button.dart'; 26 import 'package:one_key/widgets/round_button.dart';
25 import 'package:one_key/widgets/system_app_bar.dart'; 27 import 'package:one_key/widgets/system_app_bar.dart';
  28 +import 'package:one_key/widgets/text_input_field_widget.dart';
26 import 'package:one_key/widgets/v_empty_view.dart'; 29 import 'package:one_key/widgets/v_empty_view.dart';
27 import 'package:image_picker/image_picker.dart'; 30 import 'package:image_picker/image_picker.dart';
28 import 'package:permission_handler/permission_handler.dart'; 31 import 'package:permission_handler/permission_handler.dart';
@@ -47,6 +50,8 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> { @@ -47,6 +50,8 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> {
47 FocusNode _timeFocusNode = FocusNode(); 50 FocusNode _timeFocusNode = FocusNode();
48 FocusNode _addressFocusNode = FocusNode(); 51 FocusNode _addressFocusNode = FocusNode();
49 FocusNode _introductionFocusNode = FocusNode(); 52 FocusNode _introductionFocusNode = FocusNode();
  53 + TextEditingController _phoneController2 = TextEditingController();
  54 + FocusNode _phoneFocusNode2 = FocusNode();
50 55
51 Map<String, dynamic> mapAddress; 56 Map<String, dynamic> mapAddress;
52 57
@@ -54,6 +59,11 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> { @@ -54,6 +59,11 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> {
54 UploadImageProvider _uploadImageProvider; 59 UploadImageProvider _uploadImageProvider;
55 StoreBaseIndoProvider _baseIndoProvider; 60 StoreBaseIndoProvider _baseIndoProvider;
56 61
  62 + int _countName = 0;
  63 + final int maxWordLengthName = 15;
  64 +
  65 + int _countAddress = 0;
  66 + final int maxWordLengthAddress = 30;
57 @override 67 @override
58 void initState() { 68 void initState() {
59 super.initState(); 69 super.initState();
@@ -62,11 +72,12 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> { @@ -62,11 +72,12 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> {
62 'lat': '', 72 'lat': '',
63 'lng': '', 73 'lng': '',
64 }; 74 };
  75 + Utils.changeStatusColor(color: MyColours.color_F8F9FD);
65 _scrollController = ScrollController(); 76 _scrollController = ScrollController();
66 WidgetsBinding.instance.addPostFrameCallback((_) { 77 WidgetsBinding.instance.addPostFrameCallback((_) {
67 _uploadImageProvider.mentou.process = 0.01; 78 _uploadImageProvider.mentou.process = 0.01;
68 _uploadImageProvider.mentou.qiniuUrl = ''; 79 _uploadImageProvider.mentou.qiniuUrl = '';
69 - _uploadImageProvider.imgSizeMenTou = 64; 80 +
70 // _uploadImageProvider.mentou.file = null; 81 // _uploadImageProvider.mentou.file = null;
71 _getQiniuInfo(); 82 _getQiniuInfo();
72 _getStoreBaseinfo(); 83 _getStoreBaseinfo();
@@ -85,6 +96,8 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> { @@ -85,6 +96,8 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> {
85 _introductionController.text = itemModel.data.sellerdesc; 96 _introductionController.text = itemModel.data.sellerdesc;
86 _uploadImageProvider.mentou.qiniuUrl = itemModel.data.sellerImage; 97 _uploadImageProvider.mentou.qiniuUrl = itemModel.data.sellerImage;
87 // _uploadImageProvider.notifyListeners(); 98 // _uploadImageProvider.notifyListeners();
  99 + _countName = _nameController.text.trim().length;
  100 + _countAddress = _addressController.text.trim().length;
88 mapAddress = { 101 mapAddress = {
89 "address": itemModel.data.mapAddress, 102 "address": itemModel.data.mapAddress,
90 'lat': itemModel.data.lat, 103 'lat': itemModel.data.lat,
@@ -271,7 +284,6 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> { @@ -271,7 +284,6 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> {
271 } 284 }
272 }); 285 });
273 if (pickedFile != null) { 286 if (pickedFile != null) {
274 - _uploadImageProvider.imgSizeMenTou = 64;  
275 _uploadImageProvider.mentou.qiniuUrl = null; 287 _uploadImageProvider.mentou.qiniuUrl = null;
276 _uploadImageProvider.mentou.file = File(pickedFile.path); 288 _uploadImageProvider.mentou.file = File(pickedFile.path);
277 _uploadImageProvider.mentou.path = pickedFile.path; 289 _uploadImageProvider.mentou.path = pickedFile.path;
@@ -439,6 +451,33 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> { @@ -439,6 +451,33 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> {
439 ); 451 );
440 } 452 }
441 453
  454 + Widget _buildCompute(int count, int max) {
  455 + return RichText(
  456 + text: TextSpan(
  457 + style: TextStyle(
  458 + fontSize: ScreenUtil().setSp(24),
  459 + color: MyColours.color_BFC4D4),
  460 + children: [
  461 + // const TextSpan(text: '('),
  462 + TextSpan(
  463 + text: count.toString(),
  464 + style: TextStyle(color: MyColours.color_BFC4D4)),
  465 + TextSpan(text: "/${max.toString()}"),
  466 + ]));
  467 + }
  468 +
  469 + void chageCount(int count) {
  470 + setState(() {
  471 + _countName = count;
  472 + });
  473 + }
  474 +
  475 + void chageCountAddress(int count) {
  476 + setState(() {
  477 + _countAddress = count;
  478 + });
  479 + }
  480 +
442 @override 481 @override
443 Widget build(BuildContext context) { 482 Widget build(BuildContext context) {
444 _uploadImageProvider = 483 _uploadImageProvider =
@@ -446,9 +485,10 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> { @@ -446,9 +485,10 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> {
446 _baseIndoProvider = 485 _baseIndoProvider =
447 Provider.of<StoreBaseIndoProvider>(context, listen: true); 486 Provider.of<StoreBaseIndoProvider>(context, listen: true);
448 return Scaffold( 487 return Scaffold(
449 - backgroundColor: MyColours.color_fefefe, 488 + backgroundColor: MyColours.color_F8F9FD,
450 appBar: SystemAppBar( 489 appBar: SystemAppBar(
451 '店铺信息', 490 '店铺信息',
  491 + bgColor: MyColours.color_F8F9FD,
452 onTap: () { 492 onTap: () {
453 EventBus().emit('changeStatusColor'); 493 EventBus().emit('changeStatusColor');
454 Navigator.of(context).pop(); 494 Navigator.of(context).pop();
@@ -463,123 +503,1038 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> { @@ -463,123 +503,1038 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> {
463 onTap: () { 503 onTap: () {
464 FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 504 FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
465 }, 505 },
466 - child: Column(children: [  
467 - Expanded(  
468 - child: SingleChildScrollView(  
469 - controller: _scrollController,  
470 - physics: BouncingScrollPhysics(),  
471 - child: Column(  
472 - children: [  
473 - Padding(  
474 - padding: EdgeInsets.symmetric(  
475 - horizontal: ScreenUtil().setWidth(40), 506 + child: Container(
  507 + color: MyColours.color_F8F9FD,
  508 + padding: EdgeInsets.symmetric(
  509 + horizontal: ScreenUtil().setWidth(24)),
  510 + child: Column(children: [
  511 + Expanded(
  512 + child: SingleChildScrollView(
  513 + controller: _scrollController,
  514 + physics: BouncingScrollPhysics(),
  515 + child: Column(
  516 + crossAxisAlignment: CrossAxisAlignment.start,
  517 + children: [
  518 + VEmptyView(60),
  519 + Text(
  520 + '门头照片',
  521 + textAlign: TextAlign.left,
  522 + style: TextStyle(
  523 + color: MyColours.color_515151,
  524 + fontWeight: FontWeight.bold,
  525 + fontSize: ScreenUtil().setSp(32)),
476 ), 526 ),
477 - child: _textfield('店铺名称', '请填写店铺名称',  
478 - _nameController, _nameFocusNode)),  
479 - VEmptyView(10),  
480 - _imageWidget('门头照片', _uploadImageProvider.mentou,  
481 - _uploadImageProvider.imgSizeMenTou, 64),  
482 - VEmptyView(30),  
483 - Container(  
484 - height: ScreenUtil().setWidth(2),  
485 - color: MyColours.color_efefef,  
486 - margin: EdgeInsets.only(  
487 - left: ScreenUtil().setWidth(108 * 2),  
488 - right: ScreenUtil().setWidth(40)),  
489 - ),  
490 - VEmptyView(10),  
491 - Padding(  
492 - padding: EdgeInsets.symmetric(  
493 - horizontal: ScreenUtil().setWidth(40), 527 + VEmptyView(34),
  528 + InkWell(
  529 + onTap: () {
  530 + double process;
  531 + String qiniuUrl;
  532 + List<String> tempList = [];
  533 +
  534 + process =
  535 + _uploadImageProvider.mentou.process;
  536 + qiniuUrl =
  537 + _uploadImageProvider.mentou.qiniuUrl;
  538 +
  539 + if (qiniuUrl != null && qiniuUrl != '') {
  540 + tempList.add(qiniuUrl);
  541 +
  542 + ///没有上传完成的不可以点击
  543 + _showPhotoView(context, 0, tempList);
  544 + } else {
  545 + Utils.getPickPermission(context, () {
  546 + _getFromPictureOrCamera(
  547 + '门头照片',
  548 + _uploadImageProvider.mentou,
  549 + ImageSource.gallery);
  550 + },
  551 + Platform.isAndroid
  552 + ? Permission.storage
  553 + : Permission.photos);
  554 + }
  555 + },
  556 + child: Center(
  557 + // alignment: Alignment.center,
  558 + child: Container(
  559 + width: ScreenUtil().setWidth(76 * 2),
  560 + height: ScreenUtil().setWidth(76 * 2),
  561 + decoration: BoxDecoration(
  562 + boxShadow: [
  563 + // BoxShadow(
  564 + // color: Color.fromRGBO(0, 0, 0, 0.4),
  565 + // offset: Offset(0, ScreenUtil().setWidth(8)),
  566 + // spreadRadius: ScreenUtil().setWidth(2),
  567 + // blurRadius: ScreenUtil().setWidth(34))
  568 + BoxShadow(
  569 + color: Color.fromRGBO(
  570 + 0, 0, 0, 0.25),
  571 + offset: Offset(0,
  572 + ScreenUtil().setWidth(6)),
  573 + blurRadius:
  574 + ScreenUtil().setWidth(18),
  575 + spreadRadius:
  576 + ScreenUtil().setWidth(2))
  577 + ],
  578 + borderRadius: BorderRadius.circular(
  579 + ScreenUtil().setWidth(44)),
  580 + ),
  581 + child: Stack(
  582 + clipBehavior: Clip.none,
  583 + children: [
  584 + ClipRRect(
  585 + borderRadius:
  586 + BorderRadius.circular(
  587 + ScreenUtil()
  588 + .setWidth(44)),
  589 + child: _uploadImageProvider
  590 + .mentou.file ==
  591 + null
  592 + ? _uploadImageProvider
  593 + .mentou
  594 + .qiniuUrl !=
  595 + null &&
  596 + _uploadImageProvider
  597 + .mentou
  598 + .qiniuUrl !=
  599 + ''
  600 + ? Image.network(
  601 + _uploadImageProvider
  602 + .mentou
  603 + .qiniuUrl,
  604 + fit: BoxFit.cover,
  605 + width: ScreenUtil()
  606 + .setWidth(
  607 + 76 * 2),
  608 + height: ScreenUtil()
  609 + .setWidth(
  610 + 76 * 2),
  611 + )
  612 + : Container(
  613 + width: ScreenUtil()
  614 + .setWidth(
  615 + 76 * 2),
  616 + height: ScreenUtil()
  617 + .setWidth(
  618 + 76 * 2),
  619 + padding: EdgeInsets
  620 + .all(ScreenUtil()
  621 + .setWidth(
  622 + 32)),
  623 + decoration: BoxDecoration(
  624 + borderRadius: BorderRadius.circular(
  625 + ScreenUtil()
  626 + .setWidth(
  627 + 44)),
  628 + color: MyColours
  629 + .color_DBDBDB),
  630 + child: Image.asset(
  631 + Utils.getImgPath(
  632 + 'store_no_image'),
  633 + fit: BoxFit.cover,
  634 + width: ScreenUtil()
  635 + .setWidth(
  636 + 44 * 2),
  637 + height:
  638 + ScreenUtil()
  639 + .setWidth(
  640 + 44 *
  641 + 2),
  642 + ),
  643 + )
  644 + : Image.file(
  645 + _uploadImageProvider
  646 + .mentou.file,
  647 + fit: BoxFit.cover,
  648 + width: ScreenUtil()
  649 + .setWidth(76 * 2),
  650 + height: ScreenUtil()
  651 + .setWidth(76 * 2),
  652 + )),
  653 + (_uploadImageProvider.mentou.file !=
  654 + null) &&
  655 + _uploadImageProvider
  656 + .mentou.process !=
  657 + 1 &&
  658 + _uploadImageProvider
  659 + .mentou.process !=
  660 + 0.01
  661 + ? Container(
  662 + width: ScreenUtil()
  663 + .setWidth(76 * 2),
  664 + height: ScreenUtil()
  665 + .setWidth(76 * 2),
  666 + decoration: BoxDecoration(
  667 + borderRadius:
  668 + BorderRadius.circular(
  669 + ScreenUtil()
  670 + .setWidth(
  671 + 44)),
  672 + color: Color.fromRGBO(
  673 + 0, 0, 0, 0.6)),
  674 + child: Center(
  675 + child: Text('上传中',
  676 + style: TextStyle(
  677 + color: MyColours
  678 + .color_999999)),
  679 + ),
  680 + )
  681 + : Container(),
  682 + Positioned(
  683 + bottom:
  684 + ScreenUtil().setWidth(-6),
  685 + right:
  686 + ScreenUtil().setWidth(-6),
  687 + child: InkWell(
  688 + onTap: () {
  689 + Utils.getPickPermission(
  690 + context, () {
  691 + _getFromPictureOrCamera(
  692 + '门头照片',
  693 + _uploadImageProvider
  694 + .mentou,
  695 + ImageSource.gallery);
  696 + },
  697 + Platform.isAndroid
  698 + ? Permission.storage
  699 + : Permission
  700 + .photos);
  701 + },
  702 + child: Image.asset(
  703 + Utils.getImgPath(
  704 + 'store_upload'),
  705 + fit: BoxFit.cover,
  706 + width: ScreenUtil()
  707 + .setWidth(28 * 2),
  708 + height: ScreenUtil()
  709 + .setWidth(28 * 2),
  710 + ),
  711 + ))
  712 + ],
  713 + )),
  714 + ),
494 ), 715 ),
495 - child: _textfield('店铺电话', '请填写店铺电话',  
496 - _phoneController, _phoneFocusNode)),  
497 - VEmptyView(10),  
498 - Container(  
499 - height: ScreenUtil().setWidth(2),  
500 - color: MyColours.color_efefef,  
501 - margin: EdgeInsets.only(  
502 - left: ScreenUtil().setWidth(108 * 2),  
503 - right: ScreenUtil().setWidth(40)),  
504 - ),  
505 - VEmptyView(10),  
506 - Padding(  
507 - padding: EdgeInsets.symmetric(  
508 - horizontal: ScreenUtil().setWidth(40), 716 + VEmptyView(76),
  717 + RichText(
  718 + text: TextSpan(
  719 + style: TextStyle(
  720 + fontWeight: FontWeight.bold,
  721 + fontSize: ScreenUtil().setSp(32)),
  722 + children: [
  723 + // const TextSpan(text: '('),
  724 + TextSpan(
  725 + text: '店铺名称',
  726 + style: TextStyle(
  727 + color: MyColours.color_515151)),
  728 + TextSpan(
  729 + text: '*',
  730 + style: TextStyle(
  731 + color: MyColours.color_E34D59)),
  732 + ])),
  733 + VEmptyView(24),
  734 + Container(
  735 + padding: EdgeInsets.symmetric(
  736 + horizontal: ScreenUtil().setWidth(24)),
  737 + decoration: BoxDecoration(
  738 + color: MyColours.color_ffffff,
  739 + borderRadius: BorderRadius.circular(
  740 + ScreenUtil().setWidth(26))),
  741 + child: Row(
  742 + children: [
  743 + Expanded(
  744 + child: TextInputFieldWidget(
  745 + textInputFormatters: [
  746 + // FilteringTextInputFormatter.allow(
  747 + // RegExp(r"[a-z\s_-]+")),
  748 + MaxWordTextInputFormater(
  749 + maxWords: 15,
  750 + currentLength: chageCount)
  751 + ],
  752 + hasFocusColor: MyColours.color_515151,
  753 + hitColor: MyColours.color_BFC4D4,
  754 + hintText: "请输入店铺名称",
  755 + maxLines: 1,
  756 + lineHeight: 1,
  757 + fontSize: ScreenUtil().setSp(24),
  758 + textEditingController:
  759 + _nameController,
  760 + focusNode: _nameFocusNode,
  761 + )),
  762 + _buildCompute(
  763 + _countName, maxWordLengthName),
  764 + ],
  765 + )),
  766 + VEmptyView(106),
  767 + Row(
  768 + mainAxisAlignment:
  769 + MainAxisAlignment.spaceBetween,
  770 + children: [
  771 + RichText(
  772 + text: TextSpan(
  773 + style: TextStyle(
  774 + fontWeight: FontWeight.bold,
  775 + fontSize:
  776 + ScreenUtil().setSp(32)),
  777 + children: [
  778 + // const TextSpan(text: '('),
  779 + TextSpan(
  780 + text: '店铺电话',
  781 + style: TextStyle(
  782 + color:
  783 + MyColours.color_515151)),
  784 + TextSpan(
  785 + text: '*',
  786 + style: TextStyle(
  787 + color:
  788 + MyColours.color_E34D59)),
  789 + ])),
  790 + Padding(
  791 + padding: EdgeInsets.only(
  792 + right: ScreenUtil().setWidth(26)),
  793 + child: Image.asset(
  794 + Utils.getImgPath('stoore_add'),
  795 + width: ScreenUtil().setWidth(44)))
  796 + ],
509 ), 797 ),
510 - child: _textfield(  
511 - '营业时间',  
512 - '请填写营业时间,如09:00-23:00',  
513 - _timeController,  
514 - _timeFocusNode)),  
515 - VEmptyView(10),  
516 - Container(  
517 - height: ScreenUtil().setWidth(2),  
518 - color: MyColours.color_efefef,  
519 - margin: EdgeInsets.only(  
520 - left: ScreenUtil().setWidth(108 * 2),  
521 - right: ScreenUtil().setWidth(40)),  
522 - ),  
523 - VEmptyView(10),  
524 - Padding(  
525 - padding: EdgeInsets.symmetric(  
526 - horizontal: ScreenUtil().setWidth(40),  
527 - vertical: ScreenUtil().setWidth(40), 798 + VEmptyView(44),
  799 + Padding(
  800 + padding: EdgeInsets.symmetric(
  801 + horizontal: ScreenUtil().setWidth(26)),
  802 + child: Row(
  803 + children: [
  804 + Text('电话1:',
  805 + style: TextStyle(
  806 + fontSize:
  807 + ScreenUtil().setSp(28),
  808 + color: MyColours.color_999999)),
  809 + HEmptyView(32),
  810 + Expanded(
  811 + child: Container(
  812 + height: ScreenUtil().setWidth(60),
  813 + padding: EdgeInsets.symmetric(
  814 + horizontal:
  815 + ScreenUtil().setWidth(24)),
  816 + decoration: BoxDecoration(
  817 + color: MyColours.color_ffffff,
  818 + borderRadius:
  819 + BorderRadius.circular(
  820 + ScreenUtil()
  821 + .setWidth(26))),
  822 + child: TextField(
  823 + controller: _phoneController,
  824 + maxLines: 1,
  825 + // inputFormatters: [
  826 + // LengthLimitingTextInputFormatter(
  827 + // 15),
  828 + // // WhitelistingTextInputFormatter.digitsOnly
  829 + // ],
  830 +
  831 + // //光标颜色
  832 + // cursorColor:
  833 + // widget.isSelect ? Colors.white : MyColours.color_199095,
  834 + //输入文本的样式
  835 + style: TextStyle(
  836 + fontSize:
  837 + ScreenUtil().setSp(24),
  838 + color: MyColours.color_515151),
  839 + focusNode: _phoneFocusNode,
  840 + decoration: InputDecoration(
  841 + border: OutlineInputBorder(
  842 + borderSide: BorderSide.none),
  843 + hintText: '请输入区号+固定电话或11位手机号',
  844 + hintStyle: TextStyle(
  845 + color: MyColours.color_BFC4D4,
  846 + fontSize:
  847 + ScreenUtil().setSp(24),
  848 + ),
  849 + enabledBorder:
  850 + new UnderlineInputBorder(
  851 + borderSide: BorderSide.none,
  852 + ),
  853 + focusedBorder:
  854 + new UnderlineInputBorder(
  855 + borderSide: BorderSide.none,
  856 + ),
  857 + ),
  858 + onChanged: (value) {
  859 + // if (editingController == _nameController) {
  860 + // _nameController.text = value;
  861 + // }
  862 + },
  863 + onEditingComplete: () {
  864 + FocusScope.of(context)
  865 + .requestFocus(
  866 + FocusNode()); //点击空白处隐藏键盘
  867 + },
  868 + keyboardType: TextInputType.text,
  869 + ),
  870 + )),
  871 + HEmptyView(20),
  872 + Image.asset(
  873 + Utils.getImgPath('store_jian'),
  874 + width: ScreenUtil().setWidth(44))
  875 + ],
  876 + )),
  877 + VEmptyView(32),
  878 + Padding(
  879 + padding: EdgeInsets.symmetric(
  880 + horizontal: ScreenUtil().setWidth(26)),
  881 + child: Row(
  882 + children: [
  883 + Text('电话2:',
  884 + style: TextStyle(
  885 + fontSize:
  886 + ScreenUtil().setSp(28),
  887 + color: MyColours.color_999999)),
  888 + HEmptyView(32),
  889 + Expanded(
  890 + child: Container(
  891 + height: ScreenUtil().setWidth(60),
  892 + padding: EdgeInsets.symmetric(
  893 + horizontal:
  894 + ScreenUtil().setWidth(24)),
  895 + decoration: BoxDecoration(
  896 + color: MyColours.color_ffffff,
  897 + borderRadius:
  898 + BorderRadius.circular(
  899 + ScreenUtil()
  900 + .setWidth(26))),
  901 + child: TextField(
  902 + controller: _phoneController2,
  903 + maxLines: 1,
  904 + // inputFormatters: [
  905 + // LengthLimitingTextInputFormatter(
  906 + // 15),
  907 + // // WhitelistingTextInputFormatter.digitsOnly
  908 + // ],
  909 +
  910 + // //光标颜色
  911 + // cursorColor:
  912 + // widget.isSelect ? Colors.white : MyColours.color_199095,
  913 + //输入文本的样式
  914 + style: TextStyle(
  915 + fontSize:
  916 + ScreenUtil().setSp(24),
  917 + color: MyColours.color_515151),
  918 + focusNode: _phoneFocusNode2,
  919 + decoration: InputDecoration(
  920 + border: OutlineInputBorder(
  921 + borderSide: BorderSide.none),
  922 + hintText: '请输入区号+固定电话或11位手机号',
  923 + hintStyle: TextStyle(
  924 + color: MyColours.color_BFC4D4,
  925 + fontSize:
  926 + ScreenUtil().setSp(24),
  927 + ),
  928 + enabledBorder:
  929 + new UnderlineInputBorder(
  930 + borderSide: BorderSide.none,
  931 + ),
  932 + focusedBorder:
  933 + new UnderlineInputBorder(
  934 + borderSide: BorderSide.none,
  935 + ),
  936 + ),
  937 + onChanged: (value) {
  938 + // if (editingController == _nameController) {
  939 + // _nameController.text = value;
  940 + // }
  941 + },
  942 + onEditingComplete: () {
  943 + FocusScope.of(context)
  944 + .requestFocus(
  945 + FocusNode()); //点击空白处隐藏键盘
  946 + },
  947 + keyboardType: TextInputType.text,
  948 + ),
  949 + )),
  950 + HEmptyView(20),
  951 + Image.asset(
  952 + Utils.getImgPath('store_jian'),
  953 + width: ScreenUtil().setWidth(44))
  954 + ],
  955 + )),
  956 + VEmptyView(112),
  957 + RichText(
  958 + text: TextSpan(
  959 + style: TextStyle(
  960 + fontWeight: FontWeight.bold,
  961 + fontSize: ScreenUtil().setSp(32)),
  962 + children: [
  963 + // const TextSpan(text: '('),
  964 + TextSpan(
  965 + text: '营业时间',
  966 + style: TextStyle(
  967 + color: MyColours.color_515151)),
  968 + TextSpan(
  969 + text: '*',
  970 + style: TextStyle(
  971 + color: MyColours.color_E34D59)),
  972 + ])),
  973 + VEmptyView(44),
  974 + Container(
  975 + padding: EdgeInsets.symmetric(
  976 + horizontal: ScreenUtil().setWidth(24)),
  977 + decoration: BoxDecoration(
  978 + color: MyColours.color_ffffff,
  979 + borderRadius: BorderRadius.circular(
  980 + ScreenUtil().setWidth(26))),
  981 + child: TextField(
  982 + controller: _timeController,
  983 + maxLines: 1,
  984 + // inputFormatters: [
  985 + // LengthLimitingTextInputFormatter(
  986 + // 15),
  987 + // // WhitelistingTextInputFormatter.digitsOnly
  988 + // ],
  989 +
  990 + // //光标颜色
  991 + // cursorColor:
  992 + // widget.isSelect ? Colors.white : MyColours.color_199095,
  993 + //输入文本的样式
  994 + style: TextStyle(
  995 + fontSize: ScreenUtil().setSp(24),
  996 + color: MyColours.color_515151),
  997 + focusNode: _timeFocusNode,
  998 + decoration: InputDecoration(
  999 + border: OutlineInputBorder(
  1000 + borderSide: BorderSide.none),
  1001 + hintText: '如:9:00-21:00',
  1002 + hintStyle: TextStyle(
  1003 + color: MyColours.color_BFC4D4,
  1004 + fontSize: ScreenUtil().setSp(24),
  1005 + ),
  1006 + enabledBorder: new UnderlineInputBorder(
  1007 + borderSide: BorderSide.none,
  1008 + ),
  1009 + focusedBorder: new UnderlineInputBorder(
  1010 + borderSide: BorderSide.none,
  1011 + ),
  1012 + ),
  1013 + onChanged: (value) {
  1014 + // if (editingController == _nameController) {
  1015 + // _nameController.text = value;
  1016 + // }
  1017 + },
  1018 + onEditingComplete: () {
  1019 + FocusScope.of(context).requestFocus(
  1020 + FocusNode()); //点击空白处隐藏键盘
  1021 + },
  1022 + keyboardType: TextInputType.text,
  1023 + ),
528 ), 1024 ),
529 - child: _select('地图地址', mapAddress['address'])),  
530 - VEmptyView(10),  
531 - Container(  
532 - height: ScreenUtil().setWidth(2),  
533 - color: MyColours.color_efefef,  
534 - margin: EdgeInsets.only(  
535 - left: ScreenUtil().setWidth(108 * 2),  
536 - right: ScreenUtil().setWidth(40)),  
537 - ),  
538 - VEmptyView(10),  
539 - Padding(  
540 - padding: EdgeInsets.symmetric(  
541 - horizontal: ScreenUtil().setWidth(40), 1025 + VEmptyView(104),
  1026 + RichText(
  1027 + text: TextSpan(
  1028 + style: TextStyle(
  1029 + fontWeight: FontWeight.bold,
  1030 + fontSize: ScreenUtil().setSp(32)),
  1031 + children: [
  1032 + // const TextSpan(text: '('),
  1033 + TextSpan(
  1034 + text: '店铺地址',
  1035 + style: TextStyle(
  1036 + color: MyColours.color_515151)),
  1037 + TextSpan(
  1038 + text: '*',
  1039 + style: TextStyle(
  1040 + color: MyColours.color_E34D59)),
  1041 + ])),
  1042 + VEmptyView(44),
  1043 + Padding(
  1044 + padding: EdgeInsets.symmetric(
  1045 + horizontal: ScreenUtil().setWidth(24),
  1046 + ),
  1047 + child: Container(
  1048 + height: ScreenUtil().setWidth(48 * 2),
  1049 + decoration: BoxDecoration(
  1050 + borderRadius: BorderRadius.circular(
  1051 + ScreenUtil().setWidth(10)),
  1052 + border: Border.all(
  1053 + width: ScreenUtil().setWidth(2),
  1054 + color: MyColours.color_438E93)),
  1055 + child: Row(
  1056 + mainAxisAlignment:
  1057 + MainAxisAlignment.center,
  1058 + children: [
  1059 + Text(
  1060 + '选择地图定位',
  1061 + style: TextStyle(
  1062 + color: MyColours.color_438E93,
  1063 + fontSize:
  1064 + ScreenUtil().setSp(28)),
  1065 + ),
  1066 + HEmptyView(30),
  1067 + Image.asset(
  1068 + Utils.getImgPath('store_address'),
  1069 + width: ScreenUtil().setWidth(44)),
  1070 + ],
  1071 + ),
  1072 + )),
  1073 + VEmptyView(40),
  1074 + Padding(
  1075 + padding: EdgeInsets.symmetric(
  1076 + horizontal: ScreenUtil().setWidth(24),
  1077 + ),
  1078 + child: Row(children: [
  1079 + Text('详细地址:',
  1080 + style: TextStyle(
  1081 + fontSize: ScreenUtil().setSp(28),
  1082 + color: MyColours.color_999999)),
  1083 + HEmptyView(32),
  1084 + Expanded(
  1085 + child: TextInputFieldWidget(
  1086 + textInputFormatters: [
  1087 + // FilteringTextInputFormatter.allow(
  1088 + // RegExp(r"[a-z\s_-]+")),
  1089 + MaxWordTextInputFormater(
  1090 + maxWords: 15,
  1091 + currentLength: chageCountAddress)
  1092 + ],
  1093 + hasFocusColor: MyColours.color_515151,
  1094 + hitColor: MyColours.color_BFC4D4,
  1095 + hintText: "输入店铺详细地址",
  1096 + maxLines: 1,
  1097 + lineHeight: 1,
  1098 + fontSize: ScreenUtil().setSp(24),
  1099 + textEditingController:
  1100 + _addressController,
  1101 + focusNode: _addressFocusNode,
  1102 + )),
  1103 + _buildCompute(
  1104 + _countAddress, maxWordLengthAddress)
  1105 + ])),
  1106 + VEmptyView(120),
  1107 + Text('可预订时段',
  1108 + style: TextStyle(
  1109 + fontWeight: FontWeight.bold,
  1110 + fontSize: ScreenUtil().setSp(32),
  1111 + color: MyColours.color_515151)),
  1112 + VEmptyView(34),
  1113 + Padding(
  1114 + padding: EdgeInsets.symmetric(
  1115 + horizontal: ScreenUtil().setWidth(24),
  1116 + ),
  1117 + child: Column(
  1118 + children: [
  1119 + Row(
  1120 + mainAxisAlignment:
  1121 + MainAxisAlignment.spaceBetween,
  1122 + children: [
  1123 + Text('早市:',
  1124 + style: TextStyle(
  1125 + fontSize:
  1126 + ScreenUtil().setSp(28),
  1127 + color: MyColours
  1128 + .color_999999)),
  1129 + Image.asset(
  1130 + Utils.getImgPath(
  1131 + 'store_swich_on'),
  1132 + width: ScreenUtil()
  1133 + .setWidth(38 * 2)),
  1134 + ],
  1135 + ),
  1136 + VEmptyView(34),
  1137 + Row(
  1138 + children: [
  1139 + Expanded(
  1140 + child: Container(
  1141 + height:
  1142 + ScreenUtil().setWidth(34 * 2),
  1143 + alignment: Alignment.center,
  1144 + decoration: BoxDecoration(
  1145 + borderRadius:
  1146 + BorderRadius.circular(
  1147 + ScreenUtil()
  1148 + .setWidth(10)),
  1149 + border: Border.all(
  1150 + width: ScreenUtil()
  1151 + .setWidth(2),
  1152 + color: MyColours
  1153 + .color_438E93)),
  1154 + child: RichText(
  1155 + text: TextSpan(
  1156 + style: TextStyle(
  1157 + fontSize: ScreenUtil()
  1158 + .setSp(24)),
  1159 + children: [
  1160 + // const TextSpan(text: '('),
  1161 + TextSpan(
  1162 + text: '选择开始时间',
  1163 + style: TextStyle(
  1164 + color: MyColours
  1165 + .color_438E93)),
  1166 + TextSpan(
  1167 + text: '*',
  1168 + style: TextStyle(
  1169 + color: MyColours
  1170 + .color_E34D59)),
  1171 + ])),
  1172 + )),
  1173 + HEmptyView(52),
  1174 + Text('至',
  1175 + style: TextStyle(
  1176 + fontSize:
  1177 + ScreenUtil().setSp(24),
  1178 + color: MyColours
  1179 + .color_515151)),
  1180 + HEmptyView(52),
  1181 + Expanded(
  1182 + child: Container(
  1183 + height:
  1184 + ScreenUtil().setWidth(34 * 2),
  1185 + alignment: Alignment.center,
  1186 + decoration: BoxDecoration(
  1187 + borderRadius:
  1188 + BorderRadius.circular(
  1189 + ScreenUtil()
  1190 + .setWidth(10)),
  1191 + border: Border.all(
  1192 + width: ScreenUtil()
  1193 + .setWidth(2),
  1194 + color: MyColours
  1195 + .color_438E93)),
  1196 + child: RichText(
  1197 + text: TextSpan(
  1198 + style: TextStyle(
  1199 + fontSize: ScreenUtil()
  1200 + .setSp(24)),
  1201 + children: [
  1202 + // const TextSpan(text: '('),
  1203 + TextSpan(
  1204 + text: '选择结束时间',
  1205 + style: TextStyle(
  1206 + color: MyColours
  1207 + .color_438E93)),
  1208 + TextSpan(
  1209 + text: '*',
  1210 + style: TextStyle(
  1211 + color: MyColours
  1212 + .color_E34D59)),
  1213 + ])),
  1214 + )),
  1215 + ],
  1216 + ),
  1217 + VEmptyView(32),
  1218 + Row(
  1219 + mainAxisAlignment:
  1220 + MainAxisAlignment.spaceBetween,
  1221 + children: [
  1222 + Text('午市:',
  1223 + style: TextStyle(
  1224 + fontSize:
  1225 + ScreenUtil().setSp(28),
  1226 + color: MyColours
  1227 + .color_999999)),
  1228 + Image.asset(
  1229 + Utils.getImgPath(
  1230 + 'store_swich_on'),
  1231 + width: ScreenUtil()
  1232 + .setWidth(38 * 2)),
  1233 + ],
  1234 + ),
  1235 + VEmptyView(34),
  1236 + Row(
  1237 + children: [
  1238 + Expanded(
  1239 + child: Container(
  1240 + height:
  1241 + ScreenUtil().setWidth(34 * 2),
  1242 + alignment: Alignment.center,
  1243 + decoration: BoxDecoration(
  1244 + borderRadius:
  1245 + BorderRadius.circular(
  1246 + ScreenUtil()
  1247 + .setWidth(10)),
  1248 + border: Border.all(
  1249 + width: ScreenUtil()
  1250 + .setWidth(2),
  1251 + color: MyColours
  1252 + .color_438E93)),
  1253 + child: RichText(
  1254 + text: TextSpan(
  1255 + style: TextStyle(
  1256 + fontSize: ScreenUtil()
  1257 + .setSp(24)),
  1258 + children: [
  1259 + // const TextSpan(text: '('),
  1260 + TextSpan(
  1261 + text: '选择开始时间',
  1262 + style: TextStyle(
  1263 + color: MyColours
  1264 + .color_438E93)),
  1265 + TextSpan(
  1266 + text: '*',
  1267 + style: TextStyle(
  1268 + color: MyColours
  1269 + .color_E34D59)),
  1270 + ])),
  1271 + )),
  1272 + HEmptyView(52),
  1273 + Text('至',
  1274 + style: TextStyle(
  1275 + fontSize:
  1276 + ScreenUtil().setSp(24),
  1277 + color: MyColours
  1278 + .color_515151)),
  1279 + HEmptyView(52),
  1280 + Expanded(
  1281 + child: Container(
  1282 + height:
  1283 + ScreenUtil().setWidth(34 * 2),
  1284 + alignment: Alignment.center,
  1285 + decoration: BoxDecoration(
  1286 + borderRadius:
  1287 + BorderRadius.circular(
  1288 + ScreenUtil()
  1289 + .setWidth(10)),
  1290 + border: Border.all(
  1291 + width: ScreenUtil()
  1292 + .setWidth(2),
  1293 + color: MyColours
  1294 + .color_438E93)),
  1295 + child: RichText(
  1296 + text: TextSpan(
  1297 + style: TextStyle(
  1298 + fontSize: ScreenUtil()
  1299 + .setSp(24)),
  1300 + children: [
  1301 + // const TextSpan(text: '('),
  1302 + TextSpan(
  1303 + text: '选择结束时间',
  1304 + style: TextStyle(
  1305 + color: MyColours
  1306 + .color_438E93)),
  1307 + TextSpan(
  1308 + text: '*',
  1309 + style: TextStyle(
  1310 + color: MyColours
  1311 + .color_E34D59)),
  1312 + ])),
  1313 + )),
  1314 + ],
  1315 + ),
  1316 + VEmptyView(32),
  1317 + Row(
  1318 + mainAxisAlignment:
  1319 + MainAxisAlignment.spaceBetween,
  1320 + children: [
  1321 + Text('晚市:',
  1322 + style: TextStyle(
  1323 + fontSize:
  1324 + ScreenUtil().setSp(28),
  1325 + color: MyColours
  1326 + .color_999999)),
  1327 + Image.asset(
  1328 + Utils.getImgPath(
  1329 + 'store_swich_on'),
  1330 + width: ScreenUtil()
  1331 + .setWidth(38 * 2)),
  1332 + ],
  1333 + ),
  1334 + VEmptyView(34),
  1335 + Row(
  1336 + children: [
  1337 + Expanded(
  1338 + child: Container(
  1339 + height:
  1340 + ScreenUtil().setWidth(34 * 2),
  1341 + alignment: Alignment.center,
  1342 + decoration: BoxDecoration(
  1343 + borderRadius:
  1344 + BorderRadius.circular(
  1345 + ScreenUtil()
  1346 + .setWidth(10)),
  1347 + border: Border.all(
  1348 + width: ScreenUtil()
  1349 + .setWidth(2),
  1350 + color: MyColours
  1351 + .color_438E93)),
  1352 + child: RichText(
  1353 + text: TextSpan(
  1354 + style: TextStyle(
  1355 + fontSize: ScreenUtil()
  1356 + .setSp(24)),
  1357 + children: [
  1358 + // const TextSpan(text: '('),
  1359 + TextSpan(
  1360 + text: '选择开始时间',
  1361 + style: TextStyle(
  1362 + color: MyColours
  1363 + .color_438E93)),
  1364 + TextSpan(
  1365 + text: '*',
  1366 + style: TextStyle(
  1367 + color: MyColours
  1368 + .color_E34D59)),
  1369 + ])),
  1370 + )),
  1371 + HEmptyView(52),
  1372 + Text('至',
  1373 + style: TextStyle(
  1374 + fontSize:
  1375 + ScreenUtil().setSp(24),
  1376 + color: MyColours
  1377 + .color_515151)),
  1378 + HEmptyView(52),
  1379 + Expanded(
  1380 + child: Container(
  1381 + height:
  1382 + ScreenUtil().setWidth(34 * 2),
  1383 + alignment: Alignment.center,
  1384 + decoration: BoxDecoration(
  1385 + borderRadius:
  1386 + BorderRadius.circular(
  1387 + ScreenUtil()
  1388 + .setWidth(10)),
  1389 + border: Border.all(
  1390 + width: ScreenUtil()
  1391 + .setWidth(2),
  1392 + color: MyColours
  1393 + .color_438E93)),
  1394 + child: RichText(
  1395 + text: TextSpan(
  1396 + style: TextStyle(
  1397 + fontSize: ScreenUtil()
  1398 + .setSp(24)),
  1399 + children: [
  1400 + // const TextSpan(text: '('),
  1401 + TextSpan(
  1402 + text: '选择结束时间',
  1403 + style: TextStyle(
  1404 + color: MyColours
  1405 + .color_438E93)),
  1406 + TextSpan(
  1407 + text: '*',
  1408 + style: TextStyle(
  1409 + color: MyColours
  1410 + .color_E34D59)),
  1411 + ])),
  1412 + )),
  1413 + ],
  1414 + ),
  1415 + ],
  1416 + )),
  1417 + VEmptyView(96),
  1418 + Text('接单时间',
  1419 + style: TextStyle(
  1420 + fontWeight: FontWeight.bold,
  1421 + fontSize: ScreenUtil().setSp(32),
  1422 + color: MyColours.color_515151)),
  1423 + VEmptyView(32),
  1424 + Padding(
  1425 + padding: EdgeInsets.symmetric(
  1426 + horizontal: ScreenUtil().setWidth(40),
  1427 + ),
  1428 + child: _textfield('店铺名称', '请填写店铺名称',
  1429 + _nameController, _nameFocusNode)),
  1430 + VEmptyView(10),
  1431 + _imageWidget('门头照片',
  1432 + _uploadImageProvider.mentou, 76, 64),
  1433 + VEmptyView(30),
  1434 + Container(
  1435 + height: ScreenUtil().setWidth(2),
  1436 + color: MyColours.color_efefef,
  1437 + margin: EdgeInsets.only(
  1438 + left: ScreenUtil().setWidth(108 * 2),
  1439 + right: ScreenUtil().setWidth(40)),
542 ), 1440 ),
543 - child: _textfield('详细地址', '请填写店铺详细地址',  
544 - _addressController, _addressFocusNode)),  
545 - VEmptyView(10),  
546 - Container(  
547 - height: ScreenUtil().setWidth(2),  
548 - color: MyColours.color_efefef,  
549 - margin: EdgeInsets.only(  
550 - left: ScreenUtil().setWidth(108 * 2),  
551 - right: ScreenUtil().setWidth(40)),  
552 - ),  
553 - VEmptyView(10),  
554 - Padding(  
555 - padding: EdgeInsets.symmetric(  
556 - horizontal: ScreenUtil().setWidth(40), 1441 + VEmptyView(10),
  1442 + Padding(
  1443 + padding: EdgeInsets.symmetric(
  1444 + horizontal: ScreenUtil().setWidth(40),
  1445 + ),
  1446 + child: _textfield('店铺电话', '请填写店铺电话',
  1447 + _phoneController, _phoneFocusNode)),
  1448 + VEmptyView(10),
  1449 + Container(
  1450 + height: ScreenUtil().setWidth(2),
  1451 + color: MyColours.color_efefef,
  1452 + margin: EdgeInsets.only(
  1453 + left: ScreenUtil().setWidth(108 * 2),
  1454 + right: ScreenUtil().setWidth(40)),
557 ), 1455 ),
558 - child: _textfield(  
559 - '店铺简介',  
560 - '请填写店铺简介',  
561 - _introductionController,  
562 - _introductionFocusNode)),  
563 - VEmptyView(10),  
564 - ],  
565 - )),  
566 - ),  
567 - VEmptyView(20),  
568 - Padding(  
569 - padding: EdgeInsets.fromLTRB(ScreenUtil().setWidth(40), 0,  
570 - ScreenUtil().setWidth(40), ScreenUtil().setWidth(40)),  
571 - child: RoundButton(  
572 - onPressed: () {  
573 - //接口  
574 - _setSellerInfoById();  
575 - },  
576 - text: '保存',  
577 - fontSize: 34,  
578 - isBold: false,  
579 - height: ScreenUtil().setWidth(80),  
580 - width: double.infinity,  
581 - radius: ScreenUtil().setWidth(10),  
582 - ))  
583 - ])))); 1456 + VEmptyView(10),
  1457 + Padding(
  1458 + padding: EdgeInsets.symmetric(
  1459 + horizontal: ScreenUtil().setWidth(40),
  1460 + ),
  1461 + child: _textfield(
  1462 + '营业时间',
  1463 + '请填写营业时间,如09:00-23:00',
  1464 + _timeController,
  1465 + _timeFocusNode)),
  1466 + VEmptyView(10),
  1467 + Container(
  1468 + height: ScreenUtil().setWidth(2),
  1469 + color: MyColours.color_efefef,
  1470 + margin: EdgeInsets.only(
  1471 + left: ScreenUtil().setWidth(108 * 2),
  1472 + right: ScreenUtil().setWidth(40)),
  1473 + ),
  1474 + VEmptyView(10),
  1475 + Padding(
  1476 + padding: EdgeInsets.symmetric(
  1477 + horizontal: ScreenUtil().setWidth(40),
  1478 + vertical: ScreenUtil().setWidth(40),
  1479 + ),
  1480 + child:
  1481 + _select('地图地址', mapAddress['address'])),
  1482 + VEmptyView(10),
  1483 + Container(
  1484 + height: ScreenUtil().setWidth(2),
  1485 + color: MyColours.color_efefef,
  1486 + margin: EdgeInsets.only(
  1487 + left: ScreenUtil().setWidth(108 * 2),
  1488 + right: ScreenUtil().setWidth(40)),
  1489 + ),
  1490 + VEmptyView(10),
  1491 + Padding(
  1492 + padding: EdgeInsets.symmetric(
  1493 + horizontal: ScreenUtil().setWidth(40),
  1494 + ),
  1495 + child: _textfield('详细地址', '请填写店铺详细地址',
  1496 + _addressController, _addressFocusNode)),
  1497 + VEmptyView(10),
  1498 + Container(
  1499 + height: ScreenUtil().setWidth(2),
  1500 + color: MyColours.color_efefef,
  1501 + margin: EdgeInsets.only(
  1502 + left: ScreenUtil().setWidth(108 * 2),
  1503 + right: ScreenUtil().setWidth(40)),
  1504 + ),
  1505 + VEmptyView(10),
  1506 + Padding(
  1507 + padding: EdgeInsets.symmetric(
  1508 + horizontal: ScreenUtil().setWidth(40),
  1509 + ),
  1510 + child: _textfield(
  1511 + '店铺简介',
  1512 + '请填写店铺简介',
  1513 + _introductionController,
  1514 + _introductionFocusNode)),
  1515 + VEmptyView(10),
  1516 + ],
  1517 + )),
  1518 + ),
  1519 + VEmptyView(20),
  1520 + Padding(
  1521 + padding: EdgeInsets.fromLTRB(
  1522 + ScreenUtil().setWidth(40),
  1523 + 0,
  1524 + ScreenUtil().setWidth(40),
  1525 + ScreenUtil().setWidth(40)),
  1526 + child: RoundButton(
  1527 + onPressed: () {
  1528 + //接口
  1529 + _setSellerInfoById();
  1530 + },
  1531 + text: '保存',
  1532 + fontSize: 34,
  1533 + isBold: false,
  1534 + height: ScreenUtil().setWidth(80),
  1535 + width: double.infinity,
  1536 + radius: ScreenUtil().setWidth(10),
  1537 + ))
  1538 + ])))));
584 } 1539 }
585 } 1540 }
  1 +// import 'dart:io';
  2 +
  3 +// import 'package:cached_network_image/cached_network_image.dart';
  4 +// import 'package:dio/dio.dart';
  5 +// import 'package:flutter/material.dart';
  6 +// import 'package:flutter/services.dart';
  7 +// import 'package:flutter_screenutil/screenutil.dart';
  8 +// import 'package:one_key/models/get_seller_info_model.dart';
  9 +// import 'package:one_key/models/set_seller_info_model.dart';
  10 +// import 'package:one_key/models/upload_img_model.dart';
  11 +// import 'package:one_key/models/user.dart';
  12 +// import 'package:one_key/pages/online_check/photo_view_wiget.dart';
  13 +// import 'package:one_key/pages/online_check/progress.dart';
  14 +// import 'package:one_key/provider/base_info_provider.dart';
  15 +// import 'package:one_key/provider/store_base_info_provider.dart';
  16 +// import 'package:one_key/provider/upload_img_provider.dart';
  17 +// import 'package:one_key/provider/user_model.dart';
  18 +// import 'package:one_key/res/colors.dart';
  19 +// import 'package:one_key/route/navigator_util.dart';
  20 +// import 'package:one_key/utils/event_bus.dart';
  21 +// import 'package:one_key/utils/upload_image_util.dart';
  22 +// import 'package:one_key/utils/utils.dart';
  23 +// import 'package:one_key/widgets/h_empty_view.dart';
  24 +// import 'package:one_key/widgets/round_button.dart';
  25 +// import 'package:one_key/widgets/system_app_bar.dart';
  26 +// import 'package:one_key/widgets/v_empty_view.dart';
  27 +// import 'package:image_picker/image_picker.dart';
  28 +// import 'package:permission_handler/permission_handler.dart';
  29 +// import 'package:provider/provider.dart';
  30 +
  31 +// class StoreBaseInfoPage extends StatefulWidget {
  32 +// StoreBaseInfoPage({Key key}) : super(key: key);
  33 +
  34 +// @override
  35 +// _StoreBaseInfoPageState createState() => _StoreBaseInfoPageState();
  36 +// }
  37 +
  38 +// class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> {
  39 +// ScrollController _scrollController;
  40 +// TextEditingController _nameController = TextEditingController();
  41 +// TextEditingController _phoneController = TextEditingController();
  42 +// TextEditingController _timeController = TextEditingController();
  43 +// TextEditingController _addressController = TextEditingController();
  44 +// TextEditingController _introductionController = TextEditingController();
  45 +// FocusNode _nameFocusNode = FocusNode();
  46 +// FocusNode _phoneFocusNode = FocusNode();
  47 +// FocusNode _timeFocusNode = FocusNode();
  48 +// FocusNode _addressFocusNode = FocusNode();
  49 +// FocusNode _introductionFocusNode = FocusNode();
  50 +
  51 +// Map<String, dynamic> mapAddress;
  52 +
  53 +// final picker = ImagePicker();
  54 +// UploadImageProvider _uploadImageProvider;
  55 +// StoreBaseIndoProvider _baseIndoProvider;
  56 +
  57 +// @override
  58 +// void initState() {
  59 +// super.initState();
  60 +// mapAddress = {
  61 +// "address": '点击选择',
  62 +// 'lat': '',
  63 +// 'lng': '',
  64 +// };
  65 +// _scrollController = ScrollController();
  66 +// WidgetsBinding.instance.addPostFrameCallback((_) {
  67 +// _uploadImageProvider.mentou.process = 0.01;
  68 +// _uploadImageProvider.mentou.qiniuUrl = '';
  69 +// _uploadImageProvider.imgSizeMenTou = 64;
  70 +// // _uploadImageProvider.mentou.file = null;
  71 +// _getQiniuInfo();
  72 +// _getStoreBaseinfo();
  73 +// });
  74 +// }
  75 +
  76 +// ///获取店铺信息
  77 +// _getStoreBaseinfo() async {
  78 +// GetSellerInfoSunModel itemModel =
  79 +// await _baseIndoProvider.getSellerById(context);
  80 +// if (itemModel != null) {
  81 +// _nameController.text = itemModel.data.sellername;
  82 +// _phoneController.text = itemModel.data.sellerTel;
  83 +// _timeController.text = itemModel.data.dailyTime;
  84 +// _addressController.text = itemModel.data.realAddress;
  85 +// _introductionController.text = itemModel.data.sellerdesc;
  86 +// _uploadImageProvider.mentou.qiniuUrl = itemModel.data.sellerImage;
  87 +// // _uploadImageProvider.notifyListeners();
  88 +// mapAddress = {
  89 +// "address": itemModel.data.mapAddress,
  90 +// 'lat': itemModel.data.lat,
  91 +// 'lng': itemModel.data.long,
  92 +// };
  93 +// setState(() {});
  94 +// }
  95 +// }
  96 +
  97 +// ///获取七牛云token
  98 +// ///
  99 +// _getQiniuInfo() async {
  100 +// await _uploadImageProvider.getQiniuInfo(context, {});
  101 +// }
  102 +
  103 +// /// 修改店铺基本信息
  104 +// _setSellerInfoById() async {
  105 +// FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
  106 +
  107 +// User user = Provider.of<UserModel>(context, listen: false).user;
  108 +// Map<String, dynamic> params = {
  109 +// 'id': user.sellerid,
  110 +// };
  111 +
  112 +// params['name'] = _nameController.text;
  113 +
  114 +// if (_uploadImageProvider.mentou.path != null &&
  115 +// _uploadImageProvider.mentou.path != '') {
  116 +// params['image'] =
  117 +// await MultipartFile.fromFile(_uploadImageProvider.mentou.path);
  118 +// }
  119 +
  120 +// params['phone'] = _phoneController.text;
  121 +
  122 +// if (mapAddress != null && mapAddress['address'] != '') {
  123 +// params['map_address'] = mapAddress['address'];
  124 +// }
  125 +// if (mapAddress != null && mapAddress['lng'] != '') {
  126 +// params['long'] = mapAddress['lng'];
  127 +// }
  128 +// if (mapAddress != null && mapAddress['lat'] != '') {
  129 +// params['lat'] = mapAddress['lat'];
  130 +// }
  131 +
  132 +// params['real_address'] = _addressController.text;
  133 +
  134 +// params['sellerdesc'] = _introductionController.text;
  135 +
  136 +// params['daily_time'] = _timeController.text;
  137 +
  138 +// FormData formData = FormData.fromMap(params);
  139 +
  140 +// SetSellerInfoSunModel sunModel =
  141 +// await _baseIndoProvider.setSellerInfoById(context, formData);
  142 +// if (sunModel != null) {
  143 +// //修改成功
  144 +// Utils.showToast('保存成功');
  145 +// EventBus().emit('changeStatusColor');
  146 +// Navigator.pop(
  147 +// context,
  148 +// _uploadImageProvider.mentou.qiniuUrl != null &&
  149 +// _uploadImageProvider.mentou.qiniuUrl != ''
  150 +// ? {'image': _uploadImageProvider.mentou.qiniuUrl}
  151 +// : {'image': ''});
  152 +// } else {
  153 +// // Utils.showToast('保存失败');
  154 +// }
  155 +// }
  156 +
  157 +// ///输入框
  158 +// Widget _textfield(String title, String hintText,
  159 +// TextEditingController editingController, FocusNode focusNode) {
  160 +// return Container(
  161 +// child: Row(
  162 +// mainAxisAlignment: MainAxisAlignment.spaceBetween,
  163 +// children: [
  164 +// Container(
  165 +// child: Text(
  166 +// title,
  167 +// style: TextStyle(
  168 +// color: MyColours.color_333333,
  169 +// fontWeight: FontWeight.bold,
  170 +// fontSize: ScreenUtil().setSp(34)),
  171 +// ),
  172 +// ),
  173 +// HEmptyView(20),
  174 +// Spacer(),
  175 +// Container(
  176 +// width: ScreenUtil().setWidth(231 * 2),
  177 +// child: TextField(
  178 +// controller: editingController,
  179 +// textAlign: TextAlign.right,
  180 +// textAlignVertical: TextAlignVertical.bottom,
  181 +// maxLines: 1,
  182 +// inputFormatters: title == '详细地址'
  183 +// ? [
  184 +// LengthLimitingTextInputFormatter(20),
  185 +// // WhitelistingTextInputFormatter.digitsOnly
  186 +// ]
  187 +// : [],
  188 +
  189 +// // //光标颜色
  190 +// // cursorColor:
  191 +// // widget.isSelect ? Colors.white : MyColours.color_199095,
  192 +// //输入文本的样式
  193 +// style: TextStyle(
  194 +// fontSize: ScreenUtil().setSp(32),
  195 +// ),
  196 +// focusNode: focusNode,
  197 +// decoration: InputDecoration(
  198 +// border: OutlineInputBorder(borderSide: BorderSide.none),
  199 +// hintText: hintText,
  200 +// hintStyle: TextStyle(
  201 +// color: MyColours.color_999999,
  202 +// fontSize: ScreenUtil().setSp(32),
  203 +// ),
  204 +// enabledBorder: new UnderlineInputBorder(
  205 +// borderSide: BorderSide.none,
  206 +// ),
  207 +// focusedBorder: new UnderlineInputBorder(
  208 +// borderSide: BorderSide.none,
  209 +// ),
  210 +// ),
  211 +// onChanged: (value) {
  212 +// // if (editingController == _nameController) {
  213 +// // _nameController.text = value;
  214 +// // }
  215 +// },
  216 +// onEditingComplete: () {
  217 +// FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
  218 +// },
  219 +// keyboardType: TextInputType.text,
  220 +// ),
  221 +// )
  222 +// ],
  223 +// ),
  224 +// );
  225 +// }
  226 +
  227 +// //查看大图
  228 +// _showPhotoView(BuildContext context, int index, List imgs,
  229 +// {isShow = false, List dashName}) async {
  230 +// // if (imgs.length == 1 &&
  231 +// // imgs[0] ==
  232 +// // 'http://nosqn.colorcun.com/custom/lite-online/image/def-banner.png') {
  233 +// // imgs[0] = 'http://nosqn.colorcun.com/app/seller-hj-empty.png';
  234 +// // }
  235 +// Utils.setBarStatus(false, color: Colors.black);
  236 +// dynamic result = await showGeneralDialog(
  237 +// context: context,
  238 +// barrierDismissible: false,
  239 +// // barrierColor: Colors.red,
  240 +// barrierLabel:
  241 +// MaterialLocalizations.of(context).modalBarrierDismissLabel,
  242 +// transitionDuration: const Duration(milliseconds: 150),
  243 +// pageBuilder: (BuildContext context, Animation animation,
  244 +// Animation secondaryAnimation) {
  245 +// Widget child = Stack(
  246 +// children: <Widget>[
  247 +// PhotoPreview(
  248 +// initialIndex: index,
  249 +// photoList: imgs,
  250 +// isShow: isShow,
  251 +// dashName: dashName,
  252 +// needMask: false,
  253 +// )
  254 +// ],
  255 +// );
  256 +// return child;
  257 +// });
  258 +// Utils.setBarStatus(true, color: Colors.white);
  259 +// }
  260 +
  261 +// ///#相机拍照,单图选择
  262 +// Future _getFromPictureOrCamera(
  263 +// String title, UploadImgModel imgModel, imageSource) async {
  264 +// final pickedFile = await picker.getImage(source: imageSource);
  265 +// setState(() {
  266 +// if (pickedFile != null) {
  267 +// imgModel.file = File(pickedFile.path);
  268 +// imgModel.process = 0.01;
  269 +// } else {
  270 +// print('No image selected.');
  271 +// }
  272 +// });
  273 +// if (pickedFile != null) {
  274 +// _uploadImageProvider.imgSizeMenTou = 64;
  275 +// _uploadImageProvider.mentou.qiniuUrl = null;
  276 +// _uploadImageProvider.mentou.file = File(pickedFile.path);
  277 +// _uploadImageProvider.mentou.path = pickedFile.path;
  278 +// UploadImageUtil().startUploadOnly(
  279 +// context, File(pickedFile.path), 2, true, _uploadImageProvider);
  280 +// }
  281 +// }
  282 +
  283 +// ///图片 头像和二维码
  284 +// Widget _imageWidget(
  285 +// String title, UploadImgModel model, double imgSize, double radius) {
  286 +// return InkWell(
  287 +// onTap: () {
  288 +// Utils.getPickPermission(context, () {
  289 +// _getFromPictureOrCamera(title, model, ImageSource.gallery);
  290 +// }, Platform.isAndroid ? Permission.storage : Permission.photos);
  291 +// },
  292 +// child: Container(
  293 +// margin: EdgeInsets.only(
  294 +// top: ScreenUtil().setWidth(40),
  295 +// left: ScreenUtil().setWidth(40),
  296 +// right: ScreenUtil().setWidth(40)),
  297 +// height: ScreenUtil().setWidth(imgSize * 2),
  298 +// child: Row(
  299 +// mainAxisAlignment: MainAxisAlignment.spaceBetween,
  300 +// children: [
  301 +// Text(
  302 +// title,
  303 +// textAlign: TextAlign.left,
  304 +// style: TextStyle(
  305 +// color: MyColours.color_333333,
  306 +// fontWeight: FontWeight.bold,
  307 +// fontSize: ScreenUtil().setSp(34)),
  308 +// ),
  309 +// Spacer(),
  310 +// Stack(
  311 +// children: [
  312 +// InkWell(
  313 +// onTap: () {
  314 +// double process;
  315 +// String qiniuUrl;
  316 +// List<String> tempList = [];
  317 +
  318 +// process = _uploadImageProvider.mentou.process;
  319 +// qiniuUrl = _uploadImageProvider.mentou.qiniuUrl;
  320 +
  321 +// if (qiniuUrl != null && qiniuUrl != '') {
  322 +// tempList.add(qiniuUrl);
  323 +
  324 +// ///没有上传完成的不可以点击
  325 +// _showPhotoView(context, 0, tempList);
  326 +// } else {
  327 +// Utils.getPickPermission(context, () {
  328 +// _getFromPictureOrCamera(
  329 +// title, model, ImageSource.gallery);
  330 +// },
  331 +// Platform.isAndroid
  332 +// ? Permission.storage
  333 +// : Permission.photos);
  334 +// }
  335 +// },
  336 +// child: ClipRRect(
  337 +// borderRadius:
  338 +// BorderRadius.circular(ScreenUtil().setWidth(radius)),
  339 +// child: model.file == null
  340 +// ? model.qiniuUrl != null && model.qiniuUrl != ''
  341 +// ? Image.network(
  342 +// model.qiniuUrl,
  343 +// fit: BoxFit.cover,
  344 +// width: ScreenUtil().setWidth(imgSize * 2),
  345 +// height: ScreenUtil().setWidth(imgSize * 2),
  346 +// )
  347 +// : Image.asset(
  348 +// Utils.getImgPath('no_image'),
  349 +// fit: BoxFit.cover,
  350 +// width: ScreenUtil().setWidth(imgSize * 2),
  351 +// height: ScreenUtil().setWidth(imgSize * 2),
  352 +// )
  353 +// : Image.file(
  354 +// model.file,
  355 +// fit: BoxFit.cover,
  356 +// width: ScreenUtil().setWidth(imgSize * 2),
  357 +// height: ScreenUtil().setWidth(imgSize * 2),
  358 +// ),
  359 +// ),
  360 +// ),
  361 +// (model.file != null) &&
  362 +// model.process != 1 &&
  363 +// model.process != 0.01
  364 +// ? Container(
  365 +// width: ScreenUtil().setWidth(imgSize * 2),
  366 +// height: ScreenUtil().setWidth(imgSize * 2),
  367 +// decoration: BoxDecoration(
  368 +// borderRadius: BorderRadius.circular(radius),
  369 +// color: Color.fromRGBO(0, 0, 0, 0.6)),
  370 +// child: Center(
  371 +// child: Text('上传中',
  372 +// style:
  373 +// TextStyle(color: MyColours.color_999999)),
  374 +// ),
  375 +// )
  376 +// : Container(),
  377 +// ],
  378 +// ),
  379 +// HEmptyView(30),
  380 +// Image.asset(
  381 +// "assets/arr_right_gray.png",
  382 +// width: ScreenUtil().setWidth(14),
  383 +// height: ScreenUtil().setWidth(22),
  384 +// )
  385 +// ],
  386 +// ),
  387 +// ));
  388 +// }
  389 +
  390 +// ///地图地址选择
  391 +// Widget _select(String title, String hintText) {
  392 +// return InkWell(
  393 +// onTap: () {
  394 +// Utils.getPickPermission(context, () async {
  395 +// mapAddress = await NavigatorUtil.goMapChoicePointPage(context);
  396 +// if (mapAddress != null) {
  397 +// setState(() {
  398 +// // storeMapAddress = address['address'];
  399 +// // // createStoreModel.storeInfo?.address = storeAddress;
  400 +// // // createStoreModel.storeInfo?.lat = address['lat'];
  401 +// // // createStoreModel.storeInfo?.lng = address['lng'];
  402 +// });
  403 +// }
  404 +// }, Permission.location);
  405 +// },
  406 +// child: Container(
  407 +// child: Row(
  408 +// crossAxisAlignment: CrossAxisAlignment.center,
  409 +// mainAxisAlignment: MainAxisAlignment.center,
  410 +// children: [
  411 +// Container(
  412 +// child: Text(
  413 +// title,
  414 +// style: TextStyle(
  415 +// color: MyColours.color_333333,
  416 +// fontWeight: FontWeight.bold,
  417 +// fontSize: ScreenUtil().setSp(34)),
  418 +// ),
  419 +// ),
  420 +// HEmptyView(40),
  421 +// Expanded(
  422 +// child: Text(hintText,
  423 +// textAlign: TextAlign.right,
  424 +// style: TextStyle(
  425 +// color: hintText == '点击选择'
  426 +// ? MyColours.color_999999
  427 +// : MyColours.color_333333,
  428 +// fontSize: ScreenUtil().setSp(32),
  429 +// ))),
  430 +// HEmptyView(20),
  431 +// Image.asset(
  432 +// Utils.getImgPath('arr_right_gray'),
  433 +// width: ScreenUtil().setWidth(12),
  434 +// height: ScreenUtil().setWidth(22),
  435 +// )
  436 +// ],
  437 +// ),
  438 +// ),
  439 +// );
  440 +// }
  441 +
  442 +// @override
  443 +// Widget build(BuildContext context) {
  444 +// _uploadImageProvider =
  445 +// Provider.of<UploadImageProvider>(context, listen: true);
  446 +// _baseIndoProvider =
  447 +// Provider.of<StoreBaseIndoProvider>(context, listen: true);
  448 +// return Scaffold(
  449 +// backgroundColor: MyColours.color_fefefe,
  450 +// appBar: SystemAppBar(
  451 +// '店铺信息',
  452 +// onTap: () {
  453 +// EventBus().emit('changeStatusColor');
  454 +// Navigator.of(context).pop();
  455 +// },
  456 +// ),
  457 +// body: WillPopScope(
  458 +// onWillPop: () {
  459 +// EventBus().emit('changeStatusColor');
  460 +// Navigator.of(context).pop();
  461 +// },
  462 +// child: InkWell(
  463 +// onTap: () {
  464 +// FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
  465 +// },
  466 +// child: Column(children: [
  467 +// Expanded(
  468 +// child: SingleChildScrollView(
  469 +// controller: _scrollController,
  470 +// physics: BouncingScrollPhysics(),
  471 +// child: Column(
  472 +// children: [
  473 +// Padding(
  474 +// padding: EdgeInsets.symmetric(
  475 +// horizontal: ScreenUtil().setWidth(40),
  476 +// ),
  477 +// child: _textfield('店铺名称', '请填写店铺名称',
  478 +// _nameController, _nameFocusNode)),
  479 +// VEmptyView(10),
  480 +// _imageWidget('门头照片', _uploadImageProvider.mentou,
  481 +// _uploadImageProvider.imgSizeMenTou, 64),
  482 +// VEmptyView(30),
  483 +// Container(
  484 +// height: ScreenUtil().setWidth(2),
  485 +// color: MyColours.color_efefef,
  486 +// margin: EdgeInsets.only(
  487 +// left: ScreenUtil().setWidth(108 * 2),
  488 +// right: ScreenUtil().setWidth(40)),
  489 +// ),
  490 +// VEmptyView(10),
  491 +// Padding(
  492 +// padding: EdgeInsets.symmetric(
  493 +// horizontal: ScreenUtil().setWidth(40),
  494 +// ),
  495 +// child: _textfield('店铺电话', '请填写店铺电话',
  496 +// _phoneController, _phoneFocusNode)),
  497 +// VEmptyView(10),
  498 +// Container(
  499 +// height: ScreenUtil().setWidth(2),
  500 +// color: MyColours.color_efefef,
  501 +// margin: EdgeInsets.only(
  502 +// left: ScreenUtil().setWidth(108 * 2),
  503 +// right: ScreenUtil().setWidth(40)),
  504 +// ),
  505 +// VEmptyView(10),
  506 +// Padding(
  507 +// padding: EdgeInsets.symmetric(
  508 +// horizontal: ScreenUtil().setWidth(40),
  509 +// ),
  510 +// child: _textfield(
  511 +// '营业时间',
  512 +// '请填写营业时间,如09:00-23:00',
  513 +// _timeController,
  514 +// _timeFocusNode)),
  515 +// VEmptyView(10),
  516 +// Container(
  517 +// height: ScreenUtil().setWidth(2),
  518 +// color: MyColours.color_efefef,
  519 +// margin: EdgeInsets.only(
  520 +// left: ScreenUtil().setWidth(108 * 2),
  521 +// right: ScreenUtil().setWidth(40)),
  522 +// ),
  523 +// VEmptyView(10),
  524 +// Padding(
  525 +// padding: EdgeInsets.symmetric(
  526 +// horizontal: ScreenUtil().setWidth(40),
  527 +// vertical: ScreenUtil().setWidth(40),
  528 +// ),
  529 +// child: _select('地图地址', mapAddress['address'])),
  530 +// VEmptyView(10),
  531 +// Container(
  532 +// height: ScreenUtil().setWidth(2),
  533 +// color: MyColours.color_efefef,
  534 +// margin: EdgeInsets.only(
  535 +// left: ScreenUtil().setWidth(108 * 2),
  536 +// right: ScreenUtil().setWidth(40)),
  537 +// ),
  538 +// VEmptyView(10),
  539 +// Padding(
  540 +// padding: EdgeInsets.symmetric(
  541 +// horizontal: ScreenUtil().setWidth(40),
  542 +// ),
  543 +// child: _textfield('详细地址', '请填写店铺详细地址',
  544 +// _addressController, _addressFocusNode)),
  545 +// VEmptyView(10),
  546 +// Container(
  547 +// height: ScreenUtil().setWidth(2),
  548 +// color: MyColours.color_efefef,
  549 +// margin: EdgeInsets.only(
  550 +// left: ScreenUtil().setWidth(108 * 2),
  551 +// right: ScreenUtil().setWidth(40)),
  552 +// ),
  553 +// VEmptyView(10),
  554 +// Padding(
  555 +// padding: EdgeInsets.symmetric(
  556 +// horizontal: ScreenUtil().setWidth(40),
  557 +// ),
  558 +// child: _textfield(
  559 +// '店铺简介',
  560 +// '请填写店铺简介',
  561 +// _introductionController,
  562 +// _introductionFocusNode)),
  563 +// VEmptyView(10),
  564 +// ],
  565 +// )),
  566 +// ),
  567 +// VEmptyView(20),
  568 +// Padding(
  569 +// padding: EdgeInsets.fromLTRB(ScreenUtil().setWidth(40), 0,
  570 +// ScreenUtil().setWidth(40), ScreenUtil().setWidth(40)),
  571 +// child: RoundButton(
  572 +// onPressed: () {
  573 +// //接口
  574 +// _setSellerInfoById();
  575 +// },
  576 +// text: '保存',
  577 +// fontSize: 34,
  578 +// isBold: false,
  579 +// height: ScreenUtil().setWidth(80),
  580 +// width: double.infinity,
  581 +// radius: ScreenUtil().setWidth(10),
  582 +// ))
  583 +// ]))));
  584 +// }
  585 +// }
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
2 2
3 class MyColours { 3 class MyColours {
  4 + static const Color color_DBDBDB = Color(0xffDBDBDB);
4 static const Color color_F8F9FD = Color(0xffF8F9FD); 5 static const Color color_F8F9FD = Color(0xffF8F9FD);
5 static const Color color_5F7292 = Color(0xff5F7292); 6 static const Color color_5F7292 = Color(0xff5F7292);
6 static const Color color_F2995F = Color(0xffF2995F); 7 static const Color color_F2995F = Color(0xffF2995F);
  1 +class RegexUtil {
  2 + RegexUtil._();
  3 +
  4 + static final spaceOrNewLine = RegExp(r'[ \s]+');
  5 +}
  1 +import 'package:flutter/foundation.dart';
  2 +import 'package:flutter/services.dart';
  3 +import 'package:one_key/utils/regex_util.dart';
  4 +// import 'package:textfield_length_limit_word/util/regex_util.dart';
  5 +
  6 +class MaxWordTextInputFormater extends TextInputFormatter {
  7 + final int maxWords;
  8 + final ValueChanged<int> currentLength;
  9 +
  10 + MaxWordTextInputFormater({this.maxWords = 1, this.currentLength});
  11 +
  12 + @override
  13 + TextEditingValue formatEditUpdate(
  14 + TextEditingValue oldValue, TextEditingValue newValue) {
  15 + int count = 0;
  16 + if (newValue.text.isEmpty) {
  17 + count = 0;
  18 + } else {
  19 + count = newValue.text.trim().length;
  20 + // count = newValue.text.trim().split(RegexUtil.spaceOrNewLine).length;
  21 + }
  22 + if (count > maxWords) {
  23 + return oldValue;
  24 + }
  25 + currentLength?.call(count);
  26 + return newValue;
  27 + }
  28 +}
  1 +import 'package:flutter/material.dart';
  2 +import 'package:flutter/services.dart';
  3 +import 'package:one_key/widgets/max_word_textinput_formater.dart';
  4 +import 'package:one_key/widgets/text_input_field_widget.dart';
  5 +// import 'package:textfield_length_limit_word/component/max_word_textinput_formater.dart';
  6 +// import 'package:textfield_length_limit_word/component/text_input_field_widget.dart';
  7 +
  8 +class TextFieldPage extends StatefulWidget {
  9 + const TextFieldPage({Key key}) : super(key: key);
  10 +
  11 + @override
  12 + State<StatefulWidget> createState() {
  13 + return TextFieldPageState();
  14 + }
  15 +}
  16 +
  17 +class TextFieldPageState extends State<TextFieldPage> {
  18 + final Color _color = const Color(0xFFF5F6F7);
  19 + int _count = 0;
  20 + final int maxWordLength = 6;
  21 +
  22 + @override
  23 + Widget build(BuildContext context) {
  24 + return buildPage(
  25 + _buildBody(),
  26 + const Text(
  27 + "TextField Max Words Limit",
  28 + style: TextStyle(fontSize: 16, color: Colors.black),
  29 + ));
  30 + }
  31 +
  32 + Widget _buildBody() {
  33 + return Container(
  34 + color: _color,
  35 + child: Column(children: [
  36 + const SizedBox(
  37 + height: 12,
  38 + ),
  39 + _buildTextField()
  40 + ]));
  41 + }
  42 +
  43 + Widget _buildTextField() {
  44 + return _buildContain(
  45 + Column(
  46 + children: [
  47 + Row(
  48 + mainAxisAlignment: MainAxisAlignment.spaceBetween,
  49 + children: [
  50 + const Text(
  51 + "TextField",
  52 + style: TextStyle(fontSize: 16, color: Colors.black),
  53 + ),
  54 + _buildCompute(),
  55 + ],
  56 + ),
  57 + TextInputFieldWidget(
  58 + textInputFormatters: [
  59 + FilteringTextInputFormatter.allow(RegExp(r"[a-z\s_-]+")),
  60 + MaxWordTextInputFormater(maxWords: 6, currentLength: chageCount)
  61 + ],
  62 + hintText: "please fill words ",
  63 + maxLines: 4,
  64 + lineHeight: 1.5,
  65 + )
  66 + ],
  67 + ),
  68 + );
  69 + }
  70 +
  71 + Widget _buildCompute() {
  72 + return RichText(
  73 + text: TextSpan(
  74 + style: const TextStyle(fontSize: 14, color: Color(0xFF909399)),
  75 + children: [
  76 + const TextSpan(text: '('),
  77 + TextSpan(
  78 + text: _count.toString(),
  79 + style: TextStyle(
  80 + color: _count > 0
  81 + ? const Color(0xFF5269FF)
  82 + : const Color(0xFF909399))),
  83 + TextSpan(text: "/${maxWordLength.toString()})"),
  84 + ]));
  85 + }
  86 +
  87 + void chageCount(int count) {
  88 + setState(() {
  89 + _count = count;
  90 + });
  91 + }
  92 +
  93 + Scaffold buildPage(
  94 + Widget body,
  95 + Widget titleWidget,
  96 + ) {
  97 + return Scaffold(
  98 + resizeToAvoidBottomInset: false,
  99 + appBar: AppBar(
  100 + toolbarHeight: 40,
  101 + backgroundColor: _color,
  102 + // status bar color
  103 + automaticallyImplyLeading: false,
  104 + systemOverlayStyle: SystemUiOverlayStyle(
  105 + statusBarColor: _color, statusBarIconBrightness: Brightness.dark),
  106 + foregroundColor: _color,
  107 + shadowColor: Colors.transparent,
  108 + title: titleWidget,
  109 + ),
  110 + body: SafeArea(
  111 + child: body,
  112 + ),
  113 + );
  114 + }
  115 +
  116 + Widget _buildContain(Widget child) {
  117 + return Container(
  118 + padding: const EdgeInsets.all(16),
  119 + margin: const EdgeInsets.only(left: 16, right: 16, top: 12),
  120 + decoration: const BoxDecoration(
  121 + color: Colors.white,
  122 + borderRadius: BorderRadius.all(Radius.circular(12))),
  123 + child: child);
  124 + }
  125 +}
  1 +import 'package:flutter/material.dart';
  2 +import 'package:flutter/services.dart';
  3 +
  4 +class TextInputFieldWidget extends StatefulWidget {
  5 + final String hintText;
  6 + final ValueChanged<String> textChanged;
  7 + final bool obscureText;
  8 + final Color hasFocusColor;
  9 + final Color hitColor;
  10 + final double fontSize;
  11 + final int maxLines;
  12 + final double lineHeight;
  13 + final List<TextInputFormatter> textInputFormatters;
  14 + final ValueChanged<String> onChanged;
  15 + final TextEditingController textEditingController;
  16 + final FocusNode focusNode;
  17 +
  18 + const TextInputFieldWidget(
  19 + {Key key,
  20 + this.hintText = "",
  21 + this.textChanged,
  22 + this.obscureText = false,
  23 + this.hasFocusColor = const Color(0xFF303133),
  24 + this.hitColor = const Color(0xFFC0C4CC),
  25 + this.fontSize = 14,
  26 + this.lineHeight = 1,
  27 + this.maxLines = 1,
  28 + this.onChanged,
  29 + this.textInputFormatters,
  30 + this.textEditingController,
  31 + this.focusNode})
  32 + : super(key: key);
  33 +
  34 + @override
  35 + State<StatefulWidget> createState() {
  36 + return _TextInputFieldWidgetState();
  37 + }
  38 +}
  39 +
  40 +class _TextInputFieldWidgetState extends State<TextInputFieldWidget> {
  41 + String inputText = "";
  42 +
  43 + @override
  44 + void initState() {
  45 + widget.textEditingController.addListener(_handleTextInput);
  46 + super.initState();
  47 + }
  48 +
  49 + void _handleTextInput() {
  50 + widget.textChanged?.call(widget.textEditingController.text);
  51 + setState(() {
  52 + inputText = widget.textEditingController.text;
  53 + });
  54 + }
  55 +
  56 + @override
  57 + Widget build(BuildContext context) {
  58 + return TextField(
  59 + focusNode: widget.focusNode,
  60 + maxLines: widget.maxLines,
  61 + controller: widget.textEditingController,
  62 + obscureText: widget.obscureText,
  63 + onChanged: widget.onChanged,
  64 + inputFormatters: [...?widget.textInputFormatters],
  65 + style: TextStyle(
  66 + fontSize: widget.fontSize,
  67 + height: widget.lineHeight,
  68 + color: widget.hasFocusColor),
  69 + decoration: InputDecoration(
  70 + hintText: widget.hintText,
  71 + border: InputBorder.none,
  72 + hintStyle: TextStyle(
  73 + color: widget.hitColor,
  74 + height: widget.lineHeight,
  75 + fontSize: widget.fontSize,
  76 + ),
  77 + ),
  78 + );
  79 + }
  80 +
  81 + @override
  82 + void dispose() {
  83 + super.dispose();
  84 + }
  85 +}