Skip to content

Commit d70b3ec

Browse files
committed
refactor(ads): transform NativeAdCardImageTop into a provider-agnostic widget
- Remove generic NativeAd model dependency - Introduce NativeAdView widget for rendering ad content - Simplify structure to directly use NativeAdView - Update documentation to reflect new design and usage
1 parent 72b6f4f commit d70b3ec

File tree

1 file changed

+9
-67
lines changed

1 file changed

+9
-67
lines changed
Lines changed: 9 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +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_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].
88
///
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.
1111
/// {@endtemplate}
1212
class NativeAdCardImageTop extends StatelessWidget {
1313
/// {@macro native_ad_card_image_top}
14-
const NativeAdCardImageTop({required this.nativeAd, super.key});
14+
const NativeAdCardImageTop({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-
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.
2721
return Card(
2822
margin: const EdgeInsets.symmetric(
2923
horizontal: AppSpacing.paddingMedium,
3024
vertical: AppSpacing.xs,
3125
),
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
8527
);
8628
}
8729
}

0 commit comments

Comments
 (0)