添加消息红点

hmxc
张萌 4 years ago
parent f2f25f54f5
commit 32d9d1b0b3

@ -3,6 +3,7 @@
// 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/system_message_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:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -71,26 +72,16 @@ class _HomePageState extends State<HomePage>
appBar: AnimateAppBar( appBar: AnimateAppBar(
scrollController: _scrollController, scrollController: _scrollController,
actions: [ actions: [
Stack(children: [ Badge(
ColumnActionButton( elevation: 0,
showBadge: appProvider.messageCenterModel.sysCount==0,
position: BadgePosition.topEnd(),
child: ColumnActionButton(
onPressed: MessageCenterPage().to, onPressed: MessageCenterPage().to,
title: '消息', title: '消息',
path: R.ASSETS_ICONS_ALARM_PNG, 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)),
),
) )
]),
], ],
), ),
body: EasyRefresh( body: EasyRefresh(

@ -1,8 +1,10 @@
import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/constants/api.dart';
import 'package:akuCommunity/model/message/system_message_model.dart'; import 'package:akuCommunity/model/message/system_message_model.dart';
import 'package:akuCommunity/pages/things_page/widget/bee_list_view.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_divider.dart';
import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart';
import 'package:badges/badges.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/utils/headers.dart';
@ -38,7 +40,10 @@ class _MessageCenterPageState extends State<MessageCenterPage> {
SystemMessageModel model, SystemMessageModel model,
}) { }) {
return InkWell( return InkWell(
onTap: () {}, onTap: () async {
await NetUtil().dio.get(API.message.readMessage);
},
child: Container( child: Container(
padding: EdgeInsets.fromLTRB(28.w, 32.w, 28.w, 20.w), padding: EdgeInsets.fromLTRB(28.w, 32.w, 28.w, 20.w),
child: Row( child: Row(
@ -46,23 +51,11 @@ class _MessageCenterPageState extends State<MessageCenterPage> {
SizedBox( SizedBox(
width: 90.w, width: 90.w,
height: 90.w, height: 90.w,
child: Stack( child: Badge(
children: [ child: Image.asset(path),
Image.asset(path), showBadge: !isRead[model.status],
Positioned( elevation: 0,
top: 0, position: BadgePosition.topEnd(top: 8.w, end: 8.w),
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, 15.w.widthBox,
Column( Column(

Loading…
Cancel
Save