Skip to content

Commit 7eaf7de

Browse files
committed
feat(ads): make local banner ad height configurable
- Add optional 'headlineImageStyle' parameter to constructor - Adjust image height based on 'headlineImageStyle': - Use square aspect ratio (250px height) for largeThumbnail style - Default to standard banner height (90px) for other styles
1 parent ce06486 commit 7eaf7de

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/ads/widgets/local_banner_ad_widget.dart

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,27 @@ import 'package:ui_kit/ui_kit.dart';
77
/// {@endtemplate}
88
class LocalBannerAdWidget extends StatelessWidget {
99
/// {@macro local_banner_ad_widget}
10-
const LocalBannerAdWidget({required this.localBannerAd, super.key});
10+
const LocalBannerAdWidget({
11+
required this.localBannerAd,
12+
this.headlineImageStyle,
13+
super.key,
14+
});
1115

1216
/// The [LocalBannerAd] to display.
1317
final LocalBannerAd localBannerAd;
1418

19+
/// The user's preference for feed layout, used to determine the ad's visual size.
20+
final HeadlineImageStyle? headlineImageStyle;
21+
1522
@override
1623
Widget build(BuildContext context) {
1724
final theme = Theme.of(context);
25+
26+
// Determine the height based on the headlineImageStyle.
27+
// If largeThumbnail, use a square aspect ratio, otherwise a standard banner height.
28+
final double imageHeight =
29+
headlineImageStyle == HeadlineImageStyle.largeThumbnail ? 250 : 90;
30+
1831
return Card(
1932
margin: const EdgeInsets.symmetric(
2033
horizontal: AppSpacing.paddingMedium,
@@ -35,7 +48,7 @@ class LocalBannerAdWidget extends StatelessWidget {
3548
Image.network(
3649
localBannerAd.imageUrl,
3750
fit: BoxFit.cover,
38-
height: 90, // Standard banner height
51+
height: imageHeight,
3952
width: double.infinity,
4053
errorBuilder: (context, error, stackTrace) =>
4154
const SizedBox.shrink(),

0 commit comments

Comments
 (0)