重构 system message list

hmxc
张萌 3 years ago
parent 32ffd97ee1
commit cedd52d0e2

@ -0,0 +1,79 @@
import 'package:equatable/equatable.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:aku_community_manager/models/common/img_model.dart';
part 'system_message_house_keeping_model.g.dart';
@JsonSerializable()
class SystemMessageHouseKeepingModel extends Equatable {
final int id;
final String proposerName;
final String proposerTel;
final String roomName;
final int type;
final String content;
final int status;
final int? completion;
final String? handlerName;
final String? handlerTel;
final String? processDescription;
final String? handlingTime;
final List<ImgModel> handlerImgList;
final num? payFee;
final int? evaluation;
final String? evaluationContent;
final String? evaluationTime;
final List<ImgModel> evaluationImgList;
final String createDate;
final List<ImgModel> submitImgList;
SystemMessageHouseKeepingModel({
required this.id,
required this.proposerName,
required this.proposerTel,
required this.roomName,
required this.type,
required this.content,
required this.status,
this.completion,
this.handlerName,
this.handlerTel,
this.processDescription,
this.handlingTime,
required this.handlerImgList,
this.payFee,
this.evaluation,
this.evaluationContent,
this.evaluationTime,
required this.evaluationImgList,
required this.createDate,
required this.submitImgList,
});
factory SystemMessageHouseKeepingModel.fromJson(Map<String, dynamic> json) =>
_$SystemMessageHouseKeepingModelFromJson(json);
@override
List<Object?> get props {
return [
id,
proposerName,
proposerTel,
roomName,
type,
content,
status,
completion,
handlerName,
handlerTel,
processDescription,
handlingTime,
handlerImgList,
payFee,
evaluation,
evaluationContent,
evaluationTime,
evaluationImgList,
createDate,
submitImgList,
];
}
}

@ -0,0 +1,39 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'system_message_house_keeping_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
SystemMessageHouseKeepingModel _$SystemMessageHouseKeepingModelFromJson(
Map<String, dynamic> json) {
return SystemMessageHouseKeepingModel(
id: json['id'] as int,
proposerName: json['proposerName'] as String,
proposerTel: json['proposerTel'] as String,
roomName: json['roomName'] as String,
type: json['type'] as int,
content: json['content'] as String,
status: json['status'] as int,
completion: json['completion'] as int?,
handlerName: json['handlerName'] as String?,
handlerTel: json['handlerTel'] as String?,
processDescription: json['processDescription'] as String?,
handlingTime: json['handlingTime'] as String?,
handlerImgList: (json['handlerImgList'] as List<dynamic>)
.map((e) => ImgModel.fromJson(e as Map<String, dynamic>))
.toList(),
payFee: json['payFee'] as num?,
evaluation: json['evaluation'] as int?,
evaluationContent: json['evaluationContent'] as String?,
evaluationTime: json['evaluationTime'] as String?,
evaluationImgList: (json['evaluationImgList'] as List<dynamic>)
.map((e) => ImgModel.fromJson(e as Map<String, dynamic>))
.toList(),
createDate: json['createDate'] as String,
submitImgList: (json['submitImgList'] as List<dynamic>)
.map((e) => ImgModel.fromJson(e as Map<String, dynamic>))
.toList(),
);
}

@ -28,6 +28,8 @@ class MessageProvider extends ChangeNotifier {
return '绿化任务'; return '绿化任务';
case 4: case 4:
return '卫生任务'; return '卫生任务';
case 5:
return '家政服务';
default: default:
return '未知'; return '未知';
} }

