@@ -260,52 +260,27 @@ class _FilterDialogState extends State<FilterDialog> {
260260 Wrap (
261261 spacing: AppSpacing .sm,
262262 children: [
263- ChoiceChip (
264- label: Text (l10n.breakingNewsFilterAll), // 'All' option
265- selected: filterDialogState.isBreaking ==
266- BreakingNewsFilterStatus .all,
267- onSelected: (isSelected) {
268- if (isSelected) {
269- context.read <FilterDialogBloc >().add (
270- const FilterDialogBreakingNewsChanged (
271- BreakingNewsFilterStatus .all,
272- ),
273- );
274- }
275- },
276- ),
277- ChoiceChip (
278- label: Text (
279- l10n.breakingNewsFilterBreakingOnly,
280- ), // 'Breaking Only'
281- selected: filterDialogState.isBreaking ==
282- BreakingNewsFilterStatus .breakingOnly,
283- onSelected: (isSelected) {
284- if (isSelected) {
285- context.read <FilterDialogBloc >().add (
286- const FilterDialogBreakingNewsChanged (
287- BreakingNewsFilterStatus .breakingOnly,
288- ),
289- );
290- }
291- },
292- ),
293- ChoiceChip (
294- label: Text (
295- l10n.breakingNewsFilterNonBreakingOnly,
296- ), // 'Non-Breaking'
297- selected: filterDialogState.isBreaking ==
298- BreakingNewsFilterStatus .nonBreakingOnly,
299- onSelected: (isSelected) {
300- if (isSelected) {
301- context.read <FilterDialogBloc >().add (
302- const FilterDialogBreakingNewsChanged (
303- BreakingNewsFilterStatus .nonBreakingOnly,
304- ),
305- );
306- }
307- },
308- ),
263+ ...BreakingNewsFilterStatus .values.map ((status) {
264+ return ChoiceChip (
265+ label: Text (_getBreakingNewsStatusL10n (status, l10n)),
266+ selected: filterDialogState.isBreaking == status,
267+ onSelected: (isSelected) {
268+ if (isSelected) {
269+ context.read <FilterDialogBloc >().add (
270+ FilterDialogBreakingNewsChanged (status),
271+ );
272+ }
273+ },
274+ selectedColor: Theme .of (
275+ context,
276+ ).colorScheme.primaryContainer,
277+ labelStyle: TextStyle (
278+ color: filterDialogState.isBreaking == status
279+ ? Theme .of (context).colorScheme.onPrimaryContainer
280+ : Theme .of (context).colorScheme.onSurface,
281+ ),
282+ );
283+ }),
309284 ],
310285 ),
311286 const SizedBox (height: AppSpacing .lg),
@@ -551,6 +526,21 @@ class _FilterDialogState extends State<FilterDialog> {
551526 }
552527 }
553528
529+ /// Returns the localized string for a given [BreakingNewsFilterStatus] .
530+ String _getBreakingNewsStatusL10n (
531+ BreakingNewsFilterStatus status,
532+ AppLocalizations l10n,
533+ ) {
534+ switch (status) {
535+ case BreakingNewsFilterStatus .all:
536+ return l10n.breakingNewsFilterAll;
537+ case BreakingNewsFilterStatus .breakingOnly:
538+ return l10n.breakingNewsFilterBreakingOnly;
539+ case BreakingNewsFilterStatus .nonBreakingOnly:
540+ return l10n.breakingNewsFilterNonBreakingOnly;
541+ }
542+ }
543+
554544 /// Dispatches the filter applied event to the appropriate BLoC.
555545 void _dispatchFilterApplied (FilterDialogState filterDialogState) {
556546 switch (widget.activeTab) {
0 commit comments