Skip to content

Commit 8ed93f0

Browse files
committed
feat(content_management): add no results UI and filter reset functionality
- Add UI for when no headlines are found with active filters - Implement filter reset button to clear all active filters - Create _areFiltersActive function to check for active filters - Update build method to handle empty headlines list with
1 parent fa9f56c commit 8ed93f0

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

lib/content_management/view/headlines_page.dart

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,26 @@ class _HeadlinesPageState extends State<HeadlinesPage> {
3838
);
3939
}
4040

41+
/// Checks if any filters are currently active in the HeadlinesFilterBloc.
42+
bool _areFiltersActive(HeadlinesFilterState state) {
43+
return state.searchQuery.isNotEmpty ||
44+
state.selectedStatus != ContentStatus.active ||
45+
state.selectedSourceIds.isNotEmpty ||
46+
state.selectedTopicIds.isNotEmpty ||
47+
state.selectedCountryIds.isNotEmpty;
48+
}
49+
4150
@override
4251
Widget build(BuildContext context) {
4352
final l10n = AppLocalizationsX(context).l10n;
4453
return Padding(
4554
padding: const EdgeInsets.all(AppSpacing.lg),
4655
child: BlocBuilder<ContentManagementBloc, ContentManagementState>(
4756
builder: (context, state) {
57+
final headlinesFilterState =
58+
context.watch<HeadlinesFilterBloc>().state;
59+
final filtersActive = _areFiltersActive(headlinesFilterState);
60+
4861
if (state.headlinesStatus == ContentManagementStatus.loading &&
4962
state.headlines.isEmpty) {
5063
return LoadingStateWidget(
@@ -72,6 +85,29 @@ class _HeadlinesPageState extends State<HeadlinesPage> {
7285
}
7386

7487
if (state.headlines.isEmpty) {
88+
if (filtersActive) {
89+
return Center(
90+
child: Column(
91+
mainAxisAlignment: MainAxisAlignment.center,
92+
children: [
93+
Text(
94+
l10n.noResultsWithCurrentFilters,
95+
style: Theme.of(context).textTheme.titleMedium,
96+
textAlign: TextAlign.center,
97+
),
98+
const SizedBox(height: AppSpacing.lg),
99+
ElevatedButton(
100+
onPressed: () {
101+
context.read<HeadlinesFilterBloc>().add(
102+
const HeadlinesFilterReset(),
103+
);
104+
},
105+
child: Text(l10n.resetFiltersButtonText),
106+
),
107+
],
108+
),
109+
);
110+
}
75111
return Center(child: Text(l10n.noHeadlinesFound));
76112
}
77113

0 commit comments

Comments
 (0)