diff --git a/lib/pages/custom_page/bloc/custom_item_page_bloc.dart b/lib/pages/custom_page/bloc/custom_item_page_bloc.dart index 661aa28..ffc83ab 100644 --- a/lib/pages/custom_page/bloc/custom_item_page_bloc.dart +++ b/lib/pages/custom_page/bloc/custom_item_page_bloc.dart @@ -35,6 +35,7 @@ class CustomItemPageBloc extends Bloc if (event is CustomItemPageLoadEvent) { yield* _mapLoadEventToState(event); } + } /// 初始化 @@ -71,7 +72,11 @@ class CustomItemPageBloc extends Bloc bool needRestart = await _bottomNavRepository.validateBottomNavUpdate(); Logger.log('refresh 是否重新启动App = ${needRestart}'); if (needRestart) { + // App重启,不需要进行子Widget刷新 yield CustomItemPageAppRestartState(); + } else { + // 子Widget刷新,写在后面是为了等渲染完成 + yield CustomItemPageItemWidgetRefreshState(); } } diff --git a/lib/pages/custom_page/bloc/custom_item_page_state.dart b/lib/pages/custom_page/bloc/custom_item_page_state.dart index f46caa3..2bc3376 100644 --- a/lib/pages/custom_page/bloc/custom_item_page_state.dart +++ b/lib/pages/custom_page/bloc/custom_item_page_state.dart @@ -36,3 +36,6 @@ class CustomItemPageErrorState extends CustomItemPageState {} /// 需要重新渲染App,更新底部导航模版 class CustomItemPageAppRestartState extends CustomItemPageState {} + +/// 子Widget刷新状态 +class CustomItemPageItemWidgetRefreshState extends CustomItemPageState {} \ No newline at end of file diff --git a/lib/pages/custom_page/custom_item_page.dart b/lib/pages/custom_page/custom_item_page.dart index cd2a6f5..5841f90 100644 --- a/lib/pages/custom_page/custom_item_page.dart +++ b/lib/pages/custom_page/custom_item_page.dart @@ -125,11 +125,15 @@ class __CustomItemPageContainerState extends BasePageState<_CustomItemPageContai return BlocConsumer( listener: (context, state) {}, buildWhen: (prev, current) { + /// 子Item刷新 + if (current is CustomItemPageItemWidgetRefreshState) { + /// 子Widget刷新 + refreshPage(); + return false; + } /// 下拉刷新成功 if (current is CustomItemPageRefreshSuccessState) { _refreshController?.refreshCompleted(resetFooterState: true); - ///刷新页面 - refreshPage(); return false; } /// 下拉刷新出错 @@ -191,7 +195,7 @@ class __CustomItemPageContainerState extends BasePageState<_CustomItemPageContai SmartRefresher( controller: _refreshController, enablePullDown: true, - enablePullUp: true, + enablePullUp: _hasProductList(model), onRefresh: _refreshEvent, onLoading: _loadEvent, header: RefreshGifHeader(), @@ -258,6 +262,21 @@ class __CustomItemPageContainerState extends BasePageState<_CustomItemPageContai return result; } + /// 判断是否有商品列表,如果没有不进行,上拉更多 + bool _hasProductList(final List> datas) { + var rlt = false; + if (!EmptyUtil.isEmpty(datas)) { + for (int i = 0; i < datas.length; i++) { + WidgetModel item = WidgetModel.fromJson(Map.from(datas[i])); + if (item.modName == 'product') { + rlt = true; + break; + } + } + } + return rlt; + } + /// 空数据 Widget _buildEmptyWidget() { return SmartRefresher( diff --git a/lib/widgets/custom/multi_nav/custom_quick_entry.dart b/lib/widgets/custom/multi_nav/custom_quick_entry.dart index a8e1469..1874a6b 100644 --- a/lib/widgets/custom/multi_nav/custom_quick_entry.dart +++ b/lib/widgets/custom/multi_nav/custom_quick_entry.dart @@ -31,7 +31,6 @@ class _CustomQuickEntryState extends BaseWidgetState with Tick @override void refreshWidget(String value) { setState(() { - Logger.log('多言导航 ===== ' + widget?.model?.toString()); model = _repository.fetchParentData(model: widget?.model); }); }