Skip to content

Commit 839b903

Browse files
committed
feat(details): Enhance source/country chips
- Use source.name & country.name - Show country flag as chip avatar - Use category.name
1 parent b5e9493 commit 839b903

File tree

1 file changed

+27
-23
lines changed

1 file changed

+27
-23
lines changed

lib/headline-details/view/headline_details_page.dart

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -246,15 +246,16 @@ class _HeadlineDetailsView extends StatelessWidget {
246246

247247
// Source Chip
248248
if (headline.source != null) {
249-
// TODO(fulleni): Replace Icon with Image.network when source.logoUrl is available
249+
// Source model doesn't have a logoUrl, using a generic icon.
250250
chips.add(
251251
Chip(
252252
avatar: Icon(
253-
Icons.source,
253+
Icons.source, // Generic source icon
254254
size: chipAvatarSize,
255255
color: chipAvatarColor,
256256
),
257-
label: Text(headline.source!),
257+
// Use source.name
258+
label: Text(headline.source!.name),
258259
labelStyle: chipLabelStyle,
259260
backgroundColor: chipBackgroundColor,
260261
padding: chipPadding,
@@ -288,15 +289,19 @@ class _HeadlineDetailsView extends StatelessWidget {
288289

289290
// Country Chip
290291
if (headline.eventCountry != null) {
291-
// TODO(fulleni): Replace Icon with Image.network when country.flagUrl is available
292+
// Use country.flagUrl for the avatar
292293
chips.add(
293294
Chip(
294-
avatar: Icon(
295-
Icons.location_on,
296-
size: chipAvatarSize,
297-
color: chipAvatarColor,
295+
avatar: CircleAvatar( // Use CircleAvatar for better image display
296+
radius: chipAvatarSize / 2, // Adjust radius as needed
297+
backgroundColor: Colors.transparent, // Avoid background color clash
298+
backgroundImage: NetworkImage(headline.eventCountry!.flagUrl),
299+
onBackgroundImageError: (exception, stackTrace) {
300+
// Optional: Handle image loading errors, e.g., show placeholder
301+
},
298302
),
299-
label: Text(headline.eventCountry!),
303+
// Use eventCountry.name
304+
label: Text(headline.eventCountry!.name),
300305
labelStyle: chipLabelStyle,
301306
backgroundColor: chipBackgroundColor,
302307
padding: chipPadding,
@@ -306,20 +311,19 @@ class _HeadlineDetailsView extends StatelessWidget {
306311
);
307312
}
308313

309-
// Category Chips (No avatar for individual categories)
310-
if (headline.categories != null) {
311-
for (final category in headline.categories!) {
312-
chips.add(
313-
Chip(
314-
label: Text(category),
315-
labelStyle: chipLabelStyle,
316-
backgroundColor: chipBackgroundColor,
317-
padding: chipPadding,
318-
visualDensity: chipVisualDensity,
319-
materialTapTargetSize: chipMaterialTapTargetSize,
320-
),
321-
);
322-
}
314+
// Category Chip (No avatar for individual category)
315+
if (headline.category != null) {
316+
chips.add(
317+
Chip(
318+
// Use category.name
319+
label: Text(headline.category!.name),
320+
labelStyle: chipLabelStyle,
321+
backgroundColor: chipBackgroundColor,
322+
padding: chipPadding,
323+
visualDensity: chipVisualDensity,
324+
materialTapTargetSize: chipMaterialTapTargetSize,
325+
),
326+
);
323327
}
324328

325329
return chips;

0 commit comments

Comments
 (0)