@ -18,7 +18,7 @@ import 'package:provider/provider.dart';
import 'package:aku_community_manager/const/resource.dart'; import 'package:aku_community_manager/const/resource.dart';
import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/style/app_style.dart';
import 'package:aku_community_manager/ui/home/messages/comment_message.dart'; import 'package:aku_community_manager/ui/home/messages/comment_message.dart';
import 'package:aku_community_manager/ui/home/messages/system_message.dart'; import 'package:aku_community_manager/ui/home/messages/system/system_message.dart';
import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart';
class Message extends StatefulWidget { class Message extends StatefulWidget {

@ -1,5 +1,5 @@
class MessageMap { class MessageMap {
static sysType(int type){ static sysType(int type) {
switch (type) { switch (type) {
case 1: case 1:
return '报事报修'; return '报事报修';
@ -9,6 +9,8 @@ class MessageMap {
return '绿化任务'; return '绿化任务';
case 4: case 4:
return '卫生任务'; return '卫生任务';
case 5:
return '家政服务';
default: default:
return '未知'; return '未知';
} }

@ -1,6 +1,6 @@
// Flutter imports: // Flutter imports:
import 'package:aku_community_manager/ui/home/messages/system_message_green_card.dart'; import 'package:aku_community_manager/ui/home/messages/system/system_message_green_card.dart';
import 'package:aku_community_manager/ui/home/messages/system_message_hygience_card.dart'; import 'package:aku_community_manager/ui/home/messages/system/system_message_hygience_card.dart';
import 'package:common_utils/common_utils.dart'; import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -13,7 +13,7 @@ import 'package:velocity_x/velocity_x.dart';
import 'package:aku_community_manager/const/api.dart'; import 'package:aku_community_manager/const/api.dart';
import 'package:aku_community_manager/models/message/system_message_item_model.dart'; import 'package:aku_community_manager/models/message/system_message_item_model.dart';
import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/style/app_style.dart';
import 'package:aku_community_manager/ui/home/messages/system_message_card.dart'; import 'package:aku_community_manager/ui/home/messages/system/system_message_card.dart';
import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.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:aku_community_manager/ui/widgets/common/bee_list_view.dart';
@ -76,6 +76,9 @@ class _SystemMessageState extends State<SystemMessage> {
case 4: case 4:
return SystemMessageHygienceCard( return SystemMessageHygienceCard(
relationId: model.relationId!, date: _date, type: 4); relationId: model.relationId!, date: _date, type: 4);
case 5:
return SystemMessageHygienceCard(
relationId: model.relationId!, date: _date, type: 5);
default: default:
return Container(); return Container();
} }

@ -0,0 +1,318 @@
import 'package:aku_community_manager/const/api.dart';
import 'package:aku_community_manager/json_models/message/system_message_house_keeping_model.dart';
import 'package:aku_community_manager/style/app_style.dart';
import 'package:aku_community_manager/ui/home/messages/message_map.dart';
import 'package:aku_community_manager/ui/manage_pages/house_keeping/house_keeping_page.dart';
import 'package:aku_community_manager/ui/widgets/common/aku_button.dart';
import 'package:aku_community_manager/utils/network/base_model.dart';
import 'package:aku_community_manager/utils/network/net_util.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:shimmer/shimmer.dart';
import 'package:velocity_x/velocity_x.dart';
class SystemMessageHouseKeepingCard extends StatefulWidget {
final int relationId;
final String? date;
final int type;
SystemMessageHouseKeepingCard(
{Key? key, required this.relationId, this.date, required this.type})
: super(key: key);
@override
_SystemMessageHouseKeepingCardState createState() =>
_SystemMessageHouseKeepingCardState();
}
class _SystemMessageHouseKeepingCardState
extends State<SystemMessageHouseKeepingCard> {
SystemMessageHouseKeepingModel? _systemModel;
bool _onLoad = true;
@override
void initState() {
super.initState();
Future.delayed(Duration(milliseconds: 300), () async {
_systemModel = await getSystemMessage(widget.relationId);
_onLoad = false;
setState(() {});
});
}
@override
Widget build(BuildContext context) {
return (_systemModel == null || _onLoad)
? _loadingWidget()
: _messageList(_systemModel!);
}
Future getSystemMessage(int relationId) async {
BaseModel baseModel =
await NetUtil().get(API.message.getSysHygienceMessageById, params: {
"housekeepingServiceId": relationId,
});
if (baseModel.status ?? false) {
return SystemMessageHouseKeepingModel.fromJson(baseModel.data);
}
}
Widget _loadingWidget() {
return Column(
children: [
Container(
margin: EdgeInsets.only(top: 24.w, bottom: 24.w),
alignment: Alignment.center,
width: double.infinity,
child: Shimmer.fromColors(
baseColor: kPrimaryColor.withOpacity(0.3),
highlightColor: kPrimaryColor.withOpacity(0.1),
child: Text(
'',
style: TextStyle(color: AppStyle.minorTextColor, fontSize: 24.sp),
),
),
),
Container(
padding: EdgeInsets.only(top: 24.w, left: 24.w, right: 24.w),
color: Color(0xFFFFFFFF),
child: Shimmer.fromColors(
baseColor: kPrimaryColor.withOpacity(0.3),
highlightColor: kPrimaryColor.withOpacity(0.1),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(children: [
Container(
width: 16.w,
height: 16.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.w),
color: Color(0xFFFF4501)),
),
SizedBox(
width: 16.w,
),
Text(
'',
style: TextStyle(
color: AppStyle.primaryTextColor,
fontSize: 32.sp,
fontWeight: FontWeight.w600),
),
SizedBox(height: 8.w),
]),
Text(
'',
style: TextStyle(
color: AppStyle.primaryTextColor,
fontSize: 28.sp,
fontWeight: FontWeight.bold),
),
SizedBox(height: 24.w),
Row(
children: [
Image.asset(
R.ASSETS_MESSAGE_IC_PEOPLE_PNG,
width: 40.w,
height: 40.w,
),
SizedBox(
width: 4.w,
),
Text(
'',
style: TextStyle(
color: AppStyle.minorTextColor, fontSize: 28.sp),
),
Spacer(),
Text(
'',
style: TextStyle(
color: AppStyle.primaryTextColor, fontSize: 28.sp),
),
],
),
SizedBox(height: 16.w),
Row(
children: [
Image.asset(
R.ASSETS_MESSAGE_IC_STAR_PNG,
width: 40.w,
height: 40.w,
),
SizedBox(
width: 4.w,
),
Text('',
style: TextStyle(
color: AppStyle.minorTextColor, fontSize: 28.sp)),
Spacer(),
Text('',
style: TextStyle(
color: AppStyle.primaryTextColor, fontSize: 28.sp)),
],
),
SizedBox(height: 16.w),
Divider(height: 1.w),
AkuButton(
onPressed: () {},
child: Container(
height: 88.w,
alignment: Alignment.center,
padding: EdgeInsets.only(left: 24.w),
child: Row(
children: [
Text(
'',
style: TextStyle(
color: AppStyle.primaryTextColor,
fontSize: 28.sp),
),
Spacer(),
Icon(Icons.arrow_forward_ios, size: 22.w),
],
),
),
),
],
),
),
),
],
);
}
Widget _messageList(SystemMessageHouseKeepingModel model) {
return Column(
children: [
widget.date == null ? 16.w.heightBox : SizedBox(),
widget.date == null
? SizedBox()
: Container(
margin: EdgeInsets.only(top: 24.w, bottom: 24.w),
alignment: Alignment.center,
width: double.infinity,
child: Text(
widget.date!,
style: TextStyle(
color: AppStyle.minorTextColor, fontSize: 24.sp),
),
),
Container(
padding: EdgeInsets.only(top: 24.w, left: 24.w, right: 24.w),
color: Color(0xFFFFFFFF),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(children: [
Text(
'系统通知',
style: TextStyle(
color: AppStyle.primaryTextColor,
fontSize: 32.sp,
fontWeight: FontWeight.w600),
),
SizedBox(height: 8.w),
]),
Text(
'你有一条新的${MessageMap.sysType(widget.type)},请立即处理',
style: TextStyle(
color: AppStyle.primaryTextColor,
fontSize: 28.sp,
fontWeight: FontWeight.bold),
),
SizedBox(height: 24.w),
Row(
children: [
Image.asset(
R.ASSETS_MESSAGE_IC_PEOPLE_PNG,
width: 40.w,
height: 40.w,
),
SizedBox(
width: 4.w,
),
Text(
'服务人员',
style: TextStyle(
color: AppStyle.minorTextColor, fontSize: 28.sp),
),
Spacer(),
Text(
model.handlerName ?? '',
style: TextStyle(
color: AppStyle.primaryTextColor, fontSize: 28.sp),
),
],
),
SizedBox(height: 16.w),
Row(
children: [
Image.asset(
R.ASSETS_MESSAGE_IC_PHONE_PNG,
width: 40.w,
height: 40.w,
),
SizedBox(
width: 4.w,
),
Text('联系电话',
style: TextStyle(
color: AppStyle.minorTextColor, fontSize: 28.sp)),
Spacer(),
Text(model.handlerTel ?? '',
style: TextStyle(
color: AppStyle.primaryTextColor, fontSize: 28.sp)),
],
),
SizedBox(height: 16.w),
// Row(
// children: [
// Image.asset(
// R.ASSETS_MESSAGE_IC_AREA_PNG,
// width: 40.w,
// height: 40.w,
// ),
// SizedBox(
// width: 4.w,
// ),
// Text('报修区域',
// style: TextStyle(
// color: AppStyle.minorTextColor, fontSize: 28.sp)),
// Spacer(),
// Text('area',
// style: TextStyle(
// color: AppStyle.primaryTextColor, fontSize: 28.sp)),
// ],
// ),
// SizedBox(height: 16.w),
Divider(
height: 1.w,
),
AkuButton(
onPressed: () {
Get.to(() => HouseKeepingPage());
},
child: Container(
height: 88.w,
alignment: Alignment.center,
child: Row(
children: [
Text(
'查看详情',
style: TextStyle(
color: AppStyle.primaryTextColor, fontSize: 28.sp),
),
Spacer(),
Icon(Icons.arrow_forward_ios, size: 22.w),
],
),
),
),
],
),
),
],
);
}
}

@ -214,16 +214,6 @@ class _SystemMessageHygienceCardState extends State<SystemMessageHygienceCard> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Row(children: [ Row(children: [
// Container(
// width: 16.w,
// height: 16.w,
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(8.w),
// color: Color(0xFFFF4501)),
// ),
// SizedBox(
// width: 16.w,
// ),
Text( Text(
'系统通知', '系统通知',
style: TextStyle( style: TextStyle(
Loading…
Cancel
Save