Skip to content

Commit b6205d1

Browse files
committed
feat(ads): add headline image style option for local native ad widget
- Introduce HeadlineImageStyle enum to determine ad's visual size - Adjust image height based on headlineImageStyle preference - Add headlineImageStyle parameter to LocalNativeAdWidget constructor
1 parent 7eaf7de commit b6205d1

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/ads/widgets/local_native_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 LocalNativeAdWidget extends StatelessWidget {
99
/// {@macro local_native_ad_widget}
10-
const LocalNativeAdWidget({required this.localNativeAd, super.key});
10+
const LocalNativeAdWidget({
11+
required this.localNativeAd,
12+
this.headlineImageStyle,
13+
super.key,
14+
});
1115

1216
/// The [LocalNativeAd] to display.
1317
final LocalNativeAd localNativeAd;
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 native ad height.
28+
final double imageHeight =
29+
headlineImageStyle == HeadlineImageStyle.largeThumbnail ? 250 : 180;
30+
1831
return Card(
1932
margin: const EdgeInsets.symmetric(
2033
horizontal: AppSpacing.paddingMedium,
@@ -31,7 +44,7 @@ class LocalNativeAdWidget extends StatelessWidget {
3144
child: Image.network(
3245
localNativeAd.imageUrl,
3346
fit: BoxFit.cover,
34-
height: 180,
47+
height: imageHeight,
3548
width: double.infinity,
3649
errorBuilder: (context, error, stackTrace) =>
3750
const SizedBox.shrink(),

0 commit comments

Comments
 (0)