Skip to content

Commit f9ea293

Browse files
committed
Add PaginatedBaseModelViewTabs widget for pagination context
1 parent 83eb34a commit f9ea293

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:stelaris/api/model/data_model.dart';
3+
import 'package:stelaris/feature/base/model_content_tab_page.dart';
4+
import 'package:stelaris/feature/base/paginated_model_list.dart';
5+
import 'package:stelaris/util/constants.dart';
6+
import 'package:stelaris/util/typedefs.dart';
7+
8+
/// A paginated, non-breaking alternative to [BaseModelViewTabs] that supports lazy-loading.
9+
///
10+
/// This widget combines the [PaginatedModelList] with the tabbed content view from
11+
/// [ModelContentTabPage], providing a consistent layout for screens that require
12+
/// infinite scrolling for the model list.
13+
class PaginatedBaseModelViewTabs<E extends DataModel> extends StatelessWidget {
14+
/// Properties for the PaginatedModelList
15+
final MapToDataModelItem<E> mapToDataModelItem;
16+
final VoidCallback openFunction;
17+
final E? selectedItem;
18+
final MapToDeleteDialog<E> mapToDeleteDialog;
19+
final MapToDeleteSuccessfully<E> mapToDeleteSuccessfully;
20+
final Function(E) callFunction;
21+
final List<E> models;
22+
final bool Function(E) compareFunction;
23+
24+
/// New pagination hooks required by PaginatedModelList
25+
final VoidCallback? onLoadMore;
26+
final bool hasMore;
27+
final bool isLoadingMore;
28+
29+
/// Properties for the ModelContentTabPage
30+
final TabMapFunction<E> page;
31+
final MapToTabPages tabPages;
32+
final List<Tab> tabs;
33+
34+
const PaginatedBaseModelViewTabs({
35+
// List properties
36+
required this.mapToDataModelItem,
37+
required this.openFunction,
38+
required this.selectedItem,
39+
required this.mapToDeleteDialog,
40+
required this.mapToDeleteSuccessfully,
41+
required this.callFunction,
42+
required this.models,
43+
required this.compareFunction,
44+
// Pagination properties
45+
this.onLoadMore,
46+
this.hasMore = false,
47+
this.isLoadingMore = false,
48+
// Tab properties
49+
required this.page,
50+
required this.tabPages,
51+
required this.tabs,
52+
super.key,
53+
});
54+
55+
@override
56+
Widget build(BuildContext context) {
57+
return Padding(
58+
padding: const EdgeInsets.all(20),
59+
child: Row(
60+
crossAxisAlignment: CrossAxisAlignment.start,
61+
children: [
62+
// 1. The Paginated List on the left
63+
PaginatedModelList<E>(
64+
mapToDataModelItem: mapToDataModelItem,
65+
selectedItem: selectedItem,
66+
openFunction: openFunction,
67+
mapToDeleteDialog: mapToDeleteDialog,
68+
mapToDeleteSuccessfully: mapToDeleteSuccessfully,
69+
callFunction: callFunction,
70+
models: models,
71+
compareFunction: compareFunction,
72+
onLoadMore: onLoadMore,
73+
hasMore: hasMore,
74+
isLoadingMore: isLoadingMore,
75+
),
76+
77+
verticalSpacing10,
78+
Expanded(
79+
child: ModelContentTabPage<E>(
80+
selectedItem: selectedItem,
81+
page: page,
82+
tabPages: tabPages,
83+
tabs: tabs,
84+
),
85+
),
86+
],
87+
),
88+
);
89+
}
90+
}

0 commit comments

Comments
 (0)