Skip to content

Commit 1a7b605

Browse files
committed
feat(ads/widgets): add native ad placeholder for demo mode
- Create DemoNativeAdWidget to display a placeholder for native ads in demo mode - Mimics the visual dimensions of real native ads - Contains static text to indicate it's a demo placeholder - Adapts size based on the provided headlineImageStyle
1 parent f4973ba commit 1a7b605

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import 'package:core/core.dart';
2+
import 'package:flutter/material.dart';
3+
import 'package:ui_kit/ui_kit.dart';
4+
5+
/// {@template demo_native_ad_widget}
6+
/// A widget that displays a placeholder for a native ad in demo mode.
7+
///
8+
/// This widget mimics the visual dimensions of a real native ad but
9+
/// contains only static text to indicate it's a demo.
10+
/// {@endtemplate}
11+
class DemoNativeAdWidget extends StatelessWidget {
12+
/// {@macro demo_native_ad_widget}
13+
const DemoNativeAdWidget({
14+
this.headlineImageStyle,
15+
super.key,
16+
});
17+
18+
/// The user's preference for feed layout, used to determine the ad's visual size.
19+
final HeadlineImageStyle? headlineImageStyle;
20+
21+
@override
22+
Widget build(BuildContext context) {
23+
final theme = Theme.of(context);
24+
25+
// Determine the height based on the headlineImageStyle, mimicking real ad widgets.
26+
final double adHeight = headlineImageStyle == HeadlineImageStyle.largeThumbnail
27+
? 340 // Height for medium native ad template
28+
: 120; // Height for small native ad template
29+
30+
return Card(
31+
margin: const EdgeInsets.symmetric(
32+
horizontal: AppSpacing.paddingMedium,
33+
vertical: AppSpacing.xs,
34+
),
35+
child: SizedBox(
36+
height: adHeight,
37+
width: double.infinity,
38+
child: Center(
39+
child: Text(
40+
'NATIVE AD (DEMO)',
41+
style: theme.textTheme.titleMedium?.copyWith(
42+
color: theme.colorScheme.onSurfaceVariant,
43+
),
44+
textAlign: TextAlign.center,
45+
),
46+
),
47+
),
48+
);
49+
}
50+
}

0 commit comments

Comments
 (0)