Skip to content

Commit 5dfbfae

Browse files
committed
refactor(widgets): restructure headline tile layout
- Add HeadlineSourceRow above the image - Remove HeadlineMetadataRow - Adjust padding and layout of title text - Improve image loading and error handling
1 parent 4b0d1d3 commit 5dfbfae

File tree

1 file changed

+53
-58
lines changed

1 file changed

+53
-58
lines changed

lib/shared/widgets/feed_core/headline_tile_image_top.dart

Lines changed: 53 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'package:core/core.dart';
22
import 'package:flutter/material.dart';
3-
import 'package:flutter_news_app_mobile_client_full_source_code/shared/widgets/feed_core/headline_metadata_row.dart';
3+
import 'package:flutter_news_app_mobile_client_full_source_code/shared/widgets/feed_core/headline_source_row.dart';
44
import 'package:flutter_news_app_mobile_client_full_source_code/shared/widgets/feed_core/headline_tap_handler.dart';
55
import 'package:ui_kit/ui_kit.dart';
66

@@ -47,84 +47,79 @@ class HeadlineTileImageTop extends StatelessWidget {
4747
child: Column(
4848
crossAxisAlignment: CrossAxisAlignment.start,
4949
children: [
50+
Padding(
51+
padding: const EdgeInsets.fromLTRB(
52+
AppSpacing.md,
53+
AppSpacing.md,
54+
AppSpacing.md,
55+
AppSpacing.md,
56+
),
57+
child: HeadlineSourceRow(headline: headline),
58+
),
5059
InkWell(
5160
onTap:
5261
onHeadlineTap ??
5362
() => HeadlineTapHandler.handleHeadlineTap(context, headline),
54-
child: ClipRRect(
55-
borderRadius: const BorderRadius.only(
56-
topLeft: Radius.circular(AppSpacing.xs),
57-
topRight: Radius.circular(AppSpacing.xs),
58-
),
59-
child: Image.network(
60-
headline.imageUrl,
61-
width: double.infinity,
62-
height: 180,
63-
fit: BoxFit.cover,
64-
loadingBuilder: (context, child, loadingProgress) {
65-
if (loadingProgress == null) return child;
66-
return Container(
67-
width: double.infinity,
68-
height: 180,
69-
color: colorScheme.surfaceContainerHighest,
70-
child: const Center(
71-
child: CircularProgressIndicator(strokeWidth: 2),
72-
),
73-
);
74-
},
75-
errorBuilder: (context, error, stackTrace) => Container(
63+
child: Image.network(
64+
headline.imageUrl,
65+
width: double.infinity,
66+
height: 180,
67+
fit: BoxFit.cover,
68+
loadingBuilder: (context, child, loadingProgress) {
69+
if (loadingProgress == null) return child;
70+
return Container(
7671
width: double.infinity,
7772
height: 180,
7873
color: colorScheme.surfaceContainerHighest,
79-
child: Icon(
80-
Icons.broken_image_outlined,
81-
color: colorScheme.onSurfaceVariant,
82-
size: AppSpacing.xxl,
74+
child: const Center(
75+
child: CircularProgressIndicator(strokeWidth: 2),
8376
),
77+
);
78+
},
79+
errorBuilder: (context, error, stackTrace) => Container(
80+
width: double.infinity,
81+
height: 180,
82+
color: colorScheme.surfaceContainerHighest,
83+
child: Icon(
84+
Icons.broken_image_outlined,
85+
color: colorScheme.onSurfaceVariant,
86+
size: AppSpacing.xxl,
8487
),
8588
),
8689
),
8790
),
8891
Padding(
89-
padding: const EdgeInsets.all(AppSpacing.md),
90-
child: Column(
92+
padding: const EdgeInsets.fromLTRB(
93+
AppSpacing.md,
94+
AppSpacing.md,
95+
AppSpacing.md,
96+
AppSpacing.md,
97+
),
98+
child: Row(
9199
crossAxisAlignment: CrossAxisAlignment.start,
92100
children: [
93-
Row(
94-
crossAxisAlignment: CrossAxisAlignment.start,
95-
children: [
96-
Expanded(
97-
child: InkWell(
98-
onTap:
99-
onHeadlineTap ??
100-
() => HeadlineTapHandler.handleHeadlineTap(
101+
Expanded(
102+
child: InkWell(
103+
onTap:
104+
onHeadlineTap ??
105+
() => HeadlineTapHandler.handleHeadlineTap(
101106
context,
102107
headline,
103108
),
104-
child: Text(
105-
headline.title,
106-
style: textTheme.titleMedium?.copyWith(
107-
fontWeight: FontWeight.w500,
108-
),
109-
maxLines: 3,
110-
overflow: TextOverflow.ellipsis,
111-
),
109+
child: Text(
110+
headline.title,
111+
style: textTheme.titleMedium?.copyWith(
112+
fontWeight: FontWeight.w500,
112113
),
114+
maxLines: 2,
115+
overflow: TextOverflow.ellipsis,
113116
),
114-
if (trailing != null) ...[
115-
const SizedBox(width: AppSpacing.sm),
116-
trailing!,
117-
],
118-
],
119-
),
120-
const SizedBox(height: AppSpacing.sm),
121-
HeadlineMetadataRow(
122-
headline: headline,
123-
colorScheme: colorScheme,
124-
textTheme: textTheme,
125-
currentContextEntityType: currentContextEntityType,
126-
currentContextEntityId: currentContextEntityId,
117+
),
127118
),
119+
if (trailing != null) ...[
120+
const SizedBox(width: AppSpacing.sm),
121+
trailing!,
122+
],
128123
],
129124
),
130125
),

0 commit comments

Comments
 (0)