Skip to content

Commit a0ceb42

Browse files
committed
refactor(headlines): improve layout and user interaction for headline tiles
- Adjust headline source row layout and make it non-interactive - Enhance headline tile text-only layout with better padding and structure - Improve breaking news display by integrating it into the main text span
1 parent 09e7185 commit a0ceb42

File tree

2 files changed

+61
-71
lines changed

2 files changed

+61
-71
lines changed

lib/shared/widgets/feed_core/headline_source_row.dart

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -61,37 +61,35 @@ class _HeadlineSourceRowState extends State<HeadlineSourceRow> {
6161
mainAxisAlignment: MainAxisAlignment.spaceBetween,
6262
children: [
6363
Expanded(
64-
child: InkWell(
65-
onTap: () => widget._handleEntityTap(context),
66-
child: Row(
67-
mainAxisSize: MainAxisSize.min,
68-
children: [
69-
SizedBox(
70-
width: AppSpacing.md,
71-
height: AppSpacing.md,
72-
child: ClipRRect(
73-
borderRadius: BorderRadius.circular(AppSpacing.xs / 2),
74-
child: Image.network(
75-
widget.headline.source.logoUrl,
76-
fit: BoxFit.cover,
77-
errorBuilder: (context, error, stackTrace) => Icon(
78-
Icons.source_outlined,
79-
size: AppSpacing.md,
80-
color: colorScheme.onSurfaceVariant,
64+
child: Row(
65+
children: [
66+
InkWell(
67+
onTap: () => widget._handleEntityTap(context),
68+
child: Row(
69+
mainAxisSize: MainAxisSize.min,
70+
children: [
71+
SizedBox(
72+
width: AppSpacing.md,
73+
height: AppSpacing.md,
74+
child: ClipRRect(
75+
borderRadius: BorderRadius.circular(AppSpacing.xs / 2),
76+
child: Image.network(
77+
widget.headline.source.logoUrl,
78+
fit: BoxFit.cover,
79+
errorBuilder: (context, error, stackTrace) => Icon(
80+
Icons.source_outlined,
81+
size: AppSpacing.md,
82+
color: colorScheme.onSurfaceVariant,
83+
),
84+
),
8185
),
8286
),
83-
),
87+
const SizedBox(width: AppSpacing.xs),
88+
Text(widget.headline.source.name, style: sourceTextStyle),
89+
],
8490
),
85-
const SizedBox(width: AppSpacing.xs),
86-
Flexible(
87-
child: Text(
88-
widget.headline.source.name,
89-
style: sourceTextStyle,
90-
overflow: TextOverflow.ellipsis,
91-
),
92-
),
93-
],
94-
),
91+
),
92+
],
9593
),
9694
),
9795
Row(

lib/shared/widgets/feed_core/headline_tile_text_only.dart

Lines changed: 35 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -47,55 +47,47 @@ class HeadlineTileTextOnly extends StatelessWidget {
4747
horizontal: AppSpacing.paddingMedium,
4848
vertical: AppSpacing.xs,
4949
),
50-
child: InkWell(
51-
onTap:
52-
onHeadlineTap ??
53-
() => HeadlineTapHandler.handleHeadlineTap(context, headline),
54-
child: Padding(
55-
padding: const EdgeInsets.all(AppSpacing.md),
56-
child: Row(
57-
crossAxisAlignment: CrossAxisAlignment.start,
58-
children: [
59-
Expanded(
60-
child: Column(
61-
crossAxisAlignment: CrossAxisAlignment.start,
50+
child: Padding(
51+
padding: const EdgeInsets.all(AppSpacing.md),
52+
child: Column(
53+
crossAxisAlignment: CrossAxisAlignment.start,
54+
children: [
55+
HeadlineSourceRow(headline: headline),
56+
const SizedBox(height: AppSpacing.sm),
57+
InkWell(
58+
onTap: onHeadlineTap ??
59+
() => HeadlineTapHandler.handleHeadlineTap(context, headline),
60+
child: Text.rich(
61+
TextSpan(
6262
children: [
63-
HeadlineSourceRow(headline: headline),
64-
const SizedBox(height: AppSpacing.sm),
65-
Text.rich(
63+
if (headline.isBreaking)
6664
TextSpan(
67-
children: [
68-
if (headline.isBreaking)
69-
TextSpan(
70-
text: '${l10n.breakingNewsPrefix} - ',
71-
style: textTheme.titleMedium?.copyWith(
72-
fontWeight: FontWeight.w500,
73-
color: colorScheme.primary,
74-
),
75-
),
76-
TextSpan(text: headline.title),
77-
],
65+
text: '${l10n.breakingNewsPrefix} - ',
66+
style: textTheme.titleMedium?.copyWith(
67+
fontWeight: FontWeight.w500,
68+
color: colorScheme.primary,
69+
),
7870
),
79-
style: textTheme.titleMedium?.copyWith(
80-
fontWeight: FontWeight.w500,
81-
),
82-
maxLines: 2,
83-
overflow: TextOverflow.ellipsis,
84-
),
85-
const SizedBox(height: AppSpacing.md),
86-
BlocBuilder<HeadlinesFeedBloc, HeadlinesFeedState>(
87-
builder: (context, state) {
88-
return HeadlineActionsRow(
89-
headline: headline,
90-
engagements: state.engagementsMap[headline.id] ?? [],
91-
);
92-
},
93-
),
71+
TextSpan(text: headline.title),
9472
],
9573
),
74+
style: textTheme.titleMedium?.copyWith(
75+
fontWeight: FontWeight.w500,
76+
),
77+
maxLines: 2,
78+
overflow: TextOverflow.ellipsis,
9679
),
97-
],
98-
),
80+
),
81+
const SizedBox(height: AppSpacing.md),
82+
BlocBuilder<HeadlinesFeedBloc, HeadlinesFeedState>(
83+
builder: (context, state) {
84+
return HeadlineActionsRow(
85+
headline: headline,
86+
engagements: state.engagementsMap[headline.id] ?? [],
87+
);
88+
},
89+
),
90+
],
9991
),
10092
),
10193
);

0 commit comments

Comments
 (0)