Skip to content

Commit 71c95dd

Browse files
committed
refactor(feed): show clear filters button on empty feed
- Replaced InitialStateWidget with FailureState - Added retry button to clear filters
1 parent 4d81041 commit 71c95dd

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

lib/headlines-feed/view/headlines_feed_page.dart

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -168,18 +168,16 @@ class _HeadlinesFeedPageState extends State<HeadlinesFeedPage> {
168168

169169
case HeadlinesFeedLoaded():
170170
if (state.headlines.isEmpty) {
171-
// If the list is empty, show an informative message using the
172-
// shared InitialStateWidget. This is especially relevant after
173-
// filters are applied and yield no results, or if the initial
174-
// unfiltered feed is empty.
175-
return InitialStateWidget(
176-
icon:
177-
Icons
178-
.search_off_outlined, // Visually indicates no results
179-
headline:
180-
l10n.headlinesFeedEmptyFilteredHeadline, // Placeholder l10n
181-
subheadline:
182-
l10n.headlinesFeedEmptyFilteredSubheadline, // Placeholder l10n
171+
// If the list is empty after filters, show a message
172+
// with a "Clear Filters" button using FailureStateWidget.
173+
return FailureStateWidget(
174+
message: '${l10n.headlinesFeedEmptyFilteredHeadline}\n${l10n.headlinesFeedEmptyFilteredSubheadline}',
175+
onRetry: () { // This will be our "Clear Filters" action
176+
context.read<HeadlinesFeedBloc>().add(
177+
HeadlinesFeedFiltersCleared(),
178+
);
179+
},
180+
retryButtonText: l10n.headlinesFeedClearFiltersButton, // New l10n string
183181
);
184182
}
185183
// Display the list of headlines with pull-to-refresh

lib/l10n/arb/app_ar.arb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,5 +557,9 @@
557557
"headlinesFeedEmptyFilteredSubheadline": "حاول تعديل معايير الفلترة أو مسحها لرؤية جميع العناوين.",
558558
"@headlinesFeedEmptyFilteredSubheadline": {
559559
"description": "Subheadline text shown when headline filters result in an empty list"
560+
},
561+
"headlinesFeedClearFiltersButton": "مسح الفلاتر",
562+
"@headlinesFeedClearFiltersButton": {
563+
"description": "Button text to clear applied headline filters"
560564
}
561565
}

lib/l10n/arb/app_en.arb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,5 +557,9 @@
557557
"headlinesFeedEmptyFilteredSubheadline": "Try adjusting your filter criteria or clearing them to see all headlines.",
558558
"@headlinesFeedEmptyFilteredSubheadline": {
559559
"description": "Subheadline text shown when headline filters result in an empty list"
560+
},
561+
"headlinesFeedClearFiltersButton": "Clear Filters",
562+
"@headlinesFeedClearFiltersButton": {
563+
"description": "Button text to clear applied headline filters"
560564
}
561565
}

0 commit comments

Comments
 (0)