Skip to content

Commit f835fb3

Browse files
committed
refactor(ads): update NativeAdCardTextOnly to use NativeAdView
- Replace generic NativeAd model with NativeAdView widget - Simplify widget structure and rendering logic - Update documentation to reflect new implementation
1 parent d70b3ec commit f835fb3

File tree

1 file changed

+9
-45
lines changed

1 file changed

+9
-45
lines changed
Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,29 @@
11
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';
43
import 'package:ui_kit/ui_kit.dart';
54

65
/// {@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].
88
///
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.
1111
/// {@endtemplate}
1212
class NativeAdCardTextOnly extends StatelessWidget {
1313
/// {@macro native_ad_card_text_only}
14-
const NativeAdCardTextOnly({required this.nativeAd, super.key});
14+
const NativeAdCardTextOnly({required this.adView, super.key});
1515

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;
1818

1919
@override
2020
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.
2621
return Card(
2722
margin: const EdgeInsets.symmetric(
2823
horizontal: AppSpacing.paddingMedium,
2924
vertical: AppSpacing.xs,
3025
),
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
6327
);
6428
}
6529
}

0 commit comments

Comments
 (0)