From 7a561e361489f81b32721baf8e5f21066fd1906b Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Thu, 25 Mar 2021 20:14:13 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E5=B7=A1=E6=A3=80=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E7=BB=93=E6=9E=84=20=E6=B7=BB=E5=8A=A0=E5=B7=A1?= =?UTF-8?q?=E6=A3=80=E7=AE=A1=E7=90=86view=20=E6=B7=BB=E5=8A=A0list=20?= =?UTF-8?q?=E6=89=A9=E5=B1=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/style/app_style.dart | 6 +- .../inspection_manage_card.dart | 52 +-- .../inspection_manage_details_page.dart | 300 +++++++++++------- .../inspection_manage_page.dart | 56 ++-- .../inspection_manage_view.dart | 57 ++++ lib/utils/extension/list_extension.dart | 16 + 6 files changed, 335 insertions(+), 152 deletions(-) create mode 100644 lib/ui/manage_pages/inspection_manage/inspection_manage_view.dart create mode 100644 lib/utils/extension/list_extension.dart diff --git a/lib/style/app_style.dart b/lib/style/app_style.dart index 02e6412..711768d 100644 --- a/lib/style/app_style.dart +++ b/lib/style/app_style.dart @@ -15,13 +15,13 @@ const kMinorColor = Color(0xFFFFDF5D); const kSubColor = Color(0xFF3F8FFE); //字体 ///主字体颜色 -const primaryTextColor = Color(0xFF333333); +const kTextPrimaryColor = Color(0xFF333333); ///次字体颜色 -const minorTextColor = Color(0xFF999999); +const kTextSubColor = Color(0xFF999999); ///背景色 -const backgroundColor = Color(0xFFF9F9F9); +const kBackgroundColor = Color(0xFFF9F9F9); class AppStyle { //颜色,渐变主颜色和次级颜色 diff --git a/lib/ui/manage_pages/inspection_manage/inspection_manage_card.dart b/lib/ui/manage_pages/inspection_manage/inspection_manage_card.dart index a418af7..76b0dc6 100644 --- a/lib/ui/manage_pages/inspection_manage/inspection_manage_card.dart +++ b/lib/ui/manage_pages/inspection_manage/inspection_manage_card.dart @@ -52,10 +52,8 @@ class _InspectionManageCardState extends State { : () {}, child: Container( alignment: Alignment.centerLeft, - padding: EdgeInsets.only( - left: 24.w, right: 24.w, bottom: widget.extra ? 48.w : 40.w), + padding: EdgeInsets.only(left: 24.w, right: 24.w, bottom: 40.w), width: double.infinity, - height: widget.extra ? 362.w : 270.w, decoration: BoxDecoration( borderRadius: BorderRadius.circular(8.w), color: Color(0xFFFFFFFF)), @@ -67,7 +65,7 @@ class _InspectionManageCardState extends State { child: Row( children: [ Text( - '1号巡检任务', + '${widget.cardModel.name}', style: TextStyle( color: AppStyle.primaryTextColor, fontSize: widget.extra ? 32.sp : 36.sp, @@ -83,12 +81,30 @@ class _InspectionManageCardState extends State { ], ), ), - widget.extra - ? Divider( - height: 1.w, - ) - : SizedBox(), - widget.extra ? 24.w.heightBox : SizedBox(), + ...widget.extra + ? [Divider(height: 1.w), 24.w.heightBox] + : [ + Row( + children: [ + Image.asset( + R.ASSETS_MANAGE_IC_RENWU_PNG, + width: 40.w, + height: 40.w, + ), + 4.w.widthBox, + Text( + '巡检名称', + style: _textstyle, + ), + Spacer(), + Text( + widget.cardModel.name, + style: AppStyle().primaryStyle, + ) + ], + ), + 12.w.heightBox, + ], Row( children: [ Image.asset( @@ -108,7 +124,7 @@ class _InspectionManageCardState extends State { ) ], ), - Spacer(), + 12.w.heightBox, Row( children: [ Image.asset( @@ -120,13 +136,13 @@ class _InspectionManageCardState extends State { Text('规定巡检时间', style: _textstyle), Spacer(), Text( - '${DateUtil.formatDateStr(widget.cardModel.beginDate, format: "yyyy-MM-dd HH:mm")}~${DateUtil.formatDateStr(widget.cardModel.endDate, format: "HH:mm")}', + '${DateUtil.formatDateStr(widget.cardModel.beginDate, format: "yyyy-MM-dd HH:mm")}~${widget.cardModel?.endDate == null ? '' : DateUtil.formatDateStr(widget.cardModel.endDate, format: "HH:mm")}', style: AppStyle().primaryStyle, ), ], ), - Spacer(), - ...widget.cardModel.actualBeginDate == null + 12.w.heightBox, + ...widget.cardModel?.actualBeginDate == null ? [SizedBox()] : [ Row( @@ -148,10 +164,11 @@ class _InspectionManageCardState extends State { ), ], ), - Spacer(), + 12.w.heightBox, ], - widget.cardModel.actualEndDate == null - ? Row( + widget.cardModel?.actualEndDate == null + ? SizedBox() + : Row( children: [ Image.asset( R.ASSETS_MESSAGE_IC_PEOPLE_PNG, @@ -170,7 +187,6 @@ class _InspectionManageCardState extends State { ), ], ) - : SizedBox(), ]), ), ), diff --git a/lib/ui/manage_pages/inspection_manage/inspection_manage_details_page.dart b/lib/ui/manage_pages/inspection_manage/inspection_manage_details_page.dart index a9fce7f..e5cc048 100644 --- a/lib/ui/manage_pages/inspection_manage/inspection_manage_details_page.dart +++ b/lib/ui/manage_pages/inspection_manage/inspection_manage_details_page.dart @@ -1,141 +1,223 @@ // Flutter imports: +import 'package:aku_community_manager/models/manager/inspection/inspection_list_model.dart'; +import 'package:aku_community_manager/ui/manage_pages/inspection_manage/inspection_manage_card.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; - +import 'package:velocity_x/velocity_x.dart'; +import 'package:aku_community_manager/utils/extension/list_extension.dart'; +import 'package:aku_community_manager/style/app_style.dart'; // Package imports: import 'package:flutter_screenutil/flutter_screenutil.dart'; // Project imports: -import 'package:aku_community_manager/const/resource.dart'; -import 'package:aku_community_manager/mock_models/manage_models/manage_model.dart'; -import 'package:aku_community_manager/style/app_style.dart'; -import 'package:aku_community_manager/tools/widget_tool.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; -class InspectionManageDetailsPage extends StatelessWidget { - final InspectionManageCardModel cardModel; +class InspectionManageDetailsPage extends StatefulWidget { + final InspectionListModel cardModel; InspectionManageDetailsPage({Key key, this.cardModel}) : super(key: key); + @override + _InspectionManageDetailsPageState createState() => + _InspectionManageDetailsPageState(); +} + +class _InspectionManageDetailsPageState + extends State { + bool get _isFinishInspection => widget.cardModel.status == 2; + Map _inspectionStatus = { + 1: '待巡检', + 2: '已巡检', + }; + Color _inspectionColor(int status) { + switch (status) { + case 1: + return Color(0xFF4501); + break; + case 2: + return Color(0x999999); + default: + return Colors.black; + } + } + @override Widget build(BuildContext context) { return AkuScaffold( title: '巡检详情', body: Column( children: [ - // InspectionManageCard(cardModel:cardModel, extra: false), + InspectionManageCard(cardModel: widget.cardModel, extra: false), + 16.w.heightBox, Container( - width: double.infinity, - color: Color(0xFFFFFFFF), - margin: EdgeInsets.only(top: 16.w), - padding: EdgeInsets.only( - top: 24.w, left: 32.w, right: 86.w, bottom: 40.w), + padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w), + decoration: BoxDecoration(color: Color(0xFFFFFF)), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - '巡检人员', - style: TextStyle( - color: AppStyle.primaryTextColor, - fontSize: 32.sp, - fontWeight: FontWeight.bold), - ), - AkuBox.h(16), - GridView( - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 3, - childAspectRatio: 250 / 40, - mainAxisSpacing: 16.w), - children: cardModel.persons - .map((e) => _person(cardModel.persons.indexOf(e))) - .toList(), + children: [ + '巡检站点'.text.black.size(32.sp).bold.make(), + _buildInspectionTile( + '', + 1, + 1, ), - ], + ].sepWidget(separate: 16.w.heightBox), ), - ), - AkuBox.h(16), - Container( - color: Color(0xFFFFFFFF), - padding: EdgeInsets.only(top: 24.w, left: 32.w, right: 32.w), - width: double.infinity, - child: - Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text('巡检站点', - style: TextStyle( - color: AppStyle.primaryTextColor, - fontSize: 32.sp, - fontWeight: FontWeight.bold)), - AkuBox.h(16), - Wrap( - runSpacing: 16.w, - children: cardModel.stations - .map((e) => _station(cardModel.stations.indexOf(e))) - .toList(), - ), - AkuBox.h(24), - Image.asset( - R.ASSETS_INSPECTION_INSPECTION_STATION_PNG, - width: 686.w, - height: 343.w, - ), - ]), - ), + ) ], ), ); } - Widget _station(index) { + Widget _buildInspectionTile( + String inspectionStation, + int inspectionCount, + int index, + ) { return Row( - mainAxisSize: MainAxisSize.min, children: [ - Container( - padding: - EdgeInsets.only(top: 16.w, left: 24.w, bottom: 15.w, right: 24.w), - color: Color(0xFFF9F9F9), - height: 64.w, - alignment: Alignment.center, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - cardModel.stations[index], - style: TextStyle( - color: AppStyle.primaryTextColor, fontSize: 24.sp), - ), - ], - ), + CircleAvatar( + child: '巡$index'.text.color(Color(0x3F8FFE)).size(28.sp).bold.make(), + radius: 48.w, + backgroundColor: Color(0xE9F2FF), ), - AkuBox.w(8), - (cardModel.stations.length - 1) != index - ? Container( - width: 56.w, - height: 3.w, - color: Color(0xFFE8E8E8), - ) - : SizedBox(), - ], - ); - } - - Widget _person(index) { - return Container( - height: 40.w, - child: Row(mainAxisSize: MainAxisSize.min, children: [ - Image.asset( - R.ASSETS_MESSAGE_IC_PEOPLE_PNG, - width: 40.w, - height: 40.w, + 24.w.widthBox, + Column( + children: [ + inspectionStation.text.black.size(28.sp).bold.make(), + '$inspectionCount项检查'.text.color(kTextSubColor).size(24.sp).make() + ], ), - AkuBox.w(8), - Text( - cardModel.persons[index], - style: TextStyle( - color: AppStyle.primaryTextColor, - fontSize: 28.sp, - ), + Spacer(), + _inspectionStatus[widget.cardModel.status] + .text + .size(24.sp) + .bold + .color(_inspectionColor(widget.cardModel.status)) + .make(), + 14.w.widthBox, + Icon( + CupertinoIcons.chevron_right_circle, + size: 14.w, ), - ]), - ); + ], + ) + .box + .color(Color(0xF9F9F9)) + .withRounded(value: 4.w) + .padding(EdgeInsets.all(24.w)) + .make() + .onInkTap(() {}); } } +// Widget _inspectionPersons(){ +// return Container( +// width: double.infinity, +// color: Color(0xFFFFFFFF), +// margin: EdgeInsets.only(top: 16.w), +// padding: EdgeInsets.only( +// top: 24.w, left: 32.w, right: 86.w, bottom: 40.w), +// child: Column( +// crossAxisAlignment: CrossAxisAlignment.start, +// children: [ +// Text( +// '巡检人员', +// style: TextStyle( +// color: AppStyle.primaryTextColor, +// fontSize: 32.sp, +// fontWeight: FontWeight.bold), +// ), +// AkuBox.h(16), +// GridView( +// shrinkWrap: true, +// physics: NeverScrollableScrollPhysics(), +// gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( +// crossAxisCount: 3, +// childAspectRatio: 250 / 40, +// mainAxisSpacing: 16.w), +// children: widget.cardModel.persons +// .map((e) => _person(widget.cardModel.persons.indexOf(e))) +// .toList(), +// ), +// ], +// ), +// ), +// AkuBox.h(16), +// Container( +// color: Color(0xFFFFFFFF), +// padding: EdgeInsets.only(top: 24.w, left: 32.w, right: 32.w), +// width: double.infinity, +// child: +// Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ +// Text('巡检站点', +// style: TextStyle( +// color: AppStyle.primaryTextColor, +// fontSize: 32.sp, +// fontWeight: FontWeight.bold)), +// AkuBox.h(16), +// Wrap( +// runSpacing: 16.w, +// children: widget.cardModel.stations +// .map((e) => _station(widget.cardModel.stations.indexOf(e))) +// .toList(), +// ), +// AkuBox.h(24), +// Image.asset( +// R.ASSETS_INSPECTION_INSPECTION_STATION_PNG, +// width: 686.w, +// height: 343.w, +// ), +// ]), +// ); + +// Widget _station(index) { +// return Row( +// mainAxisSize: MainAxisSize.min, +// children: [ +// Container( +// padding: +// EdgeInsets.only(top: 16.w, left: 24.w, bottom: 15.w, right: 24.w), +// color: Color(0xFFF9F9F9), +// height: 64.w, +// alignment: Alignment.center, +// child: Row( +// mainAxisSize: MainAxisSize.min, +// children: [ +// Text( +// widget.cardModel.stations[index], +// style: TextStyle( +// color: AppStyle.primaryTextColor, fontSize: 24.sp), +// ), +// ], +// ), +// ), +// AkuBox.w(8), +// (widget.cardModel.stations.length - 1) != index +// ? Container( +// width: 56.w, +// height: 3.w, +// color: Color(0xFFE8E8E8), +// ) +// : SizedBox(), +// ], +// ); +// } + +// Widget _person(index) { +// return Container( +// height: 40.w, +// child: Row(mainAxisSize: MainAxisSize.min, children: [ +// Image.asset( +// R.ASSETS_MESSAGE_IC_PEOPLE_PNG, +// width: 40.w, +// height: 40.w, +// ), +// AkuBox.w(8), +// Text( +// widget.cardModel.persons[index], +// style: TextStyle( +// color: AppStyle.primaryTextColor, +// fontSize: 28.sp, +// ), +// ), +// ]), +// ); +// } diff --git a/lib/ui/manage_pages/inspection_manage/inspection_manage_page.dart b/lib/ui/manage_pages/inspection_manage/inspection_manage_page.dart index f407c1a..cc79c8a 100644 --- a/lib/ui/manage_pages/inspection_manage/inspection_manage_page.dart +++ b/lib/ui/manage_pages/inspection_manage/inspection_manage_page.dart @@ -1,11 +1,16 @@ // Flutter imports: import 'package:aku_community_manager/const/api.dart'; import 'package:aku_community_manager/models/manager/inspection/inspection_list_model.dart'; +import 'package:aku_community_manager/provider/app_provider.dart'; +import 'package:aku_community_manager/provider/user_provider.dart'; import 'package:aku_community_manager/ui/manage_pages/inspection_manage/inspection_manage_card.dart'; +import 'package:aku_community_manager/ui/manage_pages/inspection_manage/inspection_manage_view.dart'; import 'package:aku_community_manager/ui/widgets/common/bee_list_view.dart'; +import 'package:aku_community_manager/ui/widgets/inner/aku_tab_bar.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'; // Package imports: @@ -20,17 +25,30 @@ class InspectionManagePage extends StatefulWidget { _InspectionManagePageState createState() => _InspectionManagePageState(); } -class _InspectionManagePageState extends State { - EasyRefreshController _easyRefreshController; +class _InspectionManagePageState extends State + with TickerProviderStateMixin { + List get _tabs { + UserProvider _userProvider = + Provider.of(context, listen: false); + if (_userProvider.infoModel.canOperation) { + return ['待巡检', '已巡检', '巡检中', '全部']; + } else { + return ['待巡检', '已巡检', '巡检中', '全部']; + } + } + + int _selectIndex = 0; + + TabController _tabController; @override void initState() { - _easyRefreshController = EasyRefreshController(); + _tabController = TabController(length: _tabs.length, vsync: this); super.initState(); } @override void dispose() { - _easyRefreshController?.dispose(); + _tabController?.dispose(); super.dispose(); } @@ -38,24 +56,18 @@ class _InspectionManagePageState extends State { Widget build(BuildContext context) { return AkuScaffold( title: '巡检管理', - body: BeeListView( - path: API.manage.inspectionList, - controller: _easyRefreshController, - convert: (models) { - return models.tableList - .map((e) => InspectionListModel.fromJson(e)) - .toList(); - }, - builder: (items) { - return ListView.separated( - itemBuilder: (context, index) { - return InspectionManageCard(cardModel: items[index]); - }, - separatorBuilder: (_, __) { - return 8.w.heightBox; - }, - itemCount: items.length); - }, + appBarBottom: PreferredSize( + child: AkuTabBar(controller: _tabController, tabs: _tabs), + preferredSize: Size.fromHeight(96.w), + ), + body: TabBarView( + controller: _tabController, + children: List.generate( + _tabs.length, + (index) => InspectionMangeView( + inspectionStatus: index, + ), + ), ), ); } diff --git a/lib/ui/manage_pages/inspection_manage/inspection_manage_view.dart b/lib/ui/manage_pages/inspection_manage/inspection_manage_view.dart new file mode 100644 index 0000000..60f93f5 --- /dev/null +++ b/lib/ui/manage_pages/inspection_manage/inspection_manage_view.dart @@ -0,0 +1,57 @@ +import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/models/manager/inspection/inspection_list_model.dart'; +import 'package:aku_community_manager/ui/manage_pages/inspection_manage/inspection_manage_card.dart'; +import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; +import 'package:aku_community_manager/ui/widgets/common/bee_list_view.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class InspectionMangeView extends StatefulWidget { + final int inspectionStatus; + InspectionMangeView({Key key, this.inspectionStatus}) : super(key: key); + + @override + _InspectionMangeViewState createState() => _InspectionMangeViewState(); +} + +class _InspectionMangeViewState extends State { + EasyRefreshController _easyRefreshController; + @override + void initState() { + _easyRefreshController = EasyRefreshController(); + super.initState(); + } + + @override + void dispose() { + _easyRefreshController?.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return BeeListView( + path: API.manage.inspectionList, + controller: _easyRefreshController, + extraParams: {"inspectionStatus": widget.inspectionStatus}, + convert: (models) { + return models.tableList + .map((e) => InspectionListModel.fromJson(e)) + .toList(); + }, + builder: (items) { + return ListView.separated( + padding: EdgeInsets.symmetric(horizontal: 32.w), + itemBuilder: (context, index) { + return InspectionManageCard(cardModel: items[index]); + }, + separatorBuilder: (_, __) { + return 8.w.heightBox; + }, + itemCount: items.length); + }, + ); + } +} diff --git a/lib/utils/extension/list_extension.dart b/lib/utils/extension/list_extension.dart new file mode 100644 index 0000000..e17d3cd --- /dev/null +++ b/lib/utils/extension/list_extension.dart @@ -0,0 +1,16 @@ +import 'package:flutter/material.dart'; +import 'package:velocity_x/velocity_x.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +extension SeparateExt on List { + List sepWidget({Widget separate}) { + if (this == null) return null; + if (this.isEmpty) return []; + return List.generate(this.length * 2 - 1, (index) { + if (index.isEven) + return this[index ~/ 2]; + else + return separate ?? 10.w.heightBox; + }); + } +}