|
1 | 1 | // |
| 2 | +// |
2 | 3 | // ignore_for_file: lines_longer_than_80_chars |
3 | 4 |
|
4 | 5 | import 'package:core/core.dart'; |
5 | 6 | import 'package:flutter/material.dart'; |
6 | 7 | import 'package:flutter_bloc/flutter_bloc.dart'; |
| 8 | +import 'package:flutter_news_app_mobile_client_full_source_code/ads/ad_service.dart'; |
| 9 | +import 'package:flutter_news_app_mobile_client_full_source_code/ads/models/ad_placeholder.dart'; |
7 | 10 | import 'package:flutter_news_app_mobile_client_full_source_code/ads/models/ad_theme_style.dart'; |
| 11 | +import 'package:flutter_news_app_mobile_client_full_source_code/ads/widgets/ad_loader_widget.dart'; |
8 | 12 | import 'package:flutter_news_app_mobile_client_full_source_code/app/bloc/app_bloc.dart'; |
9 | 13 | // HeadlineItemWidget import removed |
10 | 14 | import 'package:flutter_news_app_mobile_client_full_source_code/headlines-search/bloc/headlines_search_bloc.dart'; |
@@ -238,10 +242,6 @@ class _HeadlinesSearchViewState extends State<_HeadlinesSearchView> { |
238 | 242 | ), |
239 | 243 | body: BlocBuilder<HeadlinesSearchBloc, HeadlinesSearchState>( |
240 | 244 | builder: (context, state) { |
241 | | - // Ensure textTheme and colorScheme are available in this scope |
242 | | - final currentTextTheme = Theme.of(context).textTheme; |
243 | | - final currentColorScheme = Theme.of(context).colorScheme; |
244 | | - |
245 | 245 | return switch (state) { |
246 | 246 | HeadlinesSearchInitial() => InitialStateWidget( |
247 | 247 | icon: Icons.search_outlined, |
@@ -344,45 +344,12 @@ class _HeadlinesSearchViewState extends State<_HeadlinesSearchView> { |
344 | 344 | return TopicItemWidget(topic: feedItem); |
345 | 345 | } else if (feedItem is Source) { |
346 | 346 | return SourceItemWidget(source: feedItem); |
347 | | - } else if (feedItem is Ad) { |
348 | | - return Card( |
349 | | - margin: const EdgeInsets.symmetric( |
350 | | - vertical: AppSpacing.xs, |
351 | | - ), |
352 | | - color: currentColorScheme.surfaceContainerHighest, |
353 | | - child: Padding( |
354 | | - padding: const EdgeInsets.all(AppSpacing.md), |
355 | | - child: Column( |
356 | | - children: [ |
357 | | - if (feedItem.imageUrl.isNotEmpty) |
358 | | - ClipRRect( |
359 | | - // Add ClipRRect for consistency |
360 | | - borderRadius: BorderRadius.circular( |
361 | | - AppSpacing.xs, |
362 | | - ), |
363 | | - child: Image.network( |
364 | | - feedItem.imageUrl, |
365 | | - height: 100, |
366 | | - fit: BoxFit.cover, |
367 | | - errorBuilder: (ctx, err, st) => Icon( |
368 | | - Icons.broken_image_outlined, |
369 | | - size: AppSpacing.xxl, |
370 | | - color: currentColorScheme |
371 | | - .onSurfaceVariant, |
372 | | - ), |
373 | | - ), |
374 | | - ), |
375 | | - const SizedBox(height: AppSpacing.sm), |
376 | | - Text( |
377 | | - 'Placeholder Ad: ${feedItem.adType.name}', |
378 | | - style: currentTextTheme.titleSmall, |
379 | | - ), |
380 | | - Text( |
381 | | - 'Placement: ${feedItem.placement.name}', |
382 | | - style: currentTextTheme.bodySmall, |
383 | | - ), |
384 | | - ], |
385 | | - ), |
| 347 | + } else if (feedItem is AdPlaceholder) { |
| 348 | + return AdLoaderWidget( |
| 349 | + adPlaceholder: feedItem, |
| 350 | + adService: context.read<AdService>(), |
| 351 | + adThemeStyle: AdThemeStyle.fromTheme( |
| 352 | + Theme.of(context), |
386 | 353 | ), |
387 | 354 | ); |
388 | 355 | } |
|
0 commit comments