Skip to content

Commit

Permalink
Release 4.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
a-abramov committed May 2, 2024
1 parent 3539be6 commit 0d041cf
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [4.4.0]

- BREAKING CHANGE: Removed PaginatedList from the ViewModels constructors

## [4.3.0]

- Bump dependencies
Expand Down
6 changes: 3 additions & 3 deletions lib/src/loadable/loadable_grid_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,22 @@ class LoadableGridViewModel<Item extends StoreListItem> {
final Widget Function(int) itemBuilder;
final VoidCallback? loadList;
final EdgeInsets? padding;
final StoreList<Item> items;
final List<Item> items;
final OperationState loadListRequestState;
final OperationState? loadPageRequestState;
final SliverGridDelegate gridDelegate;
final ScrollPhysics? physics;
final Widget? header;
final bool shrinkWrap;

int get itemsCount => items.items.length;
int get itemsCount => items.length;

PaginationState getPaginationState() {
if (loadListRequestState.isFailed) {
return PaginationState.error;
} else if (loadListRequestState.isInProgress) {
return PaginationState.loading;
} else if (loadListRequestState.isSucceed && items.items.isEmpty) {
} else if (loadListRequestState.isSucceed && items.isEmpty) {
return PaginationState.empty;
}

Expand Down
6 changes: 3 additions & 3 deletions lib/src/loadable/loadable_list_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class LoadableListViewModel<Item extends StoreListItem> {
this.key,
});

final StoreList<Item> items;
final List<Item> items;
final Widget Function(int) itemBuilder;
final Widget Function(int) itemSeparator;
final Widget errorWidget;
Expand All @@ -190,7 +190,7 @@ class LoadableListViewModel<Item extends StoreListItem> {
final Widget? footer;
final Key? key;

int get itemsCount => items.items.length;
int get itemsCount => items.length;

PaginationState getPaginationState() {
if (loadListRequestState.isFailed) {
Expand All @@ -202,7 +202,7 @@ class LoadableListViewModel<Item extends StoreListItem> {
}

if ((loadListRequestState.isSucceed || loadListRequestState.isRefreshing) &&
items.items.isEmpty) {
items.isEmpty) {
return PaginationState.empty;
}

Expand Down
11 changes: 5 additions & 6 deletions lib/src/loadable/loadable_paginated_grid_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class LoadablePaginatedGridViewState<T extends StoreListItem>
} else {
final isSucceed = loadPageRequestState.isSucceed;
final isIdle = loadPageRequestState.isIdle;
final isAllItemsNotLoaded = !viewModel.paginatedList.isAllItemsLoaded;
final isAllItemsNotLoaded = !viewModel.isAllItemsLoaded;

canLoad = (isSucceed || isIdle) && isAllItemsNotLoaded;
}
Expand All @@ -78,21 +78,20 @@ class LoadablePaginatedGridViewModel<Item extends StoreListItem>
required super.gridDelegate,
required super.loadListRequestState,
required OperationState super.loadPageRequestState,
required this.paginatedList,
required super.items,
required this.errorPageWidget,
required this.isAllItemsLoaded,
super.loadList,
super.padding,
super.header,
super.physics,
this.loadPage,
super.key,
}) : super(
items: paginatedList.items,
);
});

final VoidCallback? loadPage;
final PaginatedList<Item> paginatedList;
final Widget errorPageWidget;
final bool isAllItemsLoaded;

@override
PaginationState getPaginationState() {
Expand Down
11 changes: 6 additions & 5 deletions lib/src/loadable/loadable_paginated_list_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class LoadablePaginatedListState<T extends StoreListItem>
@override
Widget buildFooter() {
return SliverToBoxAdapter(
child: viewModel.paginatedList.isAllItemsLoaded ? viewModel.footer : null,
child: viewModel.isAllItemsLoaded ? viewModel.footer : null,
);
}

Expand All @@ -48,7 +48,7 @@ class LoadablePaginatedListState<T extends StoreListItem>
super.onScrollChanged(scrollInfo);
final canLoad = (viewModel.loadPageRequestState.isSucceed ||
viewModel.loadPageRequestState.isIdle) &&
!viewModel.paginatedList.isAllItemsLoaded;
!viewModel.isAllItemsLoaded;
final maxScrollExtent =
scrollInfo.metrics.maxScrollExtent - (widget.cacheExtent ?? 0);

Expand Down Expand Up @@ -87,22 +87,23 @@ class LoadablePaginatedListViewModel<Item extends StoreListItem>
required super.errorWidget,
required super.emptyStateWidget,
required super.loadListRequestState,
required super.items,
required this.loadPageRequestState,
required this.paginatedList,
required this.errorPageWidget,
required this.isAllItemsLoaded,
super.loadList,
super.padding,
super.sliverHeader,
super.header,
super.footer,
this.loadPage,
super.key,
}) : super(items: paginatedList.items);
});

final VoidCallback? loadPage;
final PaginatedList<Item> paginatedList;
final Widget errorPageWidget;
final OperationState loadPageRequestState;
final bool isAllItemsLoaded;

@override
int get itemsCount => super.itemsCount + 1;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: dash_kit_core
description: The core component for DashKit that provides basic architecture components
version: 4.3.0
version: 4.4.0
homepage: https://github.com/Dash-Kit/dash-kit-core

environment:
Expand Down

0 comments on commit 0d041cf

Please sign in to comment.