Skip to content

Commit ed98b8f

Browse files
committed
feat(headlines-feed): implement filter event classes
- Define base HeadlinesFilterEvent class - Add FilterDataLoaded event for initial filter data load - Implement FilterTopicToggled, FilterSourceToggled, and FilterCountryToggled events for checkbox toggles - Add FollowedItemsFilterToggled event for followed items toggle - Implement FilterSelectionsCleared event to clear all filters
1 parent 32f57d9 commit ed98b8f

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
part of 'headlines_filter_bloc.dart';
2+
3+
/// {@template headlines_filter_event}
4+
/// Base class for all events in the [HeadlinesFilterBloc].
5+
/// {@endtemplate}
6+
sealed class HeadlinesFilterEvent extends Equatable {
7+
/// {@macro headlines_filter_event}
8+
const HeadlinesFilterEvent();
9+
10+
@override
11+
List<Object> get props => [];
12+
}
13+
14+
/// {@template filter_data_loaded}
15+
/// Event triggered to load all initial filter data (topics, sources, countries).
16+
///
17+
/// This event is dispatched when the filter page is initialized.
18+
/// {@endtemplate}
19+
final class FilterDataLoaded extends HeadlinesFilterEvent {
20+
/// {@macro filter_data_loaded}
21+
const FilterDataLoaded({
22+
this.initialSelectedTopics = const [],
23+
this.initialSelectedSources = const [],
24+
this.initialSelectedCountries = const [],
25+
this.isUsingFollowedItems = false,
26+
});
27+
28+
/// The topics that were initially selected on the previous page.
29+
final List<Topic> initialSelectedTopics;
30+
31+
/// The sources that were initially selected on the previous page.
32+
final List<Source> initialSelectedSources;
33+
34+
/// The countries that were initially selected on the previous page.
35+
final List<Country> initialSelectedCountries;
36+
37+
/// Whether the filter is initially set to use followed items.
38+
final bool isUsingFollowedItems;
39+
40+
@override
41+
List<Object> get props => [
42+
initialSelectedTopics,
43+
initialSelectedSources,
44+
initialSelectedCountries,
45+
isUsingFollowedItems,
46+
];
47+
}
48+
49+
/// {@template filter_topic_toggled}
50+
/// Event triggered when a topic checkbox is toggled.
51+
/// {@endtemplate}
52+
final class FilterTopicToggled extends HeadlinesFilterEvent {
53+
/// {@macro filter_topic_toggled}
54+
const FilterTopicToggled({required this.topic, required this.isSelected});
55+
56+
/// The [Topic] that was toggled.
57+
final Topic topic;
58+
59+
/// The new selection state of the topic.
60+
final bool isSelected;
61+
62+
@override
63+
List<Object> get props => [topic, isSelected];
64+
}
65+
66+
/// {@template filter_source_toggled}
67+
/// Event triggered when a source checkbox is toggled.
68+
/// {@endtemplate}
69+
final class FilterSourceToggled extends HeadlinesFilterEvent {
70+
/// {@macro filter_source_toggled}
71+
const FilterSourceToggled({required this.source, required this.isSelected});
72+
73+
/// The [Source] that was toggled.
74+
final Source source;
75+
76+
/// The new selection state of the source.
77+
final bool isSelected;
78+
79+
@override
80+
List<Object> get props => [source, isSelected];
81+
}
82+
83+
/// {@template filter_country_toggled}
84+
/// Event triggered when a country checkbox is toggled.
85+
/// {@endtemplate}
86+
final class FilterCountryToggled extends HeadlinesFilterEvent {
87+
/// {@macro filter_country_toggled}
88+
const FilterCountryToggled({required this.country, required this.isSelected});
89+
90+
/// The [Country] that was toggled.
91+
final Country country;
92+
93+
/// The new selection state of the country.
94+
final bool isSelected;
95+
96+
@override
97+
List<Object> get props => [country, isSelected];
98+
}
99+
100+
/// {@template followed_items_filter_toggled}
101+
/// Event triggered when the "Apply my followed items" button is toggled.
102+
/// {@endtemplate}
103+
final class FollowedItemsFilterToggled extends HeadlinesFilterEvent {
104+
/// {@macro followed_items_filter_toggled}
105+
const FollowedItemsFilterToggled({required this.isUsingFollowedItems});
106+
107+
/// The new state of the "Apply my followed items" toggle.
108+
final bool isUsingFollowedItems;
109+
110+
@override
111+
List<Object> get props => [isUsingFollowedItems];
112+
}
113+
114+
/// {@template filter_selections_cleared}
115+
/// Event triggered to clear all active filter selections.
116+
/// {@endtemplate}
117+
final class FilterSelectionsCleared extends HeadlinesFilterEvent {
118+
/// {@macro filter_selections_cleared}
119+
const FilterSelectionsCleared();
120+
}

0 commit comments

Comments
 (0)