Skip to content

Commit e740bdf

Browse files
committed
style: misc
1 parent 926f281 commit e740bdf

File tree

11 files changed

+109
-95
lines changed

11 files changed

+109
-95
lines changed

analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ analyzer:
33
avoid_catches_without_on_clauses: ignore
44
avoid_print: ignore
55
document_ignores: ignore
6+
flutter_style_todos: ignore
67
lines_longer_than_80_chars: ignore
78
use_if_null_to_convert_nulls_to_bools: ignore
89
include: package:very_good_analysis/analysis_options.7.0.0.yaml

lib/account/view/content_preferences_page.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ class ContentPreferencesPage extends StatelessWidget {
234234
ElevatedButton.icon(
235235
icon: const Icon(Icons.add_circle_outline),
236236
label: Text(l10n.headlinesFeedFilterEventCountryLabel), // "Country"
237-
onPressed: null, // TODO: Implement new navigation/management for followed countries
237+
onPressed:
238+
null, // TODO: Implement new navigation/management for followed countries
238239
),
239240
],
240241
);

lib/headlines-feed/bloc/sources_filter_bloc.dart

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@ import 'package:ht_shared/ht_shared.dart'
99
part 'sources_filter_event.dart';
1010
part 'sources_filter_state.dart';
1111

