重构巡检管理结构

添加巡检管理view
添加list 扩展
hmxc
张萌 4 years ago
parent b160e2a9ba
commit 7a561e3614

@ -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 {
//

@ -52,10 +52,8 @@ class _InspectionManageCardState extends State<InspectionManageCard> {
: () {},
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<InspectionManageCard> {
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<InspectionManageCard> {
],
),
),
widget.extra
? Divider(
height: 1.w,
)
: SizedBox(),
widget.extra ? 24.w.heightBox : SizedBox(),
...widget.extra
? <Widget>[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<InspectionManageCard> {
)
],
),
Spacer(),
12.w.heightBox,
Row(
children: [
Image.asset(
@ -120,13 +136,13 @@ class _InspectionManageCardState extends State<InspectionManageCard> {
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<InspectionManageCard> {
),
],
),
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<InspectionManageCard> {
),
],
)
: SizedBox(),
]),
),
),

@ -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<InspectionManageDetailsPage> {
bool get _isFinishInspection => widget.cardModel.status == 2;
Map<int, String> _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: <Widget>[
'巡检站点'.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,
// ),
// ),
// ]),
// );
// }

@ -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<InspectionManagePage> {
EasyRefreshController _easyRefreshController;
class _InspectionManagePageState extends State<InspectionManagePage>
with TickerProviderStateMixin {
List<String> get _tabs {
UserProvider _userProvider =
Provider.of<UserProvider>(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<InspectionManagePage> {
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,
),
),
),
);
}

@ -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<InspectionMangeView> {
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);
},
);
}
}

@ -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<Widget> {
List<Widget> 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;
});
}
}
Loading…
Cancel
Save