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