Browse Source

1、消息中心的消除红点

2、收藏夹的边距
tags/0.0.2^2
PH2 4 years ago
parent
commit
0ae811e92c
8 changed files with 84 additions and 28 deletions
  1. +17
    -0
      lib/pages/message_notice_page/bloc/message_notice_bloc.dart
  2. +12
    -2
      lib/pages/message_notice_page/bloc/message_notice_event.dart
  3. +15
    -0
      lib/pages/message_notice_page/bloc/message_notice_repository.dart
  4. +8
    -4
      lib/pages/message_notice_page/message_notice_page.dart
  5. +3
    -0
      lib/register.dart
  6. +18
    -12
      lib/widgets/favorites/goods_list/favorites_goods_list_widget.dart
  7. +9
    -8
      lib/widgets/home/home_quick_entry/home_quick_entry_widget.dart
  8. +2
    -2
      lib/widgets/home/home_slide_banner/home_slide_banner.dart

+ 17
- 0
lib/pages/message_notice_page/bloc/message_notice_bloc.dart View File

@@ -2,6 +2,7 @@ import 'dart:async';


import 'package:bloc/bloc.dart'; import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.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/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_data_model.dart';
import 'package:zhiying_base_widget/pages/message_notice_page/model/message_notice_style_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<MessageNoticeEvent, MessageNoticeState> {
yield* _mapInitEventToState(event); yield* _mapInitEventToState(event);
} }


/// 消除红点
if (event is MessageNoticeClearPointEvent) {
yield* _mapClearPointEventToState(event);
}

/// 下拉刷新 /// 下拉刷新
if (event is MessageNoticeOnRefreshEvent) { if (event is MessageNoticeOnRefreshEvent) {
yield* _mapOnRefreshEventToState(event); yield* _mapOnRefreshEventToState(event);
@@ -61,6 +67,17 @@ class MessageNoticeBloc extends Bloc<MessageNoticeEvent, MessageNoticeState> {
} }
} }


