对接接口:查询所有的系统通知

消息中心页面重写
hmxc
张萌 4 years ago
parent 47500111f0
commit f2f25f54f5

@ -230,4 +230,7 @@ class _Upload {
class _Message {
///
String get center => '/user/message/messageCenter';
///
String get sysMessageList => '/user/message/sysMessageList';
}

@ -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<String, dynamic> json) {
id = json['id'];
content = json['content'];
status = json['status'];
title = json['title'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['content'] = this.content;
data['status'] = this.status;
data['title'] = this.title;
return data;
}
}

@ -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<HomePage>
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)),
),
)
]),
],
),

@ -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<MessageCenterPage> {
List<Map<String, dynamic>> _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(),
),
],
),
],
),
),
)),
),
),
);
}
}

@ -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<MessageCenterPage> {
EasyRefreshController _refreshController;
@override
void initState() {
super.initState();
_refreshController = EasyRefreshController();
}
@override
void dispose() {
_refreshController?.dispose();
super.dispose();
}
Map<int, bool> 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);
}),
);
}
}

@ -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 {

Loading…
Cancel
Save