From f2f25f54f57f881640884664d0a8c9add35ff2e1 Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Fri, 19 Feb 2021 14:45:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E6=8E=A5=E5=8F=A3=EF=BC=9A?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=89=80=E6=9C=89=E7=9A=84=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=20=E6=B6=88=E6=81=AF=E4=B8=AD=E5=BF=83?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E9=87=8D=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/api.dart | 3 + lib/model/message/system_message_model.dart | 24 ++++ lib/pages/home/home_page.dart | 25 ++-- .../message_center_page.dart | 135 ------------------ .../message_center_page.dart | 113 +++++++++++++++ lib/widget/app_bar_action.dart | 2 +- 6 files changed, 154 insertions(+), 148 deletions(-) create mode 100644 lib/model/message/system_message_model.dart delete mode 100644 lib/pages/message_center_page/message_center_page.dart create mode 100644 lib/pages/message_center_page/system_message_page/message_center_page.dart diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 10fcbc7e..cd9cf479 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -230,4 +230,7 @@ class _Upload { class _Message { ///消息中心:消息中心 获取系统通知未读数量和标题 String get center => '/user/message/messageCenter'; + + ///消息中心:查询所有的系统通知 + String get sysMessageList => '/user/message/sysMessageList'; } diff --git a/lib/model/message/system_message_model.dart b/lib/model/message/system_message_model.dart new file mode 100644 index 00000000..d13123d3 --- /dev/null +++ b/lib/model/message/system_message_model.dart @@ -0,0 +1,24 @@ +class SystemMessageModel { + int id; + String content; + int status; + String title; + + SystemMessageModel({this.id, this.content, this.status, this.title}); + + SystemMessageModel.fromJson(Map json) { + id = json['id']; + content = json['content']; + status = json['status']; + title = json['title']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['content'] = this.content; + data['status'] = this.status; + data['title'] = this.title; + return data; + } +} diff --git a/lib/pages/home/home_page.dart b/lib/pages/home/home_page.dart index 829caccf..1948fca9 100644 --- a/lib/pages/home/home_page.dart +++ b/lib/pages/home/home_page.dart @@ -1,6 +1,7 @@ // Dart imports: // Flutter imports: +import 'package:akuCommunity/pages/message_center_page/system_message_page/message_center_page.dart'; import 'package:akuCommunity/provider/app_provider.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -18,7 +19,6 @@ import 'package:akuCommunity/model/aku_shop_model.dart'; import 'package:akuCommunity/model/community/activity_item_model.dart'; import 'package:akuCommunity/model/community/board_model.dart'; import 'package:akuCommunity/pages/home/widget/animate_app_bar.dart'; -import 'package:akuCommunity/pages/message_center_page/message_center_page.dart'; import 'package:akuCommunity/ui/community/activity/activity_card.dart'; import 'package:akuCommunity/ui/community/activity/activity_list_page.dart'; import 'package:akuCommunity/ui/community/community_func.dart'; @@ -78,17 +78,18 @@ class _HomePageState extends State path: R.ASSETS_ICONS_ALARM_PNG, ), Positioned( - top: 0, - right: 0, - child: appProvider.messageCenterModel.sysCount == 0 - ? SizedBox() - : Container( - width: 2.w, - height: 2.w, - decoration: BoxDecoration( - color: Colors.red, - borderRadius: BorderRadius.circular(1.w)), - )) + top: 0, + right: 0, + child: appProvider.messageCenterModel.sysCount == 0 + ? SizedBox() + : Container( + width: 2.w, + height: 2.w, + decoration: BoxDecoration( + color: Colors.red, + borderRadius: BorderRadius.circular(1.w)), + ), + ) ]), ], ), diff --git a/lib/pages/message_center_page/message_center_page.dart b/lib/pages/message_center_page/message_center_page.dart deleted file mode 100644 index d29a6b20..00000000 --- a/lib/pages/message_center_page/message_center_page.dart +++ /dev/null @@ -1,135 +0,0 @@ -// Flutter imports: -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -// Package imports: -import 'package:velocity_x/velocity_x.dart'; - -// Project imports: -import 'package:akuCommunity/base/assets_image.dart'; -import 'package:akuCommunity/pages/message_center_page/comment_message_page/comment_message_page.dart'; -import 'package:akuCommunity/pages/message_center_page/shop_message_page/shop_message_page.dart'; -import 'package:akuCommunity/pages/message_center_page/system_message_page/system_message_page.dart'; -import 'package:akuCommunity/utils/headers.dart'; -import 'package:akuCommunity/widget/bee_scaffold.dart'; - -class MessageCenterPage extends StatefulWidget { - MessageCenterPage({Key key}) : super(key: key); - - @override - _MessageCenterPageState createState() => _MessageCenterPageState(); -} - -class _MessageCenterPageState extends State { - List> _messageList = [ - { - 'title': '系统通知', - 'imagePath': AssetsImage.SYSTEMNOTICE, - 'subtitle': '业主信息审核:未通过' - }, - { - 'title': '评论通知', - 'imagePath': AssetsImage.COMMENTNOTICE, - 'subtitle': '周玲慧评论了你的动态' - }, - { - 'title': '商城通知', - 'imagePath': AssetsImage.SHOPNOTICE, - 'subtitle': '您的宝贝已经发货' - } - ]; - - TextStyle _textStyleTitle() { - return TextStyle( - fontWeight: FontWeight.w600, - fontSize: 32.sp, - color: Color(0xff333333), - ); - } - - TextStyle _textStyleSubtitle() { - return TextStyle( - fontSize: 28.sp, - color: Color(0xff333333), - ); - } - - @override - Widget build(BuildContext context) { - return BeeScaffold( - title: '消息中心', - actions: [ - InkWell( - onTap: () {}, - child: Container( - padding: EdgeInsets.fromLTRB(32.w, 28.w, 32.w, 20.w), - child: '全部已读'.text.black.size(28.sp).make(), - alignment: Alignment.center, - ), - ) - ], - body: Container( - color: Colors.white, - child: ListView( - children: List.generate( - _messageList.length, - (index) => InkWell( - onTap: () { - switch (_messageList[index]['title']) { - case '系统通知': - SystemMessagePage().to; - break; - case '评论通知': - CommentMessagePage().to; - break; - case '商城通知': - ShopMessagePage().to; - break; - default: - } - }, - child: Container( - padding: EdgeInsets.only( - top: 36.w, - bottom: 19.w, - ), - margin: EdgeInsets.symmetric(horizontal: 32.w), - decoration: BoxDecoration( - border: Border( - bottom: Divider.createBorderSide(context, - color: Color(0xffd8d8d8), width: 0.5), - ), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Image.asset( - _messageList[index]['imagePath'], - height: 90.w, - width: 90.w, - ), - SizedBox(width: 14.w), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - _messageList[index]['title'], - style: _textStyleTitle(), - ), - SizedBox(height: 5.w), - Text( - _messageList[index]['subtitle'], - maxLines: 1, - style: _textStyleSubtitle(), - ), - ], - ), - ], - ), - ), - )), - ), - ), - ); - } -} diff --git a/lib/pages/message_center_page/system_message_page/message_center_page.dart b/lib/pages/message_center_page/system_message_page/message_center_page.dart new file mode 100644 index 00000000..67ede6df --- /dev/null +++ b/lib/pages/message_center_page/system_message_page/message_center_page.dart @@ -0,0 +1,113 @@ +import 'package:akuCommunity/constants/api.dart'; +import 'package:akuCommunity/model/message/system_message_model.dart'; +import 'package:akuCommunity/pages/things_page/widget/bee_list_view.dart'; +import 'package:akuCommunity/widget/bee_divider.dart'; +import 'package:akuCommunity/widget/bee_scaffold.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:akuCommunity/utils/headers.dart'; + +class MessageCenterPage extends StatefulWidget { + MessageCenterPage({Key key}) : super(key: key); + + @override + _MessageCenterPageState createState() => _MessageCenterPageState(); +} + +class _MessageCenterPageState extends State { + EasyRefreshController _refreshController; + @override + void initState() { + super.initState(); + _refreshController = EasyRefreshController(); + } + + @override + void dispose() { + _refreshController?.dispose(); + super.dispose(); + } + + Map isRead = { + 1: false, + 3: true, + }; + Widget _buildCard({ + String path, + String title, + SystemMessageModel model, + }) { + return InkWell( + onTap: () {}, + child: Container( + padding: EdgeInsets.fromLTRB(28.w, 32.w, 28.w, 20.w), + child: Row( + children: [ + SizedBox( + width: 90.w, + height: 90.w, + child: Stack( + children: [ + Image.asset(path), + Positioned( + top: 0, + right: 0, + child: isRead[model.status] + ? SizedBox() + : Container( + width: 2.w, + height: 2.w, + decoration: BoxDecoration( + color: Colors.red, + borderRadius: BorderRadius.circular(1.w)), + ), + ) + ], + )), + 15.w.widthBox, + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + title.text.black.bold.size(32.sp).make(), + 5.w.heightBox, + model.content.text.black.size(28.sp).make(), + ], + ).expand() + ], + ), + ), + ).material(color: Colors.transparent); + } + + @override + Widget build(BuildContext context) { + return BeeScaffold( + title: '消息中心', + body: BeeListView( + path: API.message.sysMessageList, + controller: _refreshController, + convert: (models) { + return models.tableList + .map((e) => SystemMessageModel.fromJson(e)) + .toList(); + }, + builder: (items) { + return ListView.separated( + itemBuilder: (context, index) { + return _buildCard( + path: R.ASSETS_ICONS_SYSTEM_NOTICE_PNG, + title: '系统通知', + model: items[index], + ); + }, + separatorBuilder: (_, __) { + return BeeDivider.horizontal( + indent: 28.w, + endIndent: 28.w, + ); + }, + itemCount: items.length); + }), + ); + } +} diff --git a/lib/widget/app_bar_action.dart b/lib/widget/app_bar_action.dart index 9f837184..ea8197c7 100644 --- a/lib/widget/app_bar_action.dart +++ b/lib/widget/app_bar_action.dart @@ -1,11 +1,11 @@ // Flutter imports: +import 'package:akuCommunity/pages/message_center_page/system_message_page/message_center_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; // Project imports: import 'package:akuCommunity/pages/market/market_cart_page/market_cart_page.dart'; import 'package:akuCommunity/pages/market_class/market_class_page.dart'; -import 'package:akuCommunity/pages/message_center_page/message_center_page.dart'; import 'package:akuCommunity/utils/headers.dart'; class AppBarAction extends StatefulWidget {