|
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_text_only}
|
7 |
| -/// A generic widget to display a native ad with text only. |
| 6 | +/// A widget to display a native ad with text only, |
| 7 | +/// visually mimicking [HeadlineTileTextOnly]. |
8 | 8 | ///
|
9 |
| -/// This widget is designed to visually match [HeadlineTileTextOnly] |
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 NativeAdCardTextOnly extends StatelessWidget {
|
13 | 13 | /// {@macro native_ad_card_text_only}
|
14 |
| - const NativeAdCardTextOnly({required this.nativeAd, super.key}); |
| 14 | + const NativeAdCardTextOnly({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 |
| - |
24 |
| - // Placeholder content for the generic ad. |
25 |
| - // The actual rendering of the SDK-specific ad will happen in a child widget. |
26 | 21 | return Card(
|
27 | 22 | margin: const EdgeInsets.symmetric(
|
28 | 23 | horizontal: AppSpacing.paddingMedium,
|
29 | 24 | vertical: AppSpacing.xs,
|
30 | 25 | ),
|
31 |
| - child: Padding( |
32 |
| - padding: const EdgeInsets.all(AppSpacing.md), |
33 |
| - child: Row( |
34 |
| - crossAxisAlignment: CrossAxisAlignment.start, |
35 |
| - children: [ |
36 |
| - Expanded( |
37 |
| - child: Column( |
38 |
| - crossAxisAlignment: CrossAxisAlignment.start, |
39 |
| - children: [ |
40 |
| - Text( |
41 |
| - 'Ad: ${nativeAd.id}', // Displaying ID for now |
42 |
| - style: textTheme.titleMedium?.copyWith( |
43 |
| - fontWeight: FontWeight.w500, |
44 |
| - ), |
45 |
| - maxLines: 3, // Allow more lines for text-only |
46 |
| - overflow: TextOverflow.ellipsis, |
47 |
| - ), |
48 |
| - const SizedBox(height: AppSpacing.sm), |
49 |
| - Text( |
50 |
| - 'This is a generic ad placeholder.', |
51 |
| - style: textTheme.bodySmall?.copyWith( |
52 |
| - color: theme.colorScheme.primary.withOpacity(0.7), |
53 |
| - ), |
54 |
| - maxLines: 2, |
55 |
| - overflow: TextOverflow.ellipsis, |
56 |
| - ), |
57 |
| - ], |
58 |
| - ), |
59 |
| - ), |
60 |
| - ], |
61 |
| - ), |
62 |
| - ), |
| 26 | + child: adView, // Directly render the provided NativeAdView |
63 | 27 | );
|
64 | 28 | }
|
65 | 29 | }
|
0 commit comments