11import 'package:core/core.dart' ;
22import 'package:flutter/material.dart' ;
3+ import 'package:flutter_news_app_web_dashboard_full_source_code/app_configuration/widgets/ad_config_form.dart' ;
34import 'package:flutter_news_app_web_dashboard_full_source_code/app_configuration/widgets/ad_platform_config_form.dart' ;
45import 'package:flutter_news_app_web_dashboard_full_source_code/app_configuration/widgets/article_ad_settings_form.dart' ;
56import 'package:flutter_news_app_web_dashboard_full_source_code/app_configuration/widgets/feed_ad_settings_form.dart' ;
7+ import 'package:flutter_news_app_web_dashboard_full_source_code/app_configuration/widgets/interstitial_ad_settings_form.dart' ;
68import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/l10n.dart' ;
79import 'package:ui_kit/ui_kit.dart' ;
810
@@ -46,10 +48,17 @@ class _AdvertisementsConfigurationTabState
4648 @override
4749 Widget build (BuildContext context) {
4850 final l10n = AppLocalizationsX (context).l10n;
51+ final adConfig = widget.remoteConfig.adConfig;
4952
5053 return ListView (
5154 padding: const EdgeInsets .all (AppSpacing .lg),
5255 children: [
56+ // Global Ad Configuration (AdConfigForm now includes the global switch)
57+ AdConfigForm (
58+ remoteConfig: widget.remoteConfig,
59+ onConfigChanged: widget.onConfigChanged,
60+ ),
61+ const SizedBox (height: AppSpacing .lg),
5362 // Top-level ExpansionTile for Ad Platform Configuration
5463 ValueListenableBuilder <int ?>(
5564 valueListenable: _expandedTileIndex,
@@ -64,10 +73,12 @@ class _AdvertisementsConfigurationTabState
6473 bottom: AppSpacing .md,
6574 ),
6675 expandedCrossAxisAlignment: CrossAxisAlignment .start,
67- onExpansionChanged: (isExpanded) {
68- _expandedTileIndex.value = isExpanded ? tileIndex : null ;
69- },
70- initiallyExpanded: expandedIndex == tileIndex,
76+ onExpansionChanged: adConfig.enabled
77+ ? (isExpanded) {
78+ _expandedTileIndex.value = isExpanded ? tileIndex : null ;
79+ }
80+ : null , // Disable expansion if global ads are off
81+ initiallyExpanded: expandedIndex == tileIndex && adConfig.enabled,
7182 children: [
7283 AdPlatformConfigForm (
7384 remoteConfig: widget.remoteConfig,
@@ -92,10 +103,12 @@ class _AdvertisementsConfigurationTabState
92103 bottom: AppSpacing .md,
93104 ),
94105 expandedCrossAxisAlignment: CrossAxisAlignment .start,
95- onExpansionChanged: (isExpanded) {
96- _expandedTileIndex.value = isExpanded ? tileIndex : null ;
97- },
98- initiallyExpanded: expandedIndex == tileIndex,
106+ onExpansionChanged: adConfig.enabled
107+ ? (isExpanded) {
108+ _expandedTileIndex.value = isExpanded ? tileIndex : null ;
109+ }
110+ : null , // Disable expansion if global ads are off
111+ initiallyExpanded: expandedIndex == tileIndex && adConfig.enabled,
99112 children: [
100113 FeedAdSettingsForm (
101114 remoteConfig: widget.remoteConfig,
@@ -120,10 +133,12 @@ class _AdvertisementsConfigurationTabState
120133 bottom: AppSpacing .md,
121134 ),
122135 expandedCrossAxisAlignment: CrossAxisAlignment .start,
123- onExpansionChanged: (isExpanded) {
124- _expandedTileIndex.value = isExpanded ? tileIndex : null ;
125- },
126- initiallyExpanded: expandedIndex == tileIndex,
136+ onExpansionChanged: adConfig.enabled
137+ ? (isExpanded) {
138+ _expandedTileIndex.value = isExpanded ? tileIndex : null ;
139+ }
140+ : null , // Disable expansion if global ads are off
141+ initiallyExpanded: expandedIndex == tileIndex && adConfig.enabled,
127142 children: [
128143 ArticleAdSettingsForm (
129144 remoteConfig: widget.remoteConfig,
@@ -133,6 +148,36 @@ class _AdvertisementsConfigurationTabState
133148 );
134149 },
135150 ),
151+ const SizedBox (height: AppSpacing .lg),
152+ // Top-level ExpansionTile for Interstitial Ad Settings
153+ ValueListenableBuilder <int ?>(
154+ valueListenable: _expandedTileIndex,
155+ builder: (context, expandedIndex, child) {
156+ const tileIndex = 3 ;
157+ return ExpansionTile (
158+ key: ValueKey ('interstitialAdSettingsTile_$expandedIndex ' ),
159+ title: Text (l10n.interstitialAdSettingsTitle),
160+ childrenPadding: const EdgeInsetsDirectional .only (
161+ start: AppSpacing .lg,
162+ top: AppSpacing .md,
163+ bottom: AppSpacing .md,
164+ ),
165+ expandedCrossAxisAlignment: CrossAxisAlignment .start,
166+ onExpansionChanged: adConfig.enabled
167+ ? (isExpanded) {
168+ _expandedTileIndex.value = isExpanded ? tileIndex : null ;
169+ }
170+ : null , // Disable expansion if global ads are off
171+ initiallyExpanded: expandedIndex == tileIndex && adConfig.enabled,
172+ children: [
173+ InterstitialAdSettingsForm (
174+ remoteConfig: widget.remoteConfig,
175+ onConfigChanged: widget.onConfigChanged,
176+ ),
177+ ],
178+ );
179+ },
180+ ),
136181 ],
137182 );
138183 }
0 commit comments