Skip to content

Commit b57790a

Browse files
committed
refactor(headlines-feed): replace placeholder ad widget with AdFeedItemWidget
- Remove hardcoded Ad widget implementation - Integrate AdFeedItemWidget from shared package - Use AppBloc to retrieve feed image style preference - Update import statements to include necessary packages
1 parent 5ecd4d8 commit b57790a

File tree

1 file changed

+13
-38
lines changed

1 file changed

+13
-38
lines changed

lib/headlines-feed/view/headlines_feed_page.dart

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import 'package:core/core.dart';
55
import 'package:flutter/material.dart';
66
import 'package:flutter_bloc/flutter_bloc.dart';
77
import 'package:flutter_news_app_mobile_client_full_source_code/account/bloc/account_bloc.dart';
8+
import 'package:flutter_news_app_mobile_client_full_source_code/ads/models/ad_feed_item.dart';
89
import 'package:flutter_news_app_mobile_client_full_source_code/app/bloc/app_bloc.dart';
910
import 'package:flutter_news_app_mobile_client_full_source_code/headlines-feed/bloc/headlines_feed_bloc.dart';
1011
import 'package:flutter_news_app_mobile_client_full_source_code/l10n/l10n.dart';
1112
import 'package:flutter_news_app_mobile_client_full_source_code/router/routes.dart';
12-
import 'package:flutter_news_app_mobile_client_full_source_code/shared/shared.dart';
13+
import 'package:flutter_news_app_mobile_client_full_source_code/shared/widgets/ads/ad_feed_item_widget.dart';
14+
import 'package:flutter_news_app_mobile_client_full_source_code/shared/widgets/feed_core/feed_core.dart';
1315
import 'package:flutter_news_app_mobile_client_full_source_code/shared/widgets/feed_decorators/call_to_action_decorator_widget.dart';
1416
import 'package:flutter_news_app_mobile_client_full_source_code/shared/widgets/feed_decorators/content_collection_decorator_widget.dart';
1517
import 'package:go_router/go_router.dart';
@@ -287,43 +289,16 @@ class _HeadlinesFeedPageState extends State<HeadlinesFeedPage> {
287289
);
288290
}
289291
return tile;
290-
} else if (item is Ad) {
291-
return Card(
292-
margin: const EdgeInsets.symmetric(
293-
horizontal: AppSpacing.paddingMedium,
294-
vertical: AppSpacing.xs,
295-
),
296-
color: colorScheme.surfaceContainerHighest,
297-
child: Padding(
298-
padding: const EdgeInsets.all(AppSpacing.md),
299-
child: Column(
300-
children: [
301-
if (item.imageUrl.isNotEmpty)
302-
Image.network(
303-
item.imageUrl,
304-
height: 100,
305-
errorBuilder: (ctx, err, st) =>
306-
const Icon(Icons.broken_image, size: 50),
307-
),
308-
const SizedBox(height: AppSpacing.sm),
309-
Text(
310-
'Placeholder Ad: ${item.adType}',
311-
style: textTheme.titleSmall,
312-
),
313-
Text(
314-
'Placement: ${item.placement}',
315-
style: textTheme.bodySmall,
316-
),
317-
if (item.targetUrl.isNotEmpty)
318-
TextButton(
319-
onPressed: () {
320-
// TODO(fulleni): Launch URL
321-
},
322-
child: const Text('Visit Advertiser'),
323-
),
324-
],
325-
),
326-
),
292+
} else if (item is AdFeedItem) {
293+
final imageStyle = context
294+
.watch<AppBloc>()
295+
.state
296+
.settings
297+
.feedPreferences
298+
.headlineImageStyle;
299+
return AdFeedItemWidget(
300+
adFeedItem: item,
301+
headlineImageStyle: imageStyle,
327302
);
328303
} else if (item is CallToActionItem) {
329304
return CallToActionDecoratorWidget(

0 commit comments

Comments
 (0)