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,13 @@ 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 ,
81+ initiallyExpanded: expandedIndex == tileIndex && adConfig.enabled,
82+ enabled: adConfig.enabled, // Disable the tile itself
7183 children: [
7284 AdPlatformConfigForm (
7385 remoteConfig: widget.remoteConfig,
@@ -92,10 +104,13 @@ class _AdvertisementsConfigurationTabState
92104 bottom: AppSpacing .md,
93105 ),
94106 expandedCrossAxisAlignment: CrossAxisAlignment .start,
95- onExpansionChanged: (isExpanded) {
96- _expandedTileIndex.value = isExpanded ? tileIndex : null ;
97- },
98- initiallyExpanded: expandedIndex == tileIndex,
107+ onExpansionChanged: adConfig.enabled
108+ ? (isExpanded) {
109+ _expandedTileIndex.value = isExpanded ? tileIndex : null ;
110+ }
111+ : null ,
112+ initiallyExpanded: expandedIndex == tileIndex && adConfig.enabled,
113+ enabled: adConfig.enabled, // Disable the tile itself
99114 children: [
100115 FeedAdSettingsForm (
101116 remoteConfig: widget.remoteConfig,
@@ -120,10 +135,13 @@ class _AdvertisementsConfigurationTabState
120135 bottom: AppSpacing .md,
121136 ),
122137 expandedCrossAxisAlignment: CrossAxisAlignment .start,
123- onExpansionChanged: (isExpanded) {
124- _expandedTileIndex.value = isExpanded ? tileIndex : null ;
125- },
126- initiallyExpanded: expandedIndex == tileIndex,
138+ onExpansionChanged: adConfig.enabled
139+ ? (isExpanded) {
140+ _expandedTileIndex.value = isExpanded ? tileIndex : null ;
141+ }
142+ : null ,
143+ initiallyExpanded: expandedIndex == tileIndex && adConfig.enabled,
144+ enabled: adConfig.enabled, // Disable the tile itself
127145 children: [
128146 ArticleAdSettingsForm (
129147 remoteConfig: widget.remoteConfig,
@@ -133,6 +151,37 @@ class _AdvertisementsConfigurationTabState
133151 );
134152 },
135153 ),
154+ const SizedBox (height: AppSpacing .lg),
155+ // Top-level ExpansionTile for Interstitial Ad Settings
156+ ValueListenableBuilder <int ?>(
157+ valueListenable: _expandedTileIndex,
158+ builder: (context, expandedIndex, child) {
159+ const tileIndex = 3 ;
160+ return ExpansionTile (
161+ key: ValueKey ('interstitialAdSettingsTile_$expandedIndex ' ),
162+ title: Text (l10n.interstitialAdSettingsTitle),
163+ childrenPadding: const EdgeInsetsDirectional .only (
164+ start: AppSpacing .lg,
165+ top: AppSpacing .md,
166+ bottom: AppSpacing .md,
167+ ),
168+ expandedCrossAxisAlignment: CrossAxisAlignment .start,
169+ onExpansionChanged: adConfig.enabled
170+ ? (isExpanded) {
171+ _expandedTileIndex.value = isExpanded ? tileIndex : null ;
172+ }
173+ : null ,
174+ initiallyExpanded: expandedIndex == tileIndex && adConfig.enabled,
175+ enabled: adConfig.enabled, // Disable the tile itself
176+ children: [
177+ InterstitialAdSettingsForm (
178+ remoteConfig: widget.remoteConfig,
179+ onConfigChanged: widget.onConfigChanged,
180+ ),
181+ ],
182+ );
183+ },
184+ ),
136185 ],
137186 );
138187 }
0 commit comments