12-
class SourcesFilterBloc
13-
extends Bloc<SourcesFilterEvent, SourcesFilterState> {
12+
class SourcesFilterBloc extends Bloc<SourcesFilterEvent, SourcesFilterState> {
1413
SourcesFilterBloc({
1514
required HtDataRepository<Source> sourcesRepository,
1615
required HtDataRepository<Country> countriesRepository,
17-
}) : _sourcesRepository = sourcesRepository,
18-
_countriesRepository = countriesRepository,
19-
super(const SourcesFilterState()) {
16+
}) : _sourcesRepository = sourcesRepository,
17+
_countriesRepository = countriesRepository,
18+
super(const SourcesFilterState()) {
2019
on<LoadSourceFilterData>(_onLoadSourceFilterData);
2120
on<CountryCapsuleToggled>(_onCountryCapsuleToggled);
2221
on<AllSourceTypesCapsuleToggled>(_onAllSourceTypesCapsuleToggled); // Added
@@ -34,18 +33,16 @@ class SourcesFilterBloc
3433
Emitter<SourcesFilterState> emit,
3534
) async {
3635
emit(
37-
state.copyWith(
38-
dataLoadingStatus: SourceFilterDataLoadingStatus.loading,
39-
),
36+
state.copyWith(dataLoadingStatus: SourceFilterDataLoadingStatus.loading),
4037
);
4138
try {
4239
final availableCountries = await _countriesRepository.readAll();
4340
final initialSelectedSourceIds =
4441
event.initialSelectedSources.map((s) => s.id).toSet();
45-
42+
4643
// Initialize selected capsules based on initialSelectedSources
47-
final Set<String> initialSelectedCountryIsoCodes = {};
48-
final Set<SourceType> initialSelectedSourceTypes = {};
44+
final initialSelectedCountryIsoCodes = <String>{};
45+
final initialSelectedSourceTypes = <SourceType>{};
4946

5047
if (event.initialSelectedSources.isNotEmpty) {
5148
for (final source in event.initialSelectedSources) {
@@ -84,7 +81,8 @@ class SourcesFilterBloc
8481
Emitter<SourcesFilterState> emit,
8582
) async {
8683
final currentSelected = Set<String>.from(state.selectedCountryIsoCodes);
87-
if (event.countryIsoCode.isEmpty) { // "All Countries" toggled
84+
if (event.countryIsoCode.isEmpty) {
85+
// "All Countries" toggled
8886
// If "All" is tapped and it's already effectively "All" (empty set), or if it's tapped to select "All"
8987
// we clear the set. If specific items are selected and "All" is tapped, it also clears.
9088
// Essentially, tapping "All" always results in an empty set, meaning no country filter.
@@ -163,23 +161,21 @@ class SourcesFilterBloc
163161
state.copyWith(
164162
dataLoadingStatus: SourceFilterDataLoadingStatus.loading,
165163
displayableSources: [], // Clear previous sources
166-
errorMessage: null,
167164
clearErrorMessage: true,
168165
),
169166
);
170167
try {
171168
final queryParameters = <String, dynamic>{};
172169
if (state.selectedCountryIsoCodes.isNotEmpty) {
173-
queryParameters['countries'] =
174-
state.selectedCountryIsoCodes.join(',');
170+
queryParameters['countries'] = state.selectedCountryIsoCodes.join(',');
175171
}
176172
if (state.selectedSourceTypes.isNotEmpty) {
177-
queryParameters['sourceTypes'] =
178-
state.selectedSourceTypes.map((st) => st.name).join(',');
173+
queryParameters['sourceTypes'] = state.selectedSourceTypes
174+
.map((st) => st.name)
175+
.join(',');
179176
}
180177

181-
final response =
182-
await _sourcesRepository.readAllByQuery(queryParameters);
178+
final response = await _sourcesRepository.readAllByQuery(queryParameters);
183179
emit(
184180
state.copyWith(
185181
displayableSources: response.items,

lib/headlines-feed/bloc/sources_filter_event.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// ignore_for_file: avoid_positional_boolean_parameters
2+
13
part of 'sources_filter_bloc.dart';
24

35
abstract class SourcesFilterEvent extends Equatable {

lib/headlines-feed/bloc/sources_filter_state.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ class SourcesFilterState extends Equatable {
5353

5454
@override
5555
List<Object?> get props => [
56-
availableCountries,
57-
selectedCountryIsoCodes,
58-
availableSourceTypes,
59-
selectedSourceTypes,
60-
displayableSources,
61-
finallySelectedSourceIds,
62-
dataLoadingStatus,
63-
errorMessage,
64-
];
56+
availableCountries,
57+
selectedCountryIsoCodes,
58+
availableSourceTypes,
59+
selectedSourceTypes,
60+
displayableSources,
61+
finallySelectedSourceIds,
62+
dataLoadingStatus,
63+
errorMessage,
64+
];
6565
}

lib/headlines-feed/models/headline_filter.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ class HeadlineFilter extends Equatable {
2121

2222
/// Creates a copy of this [HeadlineFilter] with the given fields
2323
/// replaced with the new values.
24-
HeadlineFilter copyWith({
25-
List<Category>? categories,
26-
List<Source>? sources,
27-
}) {
24+
HeadlineFilter copyWith({List<Category>? categories, List<Source>? sources}) {
2825
return HeadlineFilter(
2926
categories: categories ?? this.categories,
3027
sources: sources ?? this.sources,

lib/headlines-feed/view/headlines_feed_page.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ import 'package:ht_main/headlines-feed/bloc/headlines_feed_bloc.dart';
1010
import 'package:ht_main/headlines-feed/widgets/headline_item_widget.dart';
1111
import 'package:ht_main/l10n/l10n.dart';
1212
import 'package:ht_main/router/routes.dart';
13-
import 'package:ht_main/shared/constants/constants.dart';
1413
import 'package:ht_main/shared/shared.dart';
15-
import 'package:ht_main/shared/widgets/failure_state_widget.dart';
16-
import 'package:ht_main/shared/widgets/loading_state_widget.dart';
1714
// Import Source
1815

1916
/// {@template headlines_feed_view}
@@ -171,13 +168,16 @@ class _HeadlinesFeedPageState extends State<HeadlinesFeedPage> {
171168
// If the list is empty after filters, show a message
172169
// with a "Clear Filters" button using FailureStateWidget.
173170
return FailureStateWidget(
174-
message: '${l10n.headlinesFeedEmptyFilteredHeadline}\n${l10n.headlinesFeedEmptyFilteredSubheadline}',
175-
onRetry: () { // This will be our "Clear Filters" action
171+
message:
172+
'${l10n.headlinesFeedEmptyFilteredHeadline}\n${l10n.headlinesFeedEmptyFilteredSubheadline}',
173+
onRetry: () {
174+
// This will be our "Clear Filters" action
176175
context.read<HeadlinesFeedBloc>().add(
177176
HeadlinesFeedFiltersCleared(),
178177
);
179178
},
180-
retryButtonText: l10n.headlinesFeedClearFiltersButton, // New l10n string
179+
retryButtonText:
180+
l10n.headlinesFeedClearFiltersButton, // New l10n string
181181
);
182182
}
183183
// Display the list of headlines with pull-to-refresh

0 commit comments

Comments
 (0)