@@ -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 ('yyyy/MM/dd' ).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,
@@ -350,10 +361,25 @@ class _HeadlineDetailsPageState extends State<HeadlineDetailsPage> {
350361 SliverPadding (
351362 padding: horizontalPadding.copyWith (top: AppSpacing .lg),
352363 sliver: SliverToBoxAdapter (
353- child: Wrap (
354- spacing: AppSpacing .md,
355- runSpacing: AppSpacing .sm,
356- children: _buildMetadataChips (context, headline, onEntityChipTap),
364+ child: SizedBox (
365+ height: 36 ,
366+ child: BlocBuilder <HeadlineDetailsBloc , HeadlineDetailsState >(
367+ builder: (context, state) {
368+ final chips = _buildMetadataChips (
369+ context,
370+ headline,
371+ onEntityChipTap,
372+ );
373+ return ListView .separated (
374+ scrollDirection: Axis .horizontal,
375+ itemCount: chips.length,
376+ separatorBuilder: (context, index) =>
377+ const SizedBox (width: AppSpacing .sm),
378+ itemBuilder: (context, index) => chips[index],
379+ clipBehavior: Clip .none,
380+ );
381+ },
382+ ),
357383 ),
358384 ),
359385 ),
@@ -540,102 +566,54 @@ class _HeadlineDetailsPageState extends State<HeadlineDetailsPage> {
540566 final colorScheme = theme.colorScheme;
541567 final chipLabelStyle = textTheme.labelMedium? .copyWith (
542568 color: colorScheme.onSecondaryContainer,
569+ fontWeight: FontWeight .w600,
543570 );
544- final chipBackgroundColor = colorScheme.secondaryContainer;
571+ final chipBackgroundColor = colorScheme.secondaryContainer. withOpacity ( 0.6 ) ;
545572 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,
574- ),
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- ),
573+ const chipAvatarSize = 18.0 ;
574+
575+ Widget buildChip ({
576+ required IconData icon,
577+ required String label,
578+ required VoidCallback onPressed,
579+ }) {
580+ return ActionChip (
581+ avatar: Icon (icon, size: chipAvatarSize, color: chipAvatarColor),
582+ label: Text (label),
583+ labelStyle: chipLabelStyle,
584+ backgroundColor: chipBackgroundColor,
585+ onPressed: onPressed,
586+ visualDensity: VisualDensity .compact,
587+ padding: const EdgeInsets .symmetric (
588+ horizontal: AppSpacing .sm,
589+ vertical: AppSpacing .xs,
594590 ),
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- ),
614- ),
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- ),
591+ shape: RoundedRectangleBorder (
592+ borderRadius: BorderRadius .circular (AppSpacing .lg),
593+ side: BorderSide .none,
635594 ),
636595 );
596+ }
637597
638- return chips;
598+ return [
599+ buildChip (
600+ icon: Icons .source_outlined,
601+ label: headline.source.name,
602+ onPressed: () =>
603+ onEntityChipTap (ContentType .source, headline.source.id),
604+ ),
605+ buildChip (
606+ icon: Icons .category_outlined,
607+ label: headline.topic.name,
608+ onPressed: () => onEntityChipTap (ContentType .topic, headline.topic.id),
609+ ),
610+ buildChip (
611+ icon: Icons .location_city_outlined,
612+ label: headline.eventCountry.name,
613+ onPressed: () =>
614+ onEntityChipTap (ContentType .country, headline.eventCountry.id),
615+ ),
616+ ];
639617 }
640618
641619 Widget _buildSimilarHeadlinesSection (
0 commit comments