|
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_top}
|
7 |
| -/// A generic widget to display a native ad with a large image at the top. |
| 6 | +/// A widget to display a native ad with a large image at the top, |
| 7 | +/// visually mimicking [HeadlineTileImageTop]. |
8 | 8 | ///
|
9 |
| -/// This widget is designed to visually match [HeadlineTileImageTop] |
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 NativeAdCardImageTop extends StatelessWidget {
|
13 | 13 | /// {@macro native_ad_card_image_top}
|
14 |
| - const NativeAdCardImageTop({required this.nativeAd, super.key}); |
| 14 | + const NativeAdCardImageTop({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: Column( |
33 |
| - crossAxisAlignment: CrossAxisAlignment.start, |
34 |
| - children: [ |
35 |
| - ClipRRect( |
36 |
| - borderRadius: const BorderRadius.only( |
37 |
| - topLeft: Radius.circular(AppSpacing.xs), |
38 |
| - topRight: Radius.circular(AppSpacing.xs), |
39 |
| - ), |
40 |
| - child: Container( |
41 |
| - width: double.infinity, |
42 |
| - height: 180, // Standard large image height |
43 |
| - color: colorScheme.surfaceContainerHighest, |
44 |
| - child: Icon( |
45 |
| - Icons.campaign_outlined, |
46 |
| - color: colorScheme.onSurfaceVariant, |
47 |
| - size: AppSpacing.xxl, |
48 |
| - ), |
49 |
| - ), |
50 |
| - ), |
51 |
| - Padding( |
52 |
| - padding: const EdgeInsets.all(AppSpacing.md), |
53 |
| - child: Column( |
54 |
| - crossAxisAlignment: CrossAxisAlignment.start, |
55 |
| - children: [ |
56 |
| - Row( |
57 |
| - crossAxisAlignment: CrossAxisAlignment.start, |
58 |
| - children: [ |
59 |
| - Expanded( |
60 |
| - child: Text( |
61 |
| - 'Ad: ${nativeAd.id}', // Displaying ID for now |
62 |
| - style: textTheme.titleMedium?.copyWith( |
63 |
| - fontWeight: FontWeight.w500, |
64 |
| - ), |
65 |
| - maxLines: 3, |
66 |
| - overflow: TextOverflow.ellipsis, |
67 |
| - ), |
68 |
| - ), |
69 |
| - ], |
70 |
| - ), |
71 |
| - const SizedBox(height: AppSpacing.sm), |
72 |
| - Text( |
73 |
| - 'This is a generic ad placeholder.', |
74 |
| - style: textTheme.bodySmall?.copyWith( |
75 |
| - color: colorScheme.primary.withOpacity(0.7), |
76 |
| - ), |
77 |
| - maxLines: 2, |
78 |
| - overflow: TextOverflow.ellipsis, |
79 |
| - ), |
80 |
| - ], |
81 |
| - ), |
82 |
| - ), |
83 |
| - ], |
84 |
| - ), |
| 26 | + child: adView, // Directly render the provided NativeAdView |
85 | 27 | );
|
86 | 28 | }
|
87 | 29 | }
|
0 commit comments