transitionSeoCollection function
SeoCollectionState
transitionSeoCollection(
- SeoCollectionState state,
- SeoCollectionAction action, {
- required List<
SeoCollectionRecord> records, - required int categoryCount,
- required int pageSize,
Applies one closed action and returns canonical collection state.
Implementation
SeoCollectionState transitionSeoCollection(
SeoCollectionState state,
SeoCollectionAction action, {
required List<SeoCollectionRecord> records,
required int categoryCount,
required int pageSize,
}) {
final candidate = switch (action) {
SeoCollectionSetQuery(:final query) => SeoCollectionState(
query: query,
categoryIndex: state.categoryIndex,
sort: state.sort,
),
SeoCollectionSelectCategory(:final index) => SeoCollectionState(
query: state.query,
categoryIndex: index,
sort: state.sort,
),
SeoCollectionSetSort(:final sort) => SeoCollectionState(
query: state.query,
categoryIndex: state.categoryIndex,
sort: sort,
),
SeoCollectionSetPage(:final page) => SeoCollectionState(
query: state.query,
categoryIndex: state.categoryIndex,
sort: state.sort,
page: page,
),
SeoCollectionNextPage() => SeoCollectionState(
query: state.query,
categoryIndex: state.categoryIndex,
sort: state.sort,
page: state.page + 1,
),
SeoCollectionPreviousPage() => SeoCollectionState(
query: state.query,
categoryIndex: state.categoryIndex,
sort: state.sort,
page: state.page - 1,
),
};
return selectSeoCollection(
records: records,
categoryCount: categoryCount,
pageSize: pageSize,
state: candidate,
).state;
}