|
1 | 1 | import 'package:core/core.dart'; |
2 | 2 | import 'package:flutter/material.dart'; |
3 | | -import 'package:flutter_news_app_web_dashboard_full_source_code/app_configuration/widgets/app_config_form_fields.dart'; |
4 | | -import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/app_localizations.dart'; |
5 | 3 | import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/l10n.dart'; |
6 | | -import 'package:flutter_news_app_web_dashboard_full_source_code/shared/extensions/app_user_role_l10n.dart'; |
7 | | -import 'package:ui_kit/ui_kit.dart'; |
8 | 4 |
|
9 | 5 | /// {@template ad_config_form} |
10 | 6 | /// A form widget for configuring ad settings based on user role. |
@@ -139,96 +135,6 @@ class _AdConfigFormState extends State<AdConfigForm> |
139 | 135 | ); |
140 | 136 | }, |
141 | 137 | ), |
142 | | - const SizedBox(height: AppSpacing.lg), |
143 | | - AbsorbPointer( |
144 | | - absorbing: !adConfig.enabled, |
145 | | - child: Opacity( |
146 | | - opacity: adConfig.enabled ? 1.0 : 0.5, |
147 | | - child: Column( |
148 | | - crossAxisAlignment: CrossAxisAlignment.start, |
149 | | - children: [ |
150 | | - Text( |
151 | | - l10n.adSettingsDescription, |
152 | | - style: Theme.of(context).textTheme.bodySmall?.copyWith( |
153 | | - color: Theme.of( |
154 | | - context, |
155 | | - ).colorScheme.onSurface.withOpacity(0.7), |
156 | | - ), |
157 | | - ), |
158 | | - const SizedBox(height: AppSpacing.lg), |
159 | | - Align( |
160 | | - alignment: AlignmentDirectional.centerStart, |
161 | | - child: SizedBox( |
162 | | - height: kTextTabBarHeight, |
163 | | - child: TabBar( |
164 | | - controller: _tabController, |
165 | | - tabAlignment: TabAlignment.start, |
166 | | - isScrollable: true, |
167 | | - tabs: AppUserRole.values |
168 | | - .map((role) => Tab(text: role.l10n(context))) |
169 | | - .toList(), |
170 | | - ), |
171 | | - ), |
172 | | - ), |
173 | | - const SizedBox(height: AppSpacing.lg), |
174 | | - SizedBox( |
175 | | - height: 400, |
176 | | - child: TabBarView( |
177 | | - controller: _tabController, |
178 | | - children: AppUserRole.values |
179 | | - .map( |
180 | | - (role) => _buildRoleSpecificFields( |
181 | | - context, |
182 | | - l10n, |
183 | | - role, |
184 | | - adConfig, |
185 | | - ), |
186 | | - ) |
187 | | - .toList(), |
188 | | - ), |
189 | | - ), |
190 | | - ], |
191 | | - ), |
192 | | - ), |
193 | | - ), |
194 | | - ], |
195 | | - ); |
196 | | - } |
197 | | - |
198 | | - Widget _buildRoleSpecificFields( |
199 | | - BuildContext context, |
200 | | - AppLocalizations l10n, |
201 | | - AppUserRole role, |
202 | | - AdConfig config, |
203 | | - ) { |
204 | | - return Column( |
205 | | - children: [ |
206 | | - AppConfigIntField( |
207 | | - label: l10n.adFrequencyLabel, |
208 | | - description: l10n.adFrequencyDescription, |
209 | | - value: _getAdFrequency(config, role), |
210 | | - onChanged: (value) { |
211 | | - widget.onConfigChanged( |
212 | | - widget.remoteConfig.copyWith( |
213 | | - adConfig: _updateAdFrequency(config, value, role), |
214 | | - ), |
215 | | - ); |
216 | | - }, |
217 | | - controller: _adFrequencyControllers[role], |
218 | | - ), |
219 | | - AppConfigIntField( |
220 | | - label: l10n.adPlacementIntervalLabel, |
221 | | - description: l10n.adPlacementIntervalDescription, |
222 | | - value: _getAdPlacementInterval(config, role), |
223 | | - onChanged: (value) { |
224 | | - widget.onConfigChanged( |
225 | | - widget.remoteConfig.copyWith( |
226 | | - adConfig: _updateAdPlacementInterval(config, value, role), |
227 | | - ), |
228 | | - ); |
229 | | - }, |
230 | | - controller: _adPlacementIntervalControllers[role], |
231 | | - ), |
232 | 138 | ], |
233 | 139 | ); |
234 | 140 | } |
@@ -266,60 +172,4 @@ class _AdConfigFormState extends State<AdConfigForm> |
266 | 172 | .premiumAdPlacementInterval; |
267 | 173 | } |
268 | 174 | } |
269 | | - |
270 | | - AdConfig _updateAdFrequency(AdConfig config, int value, AppUserRole role) { |
271 | | - switch (role) { |
272 | | - case AppUserRole.guestUser: |
273 | | - return config.copyWith( |
274 | | - feedAdConfiguration: config.feedAdConfiguration.copyWith( |
275 | | - frequencyConfig: config.feedAdConfiguration.frequencyConfig |
276 | | - .copyWith(guestAdFrequency: value), |
277 | | - ), |
278 | | - ); |
279 | | - case AppUserRole.standardUser: |
280 | | - return config.copyWith( |
281 | | - feedAdConfiguration: config.feedAdConfiguration.copyWith( |
282 | | - frequencyConfig: config.feedAdConfiguration.frequencyConfig |
283 | | - .copyWith(authenticatedAdFrequency: value), |
284 | | - ), |
285 | | - ); |
286 | | - case AppUserRole.premiumUser: |
287 | | - return config.copyWith( |
288 | | - feedAdConfiguration: config.feedAdConfiguration.copyWith( |
289 | | - frequencyConfig: config.feedAdConfiguration.frequencyConfig |
290 | | - .copyWith(premiumAdFrequency: value), |
291 | | - ), |
292 | | - ); |
293 | | - } |
294 | | - } |
295 | | - |
296 | | - AdConfig _updateAdPlacementInterval( |
297 | | - AdConfig config, |
298 | | - int value, |
299 | | - AppUserRole role, |
300 | | - ) { |
301 | | - switch (role) { |
302 | | - case AppUserRole.guestUser: |
303 | | - return config.copyWith( |
304 | | - feedAdConfiguration: config.feedAdConfiguration.copyWith( |
305 | | - frequencyConfig: config.feedAdConfiguration.frequencyConfig |
306 | | - .copyWith(guestAdPlacementInterval: value), |
307 | | - ), |
308 | | - ); |
309 | | - case AppUserRole.standardUser: |
310 | | - return config.copyWith( |
311 | | - feedAdConfiguration: config.feedAdConfiguration.copyWith( |
312 | | - frequencyConfig: config.feedAdConfiguration.frequencyConfig |
313 | | - .copyWith(authenticatedAdPlacementInterval: value), |
314 | | - ), |
315 | | - ); |
316 | | - case AppUserRole.premiumUser: |
317 | | - return config.copyWith( |
318 | | - feedAdConfiguration: config.feedAdConfiguration.copyWith( |
319 | | - frequencyConfig: config.feedAdConfiguration.frequencyConfig |
320 | | - .copyWith(premiumAdPlacementInterval: value), |
321 | | - ), |
322 | | - ); |
323 | | - } |
324 | | - } |
325 | 175 | } |
0 commit comments