Skip to content

Commit 9c5d289

Browse files
committed
feat(ads): make ad image style configurable
- Add 'imageStyle' parameter to AdLoaderWidget - Use provided imageStyle when requesting ad from AdService - Remove hardcoded imageStyle value, allowing for dynamic ad template selection
1 parent b184edd commit 9c5d289

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/ads/widgets/ad_loader_widget.dart

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class AdLoaderWidget extends StatefulWidget {
2828
required this.adPlaceholder,
2929
required this.adService,
3030
required this.adThemeStyle,
31+
required this.imageStyle,
3132
super.key,
3233
});
3334

@@ -40,6 +41,9 @@ class AdLoaderWidget extends StatefulWidget {
4041
/// The current theme style for ads, used during ad loading.
4142
final AdThemeStyle adThemeStyle;
4243

44+
/// The desired image style for the ad, which determines the native template.
45+
final HeadlineImageStyle imageStyle;
46+
4347
@override
4448
State<AdLoaderWidget> createState() => _AdLoaderWidgetState();
4549
}
@@ -86,11 +90,12 @@ class _AdLoaderWidgetState extends State<AdLoaderWidget> {
8690
'Loading new ad for placeholder ID: ${widget.adPlaceholder.id}',
8791
);
8892
try {
89-
// Request a new native ad from the AdService.
90-
// The imageStyle is hardcoded to largeThumbnail for now, but could be
91-
// made configurable based on the feed's display preferences.
93+
// Request a new native ad from the AdService, passing the dynamically
94+
// provided imageStyle. This ensures that the correct native ad template
95+
// (small or medium) is requested based on the user's current feed
96+
// display settings.
9297
final adFeedItem = await widget.adService.getAd(
93-
imageStyle: HeadlineImageStyle.largeThumbnail,
98+
imageStyle: widget.imageStyle,
9499
adThemeStyle: widget.adThemeStyle,
95100
);
96101

0 commit comments

Comments
 (0)