Skip to content

Commit d5d08d4

Browse files
committed
feat(content_management): add no results UI when filters are active
- Implement a new UI state to display when no topics are found with active filters - Add a reset filters button to allow users to clear filters and try again - Introduce a helper function to check if any filters are active - Update the TopicsPage to handle the new state and display appropriate UI
1 parent 5bc48d0 commit d5d08d4

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

lib/content_management/view/topics_page.dart

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,22 @@ class _TopicPageState extends State<TopicPage> {
3838
);
3939
}
4040

41+
/// Checks if any filters are currently active in the TopicsFilterBloc.
42+
bool _areFiltersActive(TopicsFilterState state) {
43+
return state.searchQuery.isNotEmpty ||
44+
state.selectedStatus != ContentStatus.active;
45+
}
46+
4147
@override
4248
Widget build(BuildContext context) {
4349
final l10n = AppLocalizationsX(context).l10n;
4450
return Padding(
4551
padding: const EdgeInsets.all(AppSpacing.lg),
4652
child: BlocBuilder<ContentManagementBloc, ContentManagementState>(
4753
builder: (context, state) {
54+
final topicsFilterState = context.watch<TopicsFilterBloc>().state;
55+
final filtersActive = _areFiltersActive(topicsFilterState);
56+
4857
if (state.topicsStatus == ContentManagementStatus.loading &&
4958
state.topics.isEmpty) {
5059
return LoadingStateWidget(
@@ -72,6 +81,29 @@ class _TopicPageState extends State<TopicPage> {
7281
}
7382

7483
if (state.topics.isEmpty) {
84+
if (filtersActive) {
85+
return Center(
86+
child: Column(
87+
mainAxisAlignment: MainAxisAlignment.center,
88+
children: [
89+
Text(
90+
l10n.noResultsWithCurrentFilters,
91+
style: Theme.of(context).textTheme.titleMedium,
92+
textAlign: TextAlign.center,
93+
),
94+
const SizedBox(height: AppSpacing.lg),
95+
ElevatedButton(
96+
onPressed: () {
97+
context.read<TopicsFilterBloc>().add(
98+
const TopicsFilterReset(),
99+
);
100+
},
101+
child: Text(l10n.resetFiltersButtonText),
102+
),
103+
],
104+
),
105+
);
106+
}
75107
return Center(child: Text(l10n.noTopicsFound));
76108
}
77109

0 commit comments

Comments
 (0)