@@ -61,48 +61,66 @@ class _SourcesPageState extends State<SourcesPage> {
61
61
return Center (child: Text (l10n.noSourcesFound));
62
62
}
63
63
64
- return PaginatedDataTable2 (
65
- columns: [
66
- DataColumn2 (label: Text (l10n.sourceName), size: ColumnSize .L ),
67
- DataColumn2 (label: Text (l10n.sourceType), size: ColumnSize .M ),
68
- DataColumn2 (label: Text (l10n.status), size: ColumnSize .S ),
69
- DataColumn2 (label: Text (l10n.lastUpdated), size: ColumnSize .M ),
70
- DataColumn2 (
71
- label: Text (l10n.actions),
72
- size: ColumnSize .S ,
73
- fixedWidth: 120 ,
64
+ return Column (
65
+ children: [
66
+ if (state.sourcesStatus == ContentManagementStatus .loading &&
67
+ state.sources.isNotEmpty)
68
+ const LinearProgressIndicator (),
69
+ Expanded (
70
+ child: PaginatedDataTable2 (
71
+ columns: [
72
+ DataColumn2 (
73
+ label: Text (l10n.sourceName),
74
+ size: ColumnSize .L ,
75
+ ),
76
+ DataColumn2 (
77
+ label: Text (l10n.sourceType),
78
+ size: ColumnSize .M ,
79
+ ),
80
+ DataColumn2 (label: Text (l10n.status), size: ColumnSize .S ),
81
+ DataColumn2 (
82
+ label: Text (l10n.lastUpdated),
83
+ size: ColumnSize .M ,
84
+ ),
85
+ DataColumn2 (
86
+ label: Text (l10n.actions),
87
+ size: ColumnSize .S ,
88
+ fixedWidth: 120 ,
89
+ ),
90
+ ],
91
+ source: _SourcesDataSource (
92
+ context: context,
93
+ sources: state.sources,
94
+ hasMore: state.sourcesHasMore,
95
+ l10n: l10n,
96
+ ),
97
+ rowsPerPage: kDefaultRowsPerPage,
98
+ availableRowsPerPage: const [kDefaultRowsPerPage],
99
+ onPageChanged: (pageIndex) {
100
+ final newOffset = pageIndex * kDefaultRowsPerPage;
101
+ if (newOffset >= state.sources.length &&
102
+ state.sourcesHasMore &&
103
+ state.sourcesStatus !=
104
+ ContentManagementStatus .loading) {
105
+ context.read <ContentManagementBloc >().add (
106
+ LoadSourcesRequested (
107
+ startAfterId: state.sourcesCursor,
108
+ limit: kDefaultRowsPerPage,
109
+ ),
110
+ );
111
+ }
112
+ },
113
+ empty: Center (child: Text (l10n.noSourcesFound)),
114
+ showCheckboxColumn: false ,
115
+ showFirstLastButtons: true ,
116
+ fit: FlexFit .tight,
117
+ headingRowHeight: 56 ,
118
+ dataRowHeight: 56 ,
119
+ columnSpacing: AppSpacing .md,
120
+ horizontalMargin: AppSpacing .md,
121
+ ),
74
122
),
75
123
],
76
- source: _SourcesDataSource (
77
- context: context,
78
- sources: state.sources,
79
- isLoading: state.sourcesStatus == ContentManagementStatus .loading,
80
- hasMore: state.sourcesHasMore,
81
- l10n: l10n,
82
- ),
83
- rowsPerPage: kDefaultRowsPerPage,
84
- availableRowsPerPage: const [kDefaultRowsPerPage],
85
- onPageChanged: (pageIndex) {
86
- final newOffset = pageIndex * kDefaultRowsPerPage;
87
- if (newOffset >= state.sources.length &&
88
- state.sourcesHasMore &&
89
- state.sourcesStatus != ContentManagementStatus .loading) {
90
- context.read <ContentManagementBloc >().add (
91
- LoadSourcesRequested (
92
- startAfterId: state.sourcesCursor,
93
- limit: kDefaultRowsPerPage,
94
- ),
95
- );
96
- }
97
- },
98
- empty: Center (child: Text (l10n.noSourcesFound)),
99
- showCheckboxColumn: false ,
100
- showFirstLastButtons: true ,
101
- fit: FlexFit .tight,
102
- headingRowHeight: 56 ,
103
- dataRowHeight: 56 ,
104
- columnSpacing: AppSpacing .md,
105
- horizontalMargin: AppSpacing .md,
106
124
);
107
125
},
108
126
),
@@ -114,29 +132,18 @@ class _SourcesDataSource extends DataTableSource {
114
132
_SourcesDataSource ({
115
133
required this .context,
116
134
required this .sources,
117
- required this .isLoading,
118
135
required this .hasMore,
119
136
required this .l10n,
120
137
});
121
138
122
139
final BuildContext context;
123
140
final List <Source > sources;
124
- final bool isLoading;
125
141
final bool hasMore;
126
142
final AppLocalizations l10n;
127
143
128
144
@override
129
145
DataRow ? getRow (int index) {
130
146
if (index >= sources.length) {
131
- // This can happen if hasMore is true and the user is on the last page.
132
- // If we are loading, show a spinner. Otherwise, we've reached the end.
133
- if (isLoading) {
134
- return DataRow2 (
135
- cells: List .generate (5 , (_) {
136
- return const DataCell (Center (child: CircularProgressIndicator ()));
137
- }),
138
- );
139
- }
140
147
return null ;
141
148
}
142
149
final source = sources[index];
@@ -184,8 +191,8 @@ class _SourcesDataSource extends DataTableSource {
184
191
onPressed: () {
185
192
// Dispatch delete event
186
193
context.read <ContentManagementBloc >().add (
187
- ArchiveSourceRequested (source.id),
188
- );
194
+ ArchiveSourceRequested (source.id),
195
+ );
189
196
},
190
197
),
191
198
],
@@ -200,16 +207,6 @@ class _SourcesDataSource extends DataTableSource {
200
207
201
208
@override
202
209
int get rowCount {
203
- // If we have more items to fetch, we add 1 to the current length.
204
- // This signals to PaginatedDataTable2 that there is at least one more page,
205
- // which enables the 'next page' button.
206
- if (hasMore) {
207
- // When loading, we show an extra row for the spinner.
208
- // Otherwise, we just indicate that there are more rows.
209
- return isLoading
210
- ? sources.length + 1
211
- : sources.length + kDefaultRowsPerPage;
212
- }
213
210
return sources.length;
214
211
}
215
212
0 commit comments