@@ -4,6 +4,7 @@ import 'package:data_table_2/data_table_2.dart';
4
4
import 'package:flutter/material.dart' ;
5
5
import 'package:flutter_bloc/flutter_bloc.dart' ;
6
6
import 'package:flutter_news_app_web_dashboard_full_source_code/content_management/bloc/archived_headlines/archived_headlines_bloc.dart' ;
7
+ import 'package:flutter_news_app_web_dashboard_full_source_code/content_management/bloc/content_management_bloc.dart' ;
7
8
import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/app_localizations.dart' ;
8
9
import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/l10n.dart' ;
9
10
import 'package:intl/intl.dart' ;
@@ -35,16 +36,27 @@ class _ArchivedHeadlinesView extends StatelessWidget {
35
36
),
36
37
body: Padding (
37
38
padding: const EdgeInsets .all (AppSpacing .lg),
38
- child: BlocBuilder <ArchivedHeadlinesBloc , ArchivedHeadlinesState >(
39
- builder : (context, state) {
40
- if (state .status == ArchivedHeadlinesStatus .loading &&
41
- state.headlines.isEmpty ) {
42
- return LoadingStateWidget (
43
- icon : Icons .newspaper,
44
- headline : l10n.loadingArchivedHeadlines,
45
- subheadline : l10n.pleaseWait ,
46
- );
39
+ child: BlocListener <ArchivedHeadlinesBloc , ArchivedHeadlinesState >(
40
+ listenWhen : (previous, current) =>
41
+ previous .status != current.status,
42
+ listener : (context, state) {
43
+ if (state.status == ArchivedHeadlinesStatus .success &&
44
+ state.restoredHeadline != null ) {
45
+ context. read < ContentManagementBloc >(). add (
46
+ const LoadHeadlinesRequested (limit : kDefaultRowsPerPage) ,
47
+ );
47
48
}
49
+ },
50
+ child: BlocBuilder <ArchivedHeadlinesBloc , ArchivedHeadlinesState >(
51
+ builder: (context, state) {
52
+ if (state.status == ArchivedHeadlinesStatus .loading &&
53
+ state.headlines.isEmpty) {
54
+ return LoadingStateWidget (
55
+ icon: Icons .newspaper,
56
+ headline: l10n.loadingArchivedHeadlines,
57
+ subheadline: l10n.pleaseWait,
58
+ );
59
+ }
48
60
49
61
if (state.status == ArchivedHeadlinesStatus .failure) {
50
62
return FailureStateWidget (
@@ -116,16 +128,17 @@ class _ArchivedHeadlinesView extends StatelessWidget {
116
128
dataRowHeight: 56 ,
117
129
columnSpacing: AppSpacing .md,
118
130
horizontalMargin: AppSpacing .md,
119
- ),
120
131
),
121
- ] ,
132
+ ) ,
122
133
);
123
- },
134
+ },
135
+ ),
124
136
),
125
137
),
126
138
);
127
139
}
128
140
}
141
+ }
129
142
130
143
class _HeadlinesDataSource extends DataTableSource {
131
144
_HeadlinesDataSource ({
0 commit comments