@@ -311,6 +311,17 @@ class _HeadlineDetailsPageState extends State<HeadlineDetailsPage> {
311311 ),
312312 ),
313313 ),
314+ SliverPadding (
315+ padding: horizontalPadding.copyWith (top: AppSpacing .md),
316+ sliver: SliverToBoxAdapter (
317+ child: Text (
318+ DateFormat ('MMM d, yyyy' ).format (headline.createdAt),
319+ style: textTheme.bodyMedium? .copyWith (
320+ color: colorScheme.onSurfaceVariant.withOpacity (0.7 ),
321+ ),
322+ ),
323+ ),
324+ ),
314325 SliverPadding (
315326 padding: EdgeInsets .only (
316327 top: AppSpacing .md,
@@ -347,13 +358,22 @@ class _HeadlineDetailsPageState extends State<HeadlineDetailsPage> {
347358 ),
348359 ),
349360 ),
350- SliverPadding (
351- padding: horizontalPadding.copyWith (top: AppSpacing .lg),
352- sliver: SliverToBoxAdapter (
353- child: Wrap (
354- spacing: AppSpacing .md,
355- runSpacing: AppSpacing .sm,
356- children: _buildMetadataChips (context, headline, onEntityChipTap),
361+ SliverToBoxAdapter (
362+ child: SizedBox (
363+ height: 52 ,
364+ child: BlocBuilder <HeadlineDetailsBloc , HeadlineDetailsState >(
365+ builder: (context, state) {
366+ final chips =
367+ _buildMetadataChips (context, headline, onEntityChipTap);
368+ return ListView .separated (
369+ scrollDirection: Axis .horizontal,
370+ padding: horizontalPadding.copyWith (top: AppSpacing .lg),
371+ itemCount: chips.length,
372+ separatorBuilder: (context, index) =>
373+ const SizedBox (width: AppSpacing .sm),
374+ itemBuilder: (context, index) => chips[index],
375+ );
376+ },
357377 ),
358378 ),
359379 ),
@@ -540,102 +560,57 @@ class _HeadlineDetailsPageState extends State<HeadlineDetailsPage> {
540560 final colorScheme = theme.colorScheme;
541561 final chipLabelStyle = textTheme.labelMedium? .copyWith (
542562 color: colorScheme.onSecondaryContainer,
563+ fontWeight: FontWeight .w600,
543564 );
544- final chipBackgroundColor = colorScheme.secondaryContainer;
565+ final chipBackgroundColor = colorScheme.secondaryContainer. withOpacity ( 0.6 ) ;
545566 final chipAvatarColor = colorScheme.onSecondaryContainer;
546- const chipAvatarSize = AppSpacing .md;
547- const chipPadding = EdgeInsets .symmetric (
548- horizontal: AppSpacing .sm,
549- vertical: AppSpacing .xs,
550- );
551- final chipShape = RoundedRectangleBorder (
552- borderRadius: BorderRadius .circular (AppSpacing .sm),
553- side: BorderSide (color: colorScheme.outlineVariant.withOpacity (0.3 )),
554- );
555-
556- final chips = < Widget > [];
557-
558- final formattedDate = DateFormat ('MMM d, yyyy' ).format (headline.createdAt);
559- chips
560- ..add (
561- Chip (
562- avatar: Icon (
563- Icons .calendar_today_outlined,
564- size: chipAvatarSize,
565- color: chipAvatarColor,
566- ),
567- label: Text (formattedDate),
568- labelStyle: chipLabelStyle,
569- backgroundColor: chipBackgroundColor,
570- padding: chipPadding,
571- shape: chipShape,
572- visualDensity: VisualDensity .compact,
573- materialTapTargetSize: MaterialTapTargetSize .shrinkWrap,
567+ const chipAvatarSize = 18.0 ;
568+
569+ Widget buildChip ({
570+ required IconData icon,
571+ required String label,
572+ required VoidCallback onPressed,
573+ }) {
574+ return ActionChip (
575+ avatar: Icon (
576+ icon,
577+ size: chipAvatarSize,
578+ color: chipAvatarColor,
574579 ),
575- )
576- ..add (
577- InkWell (
578- onTap: () => onEntityChipTap (ContentType .source, headline.source.id),
579- borderRadius: BorderRadius .circular (AppSpacing .sm),
580- child: Chip (
581- avatar: Icon (
582- Icons .source_outlined,
583- size: chipAvatarSize,
584- color: chipAvatarColor,
585- ),
586- label: Text (headline.source.name),
587- labelStyle: chipLabelStyle,
588- backgroundColor: chipBackgroundColor,
589- padding: chipPadding,
590- shape: chipShape,
591- visualDensity: VisualDensity .compact,
592- materialTapTargetSize: MaterialTapTargetSize .shrinkWrap,
593- ),
594- ),
595- )
596- ..add (
597- InkWell (
598- onTap: () => onEntityChipTap (ContentType .topic, headline.topic.id),
599- borderRadius: BorderRadius .circular (AppSpacing .sm),
600- child: Chip (
601- avatar: Icon (
602- Icons .category_outlined,
603- size: chipAvatarSize,
604- color: chipAvatarColor,
605- ),
606- label: Text (headline.topic.name),
607- labelStyle: chipLabelStyle,
608- backgroundColor: chipBackgroundColor,
609- padding: chipPadding,
610- shape: chipShape,
611- visualDensity: VisualDensity .compact,
612- materialTapTargetSize: MaterialTapTargetSize .shrinkWrap,
613- ),
580+ label: Text (label),
581+ labelStyle: chipLabelStyle,
582+ backgroundColor: chipBackgroundColor,
583+ onPressed: onPressed,
584+ visualDensity: VisualDensity .compact,
585+ padding: const EdgeInsets .symmetric (
586+ horizontal: AppSpacing .sm,
587+ vertical: AppSpacing .xs,
614588 ),
615- )
616- ..add (
617- InkWell (
618- onTap: () =>
619- onEntityChipTap (ContentType .country, headline.eventCountry.id),
620- borderRadius: BorderRadius .circular (AppSpacing .sm),
621- child: Chip (
622- avatar: Icon (
623- Icons .location_city_outlined,
624- size: chipAvatarSize,
625- color: chipAvatarColor,
626- ),
627- label: Text (headline.eventCountry.name),
628- labelStyle: chipLabelStyle,
629- backgroundColor: chipBackgroundColor,
630- padding: chipPadding,
631- shape: chipShape,
632- visualDensity: VisualDensity .compact,
633- materialTapTargetSize: MaterialTapTargetSize .shrinkWrap,
634- ),
589+ shape: RoundedRectangleBorder (
590+ borderRadius: BorderRadius .circular (AppSpacing .lg),
591+ side: BorderSide .none,
635592 ),
636593 );
594+ }
637595
638- return chips;
596+ return [
597+ buildChip (
598+ icon: Icons .source_outlined,
599+ label: headline.source.name,
600+ onPressed: () => onEntityChipTap (ContentType .source, headline.source.id),
601+ ),
602+ buildChip (
603+ icon: Icons .category_outlined,
604+ label: headline.topic.name,
605+ onPressed: () => onEntityChipTap (ContentType .topic, headline.topic.id),
606+ ),
607+ buildChip (
608+ icon: Icons .location_city_outlined,
609+ label: headline.eventCountry.name,
610+ onPressed: () =>
611+ onEntityChipTap (ContentType .country, headline.eventCountry.id),
612+ ),
613+ ];
639614 }
640615
641616 Widget _buildSimilarHeadlinesSection (
0 commit comments