From 1ee9719ee19bae87626e1b622e59db667df64b5b Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Wed, 7 Apr 2021 14:54:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=20=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E4=B8=AD=E5=BF=83=EF=BC=9A=E6=A0=B9=E6=8D=AE=E6=8A=A5=E4=BA=8B?= =?UTF-8?q?=E6=8A=A5=E4=BF=AE=E4=B8=BB=E9=94=AEid=20=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=8A=A5=E4=BA=8B=E6=8A=A5=E4=BF=AE=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E4=BF=A1=E6=81=AF=EF=BC=88=E5=90=8C=E6=AD=A5=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/const/api.dart | 3 +- .../message/system_message_detail_model.dart | 24 ++ lib/ui/home/messages/comment_message.dart | 1 + .../home/messages/comment_message_card.dart | 18 +- lib/ui/home/messages/system_message.dart | 139 -------- lib/ui/home/messages/systen_message_card.dart | 319 ++++++++++++++++++ 6 files changed, 357 insertions(+), 147 deletions(-) create mode 100644 lib/models/message/system_message_detail_model.dart create mode 100644 lib/ui/home/messages/systen_message_card.dart diff --git a/lib/const/api.dart b/lib/const/api.dart index dd84d52..a443b43 100644 --- a/lib/const/api.dart +++ b/lib/const/api.dart @@ -224,5 +224,6 @@ class _Message { ///消息中心:根据工单主键id同步查询报事报修评论(同步) String get getCommentByDispatchId => '/user/message/findCommentByDispatchId'; - + ///消息中心:根据报事报修主键id 同步查询报事报修消息信息(同步) + String get getSystemByDispatchId => '/user/message/findRepairByRepairId'; } diff --git a/lib/models/message/system_message_detail_model.dart b/lib/models/message/system_message_detail_model.dart new file mode 100644 index 0000000..ebab18b --- /dev/null +++ b/lib/models/message/system_message_detail_model.dart @@ -0,0 +1,24 @@ +class SystemMessageDetailModel { + int id; + String name; + String tel; + int type; + + SystemMessageDetailModel({this.id, this.name, this.tel, this.type}); + + SystemMessageDetailModel.fromJson(Map json) { + id = json['id']; + name = json['name']; + tel = json['tel']; + type = json['type']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['name'] = this.name; + data['tel'] = this.tel; + data['type'] = this.type; + return data; + } +} \ No newline at end of file diff --git a/lib/ui/home/messages/comment_message.dart b/lib/ui/home/messages/comment_message.dart index 9994b0c..821a295 100644 --- a/lib/ui/home/messages/comment_message.dart +++ b/lib/ui/home/messages/comment_message.dart @@ -38,6 +38,7 @@ class _CommentMessageState extends State { .toList(), builder: (items) { return ListView.separated( + padding: EdgeInsets.symmetric(horizontal: 32.w), itemBuilder: (context, index) { return CommentMessageCard(itemModel: items[index]); }, diff --git a/lib/ui/home/messages/comment_message_card.dart b/lib/ui/home/messages/comment_message_card.dart index 9409e5f..665a603 100644 --- a/lib/ui/home/messages/comment_message_card.dart +++ b/lib/ui/home/messages/comment_message_card.dart @@ -201,7 +201,6 @@ class _CommentMessageCardState extends State { : Column( children: [ Container( - margin: EdgeInsets.only(top: 24.w, bottom: 24.w), alignment: Alignment.center, width: double.infinity, child: Text( @@ -211,11 +210,11 @@ class _CommentMessageCardState extends State { ), ), Container( - padding: EdgeInsets.only(top: 24.w, left: 24.w, right: 24.w), color: Color(0xFFFFFFFF), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ + 24.w.heightBox, Row(children: [ Container( width: 16.w, @@ -235,14 +234,14 @@ class _CommentMessageCardState extends State { fontWeight: FontWeight.w600), ), SizedBox(height: 8.w), - ]), + ]).pSymmetric(h: 24.w), Text( '你有一条新的评论消息,请立即查看', style: TextStyle( color: AppStyle.primaryTextColor, fontSize: 28.sp, fontWeight: FontWeight.bold), - ), + ).pSymmetric(h: 24.w), SizedBox(height: 24.w), Row( children: [ @@ -267,7 +266,7 @@ class _CommentMessageCardState extends State { fontSize: 28.sp), ), ], - ), + ).pSymmetric(h: 24.w), SizedBox(height: 16.w), Row( children: [ @@ -289,9 +288,13 @@ class _CommentMessageCardState extends State { color: AppStyle.primaryTextColor, fontSize: 28.sp)), ], - ), + ).pSymmetric(h: 24.w), SizedBox(height: 16.w), - Divider(height: 1.w), + Divider( + height: 1.w, + indent: 24.w, + endIndent: 24.w, + ), AkuButton( onPressed: () {}, child: Container( @@ -308,6 +311,7 @@ class _CommentMessageCardState extends State { ), Spacer(), Icon(Icons.arrow_forward_ios, size: 22.w), + 24.w.widthBox, ], ), ), diff --git a/lib/ui/home/messages/system_message.dart b/lib/ui/home/messages/system_message.dart index d97ecbc..4ac2d48 100644 --- a/lib/ui/home/messages/system_message.dart +++ b/lib/ui/home/messages/system_message.dart @@ -25,145 +25,6 @@ class SystemMessage extends StatefulWidget { class _SystemMessageState extends State { EasyRefreshController _refreshController = EasyRefreshController(); - Widget _messageList(String date, String name, String phone, String area) { - return Column( - children: [ - Container( - margin: EdgeInsets.only(top: 24.w, bottom: 24.w), - alignment: Alignment.center, - width: double.infinity, - child: Text( - 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: [ - 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( - name, - 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(phone, - 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: () {}, - 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), - ], - ), - ), - ), - ], - ), - ), - AkuBox.h(16), - ], - ); - } @override Widget build(BuildContext context) { diff --git a/lib/ui/home/messages/systen_message_card.dart b/lib/ui/home/messages/systen_message_card.dart new file mode 100644 index 0000000..af97648 --- /dev/null +++ b/lib/ui/home/messages/systen_message_card.dart @@ -0,0 +1,319 @@ +import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/models/message/system_message_detail_model.dart'; +import 'package:aku_community_manager/style/app_style.dart'; +import 'package:aku_community_manager/utils/network/base_model.dart'; +import 'package:aku_community_manager/utils/network/net_util.dart'; +import 'package:aku_ui/aku_ui.dart'; +import 'package:flutter/material.dart'; +import 'package:velocity_x/velocity_x.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:shimmer/shimmer.dart'; + +class SystemMessageCard extends StatefulWidget { + final int repairId; + SystemMessageCard({Key key, this.repairId}) : super(key: key); + + @override + _SystemMessageCardState createState() => _SystemMessageCardState(); +} + +class _SystemMessageCardState extends State { + SystemMessageDetailModel _systemModel; + bool _onLoad = true; + @override + void initState() { + super.initState(); + Future.delayed(Duration(milliseconds: 300), () async { + _systemModel = await getSystemMessage(widget.repairId); + _onLoad = false; + }); + } + + @override + Widget build(BuildContext context) { + return _messageList(_systemModel); + } + + Future getSystemMessage(int repairId) async { + BaseModel baseModel = + await NetUtil().get(API.message.getSystemByDispatchId, params: { + "repairId": repairId, + }); + return SystemMessageDetailModel.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(SystemMessageDetailModel model) { + return _onLoad + ? _loadingWidget() + : Column( + children: [ + Container( + margin: EdgeInsets.only(top: 24.w, bottom: 24.w), + alignment: Alignment.center, + width: double.infinity, + child: Text( + '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: [ + 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( + model.name, + 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.tel, + 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: () {}, + 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), + ], + ), + ), + ), + ], + ), + ), + 16.w.heightBox, + ], + ); + } +}