@@ -122,13 +122,27 @@ class _HeadlinesSearchViewState extends State<_HeadlinesSearchView> {
122
122
color: appBarTheme.iconTheme? .color ?? colorScheme.onSurface,
123
123
),
124
124
items: SearchModelType .values.map ((SearchModelType type) {
125
+ String displayLocalizedName;
126
+ switch (type) {
127
+ case SearchModelType .headline:
128
+ displayLocalizedName = l10n.searchModelTypeHeadline;
129
+ break ;
130
+ case SearchModelType .category:
131
+ displayLocalizedName = l10n.searchModelTypeCategory;
132
+ break ;
133
+ case SearchModelType .source:
134
+ displayLocalizedName = l10n.searchModelTypeSource;
135
+ break ;
136
+ case SearchModelType .country:
137
+ displayLocalizedName = l10n.searchModelTypeCountry;
138
+ break ;
139
+ }
125
140
return DropdownMenuItem <SearchModelType >(
126
141
value: type,
127
142
child: Text (
128
- type.displayName, // Using the new getter
129
- // Ensure text color contrasts with dropdownColor
143
+ displayLocalizedName,
130
144
style: appBarTheme.titleTextStyle? .copyWith (
131
- color: colorScheme.onSurface, // Example color
145
+ color: colorScheme.onSurface,
132
146
) ??
133
147
theme.textTheme.titleLarge? .copyWith (
134
148
color: colorScheme.onSurface,
@@ -144,9 +158,7 @@ class _HeadlinesSearchViewState extends State<_HeadlinesSearchView> {
144
158
context
145
159
.read <HeadlinesSearchBloc >()
146
160
.add (HeadlinesSearchModelTypeChanged (newValue));
147
- if (_textController.text.isNotEmpty) {
148
- _performSearch (); // Re-trigger search with new model type
149
- }
161
+ // DO NOT automatically perform search here
150
162
}
151
163
},
152
164
),
@@ -155,7 +167,7 @@ class _HeadlinesSearchViewState extends State<_HeadlinesSearchView> {
155
167
controller: _textController,
156
168
style: appBarTheme.titleTextStyle ?? theme.textTheme.titleLarge,
157
169
decoration: InputDecoration (
158
- hintText: l10n.headlinesSearchHintText ,
170
+ hintText: _getHintTextForModelType (_selectedModelType, l10n) ,
159
171
hintStyle: (appBarTheme.titleTextStyle ??
160
172
theme.textTheme.titleLarge)
161
173
? .copyWith (color: colorScheme.onSurface.withAlpha (153 )),
@@ -277,4 +289,17 @@ class _HeadlinesSearchViewState extends State<_HeadlinesSearchView> {
277
289
),
278
290
);
279
291
}
292
+
293
+ String _getHintTextForModelType (SearchModelType modelType, AppLocalizations l10n) {
294
+ switch (modelType) {
295
+ case SearchModelType .headline:
296
+ return l10n.searchHintTextHeadline;
297
+ case SearchModelType .category:
298
+ return l10n.searchHintTextCategory;
299
+ case SearchModelType .source:
300
+ return l10n.searchHintTextSource;
301
+ case SearchModelType .country:
302
+ return l10n.searchHintTextCountry;
303
+ }
304
+ }
280
305
}
0 commit comments