From bff2d1997653a60cbb8ad45364ad0f9d7b9175f2 Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Wed, 27 Jan 2021 09:38:43 +0800 Subject: [PATCH 1/5] remove some s**t code --- lib/pages/goods_deto_page/goods_deto_page.dart | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/pages/goods_deto_page/goods_deto_page.dart b/lib/pages/goods_deto_page/goods_deto_page.dart index ec657e53..38fca7bc 100644 --- a/lib/pages/goods_deto_page/goods_deto_page.dart +++ b/lib/pages/goods_deto_page/goods_deto_page.dart @@ -1,4 +1,5 @@ // Flutter imports: +import 'package:akuCommunity/base/base_style.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -12,9 +13,8 @@ import 'package:akuCommunity/pages/goods_deto_page/deto_create_page/deto_create_ import 'package:akuCommunity/pages/things_page/widget/bee_list_view.dart'; import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; -import 'package:akuCommunity/widget/bottom_button.dart'; import 'widget/goods_info_card.dart'; - +import 'package:velocity_x/velocity_x.dart'; class GoodsDetoPage extends StatefulWidget { GoodsDetoPage({Key key}) : super(key: key); @@ -48,12 +48,14 @@ class _GoodsDetoPageState extends State { }, ), ), - bottomNavi: BottomButton( - title: '新增', - fun: () { - DetoCreatePage().to(); - }, - ), + bottomNavi: MaterialButton( + color: kPrimaryColor, + + padding: EdgeInsets.only(top:26.w ,bottom: MediaQuery.of(context).padding.bottom+26.w), + child: '新增'.text.black.size(32.sp).bold.make(), + onPressed: () { + DetoCreatePage().to(); + },), ); } } From 378dfe64124d0e58aedee46add0651c985c8e0c1 Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Wed, 27 Jan 2021 14:14:20 +0800 Subject: [PATCH 2/5] rewrite deto create page --- .../deto_create_page/deto_create_page.dart | 187 ++++++++++++------ .../widget/common_picker.dart | 2 +- .../deto_create_page/widget/common_radio.dart | 96 ++++----- .../widget/add_fixed_submit_page.dart | 39 ++-- lib/utils/headers.dart | 1 + 5 files changed, 201 insertions(+), 124 deletions(-) diff --git a/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart b/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart index 608dbf88..df0ffeb9 100644 --- a/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart +++ b/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart @@ -1,15 +1,22 @@ // Flutter imports: + +import 'dart:io'; + +import 'package:akuCommunity/base/base_style.dart'; +import 'package:akuCommunity/provider/user_provider.dart'; +import 'package:akuCommunity/widget/buttons/bottom_button.dart'; +import 'package:akuCommunity/widget/buttons/radio_button.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; // Project imports: -import 'package:akuCommunity/base/assets_image.dart'; import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; -import 'package:akuCommunity/widget/bottom_button.dart'; import 'package:akuCommunity/widget/picker/grid_image_picker.dart'; +import 'package:provider/provider.dart'; import 'widget/common_picker.dart'; import 'widget/common_radio.dart'; +import 'package:akuCommunity/const/resource.dart'; class DetoCreatePage extends StatefulWidget { DetoCreatePage({Key key}) : super(key: key); @@ -19,18 +26,27 @@ class DetoCreatePage extends StatefulWidget { } class _DetoCreatePageState extends State { - List> _listWeight = [ - {'title': '< 50kg', 'isCheck': true}, - {'title': '50kg-100kg', 'isCheck': false}, - {'title': '> 100kg', 'isCheck': false} - ]; + List _files = []; + UserProvider get userProvider => Provider.of(context); + String get firstEstateName { + return userProvider.userDetailModel.estateNames.isEmpty + ? '' + : userProvider.userDetailModel.estateNames[0]; + } - List> _listMode = [ - {'title': '自己搬运', 'isCheck': true}, - {'title': '搬家公司', 'isCheck': false}, + int _selectWeight; + List _listWeight = [ + '< 50kg', + '50kg-100kg', + '> 100kg', + ]; + int _selectApproach; + List _listMode = [ + '自己搬运', + '搬家公司', ]; - bool isCheck = false; + bool needMoveCompany = false; Widget _houseAddress(String title, subtitle) { return Container( @@ -60,7 +76,7 @@ class _DetoCreatePageState extends State { Container( margin: EdgeInsets.only(right: 42.w), child: Image.asset( - AssetsImage.HOUSEATTESTATION, + R.ASSETS_IMAGES_HOUSE_ATTESTATION_PNG, height: 59.w, width: 59.w, ), @@ -102,11 +118,11 @@ class _DetoCreatePageState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ Checkbox( - value: this.isCheck, + value: needMoveCompany, activeColor: Color(0xffffc40c), onChanged: (bool val) { this.setState(() { - this.isCheck = !this.isCheck; + needMoveCompany=!needMoveCompany; }); }, ), @@ -125,7 +141,7 @@ class _DetoCreatePageState extends State { ); } - Widget _checkCard(String title, List> list) { + Widget _getWeight() { return Container( height: 96.w, padding: EdgeInsets.symmetric(vertical: 28.w), @@ -138,21 +154,70 @@ class _DetoCreatePageState extends State { Container( margin: EdgeInsets.only(right: 30.w), child: Text( - title, + '物品重量', style: TextStyle(fontSize: 28.sp, color: Color(0xff333333)), ), ), - CommonRadio( - commonlist: list, - fun: (int index) { - setState(() { - list.forEach((item) { - item['isCheck'] = false; - }); - list[index]['isCheck'] = true; - }); - }, - ) + ...List.generate( + _listWeight.length, + (index) => GestureDetector( + onTap: () { + setState(() { + _selectWeight = index; + }); + }, + child: CommonRadio( + size: 30.w, + text: _listWeight[index] + .text + .color(ktextPrimary) + .size(28.sp) + .make(), + value: index, + groupValue: _selectWeight, + ), + )), + ], + ), + ); + } + + Widget _getApproach() { + return Container( + height: 96.w, + padding: EdgeInsets.symmetric(vertical: 28.w), + decoration: BoxDecoration( + border: + Border(bottom: BorderSide(color: Color(0xffeeeeee), width: 0.5)), + ), + child: Row( + children: [ + Container( + margin: EdgeInsets.only(right: 30.w), + child: Text( + '搬运方式', + style: TextStyle(fontSize: 28.sp, color: Color(0xff333333)), + ), + ), + ...List.generate( + _listMode.length, + (index) => GestureDetector( + onTap: () { + setState(() { + _selectApproach = index; + }); + }, + child: CommonRadio( + size: 30.w, + text: _listMode[index] + .text + .color(ktextPrimary) + .size(28.sp) + .make(), + value: index, + groupValue: _selectApproach, + ), + )), ], ), ); @@ -162,45 +227,41 @@ class _DetoCreatePageState extends State { Widget build(BuildContext context) { return BeeScaffold( title: '物品出户', - body: Container( - color: Colors.white, - child: Stack( - children: [ - Container( - padding: EdgeInsets.only( - left: 32.w, - right: 32.w, - top: 32.w, - ), - child: ListView( - children: [ - _houseAddress('宁波华茂悦峰', '1幢-1单元-702室'), - _checkCard('物品重量', _listWeight), - CommonPicker(title: '出户时间'), - CommonPicker(title: '物品名称'), - _checkCard('搬运方式', _listMode), - _inkWellCheckbox(), - Container( - margin: EdgeInsets.only(top: 54.w, bottom: 24.w), - child: Text( - '添加图片信息(0/9)', - style: TextStyle( - fontSize: 28.sp, - color: Color(0xff333333), - ), - ), - ), - GridImagePicker(onChange: (files) {}), - ], + body: ListView( + padding: EdgeInsets.all(32.w), + children: [ + _houseAddress(kEstateName, firstEstateName), + _getWeight(), + CommonPicker(title: '出户时间'), + CommonPicker(title: '物品名称'), + _getApproach(), + _selectApproach==0?SizedBox(): _inkWellCheckbox(), + Container( + margin: EdgeInsets.only(top: 54.w, bottom: 24.w), + child: Text( + '添加图片信息(${_files.length}/9)', + style: TextStyle( + fontSize: 28.sp, + color: Color(0xff333333), ), ), - Positioned( - bottom: 0, - child: BottomButton(title: '确认提交'), - ) - ], - ), + ), + GridImagePicker(onChange: (files) { + _files = files; + setState(() {}); + }), + ], + ), + bottomNavi: BottomButton( + child: '确认提交'.text.color(ktextPrimary).bold.make(), + onPressed: () {}, ), ); + // Positioned( + // bottom: 0, + // child: BottomButton(title: '确认提交'), + // ) + // ], + // ), } } diff --git a/lib/pages/goods_deto_page/deto_create_page/widget/common_picker.dart b/lib/pages/goods_deto_page/deto_create_page/widget/common_picker.dart index e9e51453..37272b63 100644 --- a/lib/pages/goods_deto_page/deto_create_page/widget/common_picker.dart +++ b/lib/pages/goods_deto_page/deto_create_page/widget/common_picker.dart @@ -10,7 +10,7 @@ import 'package:flutter_picker/flutter_picker.dart'; // Project imports: import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/widget/picker/bee_date_picker.dart'; - +@Deprecated('s**t code should be remove') class CommonPicker extends StatefulWidget { final String title; CommonPicker({Key key, this.title}) : super(key: key); diff --git a/lib/pages/goods_deto_page/deto_create_page/widget/common_radio.dart b/lib/pages/goods_deto_page/deto_create_page/widget/common_radio.dart index 312fa61b..ca5d86fc 100644 --- a/lib/pages/goods_deto_page/deto_create_page/widget/common_radio.dart +++ b/lib/pages/goods_deto_page/deto_create_page/widget/common_radio.dart @@ -1,64 +1,64 @@ -// Flutter imports: -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -// Project imports: import 'package:akuCommunity/base/base_style.dart'; +import 'package:akuCommunity/widget/animated/animated_scale.dart'; +import 'package:flutter/material.dart'; import 'package:akuCommunity/utils/headers.dart'; -class CommonRadio extends StatefulWidget { - final List> commonlist; - final Function fun; - CommonRadio({Key key, this.commonlist, this.fun}) : super(key: key); +class CommonRadio extends StatefulWidget { + final T value; + final T groupValue; + final Widget text; + final double size; + CommonRadio({Key key, this.value, this.groupValue, this.text, this.size}) + : super(key: key); @override _CommonRadioState createState() => _CommonRadioState(); } class _CommonRadioState extends State { - InkWell _inkWellRadio(String title, bool isCheck,int index, Function fun) { - return InkWell( - onTap: () { - fun(index); - }, - child: Container( - margin: EdgeInsets.only(left: 20.w), - child: Row( - children: [ - Icon( - isCheck - ? Icons.radio_button_checked - : Icons.radio_button_unchecked, - size: 32.w, - color: isCheck ? BaseStyle.colorffc40c : BaseStyle.color979797, - ), - SizedBox(width: 10.w), - Text( - title, - style: TextStyle( - fontSize: BaseStyle.fontSize28, color: ktextPrimary), - ), - ], - ), - ), - ); + bool get _selected => widget.value == widget.groupValue; + double get smallSize { + return widget.size.isNull ? 24.w : (widget.size * 24 / 40); } @override Widget build(BuildContext context) { - return Container( - child: Row( - children: widget.commonlist - .asMap() - .keys - .map((index) => _inkWellRadio( - widget.commonlist[index]['title'], - widget.commonlist[index]['isCheck'], - index, - widget.fun - )) - .toList(), - ), + return Row( + children: [ + AnimatedContainer( + height: widget.size ?? 40.w, + width: widget.size ?? 40.w, + decoration: BoxDecoration( + border: Border.all( + color: _selected ? kPrimaryColor : Color(0xFF979797), + width: 3.w, + ), + borderRadius: BorderRadius.circular(20.w), + ), + duration: Duration(milliseconds: 300), + curve: Curves.easeInOutCubic, + alignment: Alignment.center, + child: AnimatedOpacity( + duration: Duration(milliseconds: 300), + curve: Curves.easeInOutCubic, + opacity: _selected ? 1 : 0, + child: AnimatedScale( + scale: _selected ? 1 : 0, + child: Container( + height: smallSize, + width: smallSize, + decoration: BoxDecoration( + color: kPrimaryColor, + borderRadius: BorderRadius.circular(12.w), + ), + ), + ), + ), + ), + 10.w.widthBox, + widget.text, + 10.w.widthBox, + ], ); } } diff --git a/lib/pages/things_page/widget/add_fixed_submit_page.dart b/lib/pages/things_page/widget/add_fixed_submit_page.dart index 99bb0ecc..aeb44e0b 100644 --- a/lib/pages/things_page/widget/add_fixed_submit_page.dart +++ b/lib/pages/things_page/widget/add_fixed_submit_page.dart @@ -38,7 +38,7 @@ class _AddFixedSubmitPageState extends State { String reportText; List _buttons = ['公区保修', '家庭维修']; int _selectType; - List _files=[]; + List _files = []; @override void initState() { super.initState(); @@ -182,16 +182,27 @@ class _AddFixedSubmitPageState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - '添加图片信息(${0}/9)'.text.black.size(28.sp).make(), + '添加图片信息(${_files.length}/9)'.text.black.size(28.sp).make(), 24.w.heightBox, GridImagePicker(onChange: (files) { _files = files; + setState(() {}); }) ], ), ); } + bool _canSubmit(int seletType, String text) { + if (seletType.isNull) { + return false; + } else if (text.isEmpty) { + return false; + } else { + return true; + } + } + @override Widget build(BuildContext context) { UserProvider userProvider = Provider.of(context); @@ -214,16 +225,20 @@ class _AddFixedSubmitPageState extends State { MaterialButton( minWidth: double.infinity, height: 98.w, - onPressed: () async { - List urls = - await NetUtil().uploadFiles(_files, API.upload.uploadRepair); - BaseModel baseModel = await ManagerFunc.reportRepairInsert( - _selectType + 1, _textEditingController.text, urls); - if (baseModel.status) { - FinishFixedSubmitPage().to(); - } else - BotToast.showText(text: baseModel.message); - }, + onPressed: _canSubmit(_selectType, _textEditingController.text) + ? () async { + List urls = await NetUtil() + .uploadFiles(_files, API.upload.uploadRepair); + BaseModel baseModel = await ManagerFunc.reportRepairInsert( + _selectType + 1, _textEditingController.text, urls); + if (baseModel.status) { + FinishFixedSubmitPage().to(); + } else + BotToast.showText(text: baseModel.message); + } + : () { + BotToast.showText(text: '请填写完整报修信息!'); + }, child: '确认提交'.text.black.bold.size(32.sp).make(), color: kPrimaryColor, elevation: 0, diff --git a/lib/utils/headers.dart b/lib/utils/headers.dart index 5a9390fb..df1f61bd 100644 --- a/lib/utils/headers.dart +++ b/lib/utils/headers.dart @@ -2,6 +2,7 @@ export 'package:flutter_screenutil/flutter_screenutil.dart'; export 'package:akuCommunity/extensions/page_router.dart'; export 'package:akuCommunity/extensions/num_ext.dart'; export 'package:akuCommunity/extensions/widget_list_ext.dart'; +export 'package:velocity_x/velocity_x.dart'; // class Screenutil { // static double length(double lengthNum) => ScreenUtil().setWidth(lengthNum); From fd1079b8bb8f948938b4ab773d8ebc06ea6ddf65 Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Wed, 27 Jan 2021 15:49:26 +0800 Subject: [PATCH 3/5] update deto create page add check box widget --- .../deto_create_page/deto_create_page.dart | 23 ++++++---- lib/widget/buttons/bee_check_box.dart | 44 +++++++++++++++++++ 2 files changed, 58 insertions(+), 9 deletions(-) create mode 100644 lib/widget/buttons/bee_check_box.dart diff --git a/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart b/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart index df0ffeb9..497056b9 100644 --- a/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart +++ b/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart @@ -4,6 +4,7 @@ import 'dart:io'; import 'package:akuCommunity/base/base_style.dart'; import 'package:akuCommunity/provider/user_provider.dart'; +import 'package:akuCommunity/widget/buttons/bee_check_box.dart'; import 'package:akuCommunity/widget/buttons/bottom_button.dart'; import 'package:akuCommunity/widget/buttons/radio_button.dart'; import 'package:flutter/cupertino.dart'; @@ -115,17 +116,15 @@ class _DetoCreatePageState extends State { child: Container( padding: EdgeInsets.only(bottom: 24.w), child: Row( + mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.start, children: [ - Checkbox( - value: needMoveCompany, - activeColor: Color(0xffffc40c), - onChanged: (bool val) { - this.setState(() { - needMoveCompany=!needMoveCompany; - }); - }, - ), + BeeCheckBox( + onChange: (value) { + needMoveCompany=value; + }, + ), + 10.w.widthBox, Container( child: Text( '是否需要物业提供搬家公司联系方式', @@ -223,6 +222,12 @@ class _DetoCreatePageState extends State { ); } + Widget _itemPicker(){ + return Container( + + ); + } + @override Widget build(BuildContext context) { return BeeScaffold( diff --git a/lib/widget/buttons/bee_check_box.dart b/lib/widget/buttons/bee_check_box.dart new file mode 100644 index 00000000..669dc31d --- /dev/null +++ b/lib/widget/buttons/bee_check_box.dart @@ -0,0 +1,44 @@ +import 'package:akuCommunity/base/base_style.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:akuCommunity/utils/headers.dart'; + +class BeeCheckBox extends StatefulWidget { + final Function(bool) onChange; + BeeCheckBox({Key key, this.onChange}) : super(key: key); + + @override + _BeeCheckBoxState createState() => _BeeCheckBoxState(); +} + +class _BeeCheckBoxState extends State { + bool _isSelect = false; + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: () { + _isSelect = !_isSelect; + setState(() {}); + widget.onChange(_isSelect); + }, + child: AnimatedContainer( + duration: Duration(milliseconds: 300), + decoration: BoxDecoration( + border: Border.all( + width: 1.w, color: _isSelect ? kPrimaryColor : kDarkSubColor), + color: _isSelect ? kPrimaryColor : Colors.transparent, + ), + curve: Curves.easeInOutCubic, + width: 28.w, + height: 28.w, + child: _isSelect + ? Icon( + CupertinoIcons.check_mark, + size: 25.w, + color: Colors.white, + ) + : SizedBox(), + ), + ); + } +} From e736b13fc1fe2dba1f63a16610f516b7df77bcbc Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Wed, 27 Jan 2021 19:27:12 +0800 Subject: [PATCH 4/5] update deto create page --- .../deto_create_page/deto_create_page.dart | 127 ++++++++++++++++-- .../widget/add_fixed_submit_page.dart | 4 +- lib/widget/picker/bee_date_picker.dart | 27 +++- 3 files changed, 143 insertions(+), 15 deletions(-) diff --git a/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart b/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart index 497056b9..da500cde 100644 --- a/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart +++ b/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart @@ -4,9 +4,13 @@ import 'dart:io'; import 'package:akuCommunity/base/base_style.dart'; import 'package:akuCommunity/provider/user_provider.dart'; +import 'package:akuCommunity/widget/bee_divider.dart'; import 'package:akuCommunity/widget/buttons/bee_check_box.dart'; import 'package:akuCommunity/widget/buttons/bottom_button.dart'; import 'package:akuCommunity/widget/buttons/radio_button.dart'; +import 'package:akuCommunity/widget/picker/bee_custom_picker.dart'; +import 'package:akuCommunity/widget/picker/bee_date_picker.dart'; +import 'package:flustars/flustars.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -14,6 +18,7 @@ import 'package:flutter/material.dart'; import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/widget/picker/grid_image_picker.dart'; +import 'package:get/get.dart'; import 'package:provider/provider.dart'; import 'widget/common_picker.dart'; import 'widget/common_radio.dart'; @@ -35,6 +40,8 @@ class _DetoCreatePageState extends State { : userProvider.userDetailModel.estateNames[0]; } + String _itemName; + DateTime _date; int _selectWeight; List _listWeight = [ '< 50kg', @@ -47,6 +54,13 @@ class _DetoCreatePageState extends State { '搬家公司', ]; + List _itemClass = [ + '全部', + '家纺', + '家具', + '电器', + ]; + bool needMoveCompany = false; Widget _houseAddress(String title, subtitle) { @@ -119,12 +133,12 @@ class _DetoCreatePageState extends State { mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.start, children: [ - BeeCheckBox( - onChange: (value) { - needMoveCompany=value; - }, - ), - 10.w.widthBox, + BeeCheckBox( + onChange: (value) { + needMoveCompany = value; + }, + ), + 10.w.widthBox, Container( child: Text( '是否需要物业提供搬家公司联系方式', @@ -222,10 +236,94 @@ class _DetoCreatePageState extends State { ); } - Widget _itemPicker(){ - return Container( + Widget _itemPicker(String title, String select, VoidCallback onTap) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Padding( + padding: EdgeInsets.symmetric(vertical: 28.w), + child: InkWell( + onTap: onTap, + child: Row( + children: [ + title.text.color(ktextPrimary).size(28.sp).make(), + 36.w.widthBox, + (select.isEmptyOrNull ? '请选择' : select) + .text + .color(select.isEmptyOrNull ? ktextSubColor : ktextPrimary) + .size(28.sp) + .make(), + Spacer(), + Icon( + CupertinoIcons.chevron_right, + size: 30.w, + ), + ], + ), + ), + ), + BeeDivider.horizontal(), + ], + ); + } + _showItmePicker() async { + _itemName = await Get.bottomSheet( + SizedBox( + child: Material( + borderRadius: BorderRadius.vertical( + top: Radius.circular(20.w), + ), + clipBehavior: Clip.antiAlias, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + ..._itemClass + .map((e) => Material( + child: InkWell( + onTap: () { + Get.back(result: e); + }, + child: Container( + alignment: Alignment.center, + height: 112.w, + width: double.infinity, + child: e.text + .color(ktextPrimary) + .isIntrinsic + .size(28.sp) + .make()), + ), + )) + .toList(), + Container( + height: 16.w, + color: Color(0xFFF7F7F7), + ), + Material( + child: InkWell( + onTap: () { + Get.back(); + }, + child: Container( + alignment: Alignment.center, + height: 112.w, + width: double.infinity, + child: '取消' + .text + .color(ktextPrimary) + .isIntrinsic + .size(28.sp) + .make()), + ), + ), + ], + ), + ), + ), ); + setState(() {}); } @override @@ -237,10 +335,17 @@ class _DetoCreatePageState extends State { children: [ _houseAddress(kEstateName, firstEstateName), _getWeight(), - CommonPicker(title: '出户时间'), - CommonPicker(title: '物品名称'), + _itemPicker( + '出户时间', DateUtil.formatDate(_date, format: "yyyy-MM-dd HH:mm:ss"), + () async { + _date = await BeeDatePicker.timePicker(DateTime.now()); + setState(() {}); + }), + _itemPicker('物品名称', _itemName, () { + _showItmePicker(); + }), _getApproach(), - _selectApproach==0?SizedBox(): _inkWellCheckbox(), + _selectApproach == 0 ? SizedBox() : _inkWellCheckbox(), Container( margin: EdgeInsets.only(top: 54.w, bottom: 24.w), child: Text( diff --git a/lib/pages/things_page/widget/add_fixed_submit_page.dart b/lib/pages/things_page/widget/add_fixed_submit_page.dart index aeb44e0b..8195fe3b 100644 --- a/lib/pages/things_page/widget/add_fixed_submit_page.dart +++ b/lib/pages/things_page/widget/add_fixed_submit_page.dart @@ -101,8 +101,8 @@ class _AddFixedSubmitPageState extends State { int value, ) { return FlatButton( - minWidth: 200.w, - height: 72.w, + // minWidth: 200.w, + // height: 72.w, onPressed: () { setState(() { _selectType = value; diff --git a/lib/widget/picker/bee_date_picker.dart b/lib/widget/picker/bee_date_picker.dart index 0f45facc..3f28f62d 100644 --- a/lib/widget/picker/bee_date_picker.dart +++ b/lib/widget/picker/bee_date_picker.dart @@ -10,11 +10,31 @@ class BeeDatePicker { static Future pick(DateTime initDate) async { return await Get.bottomSheet(_BeeDatePicker(date: initDate)); } + + static Future timePicker(DateTime initDate) async { + return await Get.bottomSheet(_BeeDatePicker( + date: initDate, + min: initDate, + max: initDate.add(Duration(days: 7)), + mode: CupertinoDatePickerMode.dateAndTime, + )); + } } class _BeeDatePicker extends StatefulWidget { final DateTime date; - _BeeDatePicker({Key key, @required this.date}) : super(key: key); + final bool use24H; + final DateTime max; + final DateTime min; + final CupertinoDatePickerMode mode; + _BeeDatePicker( + {Key key, + @required this.date, + this.use24H = false, + this.max, + this.min, + this.mode}) + : super(key: key); @override __BeeDatePickerState createState() => __BeeDatePickerState(); @@ -49,9 +69,12 @@ class __BeeDatePickerState extends State<_BeeDatePicker> { ), ), CupertinoDatePicker( + use24hFormat: widget.use24H, + maximumDate: widget.max, + minimumDate: widget.min, initialDateTime: _date, onDateTimeChanged: (date) => _date = date, - mode: CupertinoDatePickerMode.date, + mode:widget.mode?? CupertinoDatePickerMode.date, ).expand(), ], ), From 3b5ada0858100502b8ab38fb92b4e07fbc87160c Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Wed, 27 Jan 2021 20:03:37 +0800 Subject: [PATCH 5/5] update deto create page --- .../deto_create_page/deto_create_page.dart | 170 ++++++++++-------- .../widget/common_picker.dart | 1 + .../deto_create_page/widget/common_radio.dart | 7 +- .../goods_deto_page/goods_deto_page.dart | 5 +- .../things_evaluate_page.dart | 2 +- .../things_page/widget/fixed_detail_page.dart | 6 +- .../widget/fixed_evaluate_page.dart | 17 +- lib/widget/buttons/bee_check_box.dart | 5 +- lib/widget/buttons/bee_check_button.dart | 40 +++++ lib/widget/picker/bee_custom_picker.dart | 48 +++++ 10 files changed, 208 insertions(+), 93 deletions(-) create mode 100644 lib/widget/buttons/bee_check_button.dart create mode 100644 lib/widget/picker/bee_custom_picker.dart diff --git a/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart b/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart index da500cde..b9f2401d 100644 --- a/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart +++ b/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart @@ -1,28 +1,33 @@ // Flutter imports: +// Dart imports: import 'dart:io'; +// Flutter imports: +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +// Package imports: +import 'package:flustars/flustars.dart'; +import 'package:get/get.dart'; +import 'package:provider/provider.dart'; + +// Project imports: import 'package:akuCommunity/base/base_style.dart'; +import 'package:akuCommunity/const/resource.dart'; import 'package:akuCommunity/provider/user_provider.dart'; +import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/widget/bee_divider.dart'; +import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/widget/buttons/bee_check_box.dart'; +import 'package:akuCommunity/widget/buttons/bee_check_button.dart'; import 'package:akuCommunity/widget/buttons/bottom_button.dart'; import 'package:akuCommunity/widget/buttons/radio_button.dart'; import 'package:akuCommunity/widget/picker/bee_custom_picker.dart'; import 'package:akuCommunity/widget/picker/bee_date_picker.dart'; -import 'package:flustars/flustars.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -// Project imports: -import 'package:akuCommunity/utils/headers.dart'; -import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/widget/picker/grid_image_picker.dart'; -import 'package:get/get.dart'; -import 'package:provider/provider.dart'; import 'widget/common_picker.dart'; import 'widget/common_radio.dart'; -import 'package:akuCommunity/const/resource.dart'; class DetoCreatePage extends StatefulWidget { DetoCreatePage({Key key}) : super(key: key); @@ -156,40 +161,58 @@ class _DetoCreatePageState extends State { Widget _getWeight() { return Container( - height: 96.w, - padding: EdgeInsets.symmetric(vertical: 28.w), - decoration: BoxDecoration( - border: - Border(bottom: BorderSide(color: Color(0xffeeeeee), width: 0.5)), - ), - child: Row( + // margin: EdgeInsets.fromLTRB(0, 40.w, 0, 40.w), + // child: Row( + // children: [ + // Container( + // margin: EdgeInsets.only(right: 30.w), + // child: Text( + // '物品重量', + // style: TextStyle(fontSize: 28.sp, color: Color(0xff333333)), + // ), + // ), + // ...List.generate( + // _listWeight.length, + // (index) => GestureDetector( + // onTap: () { + // setState(() { + // _selectWeight = index; + // }); + // }, + // child: CommonRadio( + // size: 30.w, + // text: _listWeight[index] + // .text + // .color(ktextPrimary) + // .size(28.sp) + // .make(), + // value: index, + // groupValue: _selectWeight, + // ), + // )), + // ], + // ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - margin: EdgeInsets.only(right: 30.w), - child: Text( - '物品重量', - style: TextStyle(fontSize: 28.sp, color: Color(0xff333333)), - ), + '物品重量'.text.color(ktextPrimary).size(28.sp).make(), + 24.w.heightBox, + Wrap( + spacing: 40.w, + children: [ + ..._listWeight + .map((e) => BeeCheckButton( + title: e, + value: _listWeight.indexOf(e), + groupValue: _selectWeight, + onChange: (value) { + _selectWeight = value; + setState(() {}); + }, + )) + .toList() + ], ), - ...List.generate( - _listWeight.length, - (index) => GestureDetector( - onTap: () { - setState(() { - _selectWeight = index; - }); - }, - child: CommonRadio( - size: 30.w, - text: _listWeight[index] - .text - .color(ktextPrimary) - .size(28.sp) - .make(), - value: index, - groupValue: _selectWeight, - ), - )), ], ), ); @@ -197,40 +220,27 @@ class _DetoCreatePageState extends State { Widget _getApproach() { return Container( - height: 96.w, - padding: EdgeInsets.symmetric(vertical: 28.w), - decoration: BoxDecoration( - border: - Border(bottom: BorderSide(color: Color(0xffeeeeee), width: 0.5)), - ), - child: Row( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - margin: EdgeInsets.only(right: 30.w), - child: Text( - '搬运方式', - style: TextStyle(fontSize: 28.sp, color: Color(0xff333333)), - ), + '搬运方式'.text.color(ktextPrimary).size(28.sp).make(), + 24.w.heightBox, + Wrap( + spacing: 40.w, + children: [ + ..._listMode + .map((e) => BeeCheckButton( + title: e, + value: _listMode.indexOf(e), + groupValue: _selectApproach, + onChange: (value) { + _selectApproach = value; + setState(() {}); + }, + )) + .toList() + ], ), - ...List.generate( - _listMode.length, - (index) => GestureDetector( - onTap: () { - setState(() { - _selectApproach = index; - }); - }, - child: CommonRadio( - size: 30.w, - text: _listMode[index] - .text - .color(ktextPrimary) - .size(28.sp) - .make(), - value: index, - groupValue: _selectApproach, - ), - )), ], ), ); @@ -241,18 +251,22 @@ class _DetoCreatePageState extends State { crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ + 40.w.heightBox, + title.text.color(ktextPrimary).size(28.sp).make(), + 16.w.widthBox, Padding( - padding: EdgeInsets.symmetric(vertical: 28.w), + padding: EdgeInsets.symmetric(vertical: 30.w), child: InkWell( onTap: onTap, child: Row( children: [ - title.text.color(ktextPrimary).size(28.sp).make(), - 36.w.widthBox, (select.isEmptyOrNull ? '请选择' : select) .text .color(select.isEmptyOrNull ? ktextSubColor : ktextPrimary) - .size(28.sp) + .size(36.sp) + .fontWeight(select.isEmptyOrNull + ? FontWeight.normal + : FontWeight.bold) .make(), Spacer(), Icon( diff --git a/lib/pages/goods_deto_page/deto_create_page/widget/common_picker.dart b/lib/pages/goods_deto_page/deto_create_page/widget/common_picker.dart index 37272b63..0f331ebe 100644 --- a/lib/pages/goods_deto_page/deto_create_page/widget/common_picker.dart +++ b/lib/pages/goods_deto_page/deto_create_page/widget/common_picker.dart @@ -10,6 +10,7 @@ import 'package:flutter_picker/flutter_picker.dart'; // Project imports: import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/widget/picker/bee_date_picker.dart'; + @Deprecated('s**t code should be remove') class CommonPicker extends StatefulWidget { final String title; diff --git a/lib/pages/goods_deto_page/deto_create_page/widget/common_radio.dart b/lib/pages/goods_deto_page/deto_create_page/widget/common_radio.dart index ca5d86fc..b9aceab2 100644 --- a/lib/pages/goods_deto_page/deto_create_page/widget/common_radio.dart +++ b/lib/pages/goods_deto_page/deto_create_page/widget/common_radio.dart @@ -1,7 +1,10 @@ -import 'package:akuCommunity/base/base_style.dart'; -import 'package:akuCommunity/widget/animated/animated_scale.dart'; +// Flutter imports: import 'package:flutter/material.dart'; + +// Project imports: +import 'package:akuCommunity/base/base_style.dart'; import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/widget/animated/animated_scale.dart'; class CommonRadio extends StatefulWidget { final T value; diff --git a/lib/pages/goods_deto_page/goods_deto_page.dart b/lib/pages/goods_deto_page/goods_deto_page.dart index 38fca7bc..5b97888c 100644 --- a/lib/pages/goods_deto_page/goods_deto_page.dart +++ b/lib/pages/goods_deto_page/goods_deto_page.dart @@ -1,12 +1,13 @@ // Flutter imports: -import 'package:akuCommunity/base/base_style.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; // Package imports: import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:velocity_x/velocity_x.dart'; // Project imports: +import 'package:akuCommunity/base/base_style.dart'; import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/model/manager/goods_out_model.dart'; import 'package:akuCommunity/pages/goods_deto_page/deto_create_page/deto_create_page.dart'; @@ -14,7 +15,7 @@ import 'package:akuCommunity/pages/things_page/widget/bee_list_view.dart'; import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'widget/goods_info_card.dart'; -import 'package:velocity_x/velocity_x.dart'; + class GoodsDetoPage extends StatefulWidget { GoodsDetoPage({Key key}) : super(key: key); diff --git a/lib/pages/things_page/things_evaluate_page/things_evaluate_page.dart b/lib/pages/things_page/things_evaluate_page/things_evaluate_page.dart index c06b91f0..bcd804d3 100644 --- a/lib/pages/things_page/things_evaluate_page/things_evaluate_page.dart +++ b/lib/pages/things_page/things_evaluate_page/things_evaluate_page.dart @@ -1,5 +1,4 @@ // Flutter imports: -import 'package:akuCommunity/base/base_style.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -8,6 +7,7 @@ import 'package:flutter_icons/flutter_icons.dart'; import 'package:flutter_rating_bar/flutter_rating_bar.dart'; // Project imports: +import 'package:akuCommunity/base/base_style.dart'; import 'package:akuCommunity/routers/page_routers.dart'; import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; diff --git a/lib/pages/things_page/widget/fixed_detail_page.dart b/lib/pages/things_page/widget/fixed_detail_page.dart index a8bab8e6..afb9f517 100644 --- a/lib/pages/things_page/widget/fixed_detail_page.dart +++ b/lib/pages/things_page/widget/fixed_detail_page.dart @@ -1,11 +1,9 @@ // Flutter imports: -import 'package:akuCommunity/pages/things_page/widget/fixed_evaluate_page.dart'; -import 'package:akuCommunity/utils/network/base_model.dart'; -import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; // Package imports: +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; @@ -16,8 +14,10 @@ import 'package:akuCommunity/base/base_style.dart'; import 'package:akuCommunity/const/resource.dart'; import 'package:akuCommunity/model/manager/fixed_detail_model.dart'; import 'package:akuCommunity/pages/manager_func.dart'; +import 'package:akuCommunity/pages/things_page/widget/fixed_evaluate_page.dart'; import 'package:akuCommunity/utils/bee_map.dart'; import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/utils/network/base_model.dart'; import 'package:akuCommunity/widget/bee_divider.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/widget/views/horizontal_image_view.dart'; diff --git a/lib/pages/things_page/widget/fixed_evaluate_page.dart b/lib/pages/things_page/widget/fixed_evaluate_page.dart index a4488e55..4d4b131f 100644 --- a/lib/pages/things_page/widget/fixed_evaluate_page.dart +++ b/lib/pages/things_page/widget/fixed_evaluate_page.dart @@ -1,15 +1,20 @@ -import 'package:akuCommunity/base/base_style.dart'; -import 'package:akuCommunity/model/manager/fixed_detail_model.dart'; -import 'package:akuCommunity/pages/manager_func.dart'; -import 'package:akuCommunity/utils/network/base_model.dart'; -import 'package:akuCommunity/widget/bee_scaffold.dart'; -import 'package:bot_toast/bot_toast.dart'; +// Flutter imports: import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; + +// Package imports: +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:get/get.dart'; import 'package:velocity_x/velocity_x.dart'; + +// Project imports: +import 'package:akuCommunity/base/base_style.dart'; +import 'package:akuCommunity/model/manager/fixed_detail_model.dart'; +import 'package:akuCommunity/pages/manager_func.dart'; import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/utils/network/base_model.dart'; +import 'package:akuCommunity/widget/bee_scaffold.dart'; class FixedEvaluatePage extends StatefulWidget { final FixedDetailModel model; diff --git a/lib/widget/buttons/bee_check_box.dart b/lib/widget/buttons/bee_check_box.dart index 669dc31d..34cb0a1b 100644 --- a/lib/widget/buttons/bee_check_box.dart +++ b/lib/widget/buttons/bee_check_box.dart @@ -1,6 +1,9 @@ -import 'package:akuCommunity/base/base_style.dart'; +// Flutter imports: import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; + +// Project imports: +import 'package:akuCommunity/base/base_style.dart'; import 'package:akuCommunity/utils/headers.dart'; class BeeCheckBox extends StatefulWidget { diff --git a/lib/widget/buttons/bee_check_button.dart b/lib/widget/buttons/bee_check_button.dart new file mode 100644 index 00000000..38cfac04 --- /dev/null +++ b/lib/widget/buttons/bee_check_button.dart @@ -0,0 +1,40 @@ +// Flutter imports: +import 'package:flutter/material.dart'; + +// Project imports: +import 'package:akuCommunity/base/base_style.dart'; +import 'package:akuCommunity/utils/headers.dart'; + +class BeeCheckButton extends StatefulWidget { + final Function(T value) onChange; + final T value; + final T groupValue; + final String title; + BeeCheckButton( + {Key key, this.onChange, this.value, this.groupValue, this.title}) + : super(key: key); + + @override + _BeeCheckButtonState createState() => _BeeCheckButtonState(); +} + +class _BeeCheckButtonState extends State { + bool get isSelect => widget.groupValue == widget.value; + @override + Widget build(BuildContext context) { + return FlatButton( + onPressed: () { + widget.onChange(widget.value); + }, + child: widget.title.text + .color(isSelect ? ktextPrimary : Color(0xFF979797)) + .size(32.sp) + .make(), + padding: EdgeInsets.symmetric(horizontal: 34.w, vertical: 14.w), + shape: RoundedRectangleBorder( + side: BorderSide( + color: isSelect ? kPrimaryColor : ktextSubColor, width: 3.w), + borderRadius: BorderRadius.circular(36.w)), + ); + } +} diff --git a/lib/widget/picker/bee_custom_picker.dart b/lib/widget/picker/bee_custom_picker.dart new file mode 100644 index 00000000..1410c875 --- /dev/null +++ b/lib/widget/picker/bee_custom_picker.dart @@ -0,0 +1,48 @@ +// Flutter imports: +import 'package:flutter/material.dart'; + +// Package imports: +import 'package:get/get.dart'; + +// Project imports: +import 'package:akuCommunity/utils/headers.dart'; + +class BeeCustomPicker extends StatefulWidget { + + final Widget body; + final VoidCallback onPressed; + BeeCustomPicker({Key key, this.body, this.onPressed}) : super(key: key); + + @override + _BeeCustomPickerState createState() => _BeeCustomPickerState(); +} + +class _BeeCustomPickerState extends State { + @override + Widget build(BuildContext context) { + return SizedBox( + child: Material( + borderRadius: BorderRadius.vertical(top: Radius.circular(10)), + child: Column( + children: [ + SizedBox( + height: 48, + child: NavigationToolbar( + leading: TextButton( + onPressed: Get.back, + child: '取消'.text.black.make(), + ), + trailing: TextButton( + onPressed: widget.onPressed, + child: '确定'.text.black.make(), + ), + ), + ), + widget.body, + ], + ), + ), + height: Get.height / 3, + ); + } +}