重构消息中心,

重写系统通知页面
hmxc
张萌 4 years ago
parent 32d9d1b0b3
commit 39260008a0

@ -1,7 +1,7 @@
// Dart imports: // Dart imports:
// Flutter imports: // Flutter imports:
import 'package:akuCommunity/pages/message_center_page/system_message_page/message_center_page.dart'; import 'package:akuCommunity/pages/message_center_page/message_center_page.dart';
import 'package:akuCommunity/provider/app_provider.dart'; import 'package:akuCommunity/provider/app_provider.dart';
import 'package:badges/badges.dart'; import 'package:badges/badges.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';

@ -0,0 +1,91 @@
import 'package:akuCommunity/pages/message_center_page/system_message/system_message_page.dart';
import 'package:akuCommunity/provider/app_provider.dart';
import 'package:akuCommunity/widget/bee_scaffold.dart';
import 'package:akuCommunity/widget/buttons/column_action_button.dart';
import 'package:badges/badges.dart';
import 'package:flutter/material.dart';
import 'package:akuCommunity/utils/headers.dart';
import 'package:provider/provider.dart';
class MessageCenterPage extends StatefulWidget {
MessageCenterPage({Key key}) : super(key: key);
@override
_MessageCenterPageState createState() => _MessageCenterPageState();
}
class _MessageCenterPageState extends State<MessageCenterPage> {
Widget _buildCard({
String path,
String title,
String content,
int count,
VoidCallback onTap,
}) {
return InkWell(
onTap: 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: Badge(
child: Image.asset(path),
showBadge: count != 0,
elevation: 0,
position: BadgePosition.topEnd(top: 8.w, end: 8.w),
)),
15.w.widthBox,
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
title.text.black.bold.size(32.sp).make(),
5.w.heightBox,
content.text.black.size(28.sp).make(),
],
).expand()
],
),
),
).material(color: Colors.transparent);
}
@override
Widget build(BuildContext context) {
AppProvider appProvider = Provider.of<AppProvider>(context);
return BeeScaffold(
title: '消息中心',
actions: [
MaterialButton(
onPressed: () {},
child: '全部已读'.text.size(28.sp).black.make(),
padding: EdgeInsets.symmetric(horizontal: 32.w),
),
],
body: Column(
children: [
_buildCard(
path: R.ASSETS_ICONS_SYSTEM_NOTICE_PNG,
title: '系统通知',
content: appProvider.messageCenterModel.sysTitle,
count: appProvider.messageCenterModel.sysCount,
onTap: SystemMessagePage().to,
),
// _buildCard(
// path: R.ASSETS_ICONS_COMMENT_NOTICE_PNG,
// title: '评论通知',
// content: '',
// count: 0,
// ),
// _buildCard(
// path: R.ASSETS_ICONS_SHOP_NOTICE_PNG,
// title: '商城通知',
// content: '',
// count: 0,
// )
],
));
}
}

@ -0,0 +1,117 @@
import 'package:akuCommunity/base/base_style.dart';
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/utils/bee_map.dart';
import 'package:akuCommunity/widget/bee_divider.dart';
import 'package:akuCommunity/widget/bee_scaffold.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:akuCommunity/utils/headers.dart';
class SystemMessagePage extends StatefulWidget {
SystemMessagePage({Key key}) : super(key: key);
@override
_SystemMessagePageState createState() => _SystemMessagePageState();
}
class _SystemMessagePageState extends State<SystemMessagePage> {
EasyRefreshController _refreshController;
@override
void initState() {
super.initState();
_refreshController = EasyRefreshController();
}
@override
void dispose() {
_refreshController?.dispose();
super.dispose();
}
Widget _buildCard(SystemMessageModel model) {
return InkWell(
onTap: () {},
child: Container(
decoration: BoxDecoration(
color: kForeGroundColor,
borderRadius: BorderRadius.circular(4.w),
),
width: double.infinity,
padding: EdgeInsets.fromLTRB(30.w, 20.w, 20.w, 14.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
'系统通知'.text.black.bold.size(32.sp).make(),
Spacer(),
BeeMap.messageRead[model.status].text
.color(BeeMap.messageIsRead[model.status]
? Color(0xFF999999)
: Colors.red)
.size(32.sp)
.make()
],
),
5.w.heightBox,
model.title.text.black
.size(28.sp)
.maxLines(1)
.isIntrinsic
.ellipsis
.make(),
5.w.heightBox,
model.content.text.black
.size(28.sp)
.maxLines(1)
.overflow(TextOverflow.ellipsis)
.isIntrinsic
.make(),
30.w.heightBox,
BeeDivider.horizontal(),
14.w.heightBox,
Row(
children: [
'查看详情'.text.black.size(28.sp).make(),
Spacer(),
Icon(
CupertinoIcons.chevron_forward,
size: 28.w,
),
],
),
],
),
),
).material();
}
@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(
padding: EdgeInsets.all(32.w),
itemBuilder: (context, index) {
return _buildCard(items[index]);
},
separatorBuilder: (_, __) {
return 32.w.heightBox;
},
itemCount: items.length);
}),
);
}
}

