Skip to content

Commit 98e4e92

Browse files
committed
refactor(headlines-feed): enhance source filter list UI and functionality
- Replace CheckboxListTile with ListTile for better customization - Add source logo image with error handling - Improve checkbox tap interaction - Optimize layout and spacing
1 parent 0e23789 commit 98e4e92

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

lib/headlines-feed/view/source_filter_page.dart

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,33 @@ class _SourceFilterViewState extends State<_SourceFilterView> {
9494
itemCount: displayableSources.length,
9595
itemBuilder: (context, index) {
9696
final source = displayableSources[index];
97-
return CheckboxListTile(
97+
final isSelected = filterState.selectedSources.contains(source);
98+
99+
void handleTap(bool? value) {
100+
if (value != null) {
101+
context.read<HeadlinesFilterBloc>().add(
102+
FilterSourceToggled(source: source, isSelected: value),
103+
);
104+
}
105+
}
106+
107+
return ListTile(
108+
leading: SizedBox(
109+
width: 40,
110+
height: 40,
111+
child: ClipRRect(
112+
borderRadius: BorderRadius.circular(AppSpacing.sm),
113+
child: Image.network(
114+
source.logoUrl,
115+
fit: BoxFit.cover,
116+
errorBuilder: (context, error, stackTrace) =>
117+
const Icon(Icons.source_outlined),
118+
),
119+
),
120+
),
98121
title: Text(source.name, style: textTheme.titleMedium),
99-
value: filterState.selectedSources.contains(source),
100-
onChanged: (bool? value) {
101-
if (value != null) {
102-
context.read<HeadlinesFilterBloc>().add(
103-
FilterSourceToggled(source: source, isSelected: value),
104-
);
105-
}
106-
},
107-
controlAffinity: ListTileControlAffinity.leading,
122+
trailing: Checkbox(value: isSelected, onChanged: handleTap),
123+
onTap: () => handleTap(!isSelected),
108124
contentPadding: const EdgeInsets.symmetric(
109125
horizontal: AppSpacing.paddingMedium,
110126
),

0 commit comments

Comments
 (0)