From 06e0340cf6053d9d7d418e46d12f66a82a190ca2 Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Fri, 22 Jan 2021 14:22:01 +0800 Subject: [PATCH] add fixed submit delete function docking delete port --- lib/base/base_style.dart | 1 + lib/constants/api.dart | 3 + lib/pages/manager_func.dart | 9 + lib/pages/things_page/fixed_submit_page.dart | 165 +++++++++++++----- .../things_page/widget/fixed_check_box.dart | 45 +++++ lib/widget/horizontal_image_view.dart | 14 +- 6 files changed, 183 insertions(+), 54 deletions(-) create mode 100644 lib/pages/things_page/widget/fixed_check_box.dart diff --git a/lib/base/base_style.dart b/lib/base/base_style.dart index c3a4a239..fbff3c2b 100644 --- a/lib/base/base_style.dart +++ b/lib/base/base_style.dart @@ -9,6 +9,7 @@ const kPrimaryColor=Color(0xFFFFC40C); const kDarkPrimaryColor=Color(0xFFFF8200); const kDangerColor=Color(0xFFFF3B30); const kEstateName='宁波华悦茂峰'; +const kDarkSubColor=Color(0xFF979797); class BaseStyle { ///字体类 static final double fontSize18 = 18.sp; diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 5a42c98f..0d39e5ba 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -68,4 +68,7 @@ class _Manager { ///报事报修:app提交报事报修信息 String get reportRepairInsert => '/user/reportRepair/insert'; + + ///报事报修:批量删除报事报修信息(业主端) + String get reportRepairDelete => '/user/reportRepair/falseDelete'; } diff --git a/lib/pages/manager_func.dart b/lib/pages/manager_func.dart index 390878c7..02860aa4 100644 --- a/lib/pages/manager_func.dart +++ b/lib/pages/manager_func.dart @@ -34,4 +34,13 @@ class ManagerFunc { ); return baseModel; } + + static reportRepairDelete(List ids) async { + BaseModel baseModel = await NetUtil().post( + API.manager.reportRepairDelete, + params: {'ids': ids}, + showMessage: true, + ); + return baseModel; + } } diff --git a/lib/pages/things_page/fixed_submit_page.dart b/lib/pages/things_page/fixed_submit_page.dart index 90206992..36f40c92 100644 --- a/lib/pages/things_page/fixed_submit_page.dart +++ b/lib/pages/things_page/fixed_submit_page.dart @@ -1,14 +1,19 @@ import 'package:akuCommunity/base/base_style.dart'; import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/model/user/fixed_submit_model.dart'; +import 'package:akuCommunity/pages/manager_func.dart'; import 'package:akuCommunity/pages/things_page/widget/add_fixed_submit_page.dart'; import 'package:akuCommunity/pages/things_page/widget/bee_list_view.dart'; +import 'package:akuCommunity/pages/things_page/widget/fixed_check_box.dart'; +import 'package:akuCommunity/provider/user_provider.dart'; import 'package:akuCommunity/utils/bee_map.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/widget/horizontal_image_view.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:provider/provider.dart'; import 'package:velocity_x/velocity_x.dart'; import 'package:akuCommunity/extensions/num_ext.dart'; import 'package:akuCommunity/extensions/page_router.dart'; @@ -22,6 +27,8 @@ class FixedSubmitPage extends StatefulWidget { class _FixedSubmitPageState extends State { EasyRefreshController _easyRefreshController; + bool _isEdit = false; + List _selected = []; @override void initState() { super.initState(); @@ -50,57 +57,107 @@ class _FixedSubmitPageState extends State { } } + bool _canSkew(int state) { + switch (state) { + case 1: + case 2: + case 3: + return false; + case 4: + case 5: + case 6: + case 7: + return true; + default: + return true; + } + } + Widget _buildCard(FixedSubmitModel model) { - return Container( - decoration: BoxDecoration( - color: kForeGroundColor, borderRadius: BorderRadius.circular(8.w)), - padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 24.w), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - BeeMap() - .fixTag[model.type] - .text - .color(ktextPrimary) - .bold - .size(32.sp) - .make(), - Spacer(), - BeeMap() - .fixState[model.status] - .text - .color(_getColor(model.status)) - .size(24.sp) - .make(), - ], - ), - 24.hb, - Divider( - thickness: 1.w, - height: 0, - ), - 24.hb, - model.reportDetail.text - .color(ktextSubColor) - .size(28.sp) - .ellipsis - .make(), - 16.hb, - model.imgUrls.length != 0 - ? HorizontalImageView(List.generate( - model.imgUrls.length, (index) => model.imgUrls[index].url)) - : SizedBox(), - ], + return AnimatedPositioned( + top: 0, + left: (_canSkew(4) && _isEdit) ? 55.w : 0, + bottom: 0, + duration: Duration(milliseconds: 300), + curve: Curves.easeInOutCubic, + child: Container( + width: 686.w, + decoration: BoxDecoration( + color: kForeGroundColor, borderRadius: BorderRadius.circular(8.w)), + padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 24.w), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + BeeMap() + .fixTag[model.type] + .text + .color(ktextPrimary) + .bold + .size(32.sp) + .make(), + Spacer(), + BeeMap() + .fixState[model.status] + .text + .color(_getColor(model.status)) + .size(24.sp) + .make(), + ], + ), + 24.hb, + Divider( + thickness: 1.w, + height: 0, + ), + 24.hb, + model.reportDetail.text + .color(ktextSubColor) + .size(28.sp) + .ellipsis + .make(), + 16.hb, + model.imgUrls.length != 0 + ? HorizontalImageView(List.generate( + model.imgUrls.length, (index) => model.imgUrls[index].url)) + : SizedBox(), + ], + ), ), ); } + Widget _buildCheckBox(FixedSubmitModel model) { + return Container( + alignment: Alignment.centerLeft, + constraints: BoxConstraints(minHeight: 384.w, minWidth: 686.w), + child: FixedCheckBox( + onChanged: (isSelect) { + if (isSelect) { + _selected.add(model.id); + } else { + _selected.remove(model.id); + } + }, + )); + } + @override Widget build(BuildContext context) { + UserProvider userProvider = Provider.of(context); return BeeScaffold( title: '报事报修', + actions: [ + IconButton( + icon: _isEdit + ? '完成'.text.black.size(28.sp).make() + : '编辑'.text.black.size(28.sp).make(), + onPressed: () { + _isEdit = !_isEdit; + setState(() {}); + }) + ], body: Column( children: [ BeeListView( @@ -115,7 +172,12 @@ class _FixedSubmitPageState extends State { return ListView.separated( padding: EdgeInsets.all(32.w), itemBuilder: (context, index) { - return _buildCard(items[index]); + return Stack( + children: [ + _buildCheckBox(items[index]), + _buildCard(items[index]) + ], + ); }, separatorBuilder: (context, index) { return 24.w.heightBox; @@ -124,10 +186,19 @@ class _FixedSubmitPageState extends State { }, ).expand(), MaterialButton( - onPressed: () { - AddFixedSubmitPage().to(); - }, - child: '新增'.text.bold.color(ktextPrimary).size(32.sp).make(), + onPressed: _isEdit + ? () { + ManagerFunc.reportRepairDelete(_selected); + _easyRefreshController.callRefresh(); + } + : () { + userProvider.isLogin + ? AddFixedSubmitPage().to() + : BotToast.showText(text: '请先登录!'); + }, + child: _isEdit + ? '删除订单'.text.bold.color(ktextPrimary).size(32.sp).make() + : '新增'.text.bold.color(ktextPrimary).size(32.sp).make(), minWidth: double.infinity, height: 98.w, elevation: 0, diff --git a/lib/pages/things_page/widget/fixed_check_box.dart b/lib/pages/things_page/widget/fixed_check_box.dart new file mode 100644 index 00000000..625870f5 --- /dev/null +++ b/lib/pages/things_page/widget/fixed_check_box.dart @@ -0,0 +1,45 @@ +import 'package:akuCommunity/base/base_style.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class FixedCheckBox extends StatefulWidget { + final Function(bool isSelect) onChanged; + FixedCheckBox({Key key, this.onChanged}) : super(key: key); + + @override + _FixedCheckBoxState createState() => _FixedCheckBoxState(); +} + +class _FixedCheckBoxState extends State { + bool _isSelected = false; + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: () { + setState(() { + _isSelected = !_isSelected; + }); + widget.onChanged(_isSelected); + }, + child: Container( + alignment: Alignment.center, + width: 40.w, + height: 40.w, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(40.w), + border: Border.all( + width: 3.w, color: _isSelected ? kPrimaryColor : kDarkSubColor), + color: Colors.transparent, + ), + child: Container( + width: 24.w, + height: 24.w, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(24.w), + color: _isSelected ? kPrimaryColor : Colors.transparent, + ), + ), + ), + ); + } +} diff --git a/lib/widget/horizontal_image_view.dart b/lib/widget/horizontal_image_view.dart index 0d272974..a712766c 100644 --- a/lib/widget/horizontal_image_view.dart +++ b/lib/widget/horizontal_image_view.dart @@ -25,13 +25,13 @@ class _HorizontalImageViewState extends State { itemBuilder: (context, index) { return Padding( padding: EdgeInsets.all(16.w), - child: ClipRRect( - borderRadius: BorderRadius.circular(8.w), - child: FadeInImage.assetNetwork( - placeholder: R.ASSETS_IMAGES_DRAWINGS_PNG, - image: API.resource + widget.urls[index], - ), - ), + // child: ClipRRect( + // borderRadius: BorderRadius.circular(8.w), + // child: FadeInImage.assetNetwork( + // placeholder: R.ASSETS_IMAGES_DRAWINGS_PNG, + // image: API.resource + widget.urls[index], + // ), + // ), ); }, ),