@@ -4,16 +4,30 @@ import 'package:flutter/material.dart';
4
4
import 'package:flutter_bloc/flutter_bloc.dart' ;
5
5
import 'package:ht_data_repository/ht_data_repository.dart' ;
6
6
import 'package:ht_main/headlines-feed/bloc/sources_filter_bloc.dart' ;
7
+ import 'package:ht_main/headlines-feed/view/headlines_filter_page.dart'
8
+ show keySelectedCountryIsoCodes, keySelectedSourceTypes, keySelectedSources;
7
9
import 'package:ht_main/l10n/l10n.dart' ;
8
10
import 'package:ht_main/shared/constants/app_spacing.dart' ;
9
11
import 'package:ht_main/shared/widgets/failure_state_widget.dart' ;
10
12
import 'package:ht_main/shared/widgets/loading_state_widget.dart' ;
11
- import 'package:ht_shared/ht_shared.dart' show Country, Source;
13
+ import 'package:ht_shared/ht_shared.dart' show Country, Source, SourceType;
14
+
15
+ // Keys are defined in headlines_filter_page.dart and imported by router.dart
16
+ // const String keySelectedSources = 'selectedSources'; // REMOVED
17
+ // const String keySelectedCountryIsoCodes = 'selectedCountryIsoCodes'; // REMOVED
18
+ // const String keySelectedSourceTypes = 'selectedSourceTypes'; // REMOVED
12
19
13
20
class SourceFilterPage extends StatelessWidget {
14
- const SourceFilterPage ({super .key, this .initialSelectedSources = const []});
21
+ const SourceFilterPage ({
22
+ super .key,
23
+ this .initialSelectedSources = const [],
24
+ this .initialSelectedCountryIsoCodes = const {},
25
+ this .initialSelectedSourceTypes = const {},
26
+ });
15
27
16
28
final List <Source > initialSelectedSources;
29
+ final Set <String > initialSelectedCountryIsoCodes;
30
+ final Set <SourceType > initialSelectedSourceTypes;
17
31
18
32
@override
19
33
Widget build (BuildContext context) {
@@ -25,6 +39,8 @@ class SourceFilterPage extends StatelessWidget {
25
39
)..add (
26
40
LoadSourceFilterData (
27
41
initialSelectedSources: initialSelectedSources,
42
+ initialSelectedCountryIsoCodes: initialSelectedCountryIsoCodes,
43
+ initialSelectedSourceTypes: initialSelectedSourceTypes,
28
44
),
29
45
),
30
46
child: const _SourceFilterView (),
@@ -63,7 +79,12 @@ class _SourceFilterView extends StatelessWidget {
63
79
(s) => state.finallySelectedSourceIds.contains (s.id),
64
80
)
65
81
.toList ();
66
- Navigator .of (context).pop (selectedSources);
82
+ // Pop with a map containing all relevant filter state
83
+ Navigator .of (context).pop ({
84
+ keySelectedSources: selectedSources,
85
+ keySelectedCountryIsoCodes: state.selectedCountryIsoCodes,
86
+ keySelectedSourceTypes: state.selectedSourceTypes,
87
+ });
67
88
},
68
89
),
69
90
],
@@ -91,10 +112,15 @@ class _SourceFilterView extends StatelessWidget {
91
112
message: state.errorMessage ?? l10n.headlinesFeedFilterErrorCriteria,
92
113
onRetry: () {
93
114
context.read <SourcesFilterBloc >().add (
94
- LoadSourceFilterData (
95
- initialSelectedSources:
96
- ModalRoute .of (context)? .settings.arguments as List <Source >? ??
97
- const [],
115
+ // When retrying, we don't have initial capsule states from arguments
116
+ // So, we pass empty sets, BLoC will load all sources and countries.
117
+ // User can then re-apply capsule filters if needed.
118
+ // Or, we could try to persist/retrieve the last known good capsule state.
119
+ // For now, simple retry reloads all.
120
+ const LoadSourceFilterData (
121
+ initialSelectedSources: [], // Or pass current selections if needed
122
+ initialSelectedCountryIsoCodes: {},
123
+ initialSelectedSourceTypes: {},
98
124
),
99
125
);
100
126
},
0 commit comments