Skip to content

Commit 792e9ae

Browse files
committed
refactor(widgets): improve layout and appearance of suggestion widgets
- Remove card margin and add padding for content collection decorator - Reduce spacing between elements and adjust list view height - Update suggestion item widget to use source logo URL and improve image display - Adjust text styling and button size in suggestion item widget
1 parent f2fc776 commit 792e9ae

File tree

2 files changed

+74
-78
lines changed

2 files changed

+74
-78
lines changed

lib/shared/widgets/feed_decorators/content_collection_decorator_widget.dart

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,14 @@ class ContentCollectionDecoratorWidget extends StatelessWidget {
5454
}
5555
}
5656

57-
return Card(
58-
margin: const EdgeInsets.symmetric(
59-
horizontal: AppSpacing.lg,
60-
vertical: AppSpacing.md,
61-
),
62-
child: Padding(
63-
padding: const EdgeInsets.all(AppSpacing.lg),
64-
child: Column(
65-
crossAxisAlignment: CrossAxisAlignment.start,
66-
children: [
67-
Row(
57+
return Padding(
58+
padding: const EdgeInsets.symmetric(vertical: AppSpacing.md),
59+
child: Column(
60+
crossAxisAlignment: CrossAxisAlignment.start,
61+
children: [
62+
Padding(
63+
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.lg),
64+
child: Row(
6865
mainAxisAlignment: MainAxisAlignment.spaceBetween,
6966
children: [
7067
Expanded(
@@ -77,29 +74,30 @@ class ContentCollectionDecoratorWidget extends StatelessWidget {
7774
),
7875
],
7976
),
80-
const SizedBox(height: AppSpacing.md),
81-
SizedBox(
82-
height: 200,
83-
child: ListView.builder(
84-
scrollDirection: Axis.horizontal,
85-
itemCount: item.items.length,
86-
itemBuilder: (context, index) {
87-
final suggestion = item.items[index];
88-
final isFollowing =
89-
(suggestion is Topic &&
90-
followedTopicIds.contains(suggestion.id)) ||
91-
(suggestion is Source &&
92-
followedSourceIds.contains(suggestion.id));
93-
return SuggestionItemWidget(
94-
item: suggestion,
95-
onFollowToggle: onFollowToggle,
96-
isFollowing: isFollowing,
97-
);
98-
},
99-
),
77+
),
78+
const SizedBox(height: AppSpacing.sm),
79+
SizedBox(
80+
height: 180,
81+
child: ListView.builder(
82+
scrollDirection: Axis.horizontal,
83+
itemCount: item.items.length,
84+
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.md),
85+
itemBuilder: (context, index) {
86+
final suggestion = item.items[index];
87+
final isFollowing =
88+
(suggestion is Topic &&
89+
followedTopicIds.contains(suggestion.id)) ||
90+
(suggestion is Source &&
91+
followedSourceIds.contains(suggestion.id));
92+
return SuggestionItemWidget(
93+
item: suggestion,
94+
onFollowToggle: onFollowToggle,
95+
isFollowing: isFollowing,
96+
);
97+
},
10098
),
101-
],
102-
),
99+
),
100+
],
103101
),
104102
);
105103
}

lib/shared/widgets/feed_decorators/suggestion_item_widget.dart

Lines changed: 43 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -41,68 +41,66 @@ class SuggestionItemWidget extends StatelessWidget {
4141
name = topic.name;
4242
} else if (item is Source) {
4343
final source = item as Source;
44-
// TODO(fulleni): Add imageUrl to the Source model for a richer UI.
45-
imageUrl = '';
44+
imageUrl = source.logoUrl;
4645
name = source.name;
4746
} else {
4847
// Fallback for unexpected types, though type checking should prevent this
4948
imageUrl = '';
5049
name = 'Unknown';
5150
}
5251

53-
return Card(
54-
color: theme.colorScheme.surfaceVariant,
55-
margin: const EdgeInsets.symmetric(horizontal: AppSpacing.sm),
56-
child: SizedBox(
57-
width: 160,
58-
child: Padding(
59-
padding: const EdgeInsets.all(AppSpacing.md),
60-
child: Column(
61-
mainAxisAlignment: MainAxisAlignment.center,
62-
children: [
63-
// Square image/icon
64-
Container(
65-
width: 64,
66-
height: 64,
67-
decoration: BoxDecoration(
68-
color: theme.colorScheme.surface,
69-
borderRadius: BorderRadius.circular(AppSpacing.sm),
52+
return SizedBox(
53+
width: 150,
54+
child: Card(
55+
clipBehavior: Clip.antiAlias,
56+
margin: const EdgeInsets.symmetric(horizontal: AppSpacing.sm),
57+
child: Column(
58+
children: [
59+
Expanded(
60+
child: Padding(
61+
padding: const EdgeInsets.all(AppSpacing.md),
62+
child: Image.network(
63+
imageUrl,
64+
fit: BoxFit.contain,
65+
errorBuilder: (context, error, stackTrace) => Icon(
66+
item is Source
67+
? Icons.source_outlined
68+
: Icons.category_outlined,
69+
size: AppSpacing.xxl,
70+
color: theme.colorScheme.onSurfaceVariant,
71+
),
7072
),
71-
child: imageUrl.isNotEmpty
72-
? ClipRRect(
73-
borderRadius: BorderRadius.circular(AppSpacing.sm),
74-
child: Image.network(
75-
imageUrl,
76-
fit: BoxFit.cover,
77-
errorBuilder: (context, error, stackTrace) => Icon(
78-
Icons.broken_image,
79-
color: theme.colorScheme.onSurface,
80-
),
81-
),
82-
)
83-
: Icon(
84-
// Use a more specific icon for sources as a fallback.
85-
item is Source ? Icons.source : Icons.category,
86-
color: theme.colorScheme.onSurface,
87-
),
8873
),
89-
const SizedBox(height: AppSpacing.md),
90-
Text(
74+
),
75+
Padding(
76+
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.xs),
77+
child: Text(
9178
name,
92-
style: theme.textTheme.titleSmall,
79+
style: theme.textTheme.bodyMedium,
9380
textAlign: TextAlign.center,
9481
maxLines: 1,
9582
overflow: TextOverflow.ellipsis,
9683
),
97-
const SizedBox(height: AppSpacing.md),
98-
ElevatedButton(
84+
),
85+
Padding(
86+
padding: const EdgeInsets.all(
87+
AppSpacing.sm,
88+
).copyWith(top: AppSpacing.xs),
89+
child: ElevatedButton(
90+
style: ElevatedButton.styleFrom(
91+
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
92+
),
9993
onPressed: () => onFollowToggle(item),
100-
child: Text(
101-
isFollowing ? l10n.unfollowButtonText : l10n.followButtonText,
94+
child: FittedBox(
95+
child: Text(
96+
isFollowing
97+
? l10n.unfollowButtonText
98+
: l10n.followButtonText,
99+
),
102100
),
103101
),
104-
],
105-
),
102+
),
103+
],
106104
),
107105
),
108106
);

0 commit comments

Comments
 (0)