rewrite deto create page

hmxc
张萌 4 years ago
parent bff2d19976
commit 378dfe6412

@ -1,15 +1,22 @@
// Flutter imports: // 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/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// Project imports: // Project imports:
import 'package:akuCommunity/base/assets_image.dart';
import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/utils/headers.dart';
import 'package:akuCommunity/widget/bee_scaffold.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:akuCommunity/widget/picker/grid_image_picker.dart';
import 'package:provider/provider.dart';
import 'widget/common_picker.dart'; import 'widget/common_picker.dart';
import 'widget/common_radio.dart'; import 'widget/common_radio.dart';
import 'package:akuCommunity/const/resource.dart';
class DetoCreatePage extends StatefulWidget { class DetoCreatePage extends StatefulWidget {
DetoCreatePage({Key key}) : super(key: key); DetoCreatePage({Key key}) : super(key: key);
@ -19,18 +26,27 @@ class DetoCreatePage extends StatefulWidget {
} }
class _DetoCreatePageState extends State<DetoCreatePage> { class _DetoCreatePageState extends State<DetoCreatePage> {
List<Map<String, dynamic>> _listWeight = [ List<File> _files = [];
{'title': '< 50kg', 'isCheck': true}, UserProvider get userProvider => Provider.of<UserProvider>(context);
{'title': '50kg-100kg', 'isCheck': false}, String get firstEstateName {
{'title': '> 100kg', 'isCheck': false} return userProvider.userDetailModel.estateNames.isEmpty
]; ? ''
: userProvider.userDetailModel.estateNames[0];
}
List<Map<String, dynamic>> _listMode = [ int _selectWeight;
{'title': '自己搬运', 'isCheck': true}, List<String> _listWeight = [
{'title': '搬家公司', 'isCheck': false}, '< 50kg',
'50kg-100kg',
'> 100kg',
];
int _selectApproach;
List<String> _listMode = [
'自己搬运',
'搬家公司',
]; ];
bool isCheck = false; bool needMoveCompany = false;
Widget _houseAddress(String title, subtitle) { Widget _houseAddress(String title, subtitle) {
return Container( return Container(
@ -60,7 +76,7 @@ class _DetoCreatePageState extends State<DetoCreatePage> {
Container( Container(
margin: EdgeInsets.only(right: 42.w), margin: EdgeInsets.only(right: 42.w),
child: Image.asset( child: Image.asset(
AssetsImage.HOUSEATTESTATION, R.ASSETS_IMAGES_HOUSE_ATTESTATION_PNG,
height: 59.w, height: 59.w,
width: 59.w, width: 59.w,
), ),
@ -102,11 +118,11 @@ class _DetoCreatePageState extends State<DetoCreatePage> {
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
Checkbox( Checkbox(
value: this.isCheck, value: needMoveCompany,
activeColor: Color(0xffffc40c), activeColor: Color(0xffffc40c),
onChanged: (bool val) { onChanged: (bool val) {
this.setState(() { this.setState(() {
this.isCheck = !this.isCheck; needMoveCompany=!needMoveCompany;
}); });
}, },
), ),
@ -125,7 +141,7 @@ class _DetoCreatePageState extends State<DetoCreatePage> {
); );
} }
Widget _checkCard(String title, List<Map<String, dynamic>> list) { Widget _getWeight() {
return Container( return Container(
height: 96.w, height: 96.w,
padding: EdgeInsets.symmetric(vertical: 28.w), padding: EdgeInsets.symmetric(vertical: 28.w),
@ -138,21 +154,70 @@ class _DetoCreatePageState extends State<DetoCreatePage> {
Container( Container(
margin: EdgeInsets.only(right: 30.w), margin: EdgeInsets.only(right: 30.w),
child: Text( child: Text(
title, '物品重量',
style: TextStyle(fontSize: 28.sp, color: Color(0xff333333)), style: TextStyle(fontSize: 28.sp, color: Color(0xff333333)),
), ),
), ),
CommonRadio( ...List.generate(
commonlist: list, _listWeight.length,
fun: (int index) { (index) => GestureDetector(
onTap: () {
setState(() { setState(() {
list.forEach((item) { _selectWeight = index;
item['isCheck'] = false;
}); });
list[index]['isCheck'] = true; },
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<DetoCreatePage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BeeScaffold( return BeeScaffold(
title: '物品出户', title: '物品出户',
body: Container( body: ListView(
color: Colors.white, padding: EdgeInsets.all(32.w),
child: Stack(
children: [
Container(
padding: EdgeInsets.only(
left: 32.w,
right: 32.w,
top: 32.w,
),
child: ListView(
children: [ children: [
_houseAddress('宁波华茂悦峰', '1幢-1单元-702室'), _houseAddress(kEstateName, firstEstateName),
_checkCard('物品重量', _listWeight), _getWeight(),
CommonPicker(title: '出户时间'), CommonPicker(title: '出户时间'),
CommonPicker(title: '物品名称'), CommonPicker(title: '物品名称'),
_checkCard('搬运方式', _listMode), _getApproach(),
_inkWellCheckbox(), _selectApproach==0?SizedBox(): _inkWellCheckbox(),
Container( Container(
margin: EdgeInsets.only(top: 54.w, bottom: 24.w), margin: EdgeInsets.only(top: 54.w, bottom: 24.w),
child: Text( child: Text(
'添加图片信息(0/9)', '添加图片信息(${_files.length}/9)',
style: TextStyle( style: TextStyle(
fontSize: 28.sp, fontSize: 28.sp,
color: Color(0xff333333), color: Color(0xff333333),
), ),
), ),
), ),
GridImagePicker(onChange: (files) {}), GridImagePicker(onChange: (files) {
], _files = files;
), setState(() {});
), }),
Positioned(
bottom: 0,
child: BottomButton(title: '确认提交'),
)
], ],
), ),
bottomNavi: BottomButton(
child: '确认提交'.text.color(ktextPrimary).bold.make(),
onPressed: () {},
), ),
); );
// Positioned(
// bottom: 0,
// child: BottomButton(title: '确认提交'),
// )
// ],
// ),
} }
} }

@ -10,7 +10,7 @@ import 'package:flutter_picker/flutter_picker.dart';
// Project imports: // Project imports:
import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/utils/headers.dart';
import 'package:akuCommunity/widget/picker/bee_date_picker.dart'; import 'package:akuCommunity/widget/picker/bee_date_picker.dart';
@Deprecated('s**t code should be remove')
class CommonPicker extends StatefulWidget { class CommonPicker extends StatefulWidget {
final String title; final String title;
CommonPicker({Key key, this.title}) : super(key: key); CommonPicker({Key key, this.title}) : super(key: key);

@ -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/base/base_style.dart';
import 'package:akuCommunity/widget/animated/animated_scale.dart';
import 'package:flutter/material.dart';
import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/utils/headers.dart';
class CommonRadio extends StatefulWidget { class CommonRadio<T> extends StatefulWidget {
final List<Map<String, dynamic>> commonlist; final T value;
final Function fun; final T groupValue;
CommonRadio({Key key, this.commonlist, this.fun}) : super(key: key); final Widget text;
final double size;
CommonRadio({Key key, this.value, this.groupValue, this.text, this.size})
: super(key: key);
@override @override
_CommonRadioState createState() => _CommonRadioState(); _CommonRadioState createState() => _CommonRadioState();
} }
class _CommonRadioState extends State<CommonRadio> { class _CommonRadioState extends State<CommonRadio> {
InkWell _inkWellRadio(String title, bool isCheck,int index, Function fun) { bool get _selected => widget.value == widget.groupValue;
return InkWell( double get smallSize {
onTap: () { return widget.size.isNull ? 24.w : (widget.size * 24 / 40);
fun(index); }
},
child: Container( @override
margin: EdgeInsets.only(left: 20.w), Widget build(BuildContext context) {
child: Row( return Row(
children: [ children: [
Icon( AnimatedContainer(
isCheck height: widget.size ?? 40.w,
? Icons.radio_button_checked width: widget.size ?? 40.w,
: Icons.radio_button_unchecked, decoration: BoxDecoration(
size: 32.w, border: Border.all(
color: isCheck ? BaseStyle.colorffc40c : BaseStyle.color979797, color: _selected ? kPrimaryColor : Color(0xFF979797),
width: 3.w,
), ),
SizedBox(width: 10.w), borderRadius: BorderRadius.circular(20.w),
Text( ),
title, duration: Duration(milliseconds: 300),
style: TextStyle( curve: Curves.easeInOutCubic,
fontSize: BaseStyle.fontSize28, color: ktextPrimary), 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),
), ),
],
), ),
), ),
);
}
@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(),
), ),
),
10.w.widthBox,
widget.text,
10.w.widthBox,
],
); );
} }
} }

@ -38,7 +38,7 @@ class _AddFixedSubmitPageState extends State<AddFixedSubmitPage> {
String reportText; String reportText;
List<String> _buttons = ['公区保修', '家庭维修']; List<String> _buttons = ['公区保修', '家庭维修'];
int _selectType; int _selectType;
List<File> _files=[]; List<File> _files = [];
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@ -182,16 +182,27 @@ class _AddFixedSubmitPageState extends State<AddFixedSubmitPage> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
'添加图片信息(${0}/9)'.text.black.size(28.sp).make(), '添加图片信息(${_files.length}/9)'.text.black.size(28.sp).make(),
24.w.heightBox, 24.w.heightBox,
GridImagePicker(onChange: (files) { GridImagePicker(onChange: (files) {
_files = 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
UserProvider userProvider = Provider.of<UserProvider>(context); UserProvider userProvider = Provider.of<UserProvider>(context);
@ -214,15 +225,19 @@ class _AddFixedSubmitPageState extends State<AddFixedSubmitPage> {
MaterialButton( MaterialButton(
minWidth: double.infinity, minWidth: double.infinity,
height: 98.w, height: 98.w,
onPressed: () async { onPressed: _canSubmit(_selectType, _textEditingController.text)
List<String> urls = ? () async {
await NetUtil().uploadFiles(_files, API.upload.uploadRepair); List<String> urls = await NetUtil()
.uploadFiles(_files, API.upload.uploadRepair);
BaseModel baseModel = await ManagerFunc.reportRepairInsert( BaseModel baseModel = await ManagerFunc.reportRepairInsert(
_selectType + 1, _textEditingController.text, urls); _selectType + 1, _textEditingController.text, urls);
if (baseModel.status) { if (baseModel.status) {
FinishFixedSubmitPage().to(); FinishFixedSubmitPage().to();
} else } else
BotToast.showText(text: baseModel.message); BotToast.showText(text: baseModel.message);
}
: () {
BotToast.showText(text: '请填写完整报修信息!');
}, },
child: '确认提交'.text.black.bold.size(32.sp).make(), child: '确认提交'.text.black.bold.size(32.sp).make(),
color: kPrimaryColor, color: kPrimaryColor,

@ -2,6 +2,7 @@ export 'package:flutter_screenutil/flutter_screenutil.dart';
export 'package:akuCommunity/extensions/page_router.dart'; export 'package:akuCommunity/extensions/page_router.dart';
export 'package:akuCommunity/extensions/num_ext.dart'; export 'package:akuCommunity/extensions/num_ext.dart';
export 'package:akuCommunity/extensions/widget_list_ext.dart'; export 'package:akuCommunity/extensions/widget_list_ext.dart';
export 'package:velocity_x/velocity_x.dart';
// class Screenutil { // class Screenutil {
// static double length(double lengthNum) => ScreenUtil().setWidth(lengthNum); // static double length(double lengthNum) => ScreenUtil().setWidth(lengthNum);

Loading…
Cancel
Save