@ -1,106 +0,0 @@
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/utils/network/net_util.dart';
import 'package:akuCommunity/widget/bee_divider.dart';
import 'package:akuCommunity/widget/bee_scaffold.dart';
import 'package:badges/badges.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: () async {
await NetUtil().dio.get(API.message.readMessage);
},
child: Container(
padding: EdgeInsets.fromLTRB(28.w, 32.w, 28.w, 20.w),
child: Row(
children: [
SizedBox(
width: 90.w,
height: 90.w,
child: Badge(
child: Image.asset(path),
showBadge: !isRead[model.status],
elevation: 0,
position: BadgePosition.topEnd(top: 8.w, end: 8.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,63 +0,0 @@
// Flutter imports:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
// Project imports:
import 'package:akuCommunity/routers/page_routers.dart';
import 'package:akuCommunity/utils/headers.dart';
import 'package:akuCommunity/widget/bee_scaffold.dart';
class SystemDetailsPage extends StatelessWidget {
final Bundle bundle;
SystemDetailsPage({Key key, this.bundle}) : super(key: key);
@override
Widget build(BuildContext context) {
return BeeScaffold(
title: '查看详情',
body: Container(
color: Colors.white,
child: ListView(
children: [
Container(
padding: EdgeInsets.only(
top: 42.w,
left: 34.w,
right: 44.w,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'系统通知',
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 32.sp,
color: Color(0xff333333),
),
),
SizedBox(height: 5.w),
Text(
bundle.getMap('detailsMap')['type'],
style: TextStyle(
fontSize: 28.sp,
color: Color(0xff333333),
),
),
SizedBox(height: 110.w),
Text(
bundle.getMap('detailsMap')['content'],
style: TextStyle(
fontSize: 28.sp,
color: Color(0xff333333),
),
),
],
),
),
],
),
),
);
}
}

@ -1,187 +0,0 @@
// Flutter imports:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
// Package imports:
import 'package:flutter_icons/flutter_icons.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:velocity_x/velocity_x.dart';
// Project imports:
import 'package:akuCommunity/pages/message_center_page/system_message_page/system_details_page/system_details_page.dart';
import 'package:akuCommunity/routers/page_routers.dart';
import 'package:akuCommunity/utils/headers.dart';
import 'package:akuCommunity/widget/bee_scaffold.dart';
class SystemMessagePage extends StatefulWidget {
SystemMessagePage({Key key}) : super(key: key);
@override
_SystemMessagePageState createState() => _SystemMessagePageState();
}
class _SystemMessagePageState extends State<SystemMessagePage> {
RefreshController _refreshController =
RefreshController(initialRefresh: false);
List<Map<String, dynamic>> _listNotice = [
{'status': '已读', 'type': '业主信息审核:未通过', 'content': '您的信息有错误,请您重新填写'},
{
'status': '已读',
'type': '物品出门:未通过',
'content': '当天装修人员有些多,是否考虑换一是否考虑换一是否考虑换一…'
},
{
'status': '已读',
'type': '报修申请:未通过',
'content': '您的地址填写的不够详细,装修员工装修员工装修员工…'
},
];
@override
void initState() {
super.initState();
}
void _onRefresh() async {
await Future.delayed(Duration(milliseconds: 1500));
_refreshController.refreshCompleted();
}
void _onLoading() async {
await Future.delayed(Duration(milliseconds: 1500));
if (mounted) setState(() {});
_refreshController.loadComplete();
}
@override
void dispose() {
super.dispose();
_refreshController.dispose();
}
InkWell _inkWellLook(String type, String content) {
return InkWell(
onTap: () {
SystemDetailsPage(
bundle: Bundle()
..putMap('detailsMap', {'type': type, 'content': content}),
).to;
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'查看详情',
style: TextStyle(fontSize: 28.sp, color: Color(0xff333333)),
),
Icon(AntDesign.right, size: 40.sp),
],
),
);
}
Container _containerCard(String status, String type, String content) {
return Container(
margin: EdgeInsets.only(
top: 32.w,
left: 32.w,
right: 32.w,
),
padding:
EdgeInsets.only(top: 21.w, bottom: 14.w, left: 30.w, right: 20.w),
decoration: BoxDecoration(
color: Color(0xffffffff),
borderRadius: BorderRadius.all(Radius.circular(4)),
boxShadow: <BoxShadow>[
BoxShadow(
color: Colors.grey.withOpacity(0.1),
offset: Offset(1, 1),
blurRadius: 10.0),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: EdgeInsets.only(left: 2.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'系统通知',
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 32.sp,
color: Color(0xff333333)),
),
Text(
status,
style:
TextStyle(fontSize: 32.sp, color: Color(0xff999999)),
),
],
),
SizedBox(height: 5.w),
Text(
type,
style: TextStyle(fontSize: 28.sp, color: Color(0xff333333)),
),
SizedBox(height: 8.w),
Text(
'驳回理由:$content',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 28.sp, color: Color(0xff333333)),
),
],
),
),
SizedBox(height: 30.w),
Divider(),
_inkWellLook(type, content),
],
),
);
}
@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: RefreshConfiguration(
hideFooterWhenNotFull: true,
child: SmartRefresher(
controller: _refreshController,
header: WaterDropHeader(),
footer: ClassicFooter(),
onRefresh: _onRefresh,
onLoading: _onLoading,
enablePullUp: true,
child: ListView.builder(
itemBuilder: (context, index) => _containerCard(
_listNotice[index]['status'],
_listNotice[index]['type'],
_listNotice[index]['content'],
),
itemCount: _listNotice.length,
),
),
),
);
}
}

@ -45,4 +45,14 @@ class BeeMap {
3: '已结束', 3: '已结束',
4: '已投票', 4: '已投票',
}; };
static Map<int, String> messageRead = {
1: '未读',
3: '已读',
};
static Map<int,bool> messageIsRead ={
1:false,
2:true,
};
} }

@ -1,5 +1,5 @@
// Flutter imports: // Flutter imports:
import 'package:akuCommunity/pages/message_center_page/system_message_page/message_center_page.dart'; import 'package:akuCommunity/pages/message_center_page/message_center_page.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';

Loading…
Cancel
Save