@@ -4,6 +4,7 @@ import 'package:data_table_2/data_table_2.dart';
44import 'package:flutter/material.dart' ;
55import 'package:flutter_bloc/flutter_bloc.dart' ;
66import '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' ;
78import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/app_localizations.dart' ;
89import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/l10n.dart' ;
910import 'package:intl/intl.dart' ;
@@ -35,16 +36,27 @@ class _ArchivedHeadlinesView extends StatelessWidget {
3536 ),
3637 body: Padding (
3738 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+ );
4748 }
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+ }
4860
4961 if (state.status == ArchivedHeadlinesStatus .failure) {
5062 return FailureStateWidget (
@@ -116,16 +128,17 @@ class _ArchivedHeadlinesView extends StatelessWidget {
116128 dataRowHeight: 56 ,
117129 columnSpacing: AppSpacing .md,
118130 horizontalMargin: AppSpacing .md,
119- ),
120131 ),
121- ] ,
132+ ) ,
122133 );
123- },
134+ },
135+ ),
124136 ),
125137 ),
126138 );
127139 }
128140}
141+ }
129142
130143class _HeadlinesDataSource extends DataTableSource {
131144 _HeadlinesDataSource ({
0 commit comments