Skip to content

Commit 7918884

Browse files
fix: 6701 - correct price list from product page (#6705)
Impacted files: * `infinite_scroll_manager.dart`: added optional initial total number of items and pages * `product_prices_list.dart`: populated the new initial total number of items and pages parameters
1 parent 5fb4bb7 commit 7918884

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

packages/smooth_app/lib/pages/prices/infinite_scroll_manager.dart

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@ import 'package:smooth_app/l10n/app_localizations.dart';
44
/// A generic abstract class for handling infinite scrolling in lists.
55
/// [T] is the type of items being displayed.
66
abstract class InfiniteScrollManager<T> {
7-
/// Creates an instance of [InfiniteScrollManager] with optional initial items.
8-
InfiniteScrollManager({List<T>? initialItems})
9-
: _items = initialItems ?? <T>[],
10-
_currentPage = initialItems != null && initialItems.isNotEmpty
11-
? _initialPage
12-
: 0;
7+
/// Creates an [InfiniteScrollManager] with optional initial state.
8+
InfiniteScrollManager({
9+
final List<T>? initialItems,
10+
final int? totalItems,
11+
final int? totalPages,
12+
}) : _items = List<T>.from(initialItems ?? <T>[]),
13+
_currentPage = initialItems != null && initialItems.isNotEmpty
14+
? _initialPage
15+
: 0,
16+
_totalPages = totalPages,
17+
_totalItems = totalItems;
1318

1419
static const int _initialPage = 1;
1520

packages/smooth_app/lib/pages/prices/product_prices_list.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ class _InfiniteScrollPriceManager extends InfiniteScrollManager<Price> {
4949
_InfiniteScrollPriceManager({
5050
GetPricesResult? pricesResult,
5151
required this.model,
52-
}) : super(initialItems: pricesResult?.items);
52+
}) : super(
53+
initialItems: pricesResult?.items,
54+
totalItems: pricesResult?.total,
55+
totalPages: pricesResult?.numberOfPages,
56+
);
5357

5458
/// The model containing price query parameters
5559
final GetPricesModel model;

0 commit comments

Comments
 (0)