/// 消除消息右上角红点
Stream<MessageNoticeState> _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<MessageNoticeState> _mapOnRefreshEventToState(MessageNoticeOnRefreshEvent event) async* { Stream<MessageNoticeState> _mapOnRefreshEventToState(MessageNoticeOnRefreshEvent event) async* {
var style = repository.getStyleModel(); var style = repository.getStyleModel();


+ 12
- 2
lib/pages/message_notice_page/bloc/message_notice_event.dart View File

@@ -11,7 +11,17 @@ abstract class MessageNoticeEvent extends Equatable {
class MessageNoticeInitEvent extends MessageNoticeEvent {} class MessageNoticeInitEvent extends MessageNoticeEvent {}


/// 下拉刷新 /// 下拉刷新
class MessageNoticeOnRefreshEvent extends MessageNoticeEvent{}
class MessageNoticeOnRefreshEvent extends MessageNoticeEvent {}


/// 上拉更多 /// 上拉更多
class MessageNoticeOnLoadEvent extends MessageNoticeEvent{}
class MessageNoticeOnLoadEvent extends MessageNoticeEvent {}

/// 消除消息红点
class MessageNoticeClearPointEvent extends MessageNoticeEvent {
final String selectId;

MessageNoticeClearPointEvent({@required this.selectId});

@override
List<Object> get props => [this.selectId];
}

+ 15
- 0
lib/pages/message_notice_page/bloc/message_notice_repository.dart View File

@@ -79,6 +79,21 @@ class MessageNoticeRepository {
return null; return null;
} }


/// 消除消息红点
Future<MessageNoticeDataModel> 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<MessageNoticeDataModel> fetchRefreshData() async { Future<MessageNoticeDataModel> fetchRefreshData() async {
return fetchInitData(); return fetchInitData();


+ 8
- 4
lib/pages/message_notice_page/message_notice_page.dart View File

@@ -51,7 +51,11 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine
} }


/// 子item点击事件 /// 子item点击事件
void _onMainItemClick(MainNotificationStyleItem styleModel) {
void _onMainItemClick(MainNotificationStyleItem styleModel, MessageNoticeDataItemModel dataModel) {

/// 消除消息红点
BlocProvider.of<MessageNoticeBloc>(context).add(MessageNoticeClearPointEvent(selectId: dataModel?.id));

/// 如果是消息中心,则重新打开页面加载 /// 如果是消息中心,则重新打开页面加载
Navigator.push(context, CupertinoPageRoute(builder: (_) => MessageNoticePage({'type': styleModel?.type, 'title': styleModel?.name}))); Navigator.push(context, CupertinoPageRoute(builder: (_) => MessageNoticePage({'type': styleModel?.type, 'title': styleModel?.name})));
} }
@@ -221,7 +225,7 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine


return GestureDetector( return GestureDetector(
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTap: () => _onMainItemClick(styleModel),
onTap: () => _onMainItemClick(styleModel, dataModel),
child: Container( child: Container(
decoration: BoxDecoration(color: HexColor.fromHex(styleModel?.bg_color ?? '#FFFFFF'), borderRadius: borderRadius), decoration: BoxDecoration(color: HexColor.fromHex(styleModel?.bg_color ?? '#FFFFFF'), borderRadius: borderRadius),
padding: const EdgeInsets.only(left: 15, right: 15, top: 16), padding: const EdgeInsets.only(left: 15, right: 15, top: 16),
@@ -569,7 +573,7 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine
offset: Offset(5, -4.5), offset: Offset(5, -4.5),
child: Container( child: Container(
// width: 17, // width: 17,
height: 12,
// height: 12,
padding: const EdgeInsets.only(left: 3, right: 3, top: 1, bottom: 1), padding: const EdgeInsets.only(left: 3, right: 3, top: 1, bottom: 1),
alignment: Alignment.center, alignment: Alignment.center,
decoration: BoxDecoration( decoration: BoxDecoration(
@@ -577,7 +581,7 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine
borderRadius: BorderRadius.circular(6), borderRadius: BorderRadius.circular(6),
border: Border.all(color: HexColor.fromHex('#FFFFFF'), width: 0.5)), border: Border.all(color: HexColor.fromHex('#FFFFFF'), width: 0.5)),
child: Text( child: Text(
'18',
value?? '',
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle(fontSize: 9, color: HexColor.fromHex(unreadTextColor ?? '#FFFFFF')), style: TextStyle(fontSize: 9, color: HexColor.fromHex(unreadTextColor ?? '#FFFFFF')),
), ),


+ 3
- 0
lib/register.dart View File

@@ -156,6 +156,9 @@ class BaseWidgetRegister {
PageFactory.regist( PageFactory.regist(
'pub.flutter.message_center', (model) => MessageNoticePage(model)); 'pub.flutter.message_center', (model) => MessageNoticePage(model));


/// TODO 首页的消息中心标识和我的页面不一致,需要改
PageFactory.regist(
'pub.flutter.message', (model) => MessageNoticePage(model));
/// 我的收藏 /// 我的收藏
PageFactory.regist('pub.flutter.my_fav', (model) => FavoritesPage()); PageFactory.regist('pub.flutter.my_fav', (model) => FavoritesPage());
} }


+ 18
- 12
lib/widgets/favorites/goods_list/favorites_goods_list_widget.dart View File

@@ -241,21 +241,27 @@ class __FavoritesGoodsListWidgetContainerState extends State<_FavoritesGoodsList
closeOnScroll: false, closeOnScroll: false,
secondaryActions: <Widget>[ secondaryActions: <Widget>[
/// 分享 /// 分享
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( child: HomeGoodsItemSingle(


+ 9
- 8
lib/widgets/home/home_quick_entry/home_quick_entry_widget.dart View File

@@ -59,10 +59,11 @@ class _HomeQuickEntryWidgetContianerState
); );
} }


/// 主视图
Widget _getMainWidget(HomeQuickEntryModel model) { 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 = columSize * rowSize <= dataSize
? rowSize ? rowSize
: dataSize % columSize == 0 : dataSize % columSize == 0
@@ -84,9 +85,9 @@ class _HomeQuickEntryWidgetContianerState
const double titleHeight = 20; const double titleHeight = 20;


// 总体的高度 == 行数 * (图片高度 + 标题高度 + 元素之间的边距) + 上下内边距 // 总体的高度 == 行数 * (图片高度 + 标题高度 + 元素之间的边距) + 上下内边距
double containerHeight =
rowSize * (iconHeight + titleHeight + itemPadding * 2) +
(bottomSize * 2);
double containerHeight = rowSize * (iconHeight + titleHeight + itemPadding * 2) + (bottomSize * 2);


return Container( return Container(
// padding: const EdgeInsets.only(bottom: bottomSize, top: bottomSize), // padding: const EdgeInsets.only(bottom: bottomSize, top: bottomSize),
@@ -121,7 +122,7 @@ class _HomeQuickEntryWidgetContianerState
itemPadding: itemPadding, itemPadding: itemPadding,
); );
}, },
pagination: _SwiperCustomPagination(pageCount),
pagination: pageCount > 1 ? _SwiperCustomPagination(pageCount) : null,
), ),
), ),
) )
@@ -130,7 +131,7 @@ class _HomeQuickEntryWidgetContianerState
); );
} }


// 自定义进度条
/// 自定义进度条
SwiperPlugin _SwiperCustomPagination(int pageCount) { SwiperPlugin _SwiperCustomPagination(int pageCount) {
List list = []; List list = [];
for (int i = 0; i < pageCount; i++) { for (int i = 0; i < pageCount; i++) {


+ 2
- 2
lib/widgets/home/home_slide_banner/home_slide_banner.dart View File

@@ -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/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/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/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 'package:zhiying_comm/zhiying_comm.dart';


import 'bloc/bloc.dart'; import 'bloc/bloc.dart';
@@ -54,8 +55,7 @@ class _HomeSlideBannerContainerState extends State<HomeSlideBannerContainer> {
// )); // ));
// Navigator.push(context, CupertinoPageRoute(builder: (_)=> TeamPage())); // Navigator.push(context, CupertinoPageRoute(builder: (_)=> TeamPage()));


Navigator.push(
context, CupertinoPageRoute(builder: (_) => MessageNoticePage(null)));
// Navigator.push(context, CupertinoPageRoute(builder: (_) => VipCenterPage(null)));
} }


@override @override


Loading…
Cancel
Save