|
1 | 1 | import 'package:flutter/material.dart';
|
2 |
| -import 'package:flutter_news_app_mobile_client_full_source_code/ads/models/native_ad.dart' |
3 |
| - as app_native_ad; |
| 2 | +import 'package:flutter_news_app_mobile_client_full_source_code/ads/widgets/native_ad_view.dart'; |
4 | 3 | import 'package:ui_kit/ui_kit.dart';
|
5 | 4 |
|
6 | 5 | /// {@template native_ad_card_image_start}
|
7 |
| -/// A generic widget to display a native ad with a small image at the start. |
| 6 | +/// A widget to display a native ad with a small image at the start, |
| 7 | +/// visually mimicking [HeadlineTileImageStart]. |
8 | 8 | ///
|
9 |
| -/// This widget is designed to visually match [HeadlineTileImageStart] |
10 |
| -/// and uses a generic [app_native_ad.NativeAd] model. |
| 9 | +/// This widget accepts a [NativeAdView] to render the actual ad content, |
| 10 | +/// ensuring it remains provider-agnostic. |
11 | 11 | /// {@endtemplate}
|
12 | 12 | class NativeAdCardImageStart extends StatelessWidget {
|
13 | 13 | /// {@macro native_ad_card_image_start}
|
14 |
| - const NativeAdCardImageStart({required this.nativeAd, super.key}); |
| 14 | + const NativeAdCardImageStart({required this.adView, super.key}); |
15 | 15 |
|
16 |
| - /// The generic native ad data to display. |
17 |
| - final app_native_ad.NativeAd nativeAd; |
| 16 | + /// The widget responsible for rendering the native ad content. |
| 17 | + final NativeAdView adView; |
18 | 18 |
|
19 | 19 | @override
|
20 | 20 | Widget build(BuildContext context) {
|
21 |
| - final theme = Theme.of(context); |
22 |
| - final textTheme = theme.textTheme; |
23 |
| - final colorScheme = theme.colorScheme; |
24 |
| - |
25 |
| - // Placeholder content for the generic ad. |
26 |
| - // The actual rendering of the SDK-specific ad will happen in a child widget. |
27 | 21 | return Card(
|
28 | 22 | margin: const EdgeInsets.symmetric(
|
29 | 23 | horizontal: AppSpacing.paddingMedium,
|
30 | 24 | vertical: AppSpacing.xs,
|
31 | 25 | ),
|
32 |
| - child: Padding( |
33 |
| - padding: const EdgeInsets.all(AppSpacing.md), |
34 |
| - child: Row( |
35 |
| - crossAxisAlignment: CrossAxisAlignment.start, |
36 |
| - children: [ |
37 |
| - SizedBox( |
38 |
| - width: 72, // Standard small image size |
39 |
| - height: 72, |
40 |
| - child: ClipRRect( |
41 |
| - borderRadius: BorderRadius.circular(AppSpacing.xs), |
42 |
| - child: ColoredBox( |
43 |
| - color: colorScheme.surfaceContainerHighest, |
44 |
| - child: Icon( |
45 |
| - Icons.campaign_outlined, |
46 |
| - color: colorScheme.onSurfaceVariant, |
47 |
| - size: AppSpacing.xl, |
48 |
| - ), |
49 |
| - ), |
50 |
| - ), |
51 |
| - ), |
52 |
| - const SizedBox(width: AppSpacing.md), // Always add spacing |
53 |
| - Expanded( |
54 |
| - child: Column( |
55 |
| - crossAxisAlignment: CrossAxisAlignment.start, |
56 |
| - children: [ |
57 |
| - Text( |
58 |
| - 'Ad: ${nativeAd.id}', // Displaying ID for now |
59 |
| - style: textTheme.titleMedium?.copyWith( |
60 |
| - fontWeight: FontWeight.w500, |
61 |
| - ), |
62 |
| - maxLines: 2, |
63 |
| - overflow: TextOverflow.ellipsis, |
64 |
| - ), |
65 |
| - const SizedBox(height: AppSpacing.sm), |
66 |
| - Text( |
67 |
| - 'This is a generic ad placeholder.', |
68 |
| - style: textTheme.bodySmall?.copyWith( |
69 |
| - color: colorScheme.primary.withOpacity(0.7), |
70 |
| - ), |
71 |
| - maxLines: 2, |
72 |
| - overflow: TextOverflow.ellipsis, |
73 |
| - ), |
74 |
| - ], |
75 |
| - ), |
76 |
| - ), |
77 |
| - ], |
78 |
| - ), |
79 |
| - ), |
| 26 | + child: adView, // Directly render the provided NativeAdView |
80 | 27 | );
|
81 | 28 | }
|
82 | 29 | }
|
0 commit comments