Przeglądaj źródła

1、CustomPage的子Widget刷新问题修改

tags/0.0.17+4^0
PH2 3 lat temu
rodzic
commit
3b871f7e24
4 zmienionych plików z 30 dodań i 4 usunięć
  1. +5
    -0
      lib/pages/custom_page/bloc/custom_item_page_bloc.dart
  2. +3
    -0
      lib/pages/custom_page/bloc/custom_item_page_state.dart
  3. +22
    -3
      lib/pages/custom_page/custom_item_page.dart
  4. +0
    -1
      lib/widgets/custom/multi_nav/custom_quick_entry.dart

+ 5
- 0
lib/pages/custom_page/bloc/custom_item_page_bloc.dart Wyświetl plik

@@ -35,6 +35,7 @@ class CustomItemPageBloc extends Bloc<CustomItemPageEvent, CustomItemPageState>
if (event is CustomItemPageLoadEvent) {
yield* _mapLoadEventToState(event);
}

}

/// 初始化
@@ -71,7 +72,11 @@ class CustomItemPageBloc extends Bloc<CustomItemPageEvent, CustomItemPageState>
bool needRestart = await _bottomNavRepository.validateBottomNavUpdate();
Logger.log('refresh 是否重新启动App = ${needRestart}');
if (needRestart) {
// App重启,不需要进行子Widget刷新
yield CustomItemPageAppRestartState();
} else {
// 子Widget刷新,写在后面是为了等渲染完成
yield CustomItemPageItemWidgetRefreshState();
}
}



+ 3
- 0
lib/pages/custom_page/bloc/custom_item_page_state.dart Wyświetl plik

@@ -36,3 +36,6 @@ class CustomItemPageErrorState extends CustomItemPageState {}

/// 需要重新渲染App,更新底部导航模版
class CustomItemPageAppRestartState extends CustomItemPageState {}

/// 子Widget刷新状态
class CustomItemPageItemWidgetRefreshState extends CustomItemPageState {}

+ 22
- 3
lib/pages/custom_page/custom_item_page.dart Wyświetl plik

@@ -125,11 +125,15 @@ class __CustomItemPageContainerState extends BasePageState<_CustomItemPageContai
return BlocConsumer<CustomItemPageBloc, CustomItemPageState>(
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<Map<String, dynamic>> datas) {
var rlt = false;
if (!EmptyUtil.isEmpty(datas)) {
for (int i = 0; i < datas.length; i++) {
WidgetModel item = WidgetModel.fromJson(Map<String, dynamic>.from(datas[i]));
if (item.modName == 'product') {
rlt = true;
break;
}
}
}
return rlt;
}

/// 空数据
Widget _buildEmptyWidget() {
return SmartRefresher(


+ 0
- 1
lib/widgets/custom/multi_nav/custom_quick_entry.dart Wyświetl plik

@@ -31,7 +31,6 @@ class _CustomQuickEntryState extends BaseWidgetState<CustomQuickEntry> with Tick
@override
void refreshWidget(String value) {
setState(() {
Logger.log('多言导航 ===== ' + widget?.model?.toString());
model = _repository.fetchParentData(model: widget?.model);
});
}


Ładowanie…
Anuluj
Zapisz