diff --git a/lib/pages/home/home_page.dart b/lib/pages/home/home_page.dart index 24ad4428..e7590d23 100644 --- a/lib/pages/home/home_page.dart +++ b/lib/pages/home/home_page.dart @@ -1,7 +1,7 @@ // Dart 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:badges/badges.dart'; import 'package:flutter/cupertino.dart'; diff --git a/lib/pages/message_center_page/message_center_page.dart b/lib/pages/message_center_page/message_center_page.dart new file mode 100644 index 00000000..3e211d40 --- /dev/null +++ b/lib/pages/message_center_page/message_center_page.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 { + 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(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, + // ) + ], + )); + } +} diff --git a/lib/pages/message_center_page/system_message/system_message_page.dart b/lib/pages/message_center_page/system_message/system_message_page.dart new file mode 100644 index 00000000..8608f2e4 --- /dev/null +++ b/lib/pages/message_center_page/system_message/system_message_page.dart @@ -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 { + 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); + }), + ); + } +} 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 deleted file mode 100644 index 91bd6c82..00000000 --- a/lib/pages/message_center_page/system_message_page/message_center_page.dart +++ /dev/null @@ -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 { - 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: () 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); - }), - ); - } -} diff --git a/lib/pages/message_center_page/system_message_page/system_details_page/system_details_page.dart b/lib/pages/message_center_page/system_message_page/system_details_page/system_details_page.dart deleted file mode 100644 index 3a67af50..00000000 --- a/lib/pages/message_center_page/system_message_page/system_details_page/system_details_page.dart +++ /dev/null @@ -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), - ), - ), - ], - ), - ), - ], - ), - ), - ); - } -} diff --git a/lib/pages/message_center_page/system_message_page/system_message_page.dart b/lib/pages/message_center_page/system_message_page/system_message_page.dart deleted file mode 100644 index 8635fa72..00000000 --- a/lib/pages/message_center_page/system_message_page/system_message_page.dart +++ /dev/null @@ -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 { - RefreshController _refreshController = - RefreshController(initialRefresh: false); - List> _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( - 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, - ), - ), - ), - ); - } -} diff --git a/lib/utils/bee_map.dart b/lib/utils/bee_map.dart index 15d8ec34..33b0f7e3 100644 --- a/lib/utils/bee_map.dart +++ b/lib/utils/bee_map.dart @@ -45,4 +45,14 @@ class BeeMap { 3: '已结束', 4: '已投票', }; + + static Map messageRead = { + 1: '未读', + 3: '已读', + }; + + static Map messageIsRead ={ + 1:false, + 2:true, + }; } diff --git a/lib/widget/app_bar_action.dart b/lib/widget/app_bar_action.dart index ea8197c7..bdfad0e2 100644 --- a/lib/widget/app_bar_action.dart +++ b/lib/widget/app_bar_action.dart @@ -1,5 +1,5 @@ // 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/material.dart';