Skip to content

Commit e884114

Browse files
Add PaginatedBaseModelViewTabs widget for pagination context (#44)
* Add PaginatedBaseModelViewTabs widget for pagination context * Improve parameter order --------- Co-authored-by: theEvilReaper <[email protected]>
1 parent 83eb34a commit e884114

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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+
required this.mapToDataModelItem,
36+
required this.openFunction,
37+
required this.selectedItem,
38+
required this.mapToDeleteDialog,
39+
required this.mapToDeleteSuccessfully,
40+
required this.callFunction,
41+
required this.models,
42+
required this.compareFunction,
43+
required this.page,
44+
required this.tabPages,
45+
required this.tabs,
46+
this.onLoadMore,
47+
this.hasMore = false,
48+
this.isLoadingMore = false,
49+
super.key,
50+
});
51+
52+
@override
53+
Widget build(BuildContext context) {
54+
return Padding(
55+
padding: const EdgeInsets.all(20),
56+
child: Row(
57+
crossAxisAlignment: CrossAxisAlignment.start,
58+
children: [
59+
PaginatedModelList<E>(
60+
mapToDataModelItem: mapToDataModelItem,
61+
selectedItem: selectedItem,
62+
openFunction: openFunction,
63+
mapToDeleteDialog: mapToDeleteDialog,
64+
mapToDeleteSuccessfully: mapToDeleteSuccessfully,
65+
callFunction: callFunction,
66+
models: models,
67+
compareFunction: compareFunction,
68+
onLoadMore: onLoadMore,
69+
hasMore: hasMore,
70+
isLoadingMore: isLoadingMore,
71+
),
72+
73+
verticalSpacing10,
74+
Expanded(
75+
child: ModelContentTabPage<E>(
76+
selectedItem: selectedItem,
77+
page: page,
78+
tabPages: tabPages,
79+
tabs: tabs,
80+
),
81+
),
82+
],
83+
),
84+
);
85+
}
86+
}

0 commit comments

Comments
 (0)