Skip to content

Commit be43e40

Browse files
committed
fix(shared): handle call-to-action types in content collection decorator
- Add a getTitle() function to handle different decorator types - Return appropriate title based on decorator type - Maintain existing title for call-to-action types
1 parent f27d56b commit be43e40

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

lib/shared/widgets/feed_decorators/content_collection_decorator_widget.dart

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,22 @@ class ContentCollectionDecoratorWidget extends StatelessWidget {
4343
final l10n = AppLocalizationsX(context).l10n;
4444
final theme = Theme.of(context);
4545

46+
String getTitle() {
47+
switch (item.decoratorType) {
48+
case FeedDecoratorType.suggestedTopics:
49+
return l10n.suggestedTopicsTitle;
50+
case FeedDecoratorType.suggestedSources:
51+
return l10n.suggestedSourcesTitle;
52+
// The following cases are for call-to-action types and should not
53+
// appear in a content collection, but we handle them gracefully.
54+
case FeedDecoratorType.linkAccount:
55+
case FeedDecoratorType.upgrade:
56+
case FeedDecoratorType.rateApp:
57+
case FeedDecoratorType.enableNotifications:
58+
return item.title;
59+
}
60+
}
61+
4662
return Card(
4763
margin: const EdgeInsets.symmetric(
4864
horizontal: AppSpacing.lg,
@@ -58,7 +74,7 @@ class ContentCollectionDecoratorWidget extends StatelessWidget {
5874
children: [
5975
Expanded(
6076
child: Text(
61-
item.title,
77+
getTitle(),
6278
style: theme.textTheme.titleLarge,
6379
maxLines: 1,
6480
overflow: TextOverflow.ellipsis,

0 commit comments

Comments
 (0)