From d956cfa3b62421bfbcb2c8618e2694860891ed81 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Tue, 9 Feb 2021 10:44:57 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=88=91=E7=9A=84=E5=80=9F=E8=BF=98?= =?UTF-8?q?=E7=89=A9=E5=93=81action=E4=BD=8D=E7=BD=AE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goods_manage_page/goods_manage_page.dart | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/pages/goods_manage_page/goods_manage_page.dart b/lib/pages/goods_manage_page/goods_manage_page.dart index 085f7cb0..07c6f8c0 100644 --- a/lib/pages/goods_manage_page/goods_manage_page.dart +++ b/lib/pages/goods_manage_page/goods_manage_page.dart @@ -88,16 +88,14 @@ class _GoodsManagePageState extends State { return BeeScaffold( title: '借还管理', actions: [ - InkWell( - onTap: () { - MineGoodsPage().to(); - }, - child: Container( - padding: EdgeInsets.fromLTRB(32.w, 28.w, 32.w, 20.w), - alignment: Alignment.center, - child: '我的借还物品'.text.black.size(28.sp).make())) + MaterialButton( + onPressed: () { + MineGoodsPage().to(); + }, + child: '我的借还物品'.text.black.size(28.sp).make(), + padding: EdgeInsets.symmetric(horizontal: 32.w), + ), ], - body: BeeListView( path: API.manager.articleBorrow, controller: _easyRefreshController, From 186a448710b4187d3cccdd0b758e389eb07a2047 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Tue, 9 Feb 2021 14:18:03 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E4=B8=AD=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/model/message/message_center_model.dart | 0 .../community_views/community_page.dart | 3 +- lib/ui/message/message_center.dart | 88 +++++++++++++++++++ pubspec.lock | 7 ++ pubspec.yaml | 1 + 5 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 lib/model/message/message_center_model.dart create mode 100644 lib/ui/message/message_center.dart diff --git a/lib/model/message/message_center_model.dart b/lib/model/message/message_center_model.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/ui/community/community_views/community_page.dart b/lib/ui/community/community_views/community_page.dart index 502b81d8..33437b04 100644 --- a/lib/ui/community/community_views/community_page.dart +++ b/lib/ui/community/community_views/community_page.dart @@ -1,4 +1,5 @@ // Flutter imports: +import 'package:akuCommunity/ui/message/message_center.dart'; import 'package:flutter/material.dart'; // Package imports: @@ -46,7 +47,7 @@ class _CommunityPageState extends State title: '社区', actions: [ ColumnActionButton( - onPressed: () {}, + onPressed: MessageCenter().to, title: '消息', path: R.ASSETS_ICONS_ALARM_PNG, ), diff --git a/lib/ui/message/message_center.dart b/lib/ui/message/message_center.dart new file mode 100644 index 00000000..d57dc31e --- /dev/null +++ b/lib/ui/message/message_center.dart @@ -0,0 +1,88 @@ +import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/widget/bee_scaffold.dart'; +import 'package:badges/badges.dart'; +import 'package:common_utils/common_utils.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class MessageCenter extends StatefulWidget { + MessageCenter({Key key}) : super(key: key); + + @override + _MessageCenterState createState() => _MessageCenterState(); +} + +class _MessageCenterState extends State { + Widget _buildMessageTile({ + String title, + String content, + int count, + String path, + }) { + bool empty = count == null || count == 0; + return Row( + children: [ + Badge( + elevation: 0, + position: BadgePosition(top: 8.w, end: 8.w), + showBadge: !empty, + child: Image.asset( + path, + height: 90.w, + width: 90.w, + ), + ), + 12.wb, + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + title.text.size(32.sp).bold.make(), + 4.hb, + (TextUtil.isEmpty(content) ? '没有新通知' : content) + .text + .size(28.sp) + .make(), + ], + ).expand(), + ], + ).pSymmetric(h: 32.w, v: 18.w); + } + + _getMessageCenter()async{ + + } + + @override + Widget build(BuildContext context) { + return BeeScaffold( + title: '消息中心', + actions: [ + MaterialButton( + onPressed: () {}, + child: '全部已读'.text.size(28.sp).make(), + ), + ], + body: EasyRefresh( + header: MaterialHeader(), + onRefresh: () async {}, + child: ListView( + children: [ + _buildMessageTile( + title: '系统通知', + path: R.ASSETS_ICONS_SYSTEM_NOTICE_PNG, + content: '', + count: 4, + ), + _buildMessageTile( + title: '评论通知', + path: R.ASSETS_ICONS_COMMENT_NOTICE_PNG, + content: '', + count: 0, + ), + ].sepWidget(separate: Divider(indent: 32.w, endIndent: 32.w)), + ), + ).material(color: Colors.white), + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index 96f00fd6..8232c46c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -85,6 +85,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.1.0" + badges: + dependency: "direct main" + description: + name: badges + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.1.6" boolean_selector: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 297040a1..785d3320 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -96,6 +96,7 @@ dependencies: url: http://192.168.2.201:8099/aku_fe/power_logger.git flutter_rating_bar: ^3.2.0+1 jpush_flutter: ^0.6.3 + badges: ^1.1.6 dev_dependencies: flutter_test: From 379db683d25289a57281e7586e3b96ab752c1e01 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Tue, 9 Feb 2021 17:19:54 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/api.dart | 5 ++ lib/model/message/message_center_model.dart | 23 +++++++++ lib/ui/message/message_center.dart | 53 +++++++++++++-------- 3 files changed, 62 insertions(+), 19 deletions(-) diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 4d487fea..5e545454 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -16,6 +16,7 @@ class API { static _Manager manager = _Manager(); static _Upload upload = _Upload(); static _Community community = _Community(); + static _Message message = _Message(); } class _Login { @@ -225,3 +226,7 @@ class _Upload { String get uploadEvent => '/user/upload/uploadGambit'; } + +class _Message { + String get center => '/user/message/messageCenter'; +} diff --git a/lib/model/message/message_center_model.dart b/lib/model/message/message_center_model.dart index e69de29b..b9d9e610 100644 --- a/lib/model/message/message_center_model.dart +++ b/lib/model/message/message_center_model.dart @@ -0,0 +1,23 @@ +class MessageCenterModel { + int sysCount; + String sysTitle; + + MessageCenterModel.zero() { + sysCount = 0; + sysTitle = ''; + } + + MessageCenterModel({this.sysCount, this.sysTitle}); + + MessageCenterModel.fromJson(Map json) { + sysCount = json['sysCount']; + sysTitle = json['sysTitle']; + } + + Map toJson() { + final Map data = new Map(); + data['sysCount'] = this.sysCount; + data['sysTitle'] = this.sysTitle; + return data; + } +} diff --git a/lib/ui/message/message_center.dart b/lib/ui/message/message_center.dart index d57dc31e..6d45c388 100644 --- a/lib/ui/message/message_center.dart +++ b/lib/ui/message/message_center.dart @@ -1,8 +1,14 @@ +import 'package:akuCommunity/constants/api.dart'; +import 'package:akuCommunity/model/message/message_center_model.dart'; import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/utils/network/base_model.dart'; +import 'package:akuCommunity/utils/network/net_util.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:badges/badges.dart'; import 'package:common_utils/common_utils.dart'; +import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:velocity_x/velocity_x.dart'; @@ -14,6 +20,8 @@ class MessageCenter extends StatefulWidget { } class _MessageCenterState extends State { + MessageCenterModel _model; + Widget _buildMessageTile({ String title, String content, @@ -49,8 +57,9 @@ class _MessageCenterState extends State { ).pSymmetric(h: 32.w, v: 18.w); } - _getMessageCenter()async{ - + Future _getMessageCenter() async { + Response response = await NetUtil().dio.get(API.message.center); + return MessageCenterModel.fromJson(response.data); } @override @@ -65,23 +74,29 @@ class _MessageCenterState extends State { ], body: EasyRefresh( header: MaterialHeader(), - onRefresh: () async {}, - child: ListView( - children: [ - _buildMessageTile( - title: '系统通知', - path: R.ASSETS_ICONS_SYSTEM_NOTICE_PNG, - content: '', - count: 4, - ), - _buildMessageTile( - title: '评论通知', - path: R.ASSETS_ICONS_COMMENT_NOTICE_PNG, - content: '', - count: 0, - ), - ].sepWidget(separate: Divider(indent: 32.w, endIndent: 32.w)), - ), + firstRefresh: true, + onRefresh: () async { + _model = await _getMessageCenter(); + setState(() {}); + }, + child: _model == null + ? SizedBox() + : ListView( + children: [ + _buildMessageTile( + title: '系统通知', + path: R.ASSETS_ICONS_SYSTEM_NOTICE_PNG, + content: _model.sysTitle, + count: _model.sysCount, + ), + // _buildMessageTile( + // title: '评论通知', + // path: R.ASSETS_ICONS_COMMENT_NOTICE_PNG, + // content: '', + // count: 0, + // ), + ].sepWidget(separate: Divider(indent: 32.w, endIndent: 32.w)), + ), ).material(color: Colors.white), ); }