diff --git a/lib/pages/message_notice_page/bloc/message_notice_bloc.dart b/lib/pages/message_notice_page/bloc/message_notice_bloc.dart index 48de94f..0239471 100644 --- a/lib/pages/message_notice_page/bloc/message_notice_bloc.dart +++ b/lib/pages/message_notice_page/bloc/message_notice_bloc.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; +import 'package:flutter/cupertino.dart'; import 'package:zhiying_base_widget/pages/message_notice_page/bloc/message_notice_repository.dart'; import 'package:zhiying_base_widget/pages/message_notice_page/model/message_notice_data_model.dart'; import 'package:zhiying_base_widget/pages/message_notice_page/model/message_notice_style_model.dart'; @@ -31,6 +32,11 @@ class MessageNoticeBloc extends Bloc { yield* _mapInitEventToState(event); } + /// 消除红点 + if (event is MessageNoticeClearPointEvent) { + yield* _mapClearPointEventToState(event); + } + /// 下拉刷新 if (event is MessageNoticeOnRefreshEvent) { yield* _mapOnRefreshEventToState(event); @@ -61,6 +67,17 @@ class MessageNoticeBloc extends Bloc { } } + /// 消除消息右上角红点 + Stream _mapClearPointEventToState(MessageNoticeClearPointEvent event) async* { + var style = repository.getStyleModel(); + var data = await repository.fetchClearPointData(event.selectId); + if (!EmptyUtil.isEmpty(data)) { + yield MessageNoticeLoadedState(styleModel: style, dataModel: data); + }else{ + yield MessageNoticeOnRefreshErrorState(); + } + } + /// 下拉刷新 Stream _mapOnRefreshEventToState(MessageNoticeOnRefreshEvent event) async* { var style = repository.getStyleModel(); diff --git a/lib/pages/message_notice_page/bloc/message_notice_event.dart b/lib/pages/message_notice_page/bloc/message_notice_event.dart index 8ce3d6c..c035544 100644 --- a/lib/pages/message_notice_page/bloc/message_notice_event.dart +++ b/lib/pages/message_notice_page/bloc/message_notice_event.dart @@ -11,7 +11,17 @@ abstract class MessageNoticeEvent extends Equatable { class MessageNoticeInitEvent extends MessageNoticeEvent {} /// 下拉刷新 -class MessageNoticeOnRefreshEvent extends MessageNoticeEvent{} +class MessageNoticeOnRefreshEvent extends MessageNoticeEvent {} /// 上拉更多 -class MessageNoticeOnLoadEvent extends MessageNoticeEvent{} \ No newline at end of file +class MessageNoticeOnLoadEvent extends MessageNoticeEvent {} + +/// 消除消息红点 +class MessageNoticeClearPointEvent extends MessageNoticeEvent { + final String selectId; + + MessageNoticeClearPointEvent({@required this.selectId}); + + @override + List get props => [this.selectId]; +} diff --git a/lib/pages/message_notice_page/bloc/message_notice_repository.dart b/lib/pages/message_notice_page/bloc/message_notice_repository.dart index 105f349..ee653a0 100644 --- a/lib/pages/message_notice_page/bloc/message_notice_repository.dart +++ b/lib/pages/message_notice_page/bloc/message_notice_repository.dart @@ -79,6 +79,21 @@ class MessageNoticeRepository { return null; } + /// 消除消息红点 + Future fetchClearPointData(String selectId) async{ + try{ + _oldData.forEach((element){ + if(element.id == selectId) { + element.unread_count = ''; + } + }); + return MessageNoticeDataModel()..list = _oldData; + }catch(e, s){ + Logger.error(e,s); + } + return null; + } + /// 下拉刷新 Future fetchRefreshData() async { return fetchInitData(); diff --git a/lib/pages/message_notice_page/message_notice_page.dart b/lib/pages/message_notice_page/message_notice_page.dart index b007d2e..aa08af4 100644 --- a/lib/pages/message_notice_page/message_notice_page.dart +++ b/lib/pages/message_notice_page/message_notice_page.dart @@ -51,7 +51,11 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine } /// 子item点击事件 - void _onMainItemClick(MainNotificationStyleItem styleModel) { + void _onMainItemClick(MainNotificationStyleItem styleModel, MessageNoticeDataItemModel dataModel) { + + /// 消除消息红点 + BlocProvider.of(context).add(MessageNoticeClearPointEvent(selectId: dataModel?.id)); + /// 如果是消息中心,则重新打开页面加载 Navigator.push(context, CupertinoPageRoute(builder: (_) => MessageNoticePage({'type': styleModel?.type, 'title': styleModel?.name}))); } @@ -221,7 +225,7 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine return GestureDetector( behavior: HitTestBehavior.opaque, - onTap: () => _onMainItemClick(styleModel), + onTap: () => _onMainItemClick(styleModel, dataModel), child: Container( decoration: BoxDecoration(color: HexColor.fromHex(styleModel?.bg_color ?? '#FFFFFF'), borderRadius: borderRadius), padding: const EdgeInsets.only(left: 15, right: 15, top: 16), @@ -569,7 +573,7 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine offset: Offset(5, -4.5), child: Container( // width: 17, - height: 12, + // height: 12, padding: const EdgeInsets.only(left: 3, right: 3, top: 1, bottom: 1), alignment: Alignment.center, decoration: BoxDecoration( @@ -577,7 +581,7 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine borderRadius: BorderRadius.circular(6), border: Border.all(color: HexColor.fromHex('#FFFFFF'), width: 0.5)), child: Text( - '18', + value?? '', textAlign: TextAlign.center, style: TextStyle(fontSize: 9, color: HexColor.fromHex(unreadTextColor ?? '#FFFFFF')), ), diff --git a/lib/register.dart b/lib/register.dart index 158ad42..49998c6 100644 --- a/lib/register.dart +++ b/lib/register.dart @@ -156,6 +156,9 @@ class BaseWidgetRegister { PageFactory.regist( 'pub.flutter.message_center', (model) => MessageNoticePage(model)); + /// TODO 首页的消息中心标识和我的页面不一致,需要改 + PageFactory.regist( + 'pub.flutter.message', (model) => MessageNoticePage(model)); /// 我的收藏 PageFactory.regist('pub.flutter.my_fav', (model) => FavoritesPage()); } diff --git a/lib/widgets/favorites/goods_list/favorites_goods_list_widget.dart b/lib/widgets/favorites/goods_list/favorites_goods_list_widget.dart index 1f458ec..8b879a5 100644 --- a/lib/widgets/favorites/goods_list/favorites_goods_list_widget.dart +++ b/lib/widgets/favorites/goods_list/favorites_goods_list_widget.dart @@ -241,21 +241,27 @@ class __FavoritesGoodsListWidgetContainerState extends State<_FavoritesGoodsList closeOnScroll: false, secondaryActions: [ /// 分享 - IconSlideAction( - caption: '分享', - color: Colors.deepOrange, - icon: Icons.share, - onTap: () => _onSlideShare(), - closeOnTap: true, + Padding( + padding: const EdgeInsets.only(bottom: 8), + child: IconSlideAction( + caption: '分享', + color: Colors.deepOrange, + icon: Icons.share, + onTap: () => _onSlideShare(), + closeOnTap: true, + ), ), /// 删除 - IconSlideAction( - caption: '删除', - color: Colors.red, - closeOnTap: true, - icon: Icons.delete, - onTap: () => _onSlideDelete(styleModel?.confirmDialog ,index), + Padding( + padding: const EdgeInsets.only(bottom: 8), + child: IconSlideAction( + caption: '删除', + color: Colors.red, + closeOnTap: true, + icon: Icons.delete, + onTap: () => _onSlideDelete(styleModel?.confirmDialog ,index), + ), ), ], child: HomeGoodsItemSingle( diff --git a/lib/widgets/home/home_quick_entry/home_quick_entry_widget.dart b/lib/widgets/home/home_quick_entry/home_quick_entry_widget.dart index b091790..e474c04 100644 --- a/lib/widgets/home/home_quick_entry/home_quick_entry_widget.dart +++ b/lib/widgets/home/home_quick_entry/home_quick_entry_widget.dart @@ -59,10 +59,11 @@ class _HomeQuickEntryWidgetContianerState ); } + /// 主视图 Widget _getMainWidget(HomeQuickEntryModel model) { - int dataSize = 15; //model?.type_normal?.length ?? 0; // 总数 - int columSize = 5; //int.parse(model?.colum_size ?? '5'); // 列数 - int rowSize = 2; //int.parse(model?.row_size ?? '2'); // 行数 + int dataSize = model?.type_normal?.length ?? 0; // 总数 + int columSize = int.parse(model?.colum_size ?? '5'); // 列数 + int rowSize = int.parse(model?.row_size ?? '2'); // 行数 rowSize = columSize * rowSize <= dataSize ? rowSize : dataSize % columSize == 0 @@ -84,9 +85,9 @@ class _HomeQuickEntryWidgetContianerState const double titleHeight = 20; // 总体的高度 == 行数 * (图片高度 + 标题高度 + 元素之间的边距) + 上下内边距 - double containerHeight = - rowSize * (iconHeight + titleHeight + itemPadding * 2) + - (bottomSize * 2); + double containerHeight = rowSize * (iconHeight + titleHeight + itemPadding * 2) + (bottomSize * 2); + + return Container( // padding: const EdgeInsets.only(bottom: bottomSize, top: bottomSize), @@ -121,7 +122,7 @@ class _HomeQuickEntryWidgetContianerState itemPadding: itemPadding, ); }, - pagination: _SwiperCustomPagination(pageCount), + pagination: pageCount > 1 ? _SwiperCustomPagination(pageCount) : null, ), ), ) @@ -130,7 +131,7 @@ class _HomeQuickEntryWidgetContianerState ); } - // 自定义进度条 + /// 自定义进度条 SwiperPlugin _SwiperCustomPagination(int pageCount) { List list = []; for (int i = 0; i < pageCount; i++) { diff --git a/lib/widgets/home/home_slide_banner/home_slide_banner.dart b/lib/widgets/home/home_slide_banner/home_slide_banner.dart index 755b90b..570676a 100644 --- a/lib/widgets/home/home_slide_banner/home_slide_banner.dart +++ b/lib/widgets/home/home_slide_banner/home_slide_banner.dart @@ -7,6 +7,7 @@ import 'package:provider/provider.dart'; import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_bg_notifier.dart'; import 'package:zhiying_base_widget/pages/message_notice_page/message_notice_page.dart'; import 'package:zhiying_base_widget/pages/team_details_page/team_details_page.dart'; +import 'package:zhiying_base_widget/pages/vip_center_page/vip_center_page.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; import 'bloc/bloc.dart'; @@ -54,8 +55,7 @@ class _HomeSlideBannerContainerState extends State { // )); // Navigator.push(context, CupertinoPageRoute(builder: (_)=> TeamPage())); - Navigator.push( - context, CupertinoPageRoute(builder: (_) => MessageNoticePage(null))); + // Navigator.push(context, CupertinoPageRoute(builder: (_) => VipCenterPage(null))); } @override