|
| 1 | +import 'package:core/core.dart'; |
| 2 | +import 'package:flutter/material.dart'; |
| 3 | +import 'package:ui_kit/ui_kit.dart'; |
| 4 | + |
| 5 | +/// {@template demo_banner_ad_widget} |
| 6 | +/// A widget that displays a placeholder for a banner ad in demo mode. |
| 7 | +/// |
| 8 | +/// This widget mimics the visual dimensions of a real banner ad but |
| 9 | +/// contains only static text to indicate it's a demo. |
| 10 | +/// {@endtemplate} |
| 11 | +class DemoBannerAdWidget extends StatelessWidget { |
| 12 | + /// {@macro demo_banner_ad_widget} |
| 13 | + const DemoBannerAdWidget({ |
| 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 | + ? 250 // Height for mediumRectangle banner |
| 28 | + : 50; // Height for standard banner |
| 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 | + 'BANNER 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